Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions frontend/public/js/detailseite_pflanze.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ async function onButtonWaterPlantClick(plant) {
reloadActivities(plant.plant_id);
}

async function onButtonRepotPlantClick(plant) {
async function onButtonRePotPlantClick(plant) {
// call Backend
try{
await backend.repotPlant(plant.plant_id);
Expand Down Expand Up @@ -148,6 +148,12 @@ async function onButtonDeletePlantClick(plant) {
navigation.showPlantOverviewPage()
}

function onPlantImageClick(plant) {
if(plant.image){
navigation.showPlantImage(plant.image);
}
}

function registerEventHandlers(plant){
// Event listener for edit-button using jQuery
$('#edit-button').on('click', function() {
Expand All @@ -159,12 +165,16 @@ function registerEventHandlers(plant){
});

$('#repot-button').on('click', function() {
onButtonRepotPlantClick(plant);
onButtonRePotPlantClick(plant);
});

$('#compost-button').on('click', function() {
onButtonDeletePlantClick(plant);
});

$('#plant-image').on('click', function() {
onPlantImageClick(plant);
});
}

function showCompostInfo(date){
Expand Down
11 changes: 11 additions & 0 deletions frontend/public/mjs/navigation.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import {backendUrl_plantImages} from "./config.mjs";

/**
* Redirects the user to the plants details page.
* The plant that should be displayed will be passed to the page via the url.
Expand Down Expand Up @@ -29,4 +31,13 @@ export function showPlantEditPage(plant_id)
export function showPlantOverviewPage()
{
window.location.href = 'meine_pflanzen.html';
}

/**
* Redirects the user to the plant image specified
* @param {string} image the filename of the plant image
*/
export function showPlantImage(image)
{
window.location.href = backendUrl_plantImages + '/' + image;
}