Rebuild the Kanban board after the prototype, with the job editor and quick intake dialog
- Toolbar: whose board (own, a person, a service line, all), pipeline views (daily, sales, full), urgent and late filters with a live count, normal and compact density, and the quick intake button. - Columns side by side with horizontal scrolling on desktop, stacked on phones; each user's own column colours and order, the urgent column's threshold menu, and the continuing jobs column. - Cards in customer colours: job cards with their tasks checked off inside the card (the status select is gone), continuing job cards with the next period, PIN and quick add, and pinned task cards. Dragging moves and orders cards; the keyboard opens the job editor from the card title. - Job editor dialog: every job detail, tasks with checklists and templates, quick hours (TimeTracking) and expenses (Expenses), history. - The quick intake form also adds a contact person, initial status and priority, and opens as a dialog on the board. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -2,9 +2,13 @@
|
||||
|
||||
use App\Modules\Catalog\Application\Contracts\CatalogQueries;
|
||||
use App\Modules\Catalog\Application\DTOs\ServiceUnitSummary;
|
||||
use App\Modules\Customers\Application\Contracts\CustomerQueries;
|
||||
use App\Modules\Customers\Application\DTOs\ContactData;
|
||||
use App\Modules\Customers\Application\DTOs\ContactSummary;
|
||||
use App\Modules\Customers\Application\UseCases\AddContact;
|
||||
use App\Modules\Jobs\Application\Contracts\CustomerJobQueries;
|
||||
use App\Modules\Jobs\Application\UseCases\CreateCustomerJob;
|
||||
use App\Modules\Jobs\Domain\Enums\JobStatus;
|
||||
use App\Modules\Jobs\Domain\Enums\Priority;
|
||||
use App\Modules\Jobs\Presentation\Livewire\Concerns\PicksCustomer;
|
||||
use App\Modules\Jobs\Presentation\Livewire\Forms\QuickJobForm;
|
||||
use App\Modules\Shared\Domain\Exceptions\DomainException;
|
||||
@@ -16,16 +20,25 @@ use Livewire\Attributes\Locked;
|
||||
use Livewire\Component;
|
||||
|
||||
/**
|
||||
* Quick job intake (pikavastaanotto), made for phones: customer, name,
|
||||
* short description, service unit and responsible person. The page stays
|
||||
* open for the next job and links to the one just created.
|
||||
* Quick job intake (pikavastaanotto, docs/ui-kanban-board.md 6), made for
|
||||
* phones and also opened as a dialog on the Kanban board: customer and its
|
||||
* contact person (with a quick add), name, short description, service
|
||||
* unit, responsible person, initial status and priority. The page stays
|
||||
* open for the next job and links to the one just created; the dialog
|
||||
* closes and the board shows the new card.
|
||||
*/
|
||||
new class extends Component
|
||||
{
|
||||
use PicksCustomer;
|
||||
|
||||
public const string DIALOG = 'quick-intake-dialog';
|
||||
|
||||
public QuickJobForm $form;
|
||||
|
||||
/** Embedded in the board's dialog instead of being the page. */
|
||||
#[Locked]
|
||||
public bool $inDialog = false;
|
||||
|
||||
/**
|
||||
* The job created last on this page, shown with links to it.
|
||||
*/
|
||||
@@ -38,10 +51,11 @@ new class extends Component
|
||||
#[Locked]
|
||||
public string $createdNumber = '';
|
||||
|
||||
public function mount(): void
|
||||
public function mount(bool $inDialog = false): void
|
||||
{
|
||||
$this->authorize('jobs.manage');
|
||||
|
||||
$this->inDialog = $inDialog;
|
||||
$this->form->responsible_user_id = (string) auth()->id();
|
||||
}
|
||||
|
||||
@@ -68,10 +82,40 @@ new class extends Component
|
||||
));
|
||||
}
|
||||
|
||||
public function save(CreateCustomerJob $createJob, CustomerJobQueries $jobQueries): void
|
||||
/**
|
||||
* @return list<ContactSummary>
|
||||
*/
|
||||
#[Computed]
|
||||
public function contacts(): array
|
||||
{
|
||||
return $this->form->customer_id === '' ? [] : app(CustomerQueries::class)->contactsOf((int) $this->form->customer_id);
|
||||
}
|
||||
|
||||
public function save(CreateCustomerJob $createJob, CustomerJobQueries $jobQueries, AddContact $addContact): void
|
||||
{
|
||||
$this->authorize('jobs.manage');
|
||||
|
||||
$this->form->validate();
|
||||
|
||||
if ($this->form->adding_contact && trim($this->form->new_contact_name) !== '') {
|
||||
$this->authorize('customers.use');
|
||||
|
||||
try {
|
||||
$contactId = $addContact->execute((int) $this->form->customer_id, new ContactData(
|
||||
name: trim($this->form->new_contact_name),
|
||||
phone: trim($this->form->new_contact_phone) === '' ? null : trim($this->form->new_contact_phone),
|
||||
));
|
||||
} catch (DomainException) {
|
||||
$this->addError('form.new_contact_name', __('jobs.quick.contact_name_required'));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->form->customer_contact_id = (string) $contactId;
|
||||
$this->form->adding_contact = false;
|
||||
unset($this->contacts);
|
||||
}
|
||||
|
||||
$data = $this->form->toData();
|
||||
|
||||
try {
|
||||
@@ -90,6 +134,15 @@ new class extends Component
|
||||
$this->customerName = '';
|
||||
$this->customerSearch = '';
|
||||
$this->statusMessage = '';
|
||||
unset($this->contacts);
|
||||
|
||||
if ($this->inDialog) {
|
||||
$this->dispatch('quick-job-created', status: $data->status);
|
||||
$this->dispatch('job-editor-saved', message: $this->createdMessage);
|
||||
$this->js("document.getElementById('".self::DIALOG."').close()");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->js("document.getElementById('quick-created')?.focus()");
|
||||
}
|
||||
@@ -98,33 +151,44 @@ new class extends Component
|
||||
{
|
||||
return $this->view()->title(__('jobs.quick.title'));
|
||||
}
|
||||
|
||||
/**
|
||||
* A contact person of another customer no longer fits.
|
||||
*/
|
||||
protected function customerChosen(?int $customerId): void
|
||||
{
|
||||
$this->form->customer_contact_id = '';
|
||||
unset($this->contacts);
|
||||
}
|
||||
};
|
||||
?>
|
||||
|
||||
<div class="mx-auto max-w-lg space-y-6 p-4 sm:p-6">
|
||||
<div class="space-y-1">
|
||||
<x-page-title icon="bolt">{{ __('jobs.quick.title') }}</x-page-title>
|
||||
<p class="text-sm text-zinc-600 dark:text-zinc-200">{{ __('jobs.quick.intro') }}</p>
|
||||
</div>
|
||||
<div @class(['mx-auto max-w-lg space-y-6 p-4 sm:p-6' => ! $inDialog])>
|
||||
@unless ($inDialog)
|
||||
<div class="space-y-1">
|
||||
<x-page-title icon="bolt">{{ __('jobs.quick.title') }}</x-page-title>
|
||||
<p class="text-sm text-zinc-600 dark:text-zinc-200">{{ __('jobs.quick.intro') }}</p>
|
||||
</div>
|
||||
|
||||
<div id="quick-created" tabindex="-1" role="status" aria-live="polite" class="focus:outline-none">
|
||||
@if ($createdJobId !== null)
|
||||
<div class="space-y-2 rounded-lg border border-green-700 bg-green-50 p-4 text-sm text-green-900 dark:border-green-500 dark:bg-green-950 dark:text-green-100">
|
||||
<p class="flex items-start gap-2 font-medium">
|
||||
<x-icon name="check-circle" class="size-5 shrink-0" aria-hidden="true" />
|
||||
{{ $createdMessage }}
|
||||
</p>
|
||||
<p class="flex flex-wrap gap-x-4 gap-y-1">
|
||||
<x-link :href="route('jobs.show', $createdJobId)" navigate>{{ __('jobs.quick.open', ['number' => $createdNumber]) }}</x-link>
|
||||
<x-link :href="route('jobs.edit', $createdJobId)" navigate>{{ __('jobs.quick.complete') }}</x-link>
|
||||
</p>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
<div id="quick-created" tabindex="-1" role="status" aria-live="polite" class="focus:outline-none">
|
||||
@if ($createdJobId !== null)
|
||||
<div class="space-y-2 rounded-lg border border-green-700 bg-green-50 p-4 text-sm text-green-900 dark:border-green-500 dark:bg-green-950 dark:text-green-100">
|
||||
<p class="flex items-start gap-2 font-medium">
|
||||
<x-icon name="check-circle" class="size-5 shrink-0" aria-hidden="true" />
|
||||
{{ $createdMessage }}
|
||||
</p>
|
||||
<p class="flex flex-wrap gap-x-4 gap-y-1">
|
||||
<x-link :href="route('jobs.show', $createdJobId)" navigate>{{ __('jobs.quick.open', ['number' => $createdNumber]) }}</x-link>
|
||||
<x-link :href="route('jobs.edit', $createdJobId)" navigate>{{ __('jobs.quick.complete') }}</x-link>
|
||||
</p>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
@endunless
|
||||
|
||||
<p role="status" aria-live="polite" class="text-sm">{{ $statusMessage }}</p>
|
||||
<p role="status" aria-live="polite" @class(['text-sm', 'px-5 pt-3' => $inDialog])>{{ $statusMessage }}</p>
|
||||
|
||||
<form wire:submit="save" class="card space-y-6" novalidate>
|
||||
<form wire:submit="save" @class(['card space-y-6' => ! $inDialog, 'space-y-4 px-5 pb-5' => $inDialog]) novalidate>
|
||||
<x-jobs.customer-picker
|
||||
:customer-id="$form->customer_id"
|
||||
:customer-name="$customerName"
|
||||
@@ -132,34 +196,83 @@ new class extends Component
|
||||
:results="$this->customerResults"
|
||||
/>
|
||||
|
||||
<x-input wire:model="form.name" :label="__('jobs.fields.name')" autocomplete="off" required />
|
||||
<div class="space-y-2">
|
||||
<div class="flex flex-wrap items-end justify-between gap-2">
|
||||
<div class="min-w-0 flex-1">
|
||||
<x-select.native
|
||||
id="{{ $inDialog ? 'dialog-' : '' }}quick-contact"
|
||||
wire:model="form.customer_contact_id"
|
||||
:label="__('jobs.quick.contact')"
|
||||
:aria-label="__('jobs.quick.contact')"
|
||||
:disabled="$form->customer_id === ''"
|
||||
:hint="$form->customer_id === '' ? __('jobs.customer_picker.choose_customer_first') : null"
|
||||
>
|
||||
<option value="">{{ __('jobs.fields.none_selected') }}</option>
|
||||
@foreach ($this->contacts as $contact)
|
||||
<option wire:key="quick-contact-{{ $contact->id }}" value="{{ $contact->id }}">{{ $contact->name }}</option>
|
||||
@endforeach
|
||||
</x-select.native>
|
||||
</div>
|
||||
@if ($form->customer_id !== '')
|
||||
<x-button
|
||||
wire:click="$toggle('form.adding_contact')"
|
||||
subtle
|
||||
color="black"
|
||||
sm
|
||||
:text="__('jobs.quick.add_contact')"
|
||||
:aria-label="__('jobs.quick.add_contact_label')"
|
||||
x-bind:aria-expanded="$wire.form.adding_contact.toString()"
|
||||
/>
|
||||
@endif
|
||||
</div>
|
||||
@if ($form->adding_contact && $form->customer_id !== '')
|
||||
<div class="grid gap-3 rounded-lg border border-indigo-400 bg-indigo-50/40 p-3 sm:grid-cols-2 dark:border-indigo-500 dark:bg-[#1e2026]">
|
||||
<x-input id="{{ $inDialog ? 'dialog-' : '' }}quick-contact-name" wire:model="form.new_contact_name" :label="__('jobs.quick.contact_name')" autocomplete="off" required />
|
||||
<x-input id="{{ $inDialog ? 'dialog-' : '' }}quick-contact-phone" wire:model="form.new_contact_phone" type="tel" :label="__('jobs.quick.contact_phone')" autocomplete="off" />
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<x-textarea wire:model="form.description" :label="__('jobs.quick.description')" rows="3" />
|
||||
<x-input id="{{ $inDialog ? 'dialog-' : '' }}quick-name" wire:model="form.name" :label="__('jobs.fields.name')" autocomplete="off" required />
|
||||
|
||||
{{-- TallStackUI's native select does not tie its label to the control, so aria-label names it. --}}
|
||||
<x-select.native wire:model="form.service_unit_id" :label="__('jobs.quick.service_unit')" :aria-label="__('jobs.quick.service_unit')" required>
|
||||
<option value="">{{ __('jobs.fields.none_selected') }}</option>
|
||||
@foreach ($this->serviceUnits as $unit)
|
||||
<option value="{{ $unit->id }}">{{ $unit->name }}</option>
|
||||
@endforeach
|
||||
</x-select.native>
|
||||
<x-textarea id="{{ $inDialog ? 'dialog-' : '' }}quick-description" wire:model="form.description" :label="__('jobs.quick.description')" rows="3" />
|
||||
|
||||
<x-select.native wire:model="form.responsible_user_id" :label="__('jobs.fields.responsible_user')" :aria-label="__('jobs.fields.responsible_user')" required>
|
||||
<option value="">{{ __('jobs.fields.none_selected') }}</option>
|
||||
@foreach ($this->staff as $user)
|
||||
<option value="{{ $user->id }}">{{ $user->name }}</option>
|
||||
@endforeach
|
||||
</x-select.native>
|
||||
<div class="grid gap-4 sm:grid-cols-2">
|
||||
{{-- TallStackUI's native select does not tie its label to the control, so aria-label names it. --}}
|
||||
<x-select.native id="{{ $inDialog ? 'dialog-' : '' }}quick-service-unit" wire:model="form.service_unit_id" :label="__('jobs.quick.service_unit')" :aria-label="__('jobs.quick.service_unit')" required>
|
||||
<option value="">{{ __('jobs.fields.none_selected') }}</option>
|
||||
@foreach ($this->serviceUnits as $unit)
|
||||
<option value="{{ $unit->id }}">{{ $unit->name }}</option>
|
||||
@endforeach
|
||||
</x-select.native>
|
||||
|
||||
<x-radio.group
|
||||
wire:model="form.status"
|
||||
:label="__('jobs.fields.status')"
|
||||
:options="[
|
||||
['label' => __('jobs.statuses.'.JobStatus::Tentative->value), 'value' => JobStatus::Tentative->value],
|
||||
['label' => __('jobs.statuses.'.JobStatus::Prospect->value), 'value' => JobStatus::Prospect->value],
|
||||
]"
|
||||
/>
|
||||
<x-select.native id="{{ $inDialog ? 'dialog-' : '' }}quick-responsible" wire:model="form.responsible_user_id" :label="__('jobs.fields.responsible_user')" :aria-label="__('jobs.fields.responsible_user')" required>
|
||||
<option value="">{{ __('jobs.fields.none_selected') }}</option>
|
||||
@foreach ($this->staff as $user)
|
||||
<option value="{{ $user->id }}">{{ $user->name }}</option>
|
||||
@endforeach
|
||||
</x-select.native>
|
||||
|
||||
<x-button submit lg class="w-full" :text="__('jobs.quick.save')" />
|
||||
<x-select.native id="{{ $inDialog ? 'dialog-' : '' }}quick-status" wire:model="form.status" :label="__('jobs.quick.start_status')" :aria-label="__('jobs.quick.start_status')">
|
||||
@foreach (QuickJobForm::startStatuses() as $status)
|
||||
<option value="{{ $status->value }}">{{ __('jobs.statuses.'.$status->value) }}</option>
|
||||
@endforeach
|
||||
</x-select.native>
|
||||
|
||||
<x-select.native id="{{ $inDialog ? 'dialog-' : '' }}quick-priority" wire:model="form.priority" :label="__('jobs.fields.priority')" :aria-label="__('jobs.fields.priority')">
|
||||
@foreach (Priority::cases() as $priority)
|
||||
<option value="{{ $priority->value }}">{{ __('jobs.priorities.'.$priority->value) }}</option>
|
||||
@endforeach
|
||||
</x-select.native>
|
||||
</div>
|
||||
|
||||
@if ($inDialog)
|
||||
<div class="flex justify-end gap-2 border-t border-neutral-200 pt-3 dark:border-[#36393f]">
|
||||
<x-button subtle color="black" :text="__('layout.cancel')" x-on:click="$el.closest('dialog').close()" />
|
||||
<x-button submit :text="__('jobs.quick.save')" />
|
||||
</div>
|
||||
@else
|
||||
<x-button submit lg class="w-full" :text="__('jobs.quick.save')" />
|
||||
@endif
|
||||
</form>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user