- 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]>
194 lines
7.4 KiB
PHP
194 lines
7.4 KiB
PHP
<?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'));
|
||
}
|
||
};
|
||
?>
|
||
|
||
<x-page width="wide">
|
||
<x-page-header :title="__('jobs.title')" icon="briefcase">
|
||
<x-link :href="route('jobs.board')" navigate class="text-sm">{{ __('jobs.board.link') }}</x-link>
|
||
|
||
@can('jobs.manage')
|
||
<x-slot:actions>
|
||
<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')" />
|
||
</x-slot:actions>
|
||
@endcan
|
||
</x-page-header>
|
||
|
||
@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-200">{{ __('jobs.list.subcontractor_note') }}</p>
|
||
@endif
|
||
|
||
<div class="grid gap-4 rounded-xl border border-zinc-200 bg-white p-4 shadow-sm md:grid-cols-2 xl:grid-cols-4 dark:border-zinc-700 dark:bg-zinc-900">
|
||
<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-100">
|
||
{{ 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)
|
||
<x-empty-state icon="briefcase">{{ __('jobs.list.empty') }}</x-empty-state>
|
||
@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)
|
||
<x-jobs.status :status="$job->status" />
|
||
@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
|
||
</x-page>
|