Make job page task cards and change history collapsible

Task cards on the job page start collapsed and show the title, assignee,
due date and status; each opens on its own, so several can be open at
once, and "Expand all" / "Collapse all" open or close them together with
a status message. A card opens when focus moves into it. The change
history is a disclosure panel with the number of changes, closed by
default.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-11-25 06:12:15 +02:00
co-authored by Claude Opus 5.5
parent 6936d0950b
commit 9a9935098c
3 changed files with 239 additions and 106 deletions
@@ -335,26 +335,91 @@ new class extends Component
@php($canChangeStatus = Gate::allows('jobs.update-task-status', $job->id)) @php($canChangeStatus = Gate::allows('jobs.update-task-status', $job->id))
@php($canManageTasks = Gate::allows('jobs.manage-tasks', $job->id)) @php($canManageTasks = Gate::allows('jobs.manage-tasks', $job->id))
<ul class="space-y-3"> {{--
@foreach ($this->tasks as $task) Task cards are disclosures: collapsed by default, each opened on its own, so several can be open at once.
<li wire:key="task-{{ $task->id }}"> "Expand all" and "Collapse all" send a tasks-expand window event that every card follows. A card also opens
<article aria-labelledby="task-{{ $task->id }}-title" class="space-y-3 rounded-lg border border-zinc-200 p-4 text-sm dark:border-zinc-700"> when focus moves into it (e.g. the status select keeps focus after a re-render).
<div class="flex flex-wrap items-start justify-between gap-3"> --}}
<h3 id="task-{{ $task->id }}-title" class="text-base font-medium break-words">{{ $task->title }}</h3> <div
<span>{{ __('jobs.tasks.statuses.'.$task->status->value) }}</span> class="flex flex-wrap items-center gap-2"
x-data="{ message: '', expandedText: @js(__('jobs.tasks.all_expanded')), collapsedText: @js(__('jobs.tasks.all_collapsed')) }"
>
<x-button
x-on:click="$dispatch('tasks-expand', true); message = expandedText"
subtle
color="black"
sm
icon="chevron-double-down"
:text="__('jobs.tasks.expand_all')"
data-tasks-expand-all
/>
<x-button
x-on:click="$dispatch('tasks-expand', false); message = collapsedText"
subtle
color="black"
sm
icon="chevron-double-up"
:text="__('jobs.tasks.collapse_all')"
data-tasks-collapse-all
/>
<p role="status" aria-live="polite" class="text-sm" x-text="message"></p>
</div> </div>
<ul class="space-y-3">
@foreach ($this->tasks as $task)
<li
wire:key="task-{{ $task->id }}"
x-data="{ open: false }"
x-on:tasks-expand.window="open = $event.detail"
x-on:focusin="if ($event.target.closest('[data-task-details]')) open = true"
>
<article aria-labelledby="task-{{ $task->id }}-title" class="rounded-lg border border-zinc-200 bg-white text-sm dark:border-zinc-700 dark:bg-zinc-900">
<div class="flex flex-col gap-2 p-3 sm:flex-row sm:flex-wrap sm:items-center sm:gap-x-6">
<h3 id="task-{{ $task->id }}-title" class="min-w-0 text-base font-medium sm:flex-1">
<button
type="button"
id="task-toggle-{{ $task->id }}"
x-on:click="open = ! open"
x-bind:aria-expanded="open.toString()"
aria-expanded="false"
aria-controls="task-{{ $task->id }}-details"
class="flex min-h-6 w-full items-start gap-2 rounded-md text-left focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-700 dark:focus-visible:outline-blue-400"
>
<x-icon name="chevron-right" class="mt-0.5 size-5 shrink-0 transition-transform" x-bind:class="{ 'rotate-90': open }" aria-hidden="true" />
<span class="min-w-0 break-words">{{ $task->title }}</span>
</button>
</h3>
<dl class="flex flex-col gap-1 ps-7 sm:flex-row sm:flex-wrap sm:gap-x-6 sm:ps-0">
<div class="flex flex-wrap gap-x-1">
<dt class="font-medium">{{ __('jobs.tasks.fields.assignee') }}:</dt>
<dd>{{ $task->assignee?->name ?? __('jobs.calendar.no_assignee') }}</dd>
</div>
<div class="flex flex-wrap gap-x-1">
<dt class="font-medium">{{ __('jobs.tasks.fields.due_on') }}:</dt>
<dd><x-jobs.due-date :date="$task->dueOn" :status="$task->status" /></dd>
</div>
<div class="flex flex-wrap gap-x-1">
<dt class="font-medium">{{ __('jobs.tasks.fields.status') }}:</dt>
<dd>{{ __('jobs.tasks.statuses.'.$task->status->value) }}</dd>
</div>
</dl>
</div>
<div
id="task-{{ $task->id }}-details"
data-task-details
x-show="open"
x-cloak
class="space-y-3 border-t border-zinc-200 p-4 dark:border-zinc-700"
>
<dl class="grid gap-x-6 gap-y-1 sm:grid-cols-[max-content_1fr]"> <dl class="grid gap-x-6 gap-y-1 sm:grid-cols-[max-content_1fr]">
<dt class="font-medium">{{ __('jobs.tasks.fields.work_type') }}</dt> <dt class="font-medium">{{ __('jobs.tasks.fields.work_type') }}</dt>
<dd>{{ $task->workType->name }}</dd> <dd>{{ $task->workType->name }}</dd>
<dt class="font-medium">{{ __('jobs.tasks.fields.assignee') }}</dt>
<dd>{{ $task->assignee?->name ?? __('jobs.calendar.no_assignee') }}</dd>
@if ($task->members !== []) @if ($task->members !== [])
<dt class="font-medium">{{ __('jobs.tasks.fields.members') }}</dt> <dt class="font-medium">{{ __('jobs.tasks.fields.members') }}</dt>
<dd>{{ collect($task->members)->pluck('name')->join(', ') }}</dd> <dd>{{ collect($task->members)->pluck('name')->join(', ') }}</dd>
@endif @endif
<dt class="font-medium">{{ __('jobs.tasks.fields.due_on') }}</dt>
<dd><x-jobs.due-date :date="$task->dueOn" :status="$task->status" /></dd>
<dt class="font-medium">{{ __('jobs.tasks.schedule') }}</dt> <dt class="font-medium">{{ __('jobs.tasks.schedule') }}</dt>
<dd> <dd>
@if ($task->plannedFrom === null) @if ($task->plannedFrom === null)
@@ -425,6 +490,7 @@ new class extends Component
/> />
@endif @endif
</div> </div>
</div>
</article> </article>
</li> </li>
@endforeach @endforeach
@@ -474,9 +540,24 @@ new class extends Component
<p class="whitespace-pre-line text-sm">{{ $job->instructions ?? __('jobs.not_set') }}</p> <p class="whitespace-pre-line text-sm">{{ $job->instructions ?? __('jobs.not_set') }}</p>
</section> </section>
<section aria-labelledby="history-heading" class="space-y-3"> <section aria-labelledby="history-heading" class="space-y-3" x-data="{ open: false }">
<h2 id="history-heading" class="text-xl font-semibold">{{ __('jobs.sections.history') }}</h2> <h2 id="history-heading" class="text-xl font-semibold">
<button
type="button"
id="history-toggle"
x-on:click="open = ! open"
x-bind:aria-expanded="open.toString()"
aria-expanded="false"
aria-controls="history-panel"
class="flex min-h-6 items-center gap-2 rounded-md text-left focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-700 dark:focus-visible:outline-blue-400"
>
<x-icon name="chevron-right" class="size-5 shrink-0 transition-transform" x-bind:class="{ 'rotate-90': open }" aria-hidden="true" />
{{ __('jobs.sections.history') }}
<span class="text-base font-normal">{{ trans_choice('jobs.history.count', count($this->changes), ['count' => count($this->changes)]) }}</span>
</button>
</h2>
<div id="history-panel" x-show="open" x-cloak>
@if ($this->changes === []) @if ($this->changes === [])
<p class="text-sm text-zinc-600 dark:text-zinc-300">{{ __('jobs.history.empty') }}</p> <p class="text-sm text-zinc-600 dark:text-zinc-300">{{ __('jobs.history.empty') }}</p>
@else @else
@@ -502,5 +583,6 @@ new class extends Component
@endforeach @endforeach
</ol> </ol>
@endif @endif
</div>
</section> </section>
</div> </div>
+5
View File
@@ -22,6 +22,10 @@ return [
'edit_title' => 'Muokkaa tehtävää', 'edit_title' => 'Muokkaa tehtävää',
'job_label' => 'Asiakastyö', 'job_label' => 'Asiakastyö',
'empty' => 'Ei tehtäviä.', 'empty' => 'Ei tehtäviä.',
'expand_all' => 'Laajenna kaikki',
'collapse_all' => 'Supista kaikki',
'all_expanded' => 'Kaikki tehtävät laajennettu.',
'all_collapsed' => 'Kaikki tehtävät supistettu.',
'not_allowed_yet' => 'Tehtäviä voi lisätä, kun työ on tarjouspyyntö-tilassa tai myöhemmässä tilassa.', 'not_allowed_yet' => 'Tehtäviä voi lisätä, kun työ on tarjouspyyntö-tilassa tai myöhemmässä tilassa.',
'created' => 'Tehtävä :title lisätty.', 'created' => 'Tehtävä :title lisätty.',
'updated' => 'Tehtävä :title tallennettu.', 'updated' => 'Tehtävä :title tallennettu.',
@@ -313,6 +317,7 @@ return [
'history' => [ 'history' => [
'empty' => 'Ei muutoksia.', 'empty' => 'Ei muutoksia.',
'count' => '{0} (ei muutoksia)|{1} (1 muutos)|[2,*] (:count muutosta)',
'unlocked' => '(lukitus avattu)', 'unlocked' => '(lukitus avattu)',
'created' => ':user loi työn :number.', 'created' => ':user loi työn :number.',
'changed' => ':field: :old → :new', 'changed' => ':field: :old → :new',
+46
View File
@@ -172,6 +172,12 @@ it('has no accessibility issues on a job with tasks and on the task form', funct
$visit = $device === 'mobile' ? $visit->on()->mobile() : $visit->on()->desktop(); $visit = $device === 'mobile' ? $visit->on()->mobile() : $visit->on()->desktop();
$visit = $colorScheme === 'dark' ? $visit->inDarkMode() : $visit->inLightMode(); $visit = $colorScheme === 'dark' ? $visit->inDarkMode() : $visit->inLightMode();
if ($page === 'job page') {
$visit->click('[data-tasks-expand-all]')
->click('#history-toggle')
->assertVisible('#task-status-'.$task->id);
}
$visit->assertNoJavaScriptErrors() $visit->assertNoJavaScriptErrors()
->assertNoAccessibilityIssues(level: 2); ->assertNoAccessibilityIssues(level: 2);
})->with(['job page', 'new task', 'edit task'])->with([ })->with(['job page', 'new task', 'edit task'])->with([
@@ -188,9 +194,11 @@ it('changes a task status and removes a task with the keyboard', function () {
->create(['customer_job_id' => $this->job->id, 'work_type_id' => $workType->id, 'title' => 'Kuvauspäivä']); ->create(['customer_job_id' => $this->job->id, 'work_type_id' => $workType->id, 'title' => 'Kuvauspäivä']);
visit(route('jobs.show', $this->job->id)) visit(route('jobs.show', $this->job->id))
->keys('#task-toggle-'.$task->id, 'Enter')
->select('#task-status-'.$task->id, 'in_progress') ->select('#task-status-'.$task->id, 'in_progress')
->assertSee('Tehtävän Kuvauspäivä tila on nyt Työn alla.') ->assertSee('Tehtävän Kuvauspäivä tila on nyt Työn alla.')
->assertScript('document.activeElement.id', 'task-status-'.$task->id) ->assertScript('document.activeElement.id', 'task-status-'.$task->id)
->assertAttribute('#task-toggle-'.$task->id, 'aria-expanded', 'true')
->keys('[aria-label="Poista tehtävä Kuvauspäivä"]', 'Enter') ->keys('[aria-label="Poista tehtävä Kuvauspäivä"]', 'Enter')
->assertScript('document.getElementById("remove-task-dialog").open', true) ->assertScript('document.getElementById("remove-task-dialog").open', true)
->assertScript('document.getElementById("remove-task-dialog").contains(document.activeElement)', true) ->assertScript('document.getElementById("remove-task-dialog").contains(document.activeElement)', true)
@@ -199,6 +207,43 @@ it('changes a task status and removes a task with the keyboard', function () {
->assertScript('document.activeElement.id', 'tasks-heading'); ->assertScript('document.activeElement.id', 'tasks-heading');
}); });
it('shows task cards collapsed, opens several at once and expands or collapses them all', function () {
$this->job->update(['status' => 'order']);
$workType = WorkTypeModel::query()->where('name', 'videokuvaus')->sole();
$shoot = TaskModel::factory()
->assignedTo([$this->user->id])
->create(['customer_job_id' => $this->job->id, 'work_type_id' => $workType->id, 'title' => 'Kuvauspäivä', 'due_on' => '2026-12-04']);
$edit = TaskModel::factory()
->create(['customer_job_id' => $this->job->id, 'work_type_id' => $workType->id, 'title' => 'Editointi']);
$page = visit(route('jobs.show', $this->job->id))
->assertSee('Johanna Johto')
->assertSee('4.12.2026')
->assertAttribute('#task-toggle-'.$shoot->id, 'aria-expanded', 'false')
->assertMissing('#task-status-'.$shoot->id)
->keys('#task-toggle-'.$shoot->id, 'Enter')
->assertAttribute('#task-toggle-'.$shoot->id, 'aria-expanded', 'true')
->assertVisible('#task-status-'.$shoot->id)
->keys('#task-toggle-'.$edit->id, 'Enter')
->assertVisible('#task-status-'.$shoot->id)
->assertVisible('#task-status-'.$edit->id)
->click('[data-tasks-collapse-all]')
->assertSee('Kaikki tehtävät supistettu.')
->assertMissing('#task-status-'.$shoot->id)
->assertMissing('#task-status-'.$edit->id)
->click('[data-tasks-expand-all]')
->assertSee('Kaikki tehtävät laajennettu.')
->assertAttribute('#task-toggle-'.$shoot->id, 'aria-expanded', 'true')
->assertAttribute('#task-toggle-'.$edit->id, 'aria-expanded', 'true');
$page->assertAttribute('#history-toggle', 'aria-expanded', 'false')
->assertMissing('#history-panel')
->keys('#history-toggle', 'Enter')
->assertAttribute('#history-toggle', 'aria-expanded', 'true')
->assertVisible('#history-panel')
->assertNoAccessibilityIssues(level: 2);
});
it('adds, checks, renames, moves and removes checklist items with the keyboard', function () { it('adds, checks, renames, moves and removes checklist items with the keyboard', function () {
$this->job->update(['status' => 'order']); $this->job->update(['status' => 'order']);
$workType = WorkTypeModel::query()->where('name', 'videokuvaus')->sole(); $workType = WorkTypeModel::query()->where('name', 'videokuvaus')->sole();
@@ -206,6 +251,7 @@ it('adds, checks, renames, moves and removes checklist items with the keyboard',
->create(['customer_job_id' => $this->job->id, 'work_type_id' => $workType->id, 'title' => 'Kuvauspäivä']); ->create(['customer_job_id' => $this->job->id, 'work_type_id' => $workType->id, 'title' => 'Kuvauspäivä']);
$page = visit(route('jobs.show', $this->job->id)) $page = visit(route('jobs.show', $this->job->id))
->click('#task-toggle-'.$task->id)
->type('#checklist-new-'.$task->id, 'Valot') ->type('#checklist-new-'.$task->id, 'Valot')
->keys('#checklist-new-'.$task->id, 'Enter') ->keys('#checklist-new-'.$task->id, 'Enter')
->assertSee('Kohta Valot lisätty.') ->assertSee('Kohta Valot lisätty.')