From ede70437659e7834526940e62981727cec94b601 Mon Sep 17 00:00:00 2001 From: Petri Saarinen Date: Wed, 25 Nov 2026 11:07:43 +0200 Subject: [PATCH] Show the task's due date in the calendar's schedule dialog The dialog shows the due date as a read-only field; it is changed on the task's edit page. Co-Authored-By: Claude Sonnet 5.5 --- .../Jobs/Presentation/Livewire/⚡calendar.blade.php | 7 +++++++ lang/en/jobs.php | 2 ++ lang/fi/jobs.php | 2 ++ tests/Browser/TaskCalendarAccessibilityTest.php | 1 + tests/Feature/Modules/Jobs/TaskCalendarTest.php | 12 ++++++++++++ 5 files changed, 24 insertions(+) diff --git a/app/Modules/Jobs/Presentation/Livewire/⚡calendar.blade.php b/app/Modules/Jobs/Presentation/Livewire/⚡calendar.blade.php index 6ae3c36..a40be67 100644 --- a/app/Modules/Jobs/Presentation/Livewire/⚡calendar.blade.php +++ b/app/Modules/Jobs/Presentation/Livewire/⚡calendar.blade.php @@ -61,6 +61,10 @@ new class extends Component #[Locked] public string $dialogStatus = ''; + /** The task's due date for display (j.n.Y), changed on the task's edit page. */ + #[Locked] + public string $dialogDueOn = ''; + public string $plannedFrom = ''; public string $plannedTo = ''; @@ -255,6 +259,7 @@ new class extends Component $this->dialogUserId = $userId; $this->dialogTitle = __('jobs.calendar.dialog_task', ['title' => $task->title, 'job' => $task->jobNumber]); $this->dialogStatus = $task->status->value; + $this->dialogDueOn = $task->dueOn === null ? __('jobs.not_set') : $this->shortDate($task->dueOn); $this->plannedFrom = $task->plannedFrom ?? CarbonImmutable::today()->format('Y-m-d'); $this->plannedTo = $task->plannedTo ?? ''; $this->assignee = $userId === null ? '' : (string) $userId; @@ -818,6 +823,8 @@ new class extends Component

{{ $dialogTitle }}

+ + @if ($dialogJobId !== null && Gate::allows('jobs.manage-tasks', $dialogJobId)) diff --git a/lang/en/jobs.php b/lang/en/jobs.php index bf4491e..637d747 100644 --- a/lang/en/jobs.php +++ b/lang/en/jobs.php @@ -243,6 +243,8 @@ return [ 'dialog_title' => 'Task schedule', 'dialog_task' => ':title (:job)', 'fields' => [ + 'due_on' => 'Due date', + 'due_on_hint' => 'Change the due date when editing the task.', 'from' => 'Starts', 'to' => 'Ends', 'to_hint' => 'If left empty, the task gets as many working days as its estimate needs.', diff --git a/lang/fi/jobs.php b/lang/fi/jobs.php index 8b63105..913c6b0 100644 --- a/lang/fi/jobs.php +++ b/lang/fi/jobs.php @@ -243,6 +243,8 @@ return [ 'dialog_title' => 'Tehtävän aikataulu', 'dialog_task' => ':title (:job)', 'fields' => [ + 'due_on' => 'Määräaika', + 'due_on_hint' => 'Määräaikaa muutetaan tehtävän muokkauksessa.', 'from' => 'Alkaa', 'to' => 'Päättyy', 'to_hint' => 'Tyhjänä tehtävä saa niin monta arkipäivää kuin arvio vaatii.', diff --git a/tests/Browser/TaskCalendarAccessibilityTest.php b/tests/Browser/TaskCalendarAccessibilityTest.php index 25f034d..4490667 100644 --- a/tests/Browser/TaskCalendarAccessibilityTest.php +++ b/tests/Browser/TaskCalendarAccessibilityTest.php @@ -64,6 +64,7 @@ it('reschedules a task with the keyboard and returns focus to its bar', function ->on()->desktop() ->keys('#bar-'.$key, 'Enter') ->assertSee('Tehtävän aikataulu') + ->assertValue('#task-schedule-due-on', now()->addDay()->format('j.n.Y')) ->assertNoAccessibilityIssues(level: 2) ->type('#task-schedule-dialog [wire\:model="plannedFrom"]', now()->addDay()->format('Y-m-d')) ->type('#task-schedule-dialog [wire\:model="plannedTo"]', now()->addDays(3)->format('Y-m-d')) diff --git a/tests/Feature/Modules/Jobs/TaskCalendarTest.php b/tests/Feature/Modules/Jobs/TaskCalendarTest.php index e2ad263..6965e2d 100644 --- a/tests/Feature/Modules/Jobs/TaskCalendarTest.php +++ b/tests/Feature/Modules/Jobs/TaskCalendarTest.php @@ -96,6 +96,18 @@ it('changes the schedule and status in the dialog and takes a task out of the ca ->and($task->planned_from)->toBeNull(); }); +it('shows the task due date in the dialog', function () { + $due = calendarTaskModel(['customer_job_id' => $this->job->id, 'work_type_id' => $this->graphic->id, 'title' => 'Mainoskuvat', 'due_on' => '2026-12-24', 'planned_from' => '2026-12-22', 'planned_to' => '2026-12-22'], [$this->employee->id]); + $open = calendarTaskModel(['customer_job_id' => $this->job->id, 'work_type_id' => $this->graphic->id, 'title' => 'Taitto', 'due_on' => null, 'planned_from' => '2026-12-22', 'planned_to' => '2026-12-22'], [$this->employee->id]); + + Livewire::test('jobs::calendar') + ->call('openDialog', $due->id, $this->employee->id) + ->assertSet('dialogDueOn', '24.12.2026') + ->assertSee('Määräaika') + ->call('openDialog', $open->id, $this->employee->id) + ->assertSet('dialogDueOn', __('jobs.not_set')); +}); + it('shows a subcontractor only their own row and lets them change only the status', function () { $subcontractor = User::factory()->subcontractor()->create(['name' => 'Ville Alihankkija']); DB::table('customer_job_members')->insert(['customer_job_id' => $this->job->id, 'user_id' => $subcontractor->id]);