Files
Toiminnanohjaus/app/Modules/Jobs/Presentation/Livewire/⚡index.blade.php
petriandClaude Opus 5.5 7f3b6dff78 Add customer job Kanban board
Phase 1, item 6:
- New page /jobs/board: one column per Kanban status (archived left
  out), one card per job with number, name, customer, priority and due
  date. Filters for my jobs (default), priority and service unit;
  subcontractors see only their own cards and cannot move them.
- Cards move by dragging (Livewire wire:sort across column groups) or
  with each card's status select, which works with the keyboard. Moves
  go through ChangeJobStatus, so they are recorded in the job history;
  the result is announced and focus returns to the moved card.
- Billing statuses only for management and the job's biller: the
  jobs.set-billing-status gate now takes the biller's user id.
- Column links with counts at the top; columns wrap with the screen
  width, so there is no sideways scrolling.
- CustomerJobQueries::board() and the biller on job summaries.
- Menu link and a link from the job list; spec and CLAUDE.md updated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-23 19:15:54 +02:00

197 lines
7.5 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
use App\Modules\Catalog\Application\Contracts\CatalogQueries;
use App\Modules\Jobs\Application\Contracts\CustomerJobQueries;
use App\Modules\Jobs\Application\DTOs\CustomerJobSummary;
use App\Modules\Jobs\Application\DTOs\JobListFilter;
use App\Modules\Jobs\Domain\Enums\JobStatus;
use App\Modules\Jobs\Domain\Enums\Priority;
use App\Modules\Users\Domain\Enums\Role;
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
use Livewire\Attributes\Computed;
use Livewire\Attributes\Url;
use Livewire\Component;
use Livewire\WithPagination;
/**
* The customer job list: search, filters and "my jobs" on by default.
*/
new class extends Component
{
use WithPagination;
#[Url(as: 'q', except: '')]
public string $search = '';
#[Url(except: '')]
public string $status = '';
#[Url(except: '')]
public string $priority = '';
#[Url(as: 'unit', except: '')]
public string $serviceUnit = '';
#[Url(except: true)]
public bool $mine = true;
#[Url(except: false)]
public bool $archived = false;
public function mount(): void
{
$this->authorize('jobs.view');
}
public function updated(string $property): void
{
if (in_array($property, ['search', 'status', 'priority', 'serviceUnit', 'mine', 'archived'], true)) {
$this->resetPage();
}
}
public function isSubcontractor(): bool
{
return auth()->user()?->role === Role::Subcontractor;
}
/**
* @return LengthAwarePaginator<int, CustomerJobSummary>
*/
#[Computed]
public function jobs(): LengthAwarePaginator
{
$userId = (int) auth()->id();
return app(CustomerJobQueries::class)->paginate(new JobListFilter(
search: $this->search,
status: JobStatus::tryFrom($this->status)?->value,
priority: Priority::tryFrom($this->priority)?->value,
serviceUnitId: $this->serviceUnit === '' ? null : (int) $this->serviceUnit,
mineForUserId: $this->mine && ! $this->isSubcontractor() ? $userId : null,
onlyMemberUserId: $this->isSubcontractor() ? $userId : null,
includeArchived: $this->archived,
));
}
/**
* @return list<array{index: string, label: string, sortable: bool}>
*/
public function headers(): array
{
return [
['index' => 'number', 'label' => __('jobs.fields.number'), 'sortable' => false],
['index' => 'name', 'label' => __('jobs.fields.name'), 'sortable' => false],
['index' => 'customerName', 'label' => __('jobs.fields.customer'), 'sortable' => false],
['index' => 'status', 'label' => __('jobs.fields.status'), 'sortable' => false],
['index' => 'priority', 'label' => __('jobs.fields.priority'), 'sortable' => false],
['index' => 'dueOn', 'label' => __('jobs.fields.due_on'), 'sortable' => false],
['index' => 'responsibleName', 'label' => __('jobs.fields.responsible_user'), 'sortable' => false],
];
}
public function render(): mixed
{
return $this->view()->title(__('jobs.title'));
}
};
?>
<div class="mx-auto max-w-7xl space-y-6 p-4 sm:p-6">
<div class="flex flex-wrap items-center justify-between gap-4">
<div class="flex flex-wrap items-baseline gap-x-4 gap-y-1">
<h1 class="text-2xl font-semibold">{{ __('jobs.title') }}</h1>
<x-link :href="route('jobs.board')" navigate>{{ __('jobs.board.link') }}</x-link>
</div>
@can('jobs.manage')
<div class="flex flex-wrap gap-2">
<x-button :href="route('jobs.quick')" wire:navigate subtle color="black" icon="bolt" :text="__('jobs.quick.link')" />
<x-button :href="route('jobs.create')" wire:navigate icon="plus" :text="__('jobs.new')" />
</div>
@endcan
</div>
@if (session('status'))
<x-alert role="status" color="green" light icon="check-circle" :text="session('status')" />
@endif
@if ($this->isSubcontractor())
<p class="text-sm text-zinc-600 dark:text-zinc-300">{{ __('jobs.list.subcontractor_note') }}</p>
@endif
<div class="grid gap-4 md:grid-cols-2 xl:grid-cols-4">
<div class="md:col-span-2 xl:col-span-4">
<x-input
wire:model.live.debounce.300ms="search"
type="search"
icon="magnifying-glass"
:label="__('jobs.list.search')"
:hint="__('jobs.list.search_description')"
/>
</div>
{{-- TallStackUI's native select does not tie its label to the control, so aria-label names it. --}}
<x-select.native wire:model.live="status" :label="__('jobs.fields.status')" :aria-label="__('jobs.fields.status')">
<option value="">{{ __('jobs.list.all_statuses') }}</option>
@foreach (JobStatus::cases() as $option)
<option value="{{ $option->value }}">{{ __('jobs.statuses.'.$option->value) }}</option>
@endforeach
</x-select.native>
<x-select.native wire:model.live="priority" :label="__('jobs.fields.priority')" :aria-label="__('jobs.fields.priority')">
<option value="">{{ __('jobs.list.all_priorities') }}</option>
@foreach (Priority::cases() as $option)
<option value="{{ $option->value }}">{{ __('jobs.priorities.'.$option->value) }}</option>
@endforeach
</x-select.native>
<x-select.native wire:model.live="serviceUnit" :label="__('jobs.fields.service_units')" :aria-label="__('jobs.fields.service_units')">
<option value="">{{ __('jobs.list.all_service_units') }}</option>
@foreach (app(CatalogQueries::class)->activeServiceUnits() as $unit)
<option value="{{ $unit->id }}">{{ $unit->name }}</option>
@endforeach
</x-select.native>
<div class="space-y-2">
@unless ($this->isSubcontractor())
<x-checkbox id="only-mine" wire:model.live="mine" :label="__('jobs.list.only_mine')" />
@endunless
<x-checkbox id="include-archived" wire:model.live="archived" :label="__('jobs.list.include_archived')" />
</div>
</div>
<p role="status" aria-live="polite" aria-atomic="true" class="text-sm text-zinc-600 dark:text-zinc-300">
{{ trans_choice('jobs.list.result_count', $this->jobs->total(), ['count' => $this->jobs->total()]) }}
@if ($mine && ! $this->isSubcontractor())
– {{ __('jobs.list.only_mine_description') }}
@endif
</p>
@if ($this->jobs->total() === 0)
<p class="text-sm text-zinc-600 dark:text-zinc-300">{{ __('jobs.list.empty') }}</p>
@else
<x-table :headers="$this->headers()" :rows="$this->jobs" paginate>
@interact('column_number', $job)
<span class="whitespace-nowrap">{{ $job->number }}</span>
@endinteract
@interact('column_name', $job)
<x-link :href="route('jobs.show', $job->id)" navigate class="font-medium">{{ $job->name }}</x-link>
@endinteract
@interact('column_status', $job)
{{ __('jobs.statuses.'.$job->status->value) }}
@endinteract
@interact('column_priority', $job)
<x-jobs.priority :priority="$job->priority" />
@endinteract
@interact('column_dueOn', $job)
<x-jobs.due-date :date="$job->dueOn" :status="$job->status" />
@endinteract
</x-table>
@endif
</div>