- Dark theme page background is #5a5e60; text on it is lifted to zinc-200 / primary-100 and TallStackUI's dark labels, hints and checkbox labels are lightened so everything stays at 4.5:1. - Shared HexColor picks white or black text by the higher WCAG contrast; a native-dialog colour picker and a large work dialog component. - Customers get a header colour (customers.header_color), set on the customer page. - New job status Jatkuvat / Kausi (ongoing): open, never late, billed monthly like running jobs. - Kanban model: board columns and views, urgent threshold, per-user board preferences (density, column colours and sort), card positions, tasks of continuing jobs pinned to the board, MoveBoardCard and board queries with logged hours from TimeTracking. Co-Authored-By: Claude Opus 5.5 <[email protected]>
166 lines
6.0 KiB
PHP
166 lines
6.0 KiB
PHP
<?php
|
|
|
|
use App\Modules\Catalog\Application\Contracts\CatalogQueries;
|
|
use App\Modules\Catalog\Application\DTOs\ServiceUnitSummary;
|
|
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\Presentation\Livewire\Concerns\PicksCustomer;
|
|
use App\Modules\Jobs\Presentation\Livewire\Forms\QuickJobForm;
|
|
use App\Modules\Shared\Domain\Exceptions\DomainException;
|
|
use App\Modules\Users\Application\Contracts\UserAccountQueries;
|
|
use App\Modules\Users\Application\DTOs\UserOption;
|
|
use App\Modules\Users\Domain\Enums\Role;
|
|
use Livewire\Attributes\Computed;
|
|
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.
|
|
*/
|
|
new class extends Component
|
|
{
|
|
use PicksCustomer;
|
|
|
|
public QuickJobForm $form;
|
|
|
|
/**
|
|
* The job created last on this page, shown with links to it.
|
|
*/
|
|
#[Locked]
|
|
public ?int $createdJobId = null;
|
|
|
|
#[Locked]
|
|
public string $createdMessage = '';
|
|
|
|
#[Locked]
|
|
public string $createdNumber = '';
|
|
|
|
public function mount(): void
|
|
{
|
|
$this->authorize('jobs.manage');
|
|
|
|
$this->form->responsible_user_id = (string) auth()->id();
|
|
}
|
|
|
|
/**
|
|
* @return list<ServiceUnitSummary>
|
|
*/
|
|
#[Computed]
|
|
public function serviceUnits(): array
|
|
{
|
|
return app(CatalogQueries::class)->activeServiceUnits();
|
|
}
|
|
|
|
/**
|
|
* Users who can be responsible for a job (not subcontractors).
|
|
*
|
|
* @return list<UserOption>
|
|
*/
|
|
#[Computed]
|
|
public function staff(): array
|
|
{
|
|
return array_values(array_filter(
|
|
app(UserAccountQueries::class)->activeUserOptions(),
|
|
fn (UserOption $user): bool => $user->role !== Role::Subcontractor,
|
|
));
|
|
}
|
|
|
|
public function save(CreateCustomerJob $createJob, CustomerJobQueries $jobQueries): void
|
|
{
|
|
$this->authorize('jobs.manage');
|
|
|
|
$data = $this->form->toData();
|
|
|
|
try {
|
|
$jobId = $createJob->execute($data, (int) auth()->id());
|
|
} catch (DomainException $exception) {
|
|
$this->form->showDomainError($exception);
|
|
|
|
return;
|
|
}
|
|
|
|
$this->createdJobId = $jobId;
|
|
$this->createdNumber = $jobQueries->findDetails($jobId)->number ?? '';
|
|
$this->createdMessage = __('jobs.created', ['number' => $this->createdNumber, 'name' => trim($data->name)]);
|
|
|
|
$this->form->clearForNextJob();
|
|
$this->customerName = '';
|
|
$this->customerSearch = '';
|
|
$this->statusMessage = '';
|
|
|
|
$this->js("document.getElementById('quick-created')?.focus()");
|
|
}
|
|
|
|
public function render(): mixed
|
|
{
|
|
return $this->view()->title(__('jobs.quick.title'));
|
|
}
|
|
};
|
|
?>
|
|
|
|
<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 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>
|
|
|
|
<p role="status" aria-live="polite" class="text-sm">{{ $statusMessage }}</p>
|
|
|
|
<form wire:submit="save" class="card space-y-6" novalidate>
|
|
<x-jobs.customer-picker
|
|
:customer-id="$form->customer_id"
|
|
:customer-name="$customerName"
|
|
:search="$customerSearch"
|
|
:results="$this->customerResults"
|
|
/>
|
|
|
|
<x-input wire:model="form.name" :label="__('jobs.fields.name')" autocomplete="off" required />
|
|
|
|
<x-textarea wire:model="form.description" :label="__('jobs.quick.description')" rows="3" />
|
|
|
|
{{-- 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-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>
|
|
|
|
<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-button submit lg class="w-full" :text="__('jobs.quick.save')" />
|
|
</form>
|
|
</div>
|