diff --git a/CHANGELOG.md b/CHANGELOG.md index 8fe54b3..c06d21c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ ## [3.3.0] - 2025-01-17 +* [PR-39](https://github.com/ITK-Leantime/leantime-timetable/pull/39) + * Require timelog comments via settings * [PR-37](https://github.com/ITK-Leantime/leantime-timetable/pull/37) * Reimplement ability to move timelog to another date diff --git a/Controllers/Settings.php b/Controllers/Settings.php index d6e9d36..8def7c4 100644 --- a/Controllers/Settings.php +++ b/Controllers/Settings.php @@ -44,7 +44,9 @@ public function get(): Response { try { $ticketCacheExpiration = (int) ($this->settingsRepo->getSetting('itk-leantime-timetable.ticketCacheExpiration') ?: self::DEFAULT_TICKET_EXPIRATION); + $requireTimeRegistrationComment = ($this->settingsRepo->getSetting('itk-leantime-timetable.requireTimeRegistrationComment') ?: '0'); $this->template->assign('ticketCacheExpiration', $ticketCacheExpiration); + $this->template->assign('requireTimeRegistrationComment', $requireTimeRegistrationComment); } catch (\Exception $e) { $this->template->setNotification('An error occurred while saving the settings. ' . $e, 'error'); } @@ -63,6 +65,8 @@ public function post(array $params): RedirectResponse { try { $this->settingsRepo->saveSetting('itk-leantime-timetable.ticketCacheExpiration', (int)($params['ticketCacheExpiration'] ?? self::DEFAULT_TICKET_EXPIRATION)); + // For requireTimeRegistrationComment: 0 is false, 1 is true. + $this->settingsRepo->saveSetting('itk-leantime-timetable.requireTimeRegistrationComment', ($params['requireTimeRegistrationComment'] ?? '0')); $this->template->setNotification('The settings were successfully saved.', 'success'); } catch (\Exception $e) { $this->template->setNotification('An error occurred while saving the settings. ' . $e, 'error'); diff --git a/Controllers/TimeTable.php b/Controllers/TimeTable.php index 64d576f..cad357a 100644 --- a/Controllers/TimeTable.php +++ b/Controllers/TimeTable.php @@ -195,6 +195,7 @@ public function get(): Response $this->template->assign('fromDate', $fromDate); $this->template->assign('toDate', $toDate); $this->template->assign('allStateLabels', json_encode($allStateLabels)); + $this->template->assign('requireTimeRegistrationComment', $this->settings->getSetting('itk-leantime-timetable.requireTimeRegistrationComment') ?? 0); return $this->template->display('TimeTable.timetable'); } } diff --git a/Templates/settings.blade.php b/Templates/settings.blade.php index cc3ee83..36acb02 100644 --- a/Templates/settings.blade.php +++ b/Templates/settings.blade.php @@ -26,6 +26,15 @@ name="ticketCacheExpiration" /> +