authorize('jobs.view'); } public function isSubcontractor(): bool { return auth()->user()?->role === Role::Subcontractor; } /** * @return array> */ #[Computed] public function board(): array { $userId = (int) auth()->id(); return app(CustomerJobQueries::class)->board(new JobListFilter( 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, )); } /** * Statuses a card can be moved to by this user. * * @return list */ public function statusesFor(CustomerJobSummary $job): array { return array_values(array_filter( JobStatus::kanbanStatuses(), fn (JobStatus $status): bool => $status === $job->status || ((! $status->isBillingStatus() || Gate::allows('jobs.set-billing-status', [$job->billerUserId])) && (! $job->status->unlocksTo($status) || Gate::allows('jobs.unlock'))), )); } /** * A card's status select changed. */ public function moveJob(int $jobId, string $status, ChangeJobStatus $changeStatus): void { $this->move($jobId, $status, $changeStatus); } /** * A card was dropped into another column (wire:sort). The position * inside the column does not matter: cards are ordered by due date. */ public function moveDropped(int|string $jobId, int $position, string $status, ChangeJobStatus $changeStatus): void { $this->move((int) $jobId, $status, $changeStatus); } public function render(): mixed { return $this->view()->title(__('jobs.board.title')); } private function move(int $jobId, string $statusValue, ChangeJobStatus $changeStatus): void { $this->authorize('jobs.manage'); $status = JobStatus::tryFrom($statusValue); $job = $this->findCard($jobId); if ($status === null || $status === JobStatus::Archived || $job === null) { $this->statusMessage = __('jobs.board.not_moved'); return; } if ($status->isBillingStatus() && $status !== $job->status && ! Gate::allows('jobs.set-billing-status', [$job->billerUserId])) { $this->statusMessage = __('jobs.board.billing_not_allowed', ['job' => $job->number.' '.$job->name, 'status' => __('jobs.statuses.'.$status->value)]); unset($this->board); return; } if ($job->status->unlocksTo($status) && ! Gate::allows('jobs.unlock')) { $this->statusMessage = __('jobs.board.unlock_not_allowed', ['job' => $job->number.' '.$job->name, 'status' => __('jobs.statuses.'.$status->value)]); unset($this->board); return; } try { $changeStatus->execute($jobId, $status, (int) auth()->id()); } catch (CustomerJobNotFound) { $this->statusMessage = __('jobs.board.not_moved'); return; } unset($this->board); $this->statusMessage = __('jobs.board.moved', ['job' => $job->number.' '.$job->name, 'status' => __('jobs.statuses.'.$status->value)]); $this->js("document.getElementById('job-status-{$jobId}')?.focus()"); } private function findCard(int $jobId): ?CustomerJobSummary { foreach ($this->board as $jobs) { foreach ($jobs as $job) { if ($job->id === $jobId) { return $job; } } } return null; } }; ?> @php($canMove = Gate::allows('jobs.manage')) {{ __('jobs.board.show_list') }}
{{-- TallStackUI's native select does not tie its label to the control, so aria-label names it. --}} @foreach (Priority::cases() as $option) @endforeach @foreach (app(CatalogQueries::class)->activeServiceUnits() as $unit) @endforeach @if ($this->isSubcontractor())

{{ __('jobs.list.subcontractor_note') }}

@else
@endif

{{ $statusMessage }}

@foreach ($this->board as $status => $jobs)
'border-t-violet-500', 'order', 'invoiced' => 'border-t-sky-500', 'in_production' => 'border-t-primary-500', 'on_hold' => 'border-t-amber-500', 'done', 'billed' => 'border-t-emerald-500', 'ongoing' => 'border-t-teal-500', default => 'border-t-zinc-400', }]) >

{{ trans_choice('jobs.board.count', count($jobs), ['count' => count($jobs)]) }}

    @forelse ($jobs as $job)
  • in_array($job->priority->value, ['urgent', 'immediate'], true)]) > @if ($canMove)
  • @empty
  • {{ __('jobs.board.empty') }}
  • @endforelse
@endforeach