From 29b46723469088be3775b8ef20fd0344c37c836c Mon Sep 17 00:00:00 2001 From: Zack Arnett Date: Wed, 22 Apr 2020 12:03:05 -0400 Subject: [PATCH] Link to respective page on Calendar Event Click (#784) * Link to Page on calendar event click * Undo my Prettier Changes.. Oops --- public/css/grocy.css | 4 ++++ public/viewjs/calendar.js | 5 ++++- services/CalendarService.php | 15 ++++++++++----- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/public/css/grocy.css b/public/css/grocy.css index 90652da6..2c6f0e2e 100644 --- a/public/css/grocy.css +++ b/public/css/grocy.css @@ -518,4 +518,8 @@ canvas.drawingBuffer { .recipe-servings-input { width: 125px; +} + +.fc-event{ + cursor: pointer; } \ No newline at end of file diff --git a/public/viewjs/calendar.js b/public/viewjs/calendar.js index 42634b16..96a3b649 100644 --- a/public/viewjs/calendar.js +++ b/public/viewjs/calendar.js @@ -16,7 +16,10 @@ var calendar = $("#calendar").fullCalendar({ "firstDay": firstDay, "eventLimit": false, "height": "auto", - "eventSources": fullcalendarEventSources + "eventSources": fullcalendarEventSources, + eventClick: function(info) { + location.href = info.link; + } }); $("#ical-button").on("click", function(e) diff --git a/services/CalendarService.php b/services/CalendarService.php index d60002a6..826263c8 100644 --- a/services/CalendarService.php +++ b/services/CalendarService.php @@ -31,7 +31,8 @@ class CalendarService extends BaseService $stockEvents[] = array( 'title' => $titlePrefix . FindObjectInArrayByPropertyValue($products, 'id', $currentStockEntry->product_id)->name, 'start' => $currentStockEntry->best_before_date, - 'date_format' => 'date' + 'date_format' => 'date', + 'link' => $this->UrlManager->ConstructUrl('/stockoverview') ); } } @@ -46,7 +47,8 @@ class CalendarService extends BaseService $taskEvents[] = array( 'title' => $titlePrefix . $currentTaskEntry->name, 'start' => $currentTaskEntry->due_date, - 'date_format' => 'date' + 'date_format' => 'date', + 'link' => $this->UrlManager->ConstructUrl('/tasks') ); } } @@ -71,7 +73,8 @@ class CalendarService extends BaseService $choreEvents[] = array( 'title' => $titlePrefix . $chore->name . $assignedToText, 'start' => $currentChoreEntry->next_estimated_execution_time, - 'date_format' => 'datetime' + 'date_format' => 'datetime', + 'link' => $this->UrlManager->ConstructUrl('/choresoverview') ); } } @@ -86,7 +89,8 @@ class CalendarService extends BaseService $batteryEvents[] = array( 'title' => $titlePrefix . FindObjectInArrayByPropertyValue($batteries, 'id', $currentBatteryEntry->battery_id)->name, 'start' => $currentBatteryEntry->next_estimated_charge_time, - 'date_format' => 'datetime' + 'date_format' => 'datetime', + 'link' => $this->UrlManager->ConstructUrl('/batteriesoverview') ); } } @@ -107,7 +111,8 @@ class CalendarService extends BaseService 'title' => $titlePrefix . FindObjectInArrayByPropertyValue($recipes, 'id', $recipeOfCurrentDay->includes_recipe_id)->name, 'start' => FindObjectInArrayByPropertyValue($recipes, 'id', $recipeOfCurrentDay->recipe_id)->name, 'date_format' => 'date', - 'description' => $this->UrlManager->ConstructUrl('/mealplan' . '?week=' . FindObjectInArrayByPropertyValue($recipes, 'id', $recipeOfCurrentDay->recipe_id)->name) + 'description' => $this->UrlManager->ConstructUrl('/mealplan' . '?week=' . FindObjectInArrayByPropertyValue($recipes, 'id', $recipeOfCurrentDay->recipe_id)->name), + 'link' => $this->UrlManager->ConstructUrl('/recipes' . '?recipe=' . $recipeOfCurrentDay->includes_recipe_id . "#fullscreen") ); } }