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]>
This commit is contained in:
+49
-3
@@ -15,6 +15,7 @@ use App\Modules\Jobs\Infrastructure\Persistence\Eloquent\CustomerJobModel;
|
||||
use App\Modules\Users\Application\Contracts\UserAccountQueries;
|
||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
/**
|
||||
@@ -37,11 +38,55 @@ class EloquentCustomerJobQueries implements CustomerJobQueries
|
||||
->orderByDesc('id')
|
||||
->paginate($perPage);
|
||||
|
||||
$models = collect($page->items());
|
||||
$toSummary = $this->summaryMapper(collect($page->items()));
|
||||
|
||||
return $page->through($toSummary);
|
||||
}
|
||||
|
||||
public function board(JobListFilter $filter, int $limitPerStatus = 100): array
|
||||
{
|
||||
$board = [];
|
||||
|
||||
foreach (JobStatus::kanbanStatuses() as $status) {
|
||||
$board[$status->value] = [];
|
||||
}
|
||||
|
||||
$models = $this->filtered(new JobListFilter(
|
||||
search: $filter->search,
|
||||
priority: $filter->priority,
|
||||
serviceUnitId: $filter->serviceUnitId,
|
||||
mineForUserId: $filter->mineForUserId,
|
||||
onlyMemberUserId: $filter->onlyMemberUserId,
|
||||
))
|
||||
->orderByRaw('due_on IS NULL')
|
||||
->orderBy('due_on')
|
||||
->orderByDesc('id')
|
||||
->get();
|
||||
|
||||
$toSummary = $this->summaryMapper($models);
|
||||
|
||||
foreach ($models as $model) {
|
||||
if (isset($board[$model->status->value]) && count($board[$model->status->value]) < $limitPerStatus) {
|
||||
$board[$model->status->value][] = $toSummary($model);
|
||||
}
|
||||
}
|
||||
|
||||
return $board;
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns job rows into summaries, with customer and user names looked up
|
||||
* once for all rows.
|
||||
*
|
||||
* @param Collection<int, CustomerJobModel> $models
|
||||
* @return \Closure(CustomerJobModel): CustomerJobSummary
|
||||
*/
|
||||
private function summaryMapper(Collection $models): \Closure
|
||||
{
|
||||
$customerNames = $this->customers->namesByIds($models->pluck('customer_id')->unique()->values()->all());
|
||||
$userNames = $this->users->namesByIds($models->pluck('responsible_user_id')->unique()->values()->all());
|
||||
|
||||
return $page->through(fn (CustomerJobModel $model): CustomerJobSummary => new CustomerJobSummary(
|
||||
return fn (CustomerJobModel $model): CustomerJobSummary => new CustomerJobSummary(
|
||||
$model->id,
|
||||
$model->number,
|
||||
$model->name,
|
||||
@@ -51,7 +96,8 @@ class EloquentCustomerJobQueries implements CustomerJobQueries
|
||||
$model->priority,
|
||||
$model->due_on?->format('Y-m-d'),
|
||||
$userNames[$model->responsible_user_id] ?? '',
|
||||
));
|
||||
$model->biller_user_id,
|
||||
);
|
||||
}
|
||||
|
||||
public function findDetails(int $id): ?CustomerJobDetails
|
||||
|
||||
Reference in New Issue
Block a user