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:
@@ -36,8 +36,10 @@ class TaskForm extends Form
|
||||
|
||||
public string $description = '';
|
||||
|
||||
public string $assignee_user_id = '';
|
||||
|
||||
/** @var list<string> */
|
||||
public array $assignee_user_ids = [];
|
||||
public array $member_user_ids = [];
|
||||
|
||||
public function fillFromSummary(TaskSummary $task): void
|
||||
{
|
||||
@@ -49,7 +51,8 @@ class TaskForm extends Form
|
||||
$this->planned_from = $task->plannedFrom ?? '';
|
||||
$this->planned_to = $task->plannedTo ?? '';
|
||||
$this->description = $task->description ?? '';
|
||||
$this->assignee_user_ids = array_map(fn (NamedId $user): string => (string) $user->id, $task->assignees);
|
||||
$this->assignee_user_id = $task->assignee === null ? '' : (string) $task->assignee->id;
|
||||
$this->member_user_ids = array_map(fn (NamedId $user): string => (string) $user->id, $task->members);
|
||||
}
|
||||
|
||||
public function toData(): TaskData
|
||||
@@ -63,7 +66,8 @@ class TaskForm extends Form
|
||||
description: trim($this->description) === '' ? null : $this->description,
|
||||
dueOn: $this->due_on === '' ? null : $this->due_on,
|
||||
estimatedHours: trim($this->estimated_hours) === '' ? null : $this->estimated_hours,
|
||||
assigneeUserIds: array_map('intval', $this->assignee_user_ids),
|
||||
assigneeUserId: $this->assignee_user_id === '' ? null : (int) $this->assignee_user_id,
|
||||
memberUserIds: array_map('intval', $this->member_user_ids),
|
||||
plannedFrom: $this->planned_from === '' ? null : $this->planned_from,
|
||||
plannedTo: $this->planned_from === '' || $this->planned_to === '' ? null : $this->planned_to,
|
||||
);
|
||||
@@ -76,7 +80,11 @@ class TaskForm extends Form
|
||||
$exception instanceof InvalidEstimatedHours => ['estimated_hours', 'jobs.errors.invalid_hours'],
|
||||
$exception instanceof TasksNotAllowedYet => ['title', 'jobs.tasks.not_allowed_yet'],
|
||||
$exception instanceof PlanEndsBeforeStart => ['planned_to', 'jobs.calendar.errors.to'],
|
||||
$exception instanceof InvalidTaskReference => [$exception->field === 'work_type' ? 'work_type_id' : 'assignee_user_ids', 'jobs.errors.invalid_reference'],
|
||||
$exception instanceof InvalidTaskReference => [match ($exception->field) {
|
||||
'work_type' => 'work_type_id',
|
||||
'assignee' => 'assignee_user_id',
|
||||
default => 'member_user_ids',
|
||||
}, 'jobs.errors.invalid_reference'],
|
||||
default => throw $exception,
|
||||
};
|
||||
|
||||
@@ -97,8 +105,9 @@ class TaskForm extends Form
|
||||
'planned_to' => ['nullable', 'date_format:Y-m-d', 'after_or_equal:planned_from'],
|
||||
'estimated_hours' => ['nullable', 'numeric', 'min:0', 'max:99999'],
|
||||
'description' => ['nullable', 'string', 'max:10000'],
|
||||
'assignee_user_ids' => ['array'],
|
||||
'assignee_user_ids.*' => ['integer'],
|
||||
'assignee_user_id' => ['nullable', 'integer'],
|
||||
'member_user_ids' => ['array'],
|
||||
'member_user_ids.*' => ['integer'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -347,8 +347,12 @@ new class extends Component
|
||||
<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.assignees') }}</dt>
|
||||
<dd>{{ $task->assignees === [] ? __('jobs.not_set') : collect($task->assignees)->pluck('name')->join(', ') }}</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>
|
||||
|
||||
@@ -58,7 +58,7 @@ new class extends Component
|
||||
|
||||
if ($task === null) {
|
||||
abort_unless($details->status->allowsTasks(), 404);
|
||||
$this->form->assignee_user_ids = [(string) auth()->id()];
|
||||
$this->form->assignee_user_id = (string) auth()->id();
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -193,10 +193,18 @@ new class extends Component
|
||||
@endforeach
|
||||
</x-select.native>
|
||||
|
||||
<x-select.native wire:model="form.assignee_user_id" :label="__('jobs.tasks.fields.assignee')" :aria-label="__('jobs.tasks.fields.assignee')" :hint="__('jobs.tasks.fields.assignee_hint')">
|
||||
<option value="">{{ __('jobs.calendar.no_assignee') }}</option>
|
||||
@foreach ($this->userOptions as $user)
|
||||
<option value="{{ $user['value'] }}">{{ $user['note'] === null ? $user['label'] : $user['label'].' ('.$user['note'].')' }}</option>
|
||||
@endforeach
|
||||
</x-select.native>
|
||||
|
||||
<x-checkbox-group
|
||||
:legend="__('jobs.tasks.fields.assignees')"
|
||||
model="form.assignee_user_ids"
|
||||
:legend="__('jobs.tasks.fields.members')"
|
||||
model="form.member_user_ids"
|
||||
:options="$this->userOptions"
|
||||
:hint="__('jobs.tasks.fields.members_hint')"
|
||||
/>
|
||||
|
||||
<div class="grid gap-6 sm:grid-cols-3">
|
||||
|
||||
@@ -12,6 +12,8 @@ use App\Modules\Jobs\Domain\Exceptions\InvalidEstimatedHours;
|
||||
use App\Modules\Jobs\Domain\Exceptions\InvalidTaskReference;
|
||||
use App\Modules\Jobs\Domain\Exceptions\TasksNotAllowedYet;
|
||||
use App\Modules\Jobs\Domain\Exceptions\WorkflowTemplateNotAvailable;
|
||||
use App\Modules\Users\Application\Contracts\UserAccountQueries;
|
||||
use App\Modules\Users\Domain\Enums\Role;
|
||||
use Livewire\Attributes\Computed;
|
||||
use Livewire\Attributes\Locked;
|
||||
use Livewire\Component;
|
||||
@@ -19,7 +21,8 @@ use Livewire\Component;
|
||||
/**
|
||||
* Adds a job's tasks from a workflow template (työnkulkupohja): one task per
|
||||
* step. Once a template is chosen, a table of its tasks takes an optional
|
||||
* due date and estimate for each.
|
||||
* due date, estimate and assignee (the adder by default) for each; tasks
|
||||
* with a due date are scheduled to end on it unless that is turned off.
|
||||
*/
|
||||
new class extends Component
|
||||
{
|
||||
@@ -38,10 +41,12 @@ new class extends Component
|
||||
/**
|
||||
* One row per step of the chosen template, in step order.
|
||||
*
|
||||
* @var list<array{due_on: string, estimated_hours: string}>
|
||||
* @var list<array{due_on: string, estimated_hours: string, assignee_user_id: string}>
|
||||
*/
|
||||
public array $rows = [];
|
||||
|
||||
public bool $scheduleToDueDates = true;
|
||||
|
||||
public function mount(CustomerJobQueries $jobQueries, int $job): void
|
||||
{
|
||||
$details = $jobQueries->findDetails($job);
|
||||
@@ -85,6 +90,18 @@ new class extends Component
|
||||
], $this->templates);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array{value: int, label: string}>
|
||||
*/
|
||||
#[Computed]
|
||||
public function userOptions(): array
|
||||
{
|
||||
return array_map(fn ($user): array => [
|
||||
'value' => $user->id,
|
||||
'label' => $user->role === Role::Subcontractor ? $user->name.' ('.__('users.roles.subcontractor').')' : $user->name,
|
||||
], app(UserAccountQueries::class)->activeUserOptions());
|
||||
}
|
||||
|
||||
#[Computed]
|
||||
public function selectedTemplate(): ?WorkflowTemplateDetails
|
||||
{
|
||||
@@ -103,7 +120,7 @@ new class extends Component
|
||||
public function updatedTemplateId(): void
|
||||
{
|
||||
$this->resetErrorBag();
|
||||
$this->rows = array_map(fn (): array => ['due_on' => '', 'estimated_hours' => ''], $this->selectedTemplate?->steps ?? []);
|
||||
$this->rows = array_map(fn (): array => ['due_on' => '', 'estimated_hours' => '', 'assignee_user_id' => (string) auth()->id()], $this->selectedTemplate?->steps ?? []);
|
||||
}
|
||||
|
||||
public function add(AddTasksFromWorkflowTemplate $addTasks): void
|
||||
@@ -116,6 +133,8 @@ new class extends Component
|
||||
'rows' => ['array'],
|
||||
'rows.*.due_on' => ['nullable', 'date_format:Y-m-d'],
|
||||
'rows.*.estimated_hours' => ['nullable', 'regex:/^\s*\d{1,5}([.,]\d{1,2})?\s*$/'],
|
||||
'rows.*.assignee_user_id' => ['nullable', 'integer'],
|
||||
'scheduleToDueDates' => ['boolean'],
|
||||
],
|
||||
[
|
||||
'templateId.required' => __('jobs.tasks.from_template.choose'),
|
||||
@@ -129,10 +148,11 @@ new class extends Component
|
||||
$schedules = array_map(fn (array $row): TemplateTaskSchedule => new TemplateTaskSchedule(
|
||||
$row['due_on'] === '' ? null : $row['due_on'],
|
||||
trim($row['estimated_hours']) === '' ? null : $row['estimated_hours'],
|
||||
$row['assignee_user_id'] === '' ? null : (int) $row['assignee_user_id'],
|
||||
), $this->rows);
|
||||
|
||||
try {
|
||||
$count = $addTasks->execute($this->jobId, (int) $this->templateId, (int) auth()->id(), $schedules);
|
||||
$result = $addTasks->execute($this->jobId, (int) $this->templateId, (int) auth()->id(), $schedules, $this->scheduleToDueDates);
|
||||
} catch (CustomerJobNotFound) {
|
||||
abort(404);
|
||||
} catch (TasksNotAllowedYet) {
|
||||
@@ -143,17 +163,39 @@ new class extends Component
|
||||
$this->addError('templateId', __('jobs.errors.invalid_hours'));
|
||||
|
||||
return;
|
||||
} catch (WorkflowTemplateNotAvailable|InvalidTaskReference) {
|
||||
} catch (InvalidTaskReference $exception) {
|
||||
if ($exception->field === 'assignee') {
|
||||
unset($this->userOptions);
|
||||
$this->addError('templateId', __('jobs.errors.invalid_reference'));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
unset($this->templates, $this->options, $this->selectedTemplate);
|
||||
$this->addError('templateId', __('jobs.tasks.from_template.not_available'));
|
||||
|
||||
return;
|
||||
} catch (WorkflowTemplateNotAvailable) {
|
||||
unset($this->templates, $this->options, $this->selectedTemplate);
|
||||
$this->addError('templateId', __('jobs.tasks.from_template.not_available'));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
session()->flash('status', trans_choice('jobs.tasks.from_template.added', $count, [
|
||||
'count' => $count,
|
||||
$message = trans_choice('jobs.tasks.from_template.added', $result->added, [
|
||||
'count' => $result->added,
|
||||
'name' => $template === null ? '' : $this->labelOf($template),
|
||||
]));
|
||||
]);
|
||||
|
||||
if ($result->scheduled > 0) {
|
||||
$message .= ' '.trans_choice('jobs.tasks.from_template.scheduled', $result->scheduled, ['count' => $result->scheduled]);
|
||||
}
|
||||
|
||||
if ($result->late > 0) {
|
||||
$message .= ' '.trans_choice('jobs.tasks.from_template.late', $result->late, ['count' => $result->late]);
|
||||
}
|
||||
|
||||
session()->flash('status', $message);
|
||||
|
||||
$this->redirect(route('jobs.show', $this->jobId).'#tasks', navigate: true);
|
||||
}
|
||||
@@ -201,23 +243,26 @@ new class extends Component
|
||||
<div class="space-y-2">
|
||||
<p class="text-sm text-zinc-600 dark:text-zinc-300">{{ __('jobs.tasks.from_template.schedule_help') }}</p>
|
||||
|
||||
{{-- Below sm the rows stack (each cell on its own line, with its own visible label) so that the page reflows at 320 px. --}}
|
||||
<table class="w-full border-collapse text-sm">
|
||||
<caption class="mb-2 text-left font-medium">{{ __('jobs.tasks.from_template.table_caption', ['name' => $template->name]) }}</caption>
|
||||
<thead>
|
||||
<thead class="max-sm:hidden">
|
||||
<tr class="border-b border-zinc-200 dark:border-zinc-700">
|
||||
<th scope="col" class="py-2 pr-2 text-left font-semibold">{{ __('jobs.tasks.from_template.task') }}</th>
|
||||
<th scope="col" class="px-1 py-2 text-left font-semibold">{{ __('jobs.tasks.fields.due_on') }}</th>
|
||||
<th scope="col" class="py-2 pl-1 text-left font-semibold">{{ __('jobs.tasks.fields.estimated_hours') }}</th>
|
||||
<th scope="col" class="px-1 py-2 text-left font-semibold">{{ __('jobs.tasks.fields.estimated_hours') }}</th>
|
||||
<th scope="col" class="py-2 pl-1 text-left font-semibold">{{ __('jobs.tasks.fields.assignee') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tbody class="max-sm:block">
|
||||
@foreach ($template->steps as $index => $step)
|
||||
<tr wire:key="row-{{ $template->id }}-{{ $index }}" class="border-b border-zinc-200 align-top dark:border-zinc-700">
|
||||
<th scope="row" class="py-2 pr-2 text-left font-normal break-words">
|
||||
<tr wire:key="row-{{ $template->id }}-{{ $index }}" class="border-b border-zinc-200 align-top max-sm:block max-sm:py-2 dark:border-zinc-700">
|
||||
<th scope="row" class="py-2 pr-2 text-left font-normal break-words max-sm:block max-sm:py-0">
|
||||
<span class="font-medium">{{ $step->title }}</span>
|
||||
<span class="block text-xs text-zinc-600 dark:text-zinc-300">{{ $step->workTypeName }}</span>
|
||||
</th>
|
||||
<td class="px-1 py-2">
|
||||
<td class="px-1 py-2 max-sm:block max-sm:px-0 max-sm:py-1">
|
||||
<span class="block text-xs font-medium sm:hidden" aria-hidden="true">{{ __('jobs.tasks.fields.due_on') }}</span>
|
||||
<input
|
||||
type="date"
|
||||
id="row-{{ $index }}-due-on"
|
||||
@@ -230,7 +275,8 @@ new class extends Component
|
||||
<p id="row-{{ $index }}-due-on-error" class="mt-1 text-xs text-red-700 dark:text-red-400">{{ $message }}</p>
|
||||
@enderror
|
||||
</td>
|
||||
<td class="py-2 pl-1">
|
||||
<td class="px-1 py-2 max-sm:block max-sm:px-0 max-sm:py-1">
|
||||
<span class="block text-xs font-medium sm:hidden" aria-hidden="true">{{ __('jobs.tasks.fields.estimated_hours') }}</span>
|
||||
<input
|
||||
type="text"
|
||||
inputmode="decimal"
|
||||
@@ -239,16 +285,40 @@ new class extends Component
|
||||
wire:model="rows.{{ $index }}.estimated_hours"
|
||||
aria-label="{{ __('jobs.tasks.from_template.hours_of', ['title' => $step->title]) }}"
|
||||
@error('rows.'.$index.'.estimated_hours') aria-invalid="true" aria-describedby="row-{{ $index }}-hours-error" @enderror
|
||||
class="w-16 rounded-md border border-zinc-500 bg-white px-2 py-1 text-sm dark:border-zinc-400 dark:bg-zinc-800"
|
||||
class="w-16 rounded-md border max-sm:w-full border-zinc-500 bg-white px-2 py-1 text-sm dark:border-zinc-400 dark:bg-zinc-800"
|
||||
/>
|
||||
@error('rows.'.$index.'.estimated_hours')
|
||||
<p id="row-{{ $index }}-hours-error" class="mt-1 text-xs text-red-700 dark:text-red-400">{{ $message }}</p>
|
||||
@enderror
|
||||
</td>
|
||||
<td class="py-2 pl-1 max-sm:block max-sm:py-1 max-sm:pl-0">
|
||||
<span class="block text-xs font-medium sm:hidden" aria-hidden="true">{{ __('jobs.tasks.fields.assignee') }}</span>
|
||||
<select
|
||||
id="row-{{ $index }}-assignee"
|
||||
wire:model="rows.{{ $index }}.assignee_user_id"
|
||||
aria-label="{{ __('jobs.tasks.from_template.assignee_of', ['title' => $step->title]) }}"
|
||||
class="w-full min-w-0 rounded-md border border-zinc-500 bg-white px-1 py-1 text-sm dark:border-zinc-400 dark:bg-zinc-800"
|
||||
>
|
||||
<option value="">{{ __('jobs.calendar.no_assignee') }}</option>
|
||||
@foreach ($this->userOptions as $user)
|
||||
<option value="{{ $user['value'] }}">{{ $user['label'] }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="space-y-1 pt-2">
|
||||
<x-checkbox
|
||||
id="schedule-to-due-dates"
|
||||
wire:model="scheduleToDueDates"
|
||||
aria-describedby="schedule-to-due-dates-hint"
|
||||
:label="__('jobs.tasks.from_template.schedule_to_due')"
|
||||
/>
|
||||
<p id="schedule-to-due-dates-hint" class="text-sm text-zinc-600 dark:text-zinc-300">{{ __('jobs.tasks.from_template.schedule_to_due_hint') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user