976 lines
59 KiB
PHP
976 lines
59 KiB
PHP
<?php
|
||
|
||
use App\Modules\Catalog\Application\Contracts\WorkflowTemplateQueries;
|
||
use App\Modules\Catalog\Application\DTOs\WorkflowTemplateDetails;
|
||
use App\Modules\Jobs\Application\Contracts\CustomerJobQueries;
|
||
use App\Modules\Jobs\Application\Contracts\LoggedJobHours;
|
||
use App\Modules\Jobs\Application\Contracts\TaskQueries;
|
||
use App\Modules\Jobs\Application\DTOs\CustomerJobDetails;
|
||
use App\Modules\Jobs\Application\DTOs\TaskData;
|
||
use App\Modules\Jobs\Application\DTOs\TaskSummary;
|
||
use App\Modules\Jobs\Application\UseCases\AddTask;
|
||
use App\Modules\Jobs\Application\UseCases\AddTasksFromWorkflowTemplate;
|
||
use App\Modules\Jobs\Application\UseCases\ChangeJobPriority;
|
||
use App\Modules\Jobs\Application\UseCases\ChangeJobStatus;
|
||
use App\Modules\Jobs\Application\UseCases\ChangeTaskStatus;
|
||
use App\Modules\Jobs\Application\UseCases\PinTaskToBoard;
|
||
use App\Modules\Jobs\Application\UseCases\UpdateCustomerJob;
|
||
use App\Modules\Jobs\Application\UseCases\UpdateTask;
|
||
use App\Modules\Jobs\Domain\Enums\JobKind;
|
||
use App\Modules\Jobs\Domain\Enums\JobStatus;
|
||
use App\Modules\Jobs\Domain\Enums\PaymentBasis;
|
||
use App\Modules\Jobs\Domain\Enums\Priority;
|
||
use App\Modules\Jobs\Domain\Enums\TaskStatus;
|
||
use App\Modules\Jobs\Domain\Exceptions\CustomerJobNotFound;
|
||
use App\Modules\Jobs\Domain\Exceptions\TaskNotFound;
|
||
use App\Modules\Jobs\Presentation\Livewire\Concerns\DescribesJobHistory;
|
||
use App\Modules\Jobs\Presentation\Livewire\Concerns\EditsJobDetails;
|
||
use App\Modules\Jobs\Presentation\Livewire\Concerns\PicksCustomer;
|
||
use App\Modules\Jobs\Presentation\Livewire\Forms\JobForm;
|
||
use App\Modules\Shared\Domain\Exceptions\DomainException;
|
||
use App\Modules\Shared\Domain\ValueObjects\HexColor;
|
||
use App\Modules\Users\Domain\Enums\Role;
|
||
use Carbon\CarbonImmutable;
|
||
use Illuminate\Support\Facades\Gate;
|
||
use Livewire\Attributes\Computed;
|
||
use Livewire\Attributes\Locked;
|
||
use Livewire\Attributes\On;
|
||
use Livewire\Component;
|
||
|
||
/**
|
||
* The board's full job editor (docs/ui-kanban-board.md 5): a two-column
|
||
* work area in a dialog where every detail of a job can be seen and changed
|
||
* without leaving the board. Status and priority change at once, task rows
|
||
* save as they change, and "Tallenna ja sulje" saves the job's details.
|
||
* Without jobs.manage the editor only shows the job and lets tasks be
|
||
* marked done.
|
||
*/
|
||
new class extends Component
|
||
{
|
||
use DescribesJobHistory;
|
||
use EditsJobDetails, PicksCustomer {
|
||
EditsJobDetails::customerChosen insteadof PicksCustomer;
|
||
}
|
||
|
||
public const string DIALOG = 'job-editor-dialog';
|
||
|
||
#[Locked]
|
||
public ?int $jobId = null;
|
||
|
||
#[Locked]
|
||
public ?string $storedStatus = null;
|
||
|
||
public JobForm $form;
|
||
|
||
public string $newTag = '';
|
||
|
||
public string $newTaskTitle = '';
|
||
|
||
public string $newTaskAssignee = '';
|
||
|
||
public bool $newTaskPin = false;
|
||
|
||
public string $templateId = '';
|
||
|
||
#[On('open-job-editor')]
|
||
public function open(int $jobId): void
|
||
{
|
||
$this->authorize('jobs.view-job', [$jobId]);
|
||
|
||
$details = app(CustomerJobQueries::class)->findDetails($jobId);
|
||
|
||
if ($details === null) {
|
||
return;
|
||
}
|
||
|
||
$this->resetErrorBag();
|
||
$this->reset('newTag', 'newTaskTitle', 'newTaskPin', 'templateId', 'statusMessage', 'customerSearch');
|
||
$this->jobId = $details->id;
|
||
$this->loadDetails($details);
|
||
$this->newTaskAssignee = (string) $details->responsible->id;
|
||
unset($this->job, $this->tasks, $this->changes, $this->contacts, $this->billingUnits, $this->statusOptions);
|
||
|
||
$this->js("document.getElementById('".self::DIALOG."').showModal(); document.getElementById('job-editor-name')?.focus()");
|
||
}
|
||
|
||
#[Computed]
|
||
public function job(): ?CustomerJobDetails
|
||
{
|
||
return $this->jobId === null ? null : app(CustomerJobQueries::class)->findDetails($this->jobId);
|
||
}
|
||
|
||
/**
|
||
* @return list<TaskSummary>
|
||
*/
|
||
#[Computed]
|
||
public function tasks(): array
|
||
{
|
||
return $this->jobId === null ? [] : app(TaskQueries::class)->tasksOf($this->jobId);
|
||
}
|
||
|
||
/**
|
||
* @return list<WorkflowTemplateDetails>
|
||
*/
|
||
#[Computed]
|
||
public function templates(): array
|
||
{
|
||
$job = $this->job;
|
||
|
||
return $job === null ? [] : app(WorkflowTemplateQueries::class)->activeFor(array_map(fn ($unit): int => $unit->id, $job->serviceUnits));
|
||
}
|
||
|
||
/**
|
||
* Pinned state of the job's tasks: TaskSummary does not carry it.
|
||
*
|
||
* @return array<int, bool>
|
||
*/
|
||
#[Computed]
|
||
public function pinnedTasks(): array
|
||
{
|
||
return $this->jobId === null ? [] : app(TaskQueries::class)->pinnedTaskIds($this->jobId);
|
||
}
|
||
|
||
/**
|
||
* The colour picker lives on the board, so the board tells the editor
|
||
* when a customer's colour changed; the header colour is read on render.
|
||
*/
|
||
#[On('customer-color-changed')]
|
||
public function customerColorChanged(): void
|
||
{
|
||
unset($this->job);
|
||
}
|
||
|
||
#[On('task-comments-changed')]
|
||
#[On('task-images-changed')]
|
||
public function refreshTasks(): void
|
||
{
|
||
unset($this->tasks);
|
||
}
|
||
|
||
public function canEdit(): bool
|
||
{
|
||
return Gate::allows('jobs.manage');
|
||
}
|
||
|
||
public function loggedHours(): string
|
||
{
|
||
$quarters = $this->jobId === null ? 0 : (app(LoggedJobHours::class)->quartersByJobs([$this->jobId])[$this->jobId] ?? 0);
|
||
|
||
return str_replace('.', ',', rtrim(rtrim(number_format($quarters / 4, 2, '.', ''), '0'), '.'));
|
||
}
|
||
|
||
public function changeStatus(string $value, ChangeJobStatus $changeStatus): void
|
||
{
|
||
$this->authorize('jobs.manage');
|
||
|
||
$status = JobStatus::tryFrom($value);
|
||
$job = $this->job;
|
||
|
||
if ($status === null || $job === null) {
|
||
return;
|
||
}
|
||
|
||
if ($status->value !== $this->storedStatus && ! $this->maySetStatus($status)) {
|
||
$this->addError('form.status', __('jobs.errors.status_not_allowed'));
|
||
$this->form->status = (string) $this->storedStatus;
|
||
|
||
return;
|
||
}
|
||
|
||
try {
|
||
$changeStatus->execute($job->id, $status, (int) auth()->id());
|
||
} catch (CustomerJobNotFound) {
|
||
return;
|
||
}
|
||
|
||
$this->resetErrorBag('form.status');
|
||
$this->storedStatus = $status->value;
|
||
$this->form->status = $status->value;
|
||
unset($this->job, $this->changes, $this->statusOptions);
|
||
$this->statusMessage = __('jobs.editor.status_changed', ['number' => $job->number, 'status' => __('jobs.statuses.'.$status->value)]);
|
||
$this->dispatch('job-saved');
|
||
}
|
||
|
||
public function unlock(ChangeJobStatus $changeStatus): void
|
||
{
|
||
$this->authorize('jobs.unlock');
|
||
|
||
$this->changeStatus(JobStatus::InProduction->value, $changeStatus);
|
||
}
|
||
|
||
public function changePriority(string $value, ChangeJobPriority $changePriority): void
|
||
{
|
||
$this->authorize('jobs.manage');
|
||
|
||
$priority = Priority::tryFrom($value);
|
||
$job = $this->job;
|
||
|
||
if ($priority === null || $job === null) {
|
||
return;
|
||
}
|
||
|
||
$changePriority->execute($job->id, $priority, (int) auth()->id());
|
||
|
||
$this->form->priority = $priority->value;
|
||
unset($this->job, $this->changes);
|
||
$this->statusMessage = __('jobs.editor.priority_changed', ['number' => $job->number, 'priority' => __('jobs.priorities.'.$priority->value)]);
|
||
$this->dispatch('job-saved');
|
||
}
|
||
|
||
public function setTaskDone(int $taskId, bool $done, ChangeTaskStatus $changeStatus): void
|
||
{
|
||
$this->authorize('jobs.update-task-status', [$this->jobId]);
|
||
|
||
$task = $this->findTask($taskId);
|
||
|
||
if ($task === null) {
|
||
return;
|
||
}
|
||
|
||
try {
|
||
$changeStatus->execute((int) $this->jobId, $taskId, $done ? TaskStatus::Done : TaskStatus::InProgress);
|
||
} catch (TaskNotFound) {
|
||
return;
|
||
}
|
||
|
||
unset($this->tasks);
|
||
$this->statusMessage = __($done ? 'jobs.board.task_done' : 'jobs.board.task_reopened', ['task' => $task->title]);
|
||
$this->dispatch('job-saved');
|
||
}
|
||
|
||
/**
|
||
* One field of a task row changed: title, status, assignee or due date.
|
||
*/
|
||
public function updateTaskField(int $taskId, string $field, string $value, UpdateTask $updateTask): void
|
||
{
|
||
$this->authorize('jobs.manage-tasks', [$this->jobId]);
|
||
|
||
$task = $this->findTask($taskId);
|
||
|
||
if ($task === null || ! in_array($field, ['title', 'status', 'assignee', 'due_on'], true)) {
|
||
return;
|
||
}
|
||
|
||
$data = new TaskData(
|
||
title: $field === 'title' ? $value : $task->title,
|
||
workTypeId: $task->workType->id,
|
||
status: $field === 'status' ? $value : $task->status->value,
|
||
description: $task->description,
|
||
dueOn: $field === 'due_on' ? ($value === '' ? null : $value) : $task->dueOn,
|
||
estimatedHours: $task->estimatedHours,
|
||
assigneeUserId: $field === 'assignee' ? ($value === '' ? null : (int) $value) : $task->assignee?->id,
|
||
memberUserIds: array_map(fn ($member): int => $member->id, $task->members),
|
||
plannedFrom: $task->plannedFrom,
|
||
plannedTo: $task->plannedTo,
|
||
);
|
||
|
||
try {
|
||
$updateTask->execute((int) $this->jobId, $taskId, $data, (int) auth()->id());
|
||
} catch (DomainException) {
|
||
$this->addError('tasks.'.$taskId, __('jobs.board.not_moved'));
|
||
unset($this->tasks);
|
||
|
||
return;
|
||
}
|
||
|
||
$this->resetErrorBag('tasks.'.$taskId);
|
||
unset($this->tasks);
|
||
$this->statusMessage = __('jobs.editor.task_saved', ['task' => $data->title]);
|
||
$this->dispatch('job-saved');
|
||
}
|
||
|
||
public function pinTask(int $taskId, bool $pinned, PinTaskToBoard $pin): void
|
||
{
|
||
$this->authorize('jobs.manage-tasks', [$this->jobId]);
|
||
|
||
$task = $this->findTask($taskId);
|
||
|
||
try {
|
||
$pin->execute((int) $this->jobId, $taskId, $pinned);
|
||
} catch (DomainException) {
|
||
return;
|
||
}
|
||
|
||
unset($this->pinnedTasks);
|
||
$this->statusMessage = __($pinned ? 'jobs.board.task_pinned' : 'jobs.board.task_unpinned', ['task' => $task->title ?? '']);
|
||
$this->dispatch('job-saved');
|
||
}
|
||
|
||
public function addTask(AddTask $addTask, PinTaskToBoard $pin): void
|
||
{
|
||
$this->authorize('jobs.manage-tasks', [$this->jobId]);
|
||
|
||
$title = trim($this->newTaskTitle);
|
||
$workTypeId = $this->firstWorkTypeId();
|
||
|
||
if ($title === '') {
|
||
$this->addError('newTaskTitle', __('jobs.board.task_title_required'));
|
||
|
||
return;
|
||
}
|
||
|
||
if ($workTypeId === null) {
|
||
$this->addError('newTaskTitle', __('jobs.board.no_work_type'));
|
||
|
||
return;
|
||
}
|
||
|
||
try {
|
||
$taskId = $addTask->execute((int) $this->jobId, new TaskData(
|
||
$title,
|
||
$workTypeId,
|
||
TaskStatus::Waiting->value,
|
||
assigneeUserId: $this->newTaskAssignee === '' ? null : (int) $this->newTaskAssignee,
|
||
), (int) auth()->id());
|
||
|
||
if ($this->newTaskPin && $this->job?->status === JobStatus::Ongoing) {
|
||
$pin->execute((int) $this->jobId, $taskId, true);
|
||
}
|
||
} catch (DomainException) {
|
||
$this->addError('newTaskTitle', __('jobs.board.not_moved'));
|
||
|
||
return;
|
||
}
|
||
|
||
$this->reset('newTaskTitle', 'newTaskPin');
|
||
unset($this->tasks, $this->pinnedTasks);
|
||
$this->statusMessage = __('jobs.editor.task_added', ['task' => $title]);
|
||
$this->dispatch('job-saved');
|
||
$this->js("document.getElementById('job-editor-new-task')?.focus()");
|
||
}
|
||
|
||
public function applyTemplate(AddTasksFromWorkflowTemplate $addFromTemplate): void
|
||
{
|
||
$this->authorize('jobs.manage-tasks', [$this->jobId]);
|
||
|
||
if ($this->templateId === '') {
|
||
return;
|
||
}
|
||
|
||
try {
|
||
$result = $addFromTemplate->execute((int) $this->jobId, (int) $this->templateId, (int) auth()->id(), [], true);
|
||
} catch (DomainException) {
|
||
$this->addError('templateId', __('jobs.board.not_moved'));
|
||
|
||
return;
|
||
}
|
||
|
||
$this->templateId = '';
|
||
unset($this->tasks);
|
||
$count = $result->added;
|
||
$this->statusMessage = trans_choice('jobs.editor.template_added', $count, ['count' => $count]);
|
||
$this->dispatch('job-saved');
|
||
}
|
||
|
||
public function save(UpdateCustomerJob $updateJob): void
|
||
{
|
||
$this->authorize('jobs.manage');
|
||
|
||
$job = $this->job;
|
||
|
||
if ($job === null) {
|
||
return;
|
||
}
|
||
|
||
// Status and priority are saved by their own controls in the header.
|
||
$this->form->status = $job->status->value;
|
||
$this->form->priority = $job->priority->value;
|
||
|
||
try {
|
||
$updateJob->execute($job->id, $this->form->toData(), (int) auth()->id());
|
||
} catch (CustomerJobNotFound) {
|
||
return;
|
||
} catch (DomainException $exception) {
|
||
$this->form->showDomainError($exception);
|
||
|
||
return;
|
||
}
|
||
|
||
$this->dispatch('job-saved');
|
||
$this->js("document.getElementById('".self::DIALOG."').close()");
|
||
$this->statusMessage = __('jobs.editor.saved', ['number' => $job->number]);
|
||
$this->dispatch('job-editor-saved', message: $this->statusMessage);
|
||
}
|
||
|
||
public function render(): mixed
|
||
{
|
||
return $this->view();
|
||
}
|
||
|
||
private function loadDetails(CustomerJobDetails $details): void
|
||
{
|
||
$this->storedStatus = $details->status->value;
|
||
$this->customerName = $details->customer->name;
|
||
$this->form->reset();
|
||
$this->form->fillFromDetails($details);
|
||
}
|
||
|
||
private function findTask(int $taskId): ?TaskSummary
|
||
{
|
||
foreach ($this->tasks as $task) {
|
||
if ($task->id === $taskId) {
|
||
return $task;
|
||
}
|
||
}
|
||
|
||
return null;
|
||
}
|
||
|
||
private function firstWorkTypeId(): ?int
|
||
{
|
||
$job = $this->job;
|
||
|
||
if ($job === null) {
|
||
return null;
|
||
}
|
||
|
||
$unitIds = array_map(fn ($unit): int => $unit->id, $job->serviceUnits);
|
||
$shared = null;
|
||
|
||
foreach (app(\App\Modules\Catalog\Application\Contracts\CatalogQueries::class)->activeWorkTypesFor($unitIds) as $node) {
|
||
$workTypes = [...$node->workTypes, ...array_merge([], ...array_map(fn ($service): array => $service->workTypes, $node->services))];
|
||
$first = $workTypes[0]->id ?? null;
|
||
|
||
if ($first === null) {
|
||
continue;
|
||
}
|
||
|
||
if (in_array($node->serviceUnit->id, $unitIds, true)) {
|
||
return $first;
|
||
}
|
||
|
||
$shared ??= $first;
|
||
}
|
||
|
||
return $shared;
|
||
}
|
||
};
|
||
?>
|
||
|
||
@php
|
||
$job = $this->job;
|
||
$canEdit = $this->canEdit();
|
||
$staff = collect($this->users)->reject(fn ($user) => $user->role === Role::Subcontractor);
|
||
$headerColor = new HexColor($job?->customer->id !== null ? (app(\App\Modules\Customers\Application\Contracts\CustomerQueries::class)->headerColorsByIds([$job->customer->id])[$job->customer->id] ?? '#23476a') : '#23476a');
|
||
$fieldClass = 'w-full rounded-lg border border-neutral-400 bg-white px-2.5 py-1.5 text-xs text-neutral-900 focus-visible:outline-2 focus-visible:outline-primary-600 dark:border-[#6b7079] dark:bg-[#24262a] dark:text-white dark:focus-visible:outline-primary-300';
|
||
$controlClass = 'w-auto max-w-full rounded-lg border border-neutral-400 bg-white px-2.5 py-1.5 text-xs text-neutral-900 focus-visible:outline-2 focus-visible:outline-primary-600 dark:border-[#6b7079] dark:bg-[#24262a] dark:text-white dark:focus-visible:outline-primary-300';
|
||
$labelClass = 'mb-1 block text-[11px] font-semibold text-neutral-800 dark:text-neutral-100';
|
||
$boxClass = 'space-y-2.5 rounded-xl border border-neutral-200 bg-neutral-100 p-3.5 dark:border-[#36393f] dark:bg-[#18191b]';
|
||
$boxHeading = 'text-[10px] font-extrabold tracking-wider text-neutral-700 uppercase dark:text-neutral-200';
|
||
@endphp
|
||
|
||
<div>
|
||
<x-work-dialog id="job-editor-dialog" width="max-w-5xl">
|
||
<x-slot:header>
|
||
<div
|
||
style="background-color: {{ $headerColor->value }}; color: {{ $headerColor->textColor() }}"
|
||
class="flex shrink-0 flex-wrap items-center justify-between gap-3 rounded-t-2xl border-b border-black/15 px-5 py-3"
|
||
>
|
||
<div class="flex min-w-0 flex-1 flex-wrap items-center gap-2.5">
|
||
<span class="shrink-0 rounded bg-black/25 px-2 py-0.5 text-xs font-extrabold tracking-wider text-white uppercase">{{ $job?->number }}</span>
|
||
<h2 id="job-editor-dialog-title" class="min-w-0 truncate text-sm font-extrabold">
|
||
<span class="sr-only">{{ __('jobs.editor.heading', ['number' => $job?->number]) }}: </span>{{ $job?->customer->name }}
|
||
</h2>
|
||
@if ($job !== null && Gate::allows('customers.use'))
|
||
<button
|
||
type="button"
|
||
x-on:click="$dispatch('color-picker:open', {{ Js::from([
|
||
'id' => 'colour-picker',
|
||
'title' => __('jobs.board.customer_color_title', ['customer' => $job->customer->name]),
|
||
'color' => $headerColor->value,
|
||
'method' => 'setCustomerColor',
|
||
'args' => [$job->customer->id],
|
||
'resettable' => true,
|
||
]) }})"
|
||
aria-label="{{ __('jobs.editor.color_label', ['customer' => $job->customer->name]) }}"
|
||
class="inline-flex min-h-6 items-center gap-1 rounded bg-black/20 px-2 text-[11px] font-semibold transition hover:bg-black/30 focus-visible:outline-2 focus-visible:outline-current"
|
||
>
|
||
<x-icon name="swatch" class="size-3.5" aria-hidden="true" />
|
||
<span>{{ __('jobs.editor.color') }}</span>
|
||
</button>
|
||
@endif
|
||
</div>
|
||
|
||
<div class="flex shrink-0 flex-wrap items-center gap-2">
|
||
@if ($job !== null)
|
||
<div class="flex items-center gap-1 rounded-lg bg-black/20 px-2 py-1">
|
||
<label for="job-editor-status" class="text-[11px] font-bold">{{ __('jobs.editor.status') }}:</label>
|
||
<select
|
||
id="job-editor-status"
|
||
wire:model="form.status"
|
||
wire:change="changeStatus($event.target.value)"
|
||
@disabled(! $canEdit)
|
||
class="rounded border-0 bg-transparent py-0 pr-7 pl-1 text-xs font-extrabold focus-visible:outline-2 focus-visible:outline-current"
|
||
>
|
||
@foreach ($this->statusOptions as $status)
|
||
<option value="{{ $status->value }}" class="bg-white text-neutral-900 dark:bg-[#282a2e] dark:text-white">{{ __('jobs.statuses.'.$status->value) }}</option>
|
||
@endforeach
|
||
</select>
|
||
</div>
|
||
<div class="flex items-center gap-1 rounded-lg bg-black/20 px-2 py-1">
|
||
<label for="job-editor-priority" class="text-[11px] font-bold">{{ __('jobs.editor.priority') }}:</label>
|
||
<select
|
||
id="job-editor-priority"
|
||
wire:model="form.priority"
|
||
wire:change="changePriority($event.target.value)"
|
||
@disabled(! $canEdit)
|
||
class="rounded border-0 bg-transparent py-0 pr-7 pl-1 text-xs font-extrabold focus-visible:outline-2 focus-visible:outline-current"
|
||
>
|
||
@foreach (Priority::cases() as $priority)
|
||
<option value="{{ $priority->value }}" class="bg-white text-neutral-900 dark:bg-[#282a2e] dark:text-white">{{ __('jobs.priorities.'.$priority->value) }}</option>
|
||
@endforeach
|
||
</select>
|
||
</div>
|
||
@endif
|
||
<button
|
||
type="button"
|
||
x-on:click="$el.closest('dialog').close()"
|
||
aria-label="{{ __('jobs.editor.close') }}"
|
||
class="inline-flex size-8 items-center justify-center rounded-lg bg-black/20 transition hover:bg-black/35 focus-visible:outline-2 focus-visible:outline-current"
|
||
>
|
||
<x-icon name="x-mark" class="size-4" aria-hidden="true" />
|
||
</button>
|
||
</div>
|
||
</div>
|
||
</x-slot:header>
|
||
|
||
@if ($job !== null)
|
||
@error('form.status')
|
||
<p role="alert" class="border-b border-red-300 bg-red-50 px-5 py-2 text-xs font-semibold text-red-800 dark:border-red-800 dark:bg-red-950 dark:text-red-100">{{ $message }}</p>
|
||
@enderror
|
||
|
||
@if (in_array($job->status, [JobStatus::Done, JobStatus::Invoiced, JobStatus::Billed], true))
|
||
<div role="status" class="flex flex-wrap items-center justify-between gap-2 border-b border-amber-300 bg-amber-100 px-5 py-2 text-xs font-semibold text-amber-950 dark:border-amber-800 dark:bg-amber-950/90 dark:text-amber-100">
|
||
<span class="inline-flex items-center gap-1.5"><x-icon name="lock-closed" class="size-4" aria-hidden="true" />{{ __('jobs.editor.locked') }}</span>
|
||
@can('jobs.unlock')
|
||
<button type="button" wire:click="unlock" class="min-h-6 rounded bg-amber-800 px-2.5 text-[11px] font-bold text-white hover:bg-amber-900 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-amber-900 dark:focus-visible:outline-amber-200">{{ __('jobs.editor.unlock') }}</button>
|
||
@endcan
|
||
</div>
|
||
@endif
|
||
|
||
<p role="status" aria-live="polite" class="min-h-4 px-5 pt-2 text-xs font-medium">{{ $statusMessage }}</p>
|
||
@unless ($canEdit)
|
||
<p class="px-5 text-xs">{{ __('jobs.editor.read_only') }}</p>
|
||
@endunless
|
||
|
||
<div class="grid grid-cols-1 gap-5 p-5 lg:grid-cols-12">
|
||
{{-- Left: content, tasks and records --}}
|
||
<div class="space-y-5 lg:col-span-8">
|
||
<fieldset @disabled(! $canEdit) class="space-y-3">
|
||
<div>
|
||
<label for="job-editor-name" class="{{ $labelClass }}">{{ __('jobs.fields.name') }}</label>
|
||
<input id="job-editor-name" type="text" wire:model="form.name" maxlength="255" autocomplete="off" class="w-full rounded-xl border border-neutral-300 bg-neutral-100/70 px-3 py-2 text-base font-extrabold text-neutral-900 focus-visible:outline-2 focus-visible:outline-primary-600 dark:border-[#4b5058] dark:bg-[#18191b] dark:text-white dark:focus-visible:outline-primary-300" />
|
||
@error('form.name') <p class="mt-1 text-xs font-semibold text-red-700 dark:text-red-200">{{ $message }}</p> @enderror
|
||
</div>
|
||
<div class="grid grid-cols-1 gap-3 md:grid-cols-2">
|
||
<div>
|
||
<label for="job-editor-description" class="{{ $labelClass }}">{{ __('jobs.fields.description') }}</label>
|
||
<textarea id="job-editor-description" rows="3" wire:model="form.description" class="{{ $fieldClass }} bg-neutral-50 p-2.5 dark:bg-[#18191b]"></textarea>
|
||
</div>
|
||
<div>
|
||
<label for="job-editor-instructions" class="{{ $labelClass }}">{{ __('jobs.fields.instructions') }}</label>
|
||
<textarea id="job-editor-instructions" rows="3" wire:model="form.instructions" class="{{ $fieldClass }} bg-amber-50/40 p-2.5 dark:bg-[#1e1d19]"></textarea>
|
||
</div>
|
||
</div>
|
||
</fieldset>
|
||
|
||
<section aria-labelledby="job-editor-links-heading" class="{{ $boxClass }} bg-neutral-50">
|
||
<div class="flex items-center justify-between">
|
||
<h3 id="job-editor-links-heading" class="{{ $boxHeading }}">{{ __('jobs.editor.links') }}</h3>
|
||
@if ($canEdit)
|
||
<button type="button" id="add-link" wire:click="addLink" class="min-h-6 text-xs font-bold text-primary-700 hover:underline focus-visible:outline-2 focus-visible:outline-primary-600 dark:text-primary-100 dark:focus-visible:outline-primary-300">+ {{ __('jobs.links.add') }}</button>
|
||
@endif
|
||
</div>
|
||
@if ($form->links === [])
|
||
<p class="text-[11px]">{{ __('jobs.links.none') }}</p>
|
||
@endif
|
||
<ul class="space-y-1.5">
|
||
@foreach ($form->links as $index => $link)
|
||
<li wire:key="editor-link-{{ $index }}" class="grid grid-cols-1 gap-2 rounded-lg border border-neutral-200 bg-white p-2 sm:grid-cols-12 dark:border-[#36393f] dark:bg-[#25272b]">
|
||
@if ($canEdit)
|
||
<div class="sm:col-span-5">
|
||
<label for="link-title-{{ $index }}" class="sr-only">{{ __('jobs.links.title') }}</label>
|
||
<input id="link-title-{{ $index }}" wire:model="form.links.{{ $index }}.title" placeholder="{{ __('jobs.links.title') }}" class="{{ $fieldClass }}" />
|
||
</div>
|
||
<div class="sm:col-span-5">
|
||
<label for="link-url-{{ $index }}" class="sr-only">{{ __('jobs.links.url') }}</label>
|
||
<input id="link-url-{{ $index }}" type="url" wire:model="form.links.{{ $index }}.url" placeholder="https://…" class="{{ $fieldClass }}" />
|
||
</div>
|
||
<button type="button" wire:click="removeLink({{ $index }})" aria-label="{{ __('jobs.links.remove', ['number' => $index + 1]) }}" class="min-h-6 rounded text-xs font-bold text-red-700 hover:underline focus-visible:outline-2 focus-visible:outline-primary-600 sm:col-span-2 dark:text-red-200 dark:focus-visible:outline-primary-300">✕</button>
|
||
@else
|
||
<a href="{{ $link['url'] }}" target="_blank" rel="noopener" class="font-semibold text-primary-700 hover:underline sm:col-span-12 dark:text-primary-100">{{ $link['title'] }} <span class="sr-only">({{ __('layout.opens_in_new_window') }})</span></a>
|
||
@endif
|
||
</li>
|
||
@endforeach
|
||
</ul>
|
||
@error('form.links') <p class="text-xs font-semibold text-red-700 dark:text-red-200">{{ $message }}</p> @enderror
|
||
</section>
|
||
|
||
{{-- Tasks --}}
|
||
<section aria-labelledby="job-editor-tasks-heading" class="{{ $boxClass }} bg-neutral-50">
|
||
<div class="flex flex-wrap items-center justify-between gap-2">
|
||
<div>
|
||
<h3 id="job-editor-tasks-heading" class="{{ $boxHeading }}">{{ $job->status === JobStatus::Ongoing ? __('jobs.editor.tasks_ongoing') : __('jobs.editor.tasks') }}</h3>
|
||
<p class="text-[11px]">{{ $job->status === JobStatus::Ongoing ? __('jobs.editor.tasks_hint_ongoing') : __('jobs.editor.tasks_hint') }}</p>
|
||
</div>
|
||
@if (Gate::allows('jobs.manage-tasks', [$job->id]) && $this->templates !== [] && $job->status->allowsTasks())
|
||
<form wire:submit="applyTemplate" class="flex items-center gap-1.5">
|
||
<label for="job-editor-template" class="sr-only">{{ __('jobs.editor.template') }}</label>
|
||
<select id="job-editor-template" wire:model="templateId" class="{{ $controlClass }} py-1 text-[11px]">
|
||
<option value="">{{ __('jobs.editor.template_choose') }}</option>
|
||
@foreach ($this->templates as $template)
|
||
<option value="{{ $template->id }}">{{ $template->name }}</option>
|
||
@endforeach
|
||
</select>
|
||
<button type="submit" class="min-h-6 rounded-lg bg-indigo-700 px-2.5 text-[11px] font-bold text-white hover:bg-indigo-800 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary-600 dark:focus-visible:outline-primary-300">{{ __('jobs.editor.template_apply') }}</button>
|
||
</form>
|
||
@endif
|
||
</div>
|
||
|
||
@if ($this->tasks === [])
|
||
<p class="text-[11px]">{{ __('jobs.editor.no_tasks') }}</p>
|
||
@endif
|
||
|
||
<ul class="space-y-2">
|
||
@foreach ($this->tasks as $task)
|
||
@php($canManageTask = Gate::allows('jobs.manage-tasks', [$job->id]))
|
||
<li wire:key="editor-task-{{ $task->id }}" x-data="{ checklist: false, extras: false }" class="space-y-2 rounded-xl border border-neutral-200 bg-white p-2.5 text-xs dark:border-[#36393f] dark:bg-[#25272b]">
|
||
<div class="flex flex-wrap items-center justify-between gap-2">
|
||
<div class="flex min-w-0 flex-1 items-center gap-2">
|
||
<input
|
||
type="checkbox"
|
||
id="editor-task-done-{{ $task->id }}"
|
||
@checked($task->status === TaskStatus::Done)
|
||
@disabled(! Gate::allows('jobs.update-task-status', [$job->id]))
|
||
wire:change="setTaskDone({{ $task->id }}, $event.target.checked)"
|
||
aria-label="{{ __('jobs.editor.task_done', ['task' => $task->title]) }}"
|
||
class="size-4 rounded border-neutral-500 text-emerald-700 dark:border-neutral-400 dark:bg-[#16171a]"
|
||
/>
|
||
@if ($canManageTask)
|
||
<label for="editor-task-title-{{ $task->id }}" class="sr-only">{{ __('jobs.editor.task_title') }}</label>
|
||
<input
|
||
id="editor-task-title-{{ $task->id }}"
|
||
type="text"
|
||
value="{{ $task->title }}"
|
||
maxlength="255"
|
||
wire:change="updateTaskField({{ $task->id }}, 'title', $event.target.value)"
|
||
class="min-w-0 flex-1 rounded border border-transparent bg-transparent px-1 py-0.5 font-bold text-neutral-900 hover:border-neutral-300 focus-visible:outline-2 focus-visible:outline-primary-600 dark:text-white dark:hover:border-[#4b5058] dark:focus-visible:outline-primary-300"
|
||
/>
|
||
@else
|
||
<span class="font-bold">{{ $task->title }}</span>
|
||
@endif
|
||
</div>
|
||
|
||
@if ($canManageTask)
|
||
<div class="flex flex-wrap items-center gap-1.5">
|
||
<label for="editor-task-status-{{ $task->id }}" class="sr-only">{{ __('jobs.editor.task_status', ['task' => $task->title]) }}</label>
|
||
<select id="editor-task-status-{{ $task->id }}" wire:change="updateTaskField({{ $task->id }}, 'status', $event.target.value)" class="{{ $controlClass }} py-0.5 text-[11px]">
|
||
@foreach (TaskStatus::cases() as $taskStatus)
|
||
<option value="{{ $taskStatus->value }}" @selected($taskStatus === $task->status)>{{ __('jobs.tasks.statuses.'.$taskStatus->value) }}</option>
|
||
@endforeach
|
||
</select>
|
||
<label for="editor-task-assignee-{{ $task->id }}" class="sr-only">{{ __('jobs.editor.task_assignee', ['task' => $task->title]) }}</label>
|
||
<select id="editor-task-assignee-{{ $task->id }}" wire:change="updateTaskField({{ $task->id }}, 'assignee', $event.target.value)" class="{{ $controlClass }} py-0.5 text-[11px]">
|
||
<option value="">{{ __('jobs.editor.no_assignee') }}</option>
|
||
@foreach ($this->users as $user)
|
||
<option value="{{ $user->id }}" @selected($user->id === $task->assignee?->id)>{{ $user->name }}</option>
|
||
@endforeach
|
||
</select>
|
||
<label for="editor-task-due-{{ $task->id }}" class="sr-only">{{ __('jobs.editor.task_due', ['task' => $task->title]) }}</label>
|
||
<input id="editor-task-due-{{ $task->id }}" type="date" value="{{ $task->dueOn }}" wire:change="updateTaskField({{ $task->id }}, 'due_on', $event.target.value)" class="{{ $controlClass }} py-0.5 text-[11px]" />
|
||
@if ($job->status === JobStatus::Ongoing)
|
||
@php($pinned = $this->pinnedTasks[$task->id] ?? false)
|
||
<button
|
||
type="button"
|
||
wire:click="pinTask({{ $task->id }}, {{ $pinned ? 'false' : 'true' }})"
|
||
aria-label="{{ $pinned ? __('jobs.board.unpin_label', ['task' => $task->title]) : __('jobs.board.pin_label', ['task' => $task->title]) }}"
|
||
@class(['min-h-6 rounded px-2.5 text-[11px] font-bold text-white transition focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary-600 dark:focus-visible:outline-primary-300', 'bg-amber-700 hover:bg-amber-800' => $pinned, 'bg-indigo-600 hover:bg-indigo-700' => ! $pinned])
|
||
>{{ $pinned ? __('jobs.board.unpin') : __('jobs.board.pin') }}</button>
|
||
@endif
|
||
</div>
|
||
@endif
|
||
</div>
|
||
@error('tasks.'.$task->id) <p class="text-xs font-semibold text-red-700 dark:text-red-200">{{ $message }}</p> @enderror
|
||
|
||
<div class="space-y-1 pl-6">
|
||
<div class="flex flex-wrap gap-3">
|
||
<button
|
||
type="button"
|
||
x-on:click="checklist = ! checklist"
|
||
x-bind:aria-expanded="checklist.toString()"
|
||
aria-controls="editor-checklist-{{ $task->id }}"
|
||
class="inline-flex min-h-6 items-center gap-1 rounded text-[11px] font-semibold text-indigo-800 hover:underline focus-visible:outline-2 focus-visible:outline-primary-600 dark:text-indigo-100 dark:focus-visible:outline-primary-300"
|
||
>
|
||
<x-icon name="chevron-right" class="size-3 transition" x-bind:class="checklist && 'rotate-90'" aria-hidden="true" />
|
||
{{ __('jobs.editor.checklist') }}
|
||
</button>
|
||
<button
|
||
type="button"
|
||
x-on:click="extras = ! extras"
|
||
x-bind:aria-expanded="extras.toString()"
|
||
aria-controls="editor-extras-{{ $task->id }}"
|
||
class="inline-flex min-h-6 items-center gap-1 rounded text-[11px] font-semibold text-indigo-800 hover:underline focus-visible:outline-2 focus-visible:outline-primary-600 dark:text-indigo-100 dark:focus-visible:outline-primary-300"
|
||
>
|
||
<x-icon name="chevron-right" class="size-3 transition" x-bind:class="extras && 'rotate-90'" aria-hidden="true" />
|
||
{{ __('jobs.editor.extras', ['comments' => $task->commentCount, 'images' => $task->imageCount]) }}
|
||
</button>
|
||
</div>
|
||
<div id="editor-checklist-{{ $task->id }}" x-show="checklist" x-cloak class="pt-1">
|
||
<livewire:jobs::task-checklist :job-id="$job->id" :task-id="$task->id" :task-title="$task->title" :wire:key="'editor-checklist-'.$task->id" />
|
||
</div>
|
||
<div id="editor-extras-{{ $task->id }}" x-show="extras" x-cloak class="pt-1">
|
||
<x-tabs
|
||
id="editor-task-{{ $task->id }}-tabs"
|
||
:label="__('jobs.tasks.tabs.label', ['title' => $task->title])"
|
||
:tabs="[
|
||
'comments' => __('jobs.editor.tab_comments', ['count' => $task->commentCount]),
|
||
'images' => __('jobs.editor.tab_images', ['count' => $task->imageCount]),
|
||
]"
|
||
>
|
||
<x-tabs.panel tabs-id="editor-task-{{ $task->id }}-tabs" name="comments">
|
||
<livewire:jobs::task-comments :job-id="$job->id" :task-id="$task->id" :task-title="$task->title" :wire:key="'editor-comments-'.$task->id" />
|
||
</x-tabs.panel>
|
||
<x-tabs.panel tabs-id="editor-task-{{ $task->id }}-tabs" name="images">
|
||
<livewire:jobs::task-images :job-id="$job->id" :task-id="$task->id" :task-title="$task->title" :wire:key="'editor-images-'.$task->id" />
|
||
</x-tabs.panel>
|
||
</x-tabs>
|
||
</div>
|
||
</div>
|
||
</li>
|
||
@endforeach
|
||
</ul>
|
||
|
||
@if (Gate::allows('jobs.manage-tasks', [$job->id]) && $job->status->allowsTasks())
|
||
<form wire:submit="addTask" class="space-y-2 border-t border-neutral-200 pt-2 dark:border-[#36393f]">
|
||
<div class="flex flex-wrap gap-2">
|
||
<label for="job-editor-new-task" class="sr-only">{{ __('jobs.editor.new_task') }}</label>
|
||
<input id="job-editor-new-task" type="text" wire:model="newTaskTitle" maxlength="255" placeholder="{{ __('jobs.editor.new_task_placeholder') }}" class="{{ $fieldClass }} min-w-[200px] flex-1 placeholder:text-neutral-600 dark:placeholder:text-neutral-300" />
|
||
<label for="job-editor-new-task-assignee" class="sr-only">{{ __('jobs.editor.new_task_assignee') }}</label>
|
||
<select id="job-editor-new-task-assignee" wire:model="newTaskAssignee" class="{{ $controlClass }}">
|
||
<option value="">{{ __('jobs.editor.no_assignee') }}</option>
|
||
@foreach ($this->users as $user)
|
||
<option value="{{ $user->id }}">{{ $user->name }}</option>
|
||
@endforeach
|
||
</select>
|
||
<button type="submit" class="min-h-6 rounded-lg bg-primary-600 px-3.5 text-xs font-bold text-white hover:bg-primary-700 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary-600 dark:focus-visible:outline-primary-300">+ {{ __('jobs.editor.add_task') }}</button>
|
||
</div>
|
||
@error('newTaskTitle') <p class="text-xs font-semibold text-red-700 dark:text-red-200">{{ $message }}</p> @enderror
|
||
@if ($job->status === JobStatus::Ongoing)
|
||
<label class="flex cursor-pointer items-center gap-2 text-xs">
|
||
<input type="checkbox" wire:model="newTaskPin" class="size-4 rounded border-neutral-500 text-indigo-600 dark:border-neutral-400 dark:bg-[#16171a]" />
|
||
<span>{{ __('jobs.editor.pin_new') }}</span>
|
||
</label>
|
||
@endif
|
||
</form>
|
||
@endif
|
||
</section>
|
||
|
||
{{-- Records: hours, expenses, history --}}
|
||
<div class="rounded-xl border border-neutral-200 bg-neutral-50 p-3.5 dark:border-[#36393f] dark:bg-[#1b1c1f]">
|
||
<x-tabs
|
||
id="job-editor-tabs-{{ $job->id }}"
|
||
wire:key="job-editor-tabs-{{ $job->id }}"
|
||
:label="__('jobs.editor.tabs_label')"
|
||
:tabs="[
|
||
'hours' => __('jobs.editor.tab_hours', ['hours' => $this->loggedHours()]),
|
||
'expenses' => __('jobs.editor.tab_expenses'),
|
||
'history' => __('jobs.editor.tab_history', ['count' => count($this->changes)]),
|
||
]"
|
||
>
|
||
<x-tabs.panel tabs-id="job-editor-tabs-{{ $job->id }}" name="hours">
|
||
<livewire:time::job-quick-hours :job-id="$job->id" :wire:key="'editor-hours-'.$job->id" />
|
||
</x-tabs.panel>
|
||
<x-tabs.panel tabs-id="job-editor-tabs-{{ $job->id }}" name="expenses">
|
||
<livewire:expenses::job-quick-expense :job-id="$job->id" :wire:key="'editor-expenses-'.$job->id" />
|
||
</x-tabs.panel>
|
||
<x-tabs.panel tabs-id="job-editor-tabs-{{ $job->id }}" name="history">
|
||
@if ($this->changes === [])
|
||
<p class="text-xs">{{ __('jobs.history.empty') }}</p>
|
||
@else
|
||
<ol class="max-h-48 space-y-1.5 overflow-y-auto text-[11px]" tabindex="0" aria-label="{{ __('jobs.sections.history') }}">
|
||
@foreach ($this->changes as $change)
|
||
<li class="flex flex-wrap items-center justify-between gap-2 border-b border-neutral-200 py-1 dark:border-[#2e3137]">
|
||
<span>
|
||
<strong>{{ $change->userName }}</strong>:
|
||
@if ($change->field === 'created')
|
||
{{ __('jobs.history.created', ['user' => $change->userName, 'number' => $change->newValue]) }}
|
||
@else
|
||
{{ __('jobs.history.changed', [
|
||
'field' => __('jobs.fields.'.$change->field),
|
||
'old' => $this->historyValue($change->field, $change->oldValue),
|
||
'new' => $this->historyValue($change->field, $change->newValue),
|
||
]) }}
|
||
@endif
|
||
</span>
|
||
<span class="shrink-0">{{ CarbonImmutable::parse($change->changedAt)->format('j.n.Y H.i') }}</span>
|
||
</li>
|
||
@endforeach
|
||
</ol>
|
||
@endif
|
||
</x-tabs.panel>
|
||
</x-tabs>
|
||
</div>
|
||
</div>
|
||
|
||
{{-- Right: metadata, schedule, team and money --}}
|
||
<fieldset @disabled(! $canEdit) class="space-y-4 text-xs lg:col-span-4">
|
||
<legend class="sr-only">{{ __('jobs.sections.basics') }}</legend>
|
||
|
||
<section aria-labelledby="job-editor-customer-heading" class="{{ $boxClass }}">
|
||
<h3 id="job-editor-customer-heading" class="{{ $boxHeading }}">{{ __('jobs.editor.customer_section') }}</h3>
|
||
<x-jobs.customer-picker :customer-id="$form->customer_id" :customer-name="$customerName" :search="$customerSearch" :results="$this->customerResults" />
|
||
<div>
|
||
<label for="job-editor-contact" class="{{ $labelClass }}">{{ __('jobs.fields.customer_contact') }}</label>
|
||
<select id="job-editor-contact" wire:model="form.customer_contact_id" class="{{ $fieldClass }}">
|
||
<option value="">{{ __('jobs.fields.none_selected') }}</option>
|
||
@foreach ($this->contacts as $contact)
|
||
<option wire:key="editor-contact-{{ $contact->id }}" value="{{ $contact->id }}">{{ $contact->name }}</option>
|
||
@endforeach
|
||
</select>
|
||
</div>
|
||
<div>
|
||
<label for="job-editor-billing-unit" class="{{ $labelClass }}">{{ __('jobs.fields.billing_unit') }}</label>
|
||
<select id="job-editor-billing-unit" wire:model="form.billing_unit_id" class="{{ $fieldClass }}">
|
||
<option value="">{{ __('jobs.fields.none_selected') }}</option>
|
||
@foreach ($this->billingUnits as $unit)
|
||
<option wire:key="editor-billing-unit-{{ $unit->id }}" value="{{ $unit->id }}">{{ $unit->name }}</option>
|
||
@endforeach
|
||
</select>
|
||
</div>
|
||
</section>
|
||
|
||
<section aria-labelledby="job-editor-team-heading" class="{{ $boxClass }}">
|
||
<h3 id="job-editor-team-heading" class="{{ $boxHeading }}">{{ __('jobs.editor.team_section') }}</h3>
|
||
@foreach (['responsible_user_id' => 'responsible_user', 'contact_user_id' => 'contact_user', 'biller_user_id' => 'biller_user'] as $field => $label)
|
||
<div>
|
||
<label for="job-editor-{{ $field }}" class="{{ $labelClass }}">{{ __('jobs.fields.'.$label) }}</label>
|
||
<select id="job-editor-{{ $field }}" wire:model="form.{{ $field }}" class="{{ $fieldClass }}">
|
||
@if ($field !== 'responsible_user_id')
|
||
<option value="">{{ __('jobs.fields.none_selected') }}</option>
|
||
@endif
|
||
@foreach ($staff as $user)
|
||
<option value="{{ $user->id }}">{{ $user->name }}</option>
|
||
@endforeach
|
||
</select>
|
||
@error('form.'.$field) <p class="mt-1 text-xs font-semibold text-red-700 dark:text-red-200">{{ $message }}</p> @enderror
|
||
</div>
|
||
@endforeach
|
||
<x-checkbox-group
|
||
:columns="2"
|
||
:legend="__('jobs.fields.members')"
|
||
model="form.member_user_ids"
|
||
:options="collect($this->users)->map(fn ($user) => ['value' => $user->id, 'label' => $user->name, 'note' => $user->role === Role::Subcontractor ? __('users.roles.subcontractor') : null])->all()"
|
||
/>
|
||
</section>
|
||
|
||
<section aria-labelledby="job-editor-units-heading" class="{{ $boxClass }}">
|
||
<h3 id="job-editor-units-heading" class="{{ $boxHeading }}">{{ __('jobs.editor.units_section') }}</h3>
|
||
<x-checkbox-group :columns="2" :legend="__('jobs.fields.service_units')" model="form.service_unit_ids" :options="$this->serviceUnitOptions" />
|
||
<div class="space-y-1.5">
|
||
<p id="editor-tags-label" class="{{ $labelClass }}">{{ __('jobs.fields.tags') }}</p>
|
||
@if ($form->tags !== [])
|
||
<ul aria-labelledby="editor-tags-label" class="flex flex-wrap gap-1">
|
||
@foreach ($form->tags as $index => $tag)
|
||
<li wire:key="editor-tag-{{ $tag }}" class="inline-flex items-center gap-1 rounded-full border border-indigo-300 bg-indigo-100 px-2 py-0.5 text-[11px] font-bold text-indigo-900 dark:border-indigo-700 dark:bg-indigo-950 dark:text-indigo-100">
|
||
{{ $tag }}
|
||
@if ($canEdit)
|
||
<button type="button" wire:click="removeTag({{ $index }})" aria-label="{{ __('jobs.tags.remove', ['tag' => $tag]) }}" class="inline-flex size-5 items-center justify-center rounded-full hover:bg-indigo-200 focus-visible:outline-2 focus-visible:outline-primary-600 dark:hover:bg-indigo-900 dark:focus-visible:outline-primary-300">×</button>
|
||
@endif
|
||
</li>
|
||
@endforeach
|
||
</ul>
|
||
@endif
|
||
@if ($canEdit)
|
||
<div class="flex gap-1">
|
||
<label for="new-tag" class="sr-only">{{ __('jobs.tags.new') }}</label>
|
||
<input id="new-tag" type="text" list="editor-tag-suggestions" wire:model.live.debounce.300ms="newTag" wire:keydown.enter.prevent="addTag" autocomplete="off" placeholder="{{ __('jobs.tags.new') }}" class="{{ $fieldClass }} placeholder:text-neutral-600 dark:placeholder:text-neutral-300" />
|
||
<datalist id="editor-tag-suggestions">
|
||
@foreach ($this->tagSuggestions as $suggestion)
|
||
<option value="{{ $suggestion }}"></option>
|
||
@endforeach
|
||
</datalist>
|
||
<button type="button" wire:click="addTag" class="min-h-6 rounded-lg bg-neutral-700 px-2 text-[11px] font-bold text-white hover:bg-neutral-800 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary-600 dark:focus-visible:outline-primary-300">{{ __('jobs.tags.add') }}</button>
|
||
</div>
|
||
@error('newTag') <p class="text-xs font-semibold text-red-700 dark:text-red-200">{{ $message }}</p> @enderror
|
||
@endif
|
||
</div>
|
||
</section>
|
||
|
||
<section aria-labelledby="job-editor-schedule-heading" class="{{ $boxClass }}">
|
||
<h3 id="job-editor-schedule-heading" class="{{ $boxHeading }}">{{ __('jobs.editor.schedule_section') }}</h3>
|
||
<div>
|
||
<label for="job-editor-kind" class="{{ $labelClass }}">{{ __('jobs.fields.kind') }}</label>
|
||
<select id="job-editor-kind" wire:model="form.kind" class="{{ $fieldClass }}">
|
||
@foreach (JobKind::cases() as $kind)
|
||
<option value="{{ $kind->value }}">{{ __('jobs.kinds.'.$kind->value) }}</option>
|
||
@endforeach
|
||
</select>
|
||
</div>
|
||
<div class="grid grid-cols-2 gap-2">
|
||
@foreach (['starts_on', 'due_on', 'planned_from', 'planned_to'] as $field)
|
||
<div>
|
||
<label for="job-editor-{{ $field }}" class="{{ $labelClass }}">{{ __('jobs.fields.'.$field) }}</label>
|
||
<input id="job-editor-{{ $field }}" type="date" wire:model="form.{{ $field }}" class="{{ $fieldClass }}" />
|
||
@error('form.'.$field) <p class="mt-1 text-xs font-semibold text-red-700 dark:text-red-200">{{ $message }}</p> @enderror
|
||
</div>
|
||
@endforeach
|
||
</div>
|
||
<div>
|
||
<label for="job-editor-estimated-hours" class="{{ $labelClass }}">{{ __('jobs.fields.estimated_hours') }}</label>
|
||
<input id="job-editor-estimated-hours" type="number" step="0.25" min="0" inputmode="decimal" wire:model="form.estimated_hours" class="{{ $fieldClass }}" />
|
||
@error('form.estimated_hours') <p class="mt-1 text-xs font-semibold text-red-700 dark:text-red-200">{{ $message }}</p> @enderror
|
||
</div>
|
||
</section>
|
||
|
||
<section aria-labelledby="job-editor-money-heading" class="{{ $boxClass }}">
|
||
<h3 id="job-editor-money-heading" class="{{ $boxHeading }}">{{ __('jobs.editor.money_section') }}</h3>
|
||
<div>
|
||
<label for="job-editor-payment-basis" class="{{ $labelClass }}">{{ __('jobs.fields.payment_basis') }}</label>
|
||
<select id="job-editor-payment-basis" wire:model.live="form.payment_basis" class="{{ $fieldClass }}">
|
||
<option value="">{{ __('jobs.fields.no_payment_basis') }}</option>
|
||
@foreach (PaymentBasis::cases() as $basis)
|
||
<option value="{{ $basis->value }}">{{ __('jobs.payment_bases.'.$basis->value) }}</option>
|
||
@endforeach
|
||
</select>
|
||
</div>
|
||
@can('money.quotes')
|
||
<div class="grid grid-cols-2 gap-2">
|
||
<div>
|
||
<label for="job-editor-quoted" class="{{ $labelClass }}">{{ __('jobs.fields.quoted_amount_input') }}</label>
|
||
<input id="job-editor-quoted" inputmode="decimal" autocomplete="off" wire:model="form.quoted_amount" class="{{ $fieldClass }}" />
|
||
@error('form.quoted_amount') <p class="mt-1 text-xs font-semibold text-red-700 dark:text-red-200">{{ $message }}</p> @enderror
|
||
</div>
|
||
@if ($form->payment_basis === 'monthly_fee')
|
||
<div>
|
||
<label for="job-editor-monthly-fee" class="{{ $labelClass }}">{{ __('jobs.fields.monthly_fee_input') }}</label>
|
||
<input id="job-editor-monthly-fee" inputmode="decimal" autocomplete="off" wire:model="form.monthly_fee" class="{{ $fieldClass }}" />
|
||
@error('form.monthly_fee') <p class="mt-1 text-xs font-semibold text-red-700 dark:text-red-200">{{ $message }}</p> @enderror
|
||
</div>
|
||
@endif
|
||
</div>
|
||
@else
|
||
<p class="rounded bg-neutral-200/70 p-2 text-[11px] dark:bg-[#24262a]">{{ __('jobs.editor.money_hidden') }}</p>
|
||
@endcan
|
||
<div>
|
||
<label for="job-editor-reference" class="{{ $labelClass }}">{{ __('jobs.fields.customer_reference') }}</label>
|
||
<input id="job-editor-reference" autocomplete="off" wire:model="form.customer_reference" class="{{ $fieldClass }}" />
|
||
</div>
|
||
</section>
|
||
</fieldset>
|
||
</div>
|
||
@endif
|
||
|
||
<x-slot:footer>
|
||
<span class="text-[11px]">{{ __('jobs.editor.footer') }}</span>
|
||
<div class="flex flex-wrap items-center gap-3">
|
||
@if ($job !== null)
|
||
<x-link :href="route('jobs.show', $job->id)" navigate class="text-xs">{{ __('jobs.editor.open_page') }}</x-link>
|
||
@endif
|
||
@if ($job !== null && $canEdit)
|
||
<x-button wire:click="save" sm :text="__('jobs.editor.save')" />
|
||
@endif
|
||
</div>
|
||
</x-slot:footer>
|
||
</x-work-dialog>
|
||
</div>
|