Give tasks one assignee and members, and schedule template tasks to due dates
- A task now has one optional assignee (tasks.assignee_user_id), whose calendar row it is on and whose days its estimate books, and members (task_members) who see it among their own jobs and in the weekly sheet but get no bookings. A migration moves existing assignees over: the one with most booked time becomes the assignee, the others members. - Adding tasks from a workflow template asks for each step's assignee and, by default, schedules tasks with a due date to end on it, booking the estimate backwards from the due date (not before today); what does not fit runs past the due date and is reported as late. - The task calendar leaves quick sale tasks out of the unscheduled list, shows a bar's job details in a popover on hover and focus, and shows the day load on its own grid line. - The template table stacks its cells on narrow screens to reflow at 320 px. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -365,6 +365,10 @@ new class extends Component
|
||||
|
||||
public function hours(int $minutes): string
|
||||
{
|
||||
if ($minutes === 0) {
|
||||
return '0';
|
||||
}
|
||||
|
||||
return rtrim(rtrim(number_format($minutes / 60, 2, ',', ''), '0'), ',');
|
||||
}
|
||||
|
||||
@@ -389,12 +393,11 @@ new class extends Component
|
||||
|
||||
/**
|
||||
* The person an unscheduled task is moved from when it is dropped on a
|
||||
* row: its only assignee, so that the task moves rather than gets a
|
||||
* second assignee.
|
||||
* row: its assignee, who the person on the row replaces.
|
||||
*/
|
||||
public function onlyAssignee(CalendarTask $task): ?int
|
||||
{
|
||||
return count($task->assignments) === 1 ? $task->assignments[0]->userId : null;
|
||||
return $task->assignment?->userId;
|
||||
}
|
||||
|
||||
public function render(): mixed
|
||||
@@ -543,7 +546,7 @@ new class extends Component
|
||||
x-data="taskCalendar(@js($canManage))"
|
||||
x-on:pointermove.window="track($event)"
|
||||
x-on:pointerup.window="drop($event)"
|
||||
x-on:keydown.escape.window="cancel()"
|
||||
x-on:keydown.escape.window="cancel(); closeInfo()"
|
||||
x-on:task-calendar-place.window="begin($event.detail.event, 'place', $event.detail.bar)"
|
||||
>
|
||||
<div class="grid border-b border-zinc-300 text-sm dark:border-zinc-600" style="{{ $columns }}" aria-hidden="true">
|
||||
@@ -598,22 +601,31 @@ new class extends Component
|
||||
data-calendar-user="{{ $row->userId ?? '' }}"
|
||||
x-bind:class="isTarget('{{ $day }}', '{{ $row->userId ?? '' }}') && 'outline-2 -outline-offset-2 outline-blue-700 dark:outline-blue-300'"
|
||||
@class([
|
||||
'min-h-12 border-l border-zinc-200 px-1 pt-1 pb-2 text-right text-xs dark:border-zinc-700',
|
||||
'min-h-12 border-l border-zinc-200 dark:border-zinc-700',
|
||||
'bg-zinc-200 dark:bg-zinc-800' => $this->isDayOff($day),
|
||||
])
|
||||
style="grid-column: {{ $index + 2 }}; grid-row: 1 / span {{ $row->lanes + 1 }};"
|
||||
>
|
||||
@if ($booked > 0)
|
||||
></div>
|
||||
|
||||
{{-- The day's booked time on its own grid line, above the task bars. --}}
|
||||
@if ($row->userId !== null && ($booked > 0 || ! $this->isDayOff($day)))
|
||||
<div
|
||||
wire:key="load-{{ $rowKey }}-{{ $day }}"
|
||||
@class([
|
||||
'pointer-events-none px-1 pt-1 text-right text-xs whitespace-nowrap',
|
||||
'font-semibold' => $booked > $this->capacityMinutes,
|
||||
'text-zinc-600 dark:text-zinc-300' => $booked === 0,
|
||||
])
|
||||
style="grid-column: {{ $index + 2 }}; grid-row: 1;"
|
||||
>
|
||||
<span class="sr-only">{{ $this->dayLabel($day) }}:</span>
|
||||
<span @class(['font-semibold' => $booked > $this->capacityMinutes])>
|
||||
{{ __('jobs.calendar.load', ['booked' => $this->hours($booked), 'capacity' => $capacity]) }}
|
||||
@if ($booked > $this->capacityMinutes)
|
||||
<x-icon name="exclamation-triangle" class="inline size-3" aria-hidden="true" />
|
||||
{{ __('jobs.calendar.over_capacity') }}
|
||||
@endif
|
||||
</span>
|
||||
@endif
|
||||
</div>
|
||||
{{ __('jobs.calendar.load', ['booked' => $this->hours($booked), 'capacity' => $capacity]) }}
|
||||
@if ($booked > $this->capacityMinutes)
|
||||
<x-icon name="exclamation-triangle" class="inline size-3" aria-hidden="true" />
|
||||
{{ __('jobs.calendar.over_capacity') }}
|
||||
@endif
|
||||
</div>
|
||||
@endif
|
||||
@endforeach
|
||||
|
||||
@foreach ($row->bars as $bar)
|
||||
@@ -622,6 +634,11 @@ new class extends Component
|
||||
id="bar-{{ $bar->key() }}"
|
||||
wire:key="bar-{{ $bar->key() }}"
|
||||
aria-label="{{ $this->barLabel($bar) }}"
|
||||
aria-describedby="bar-info-{{ $bar->key() }}"
|
||||
x-on:mouseenter="showInfo($el, 'bar-info-{{ $bar->key() }}')"
|
||||
x-on:mouseleave="hideInfo('bar-info-{{ $bar->key() }}')"
|
||||
x-on:focus="showInfo($el, 'bar-info-{{ $bar->key() }}')"
|
||||
x-on:blur="hideInfo('bar-info-{{ $bar->key() }}', 0)"
|
||||
x-on:pointerdown="begin($event, 'move', @js(['task' => $bar->task->taskId, 'job' => $bar->task->jobId, 'user' => $bar->userId, 'from' => $bar->from, 'to' => $bar->to]))"
|
||||
x-on:click="if (! consumeDrag()) $wire.openDialog({{ $bar->task->taskId }}, {{ $bar->userId ?? 'null' }})"
|
||||
@class([
|
||||
@@ -656,6 +673,48 @@ new class extends Component
|
||||
></span>
|
||||
@endif
|
||||
</button>
|
||||
|
||||
{{-- The job's basic details on hover and focus (WCAG 1.4.13: hoverable, Escape closes it). --}}
|
||||
<div
|
||||
id="bar-info-{{ $bar->key() }}"
|
||||
wire:key="bar-info-{{ $bar->key() }}"
|
||||
popover="manual"
|
||||
role="tooltip"
|
||||
x-on:mouseenter="keepInfo()"
|
||||
x-on:mouseleave="hideInfo('bar-info-{{ $bar->key() }}')"
|
||||
class="m-0 w-80 max-w-[calc(100vw-1rem)] rounded-lg border border-zinc-300 bg-white p-3 text-left text-sm text-zinc-900 shadow-lg dark:border-zinc-600 dark:bg-zinc-800 dark:text-white"
|
||||
style="inset: auto;"
|
||||
>
|
||||
<p class="font-semibold break-words">{{ $bar->task->title }}</p>
|
||||
<dl class="mt-2 grid grid-cols-[max-content_1fr] gap-x-3 gap-y-1">
|
||||
<dt class="font-medium">{{ __('jobs.calendar.info.job') }}</dt>
|
||||
<dd class="break-words">{{ $bar->task->jobNumber }} {{ $bar->task->jobName }}</dd>
|
||||
<dt class="font-medium">{{ __('jobs.calendar.info.customer') }}</dt>
|
||||
<dd class="break-words">{{ $bar->task->customerName ?? __('jobs.not_set') }}</dd>
|
||||
<dt class="font-medium">{{ __('jobs.calendar.info.job_status') }}</dt>
|
||||
<dd>{{ $bar->task->jobStatus === null ? __('jobs.not_set') : __('jobs.statuses.'.$bar->task->jobStatus->value) }}</dd>
|
||||
<dt class="font-medium">{{ __('jobs.calendar.info.job_due_on') }}</dt>
|
||||
<dd>{{ $bar->task->jobDueOn === null ? __('jobs.not_set') : $this->shortDate($bar->task->jobDueOn) }}</dd>
|
||||
<dt class="font-medium">{{ __('jobs.calendar.info.responsible') }}</dt>
|
||||
<dd class="break-words">{{ $bar->task->responsibleName ?? __('jobs.not_set') }}</dd>
|
||||
<dt class="font-medium">{{ __('jobs.calendar.info.work_type') }}</dt>
|
||||
<dd class="break-words">{{ $bar->task->workTypeName ?? __('jobs.not_set') }}</dd>
|
||||
<dt class="font-medium">{{ __('jobs.calendar.info.due_on') }}</dt>
|
||||
<dd>{{ $bar->task->dueOn === null ? __('jobs.not_set') : $this->shortDate($bar->task->dueOn) }}</dd>
|
||||
<dt class="font-medium">{{ __('jobs.calendar.info.schedule') }}</dt>
|
||||
<dd>
|
||||
{{ $this->shortDate($bar->from) }}–{{ $this->shortDate($bar->to) }}@if ($bar->minutes > 0), {{ $this->hours($bar->minutes) }} h @endif
|
||||
@if ($bar->late)
|
||||
<span class="inline-flex items-center gap-1 font-semibold">
|
||||
<x-icon name="exclamation-triangle" class="size-4" aria-hidden="true" />{{ __('jobs.late') }}
|
||||
</span>
|
||||
@endif
|
||||
</dd>
|
||||
</dl>
|
||||
@if ($bar->task->description !== null)
|
||||
<p class="mt-2 line-clamp-3 break-words whitespace-pre-line text-zinc-700 dark:text-zinc-200">{{ $bar->task->description }}</p>
|
||||
@endif
|
||||
</div>
|
||||
@endforeach
|
||||
</section>
|
||||
@endforeach
|
||||
@@ -683,6 +742,9 @@ new class extends Component
|
||||
<span class="font-semibold break-words">{{ $bar->task->title }}</span>
|
||||
<span>{{ $this->shortDate($bar->from) }}–{{ $this->shortDate($bar->to) }}@if ($bar->minutes > 0), {{ $this->hours($bar->minutes) }} h @endif</span>
|
||||
<span class="break-words">{{ $bar->task->jobNumber }} {{ $bar->task->jobName }} · {{ __('jobs.tasks.statuses.'.$bar->task->status->value) }}</span>
|
||||
@if ($bar->task->customerName !== null)
|
||||
<span class="break-words">{{ __('jobs.calendar.info.customer') }}: {{ $bar->task->customerName }}</span>
|
||||
@endif
|
||||
@if ($bar->late)
|
||||
<span class="inline-flex items-center gap-1 font-semibold">
|
||||
<x-icon name="exclamation-triangle" class="size-4" aria-hidden="true" />{{ __('jobs.late') }}
|
||||
@@ -721,7 +783,7 @@ new class extends Component
|
||||
<span class="font-semibold break-words">{{ $task->title }}</span>
|
||||
<span class="break-words">{{ $task->jobNumber }} {{ $task->jobName }}</span>
|
||||
<span class="break-words">
|
||||
{{ $task->assignments === [] ? __('jobs.calendar.no_assignee') : implode(', ', array_map(fn ($assignment) => $this->userNames[$assignment->userId] ?? '', $task->assignments)) }}
|
||||
{{ $task->assignment === null ? __('jobs.calendar.no_assignee') : ($this->userNames[$task->assignment->userId] ?? '') }}
|
||||
@if ($task->estimatedHours !== null) · {{ str_replace('.', ',', $task->estimatedHours) }} h @endif
|
||||
</span>
|
||||
@if ($task->dueOn !== null)
|
||||
|
||||
Reference in New Issue
Block a user