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" /> +
+
+ +
+
+ +
+
diff --git a/Templates/timetable.blade.php b/Templates/timetable.blade.php index adb67f9..3525260 100644 --- a/Templates/timetable.blade.php +++ b/Templates/timetable.blade.php @@ -8,6 +8,7 @@

{{ __('timeTable.headline') }}

+
@@ -88,7 +89,8 @@ class="timetable-to-today btn btn-default">{{ __('timeTable.button_show_this_wee $hours = $timesheetDate[0]['hours'] ?? null; $hoursLeft = $timesheetDate[0]['hourRemaining'] ?? null; $description = $timesheetDate[0]['description'] ?? null; - $isMissingDescription = isset($hours) && trim($description) === ''; + $requireTimeRegistrationComment = $requireTimeRegistrationComment ?? 0; + $isMissingDescription = isset($hours) & (trim($description) === '') && $requireTimeRegistrationComment !== 0; // accumulate hours if ($hours) { @@ -206,7 +208,8 @@ class="timetable-edit-entry {{ $weekendClass }} {{ $todayClass }} {{ $newWeekCla {{-- Description input --}}
+ placeholder="{{ __('timeTable.description') }}" + {{ $requireTimeRegistrationComment === '1' ? 'required' : '' }}>
diff --git a/bin/create-release b/bin/create-release index d38cfd3..c849012 100755 --- a/bin/create-release +++ b/bin/create-release @@ -62,7 +62,7 @@ find "${target_dir}" -type f -exec sed -i "s/%%VERSION%%/${tag}/g" {} \; # Strip any leading `dev-` from tag name in package name. name="${plugin_name}-${tag#dev-}.tar.gz" -tar --create --file "$name" -C "$release_dir" "$plugin_name" +tar --gzip --create --file "$name" -C "$release_dir" "$plugin_name" sha256sum "$name" >| checksum.txt # Clean up diff --git a/register.php b/register.php index b822c81..acb9c78 100644 --- a/register.php +++ b/register.php @@ -59,12 +59,14 @@ function () { echo ''; $userId = htmlspecialchars(session('userdata.id'), ENT_QUOTES, 'UTF-8'); $ticketCacheExpiration = app()->make(Setting::class)->getSetting('itk-leantime-timetable.ticketCacheExpiration') ?: '1200'; + $requireTimeRegistrationComment = app()->make(Setting::class)->getSetting('itk-leantime-timetable.requireTimeRegistrationComment') ?: '0'; echo '';