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:
@@ -335,95 +335,161 @@ new class extends Component
|
||||
@php($canChangeStatus = Gate::allows('jobs.update-task-status', $job->id))
|
||||
@php($canManageTasks = Gate::allows('jobs.manage-tasks', $job->id))
|
||||
|
||||
{{--
|
||||
Task cards are disclosures: collapsed by default, each opened on its own, so several can be open at once.
|
||||
"Expand all" and "Collapse all" send a tasks-expand window event that every card follows. A card also opens
|
||||
when focus moves into it (e.g. the status select keeps focus after a re-render).
|
||||
--}}
|
||||
<div
|
||||
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>
|
||||
|
||||
<ul class="space-y-3">
|
||||
@foreach ($this->tasks as $task)
|
||||
<li wire:key="task-{{ $task->id }}">
|
||||
<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">
|
||||
<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>
|
||||
<span>{{ __('jobs.tasks.statuses.'.$task->status->value) }}</span>
|
||||
<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>
|
||||
|
||||
<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>
|
||||
<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 !== [])
|
||||
<dt class="font-medium">{{ __('jobs.tasks.fields.members') }}</dt>
|
||||
<dd>{{ collect($task->members)->pluck('name')->join(', ') }}</dd>
|
||||
@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>
|
||||
<dd>
|
||||
@if ($task->plannedFrom === null)
|
||||
{{ __('jobs.not_set') }}
|
||||
@else
|
||||
{{ __('jobs.tasks.schedule_range', ['from' => $this->formatDate($task->plannedFrom), 'to' => $this->formatDate($task->plannedTo)]) }}
|
||||
<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]">
|
||||
<dt class="font-medium">{{ __('jobs.tasks.fields.work_type') }}</dt>
|
||||
<dd>{{ $task->workType->name }}</dd>
|
||||
@if ($task->members !== [])
|
||||
<dt class="font-medium">{{ __('jobs.tasks.fields.members') }}</dt>
|
||||
<dd>{{ collect($task->members)->pluck('name')->join(', ') }}</dd>
|
||||
@endif
|
||||
</dd>
|
||||
<dt class="font-medium">{{ __('jobs.tasks.fields.estimated_hours') }}</dt>
|
||||
<dd>{{ $task->estimatedHours === null ? __('jobs.not_set') : str_replace('.', ',', $task->estimatedHours).' h' }}</dd>
|
||||
</dl>
|
||||
<dt class="font-medium">{{ __('jobs.tasks.schedule') }}</dt>
|
||||
<dd>
|
||||
@if ($task->plannedFrom === null)
|
||||
{{ __('jobs.not_set') }}
|
||||
@else
|
||||
{{ __('jobs.tasks.schedule_range', ['from' => $this->formatDate($task->plannedFrom), 'to' => $this->formatDate($task->plannedTo)]) }}
|
||||
@endif
|
||||
</dd>
|
||||
<dt class="font-medium">{{ __('jobs.tasks.fields.estimated_hours') }}</dt>
|
||||
<dd>{{ $task->estimatedHours === null ? __('jobs.not_set') : str_replace('.', ',', $task->estimatedHours).' h' }}</dd>
|
||||
</dl>
|
||||
|
||||
@if ($task->description !== null)
|
||||
<p class="whitespace-pre-line">{{ $task->description }}</p>
|
||||
@endif
|
||||
|
||||
<livewire:jobs::task-checklist :job-id="$job->id" :task-id="$task->id" :task-title="$task->title" :wire:key="'checklist-'.$task->id" />
|
||||
|
||||
<div class="flex flex-wrap items-end gap-3">
|
||||
@if ($canChangeStatus)
|
||||
<div class="w-full sm:w-56">
|
||||
{{-- TallStackUI's native select does not tie its label to the control, so aria-label names it. --}}
|
||||
<x-select.native
|
||||
id="task-status-{{ $task->id }}"
|
||||
wire:change="changeTaskStatus({{ $task->id }}, $event.target.value)"
|
||||
:label="__('jobs.tasks.fields.status')"
|
||||
:aria-label="__('jobs.tasks.status_of', ['title' => $task->title])"
|
||||
>
|
||||
@foreach (TaskStatus::cases() as $status)
|
||||
<option value="{{ $status->value }}" @selected($status === $task->status)>{{ __('jobs.tasks.statuses.'.$status->value) }}</option>
|
||||
@endforeach
|
||||
</x-select.native>
|
||||
</div>
|
||||
@if ($task->description !== null)
|
||||
<p class="whitespace-pre-line">{{ $task->description }}</p>
|
||||
@endif
|
||||
|
||||
@if (! $job->status->locksTime() && Gate::allows('time.book', $job->id))
|
||||
<x-button
|
||||
:href="route('time.task', $task->id)"
|
||||
wire:navigate
|
||||
subtle
|
||||
color="black"
|
||||
sm
|
||||
icon="clock"
|
||||
:text="__('jobs.tasks.book_time')"
|
||||
:aria-label="__('jobs.tasks.book_time_named', ['title' => $task->title])"
|
||||
/>
|
||||
@endif
|
||||
<livewire:jobs::task-checklist :job-id="$job->id" :task-id="$task->id" :task-title="$task->title" :wire:key="'checklist-'.$task->id" />
|
||||
|
||||
@if ($canManageTasks)
|
||||
<x-button
|
||||
:href="route('jobs.tasks.edit', [$job->id, $task->id])"
|
||||
wire:navigate
|
||||
subtle
|
||||
color="black"
|
||||
sm
|
||||
icon="pencil"
|
||||
:text="__('jobs.edit')"
|
||||
:aria-label="__('jobs.tasks.edit_named', ['title' => $task->title])"
|
||||
/>
|
||||
<x-button
|
||||
wire:click="confirmTaskRemoval({{ $task->id }})"
|
||||
subtle
|
||||
color="black"
|
||||
sm
|
||||
icon="trash"
|
||||
:text="__('customers.remove')"
|
||||
:aria-label="__('jobs.tasks.remove_named', ['title' => $task->title])"
|
||||
/>
|
||||
@endif
|
||||
<div class="flex flex-wrap items-end gap-3">
|
||||
@if ($canChangeStatus)
|
||||
<div class="w-full sm:w-56">
|
||||
{{-- TallStackUI's native select does not tie its label to the control, so aria-label names it. --}}
|
||||
<x-select.native
|
||||
id="task-status-{{ $task->id }}"
|
||||
wire:change="changeTaskStatus({{ $task->id }}, $event.target.value)"
|
||||
:label="__('jobs.tasks.fields.status')"
|
||||
:aria-label="__('jobs.tasks.status_of', ['title' => $task->title])"
|
||||
>
|
||||
@foreach (TaskStatus::cases() as $status)
|
||||
<option value="{{ $status->value }}" @selected($status === $task->status)>{{ __('jobs.tasks.statuses.'.$status->value) }}</option>
|
||||
@endforeach
|
||||
</x-select.native>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@if (! $job->status->locksTime() && Gate::allows('time.book', $job->id))
|
||||
<x-button
|
||||
:href="route('time.task', $task->id)"
|
||||
wire:navigate
|
||||
subtle
|
||||
color="black"
|
||||
sm
|
||||
icon="clock"
|
||||
:text="__('jobs.tasks.book_time')"
|
||||
:aria-label="__('jobs.tasks.book_time_named', ['title' => $task->title])"
|
||||
/>
|
||||
@endif
|
||||
|
||||
@if ($canManageTasks)
|
||||
<x-button
|
||||
:href="route('jobs.tasks.edit', [$job->id, $task->id])"
|
||||
wire:navigate
|
||||
subtle
|
||||
color="black"
|
||||
sm
|
||||
icon="pencil"
|
||||
:text="__('jobs.edit')"
|
||||
:aria-label="__('jobs.tasks.edit_named', ['title' => $task->title])"
|
||||
/>
|
||||
<x-button
|
||||
wire:click="confirmTaskRemoval({{ $task->id }})"
|
||||
subtle
|
||||
color="black"
|
||||
sm
|
||||
icon="trash"
|
||||
:text="__('customers.remove')"
|
||||
:aria-label="__('jobs.tasks.remove_named', ['title' => $task->title])"
|
||||
/>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
</li>
|
||||
@@ -474,33 +540,49 @@ new class extends Component
|
||||
<p class="whitespace-pre-line text-sm">{{ $job->instructions ?? __('jobs.not_set') }}</p>
|
||||
</section>
|
||||
|
||||
<section aria-labelledby="history-heading" class="space-y-3">
|
||||
<h2 id="history-heading" class="text-xl font-semibold">{{ __('jobs.sections.history') }}</h2>
|
||||
<section aria-labelledby="history-heading" class="space-y-3" x-data="{ open: false }">
|
||||
<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>
|
||||
|
||||
@if ($this->changes === [])
|
||||
<p class="text-sm text-zinc-600 dark:text-zinc-300">{{ __('jobs.history.empty') }}</p>
|
||||
@else
|
||||
<ol class="space-y-2 text-sm">
|
||||
@foreach ($this->changes as $change)
|
||||
<li class="border-b border-zinc-200 pb-2 dark:border-zinc-700">
|
||||
@if ($change->field === 'created')
|
||||
{{ __('jobs.history.created', ['user' => $change->userName, 'number' => $change->newValue]) }}
|
||||
@else
|
||||
<span class="break-words">{{ __('jobs.history.changed', [
|
||||
'field' => __('jobs.fields.'.$change->field),
|
||||
'old' => $this->historyValue($change->field, $change->oldValue),
|
||||
'new' => $this->historyValue($change->field, $change->newValue),
|
||||
]) }}</span>
|
||||
@if ($change->field === 'status' && \App\Modules\Jobs\Domain\Enums\JobStatus::tryFrom((string) $change->oldValue)?->unlocksTo(\App\Modules\Jobs\Domain\Enums\JobStatus::from((string) $change->newValue)))
|
||||
<span class="font-medium">{{ __('jobs.history.unlocked') }}</span>
|
||||
<div id="history-panel" x-show="open" x-cloak>
|
||||
@if ($this->changes === [])
|
||||
<p class="text-sm text-zinc-600 dark:text-zinc-300">{{ __('jobs.history.empty') }}</p>
|
||||
@else
|
||||
<ol class="space-y-2 text-sm">
|
||||
@foreach ($this->changes as $change)
|
||||
<li class="border-b border-zinc-200 pb-2 dark:border-zinc-700">
|
||||
@if ($change->field === 'created')
|
||||
{{ __('jobs.history.created', ['user' => $change->userName, 'number' => $change->newValue]) }}
|
||||
@else
|
||||
<span class="break-words">{{ __('jobs.history.changed', [
|
||||
'field' => __('jobs.fields.'.$change->field),
|
||||
'old' => $this->historyValue($change->field, $change->oldValue),
|
||||
'new' => $this->historyValue($change->field, $change->newValue),
|
||||
]) }}</span>
|
||||
@if ($change->field === 'status' && \App\Modules\Jobs\Domain\Enums\JobStatus::tryFrom((string) $change->oldValue)?->unlocksTo(\App\Modules\Jobs\Domain\Enums\JobStatus::from((string) $change->newValue)))
|
||||
<span class="font-medium">{{ __('jobs.history.unlocked') }}</span>
|
||||
@endif
|
||||
@endif
|
||||
@endif
|
||||
<span class="block text-zinc-600 dark:text-zinc-300">
|
||||
{{ __('jobs.history.by', ['user' => $change->userName, 'time' => CarbonImmutable::parse($change->changedAt)->format('j.n.Y H.i')]) }}
|
||||
</span>
|
||||
</li>
|
||||
@endforeach
|
||||
</ol>
|
||||
@endif
|
||||
<span class="block text-zinc-600 dark:text-zinc-300">
|
||||
{{ __('jobs.history.by', ['user' => $change->userName, 'time' => CarbonImmutable::parse($change->changedAt)->format('j.n.Y H.i')]) }}
|
||||
</span>
|
||||
</li>
|
||||
@endforeach
|
||||
</ol>
|
||||
@endif
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user