- Toolbar: whose board (own, a person, a service line, all), pipeline views (daily, sales, full), urgent and late filters with a live count, normal and compact density, and the quick intake button. - Columns side by side with horizontal scrolling on desktop, stacked on phones; each user's own column colours and order, the urgent column's threshold menu, and the continuing jobs column. - Cards in customer colours: job cards with their tasks checked off inside the card (the status select is gone), continuing job cards with the next period, PIN and quick add, and pinned task cards. Dragging moves and orders cards; the keyboard opens the job editor from the card title. - Job editor dialog: every job detail, tasks with checklists and templates, quick hours (TimeTracking) and expenses (Expenses), history. - The quick intake form also adds a contact person, initial status and priority, and opens as a dialog on the board. Co-Authored-By: Claude Opus 5.5 <[email protected]>
811 lines
36 KiB
PHP
811 lines
36 KiB
PHP
<?php
|
|
|
|
use App\Modules\Catalog\Application\Contracts\CatalogQueries;
|
|
use App\Modules\Customers\Application\UseCases\ChangeCustomerHeaderColor;
|
|
use App\Modules\Customers\Domain\Exceptions\CustomerNotFound;
|
|
use App\Modules\Jobs\Application\Contracts\CustomerJobQueries;
|
|
use App\Modules\Jobs\Application\Contracts\JobBoardQueries;
|
|
use App\Modules\Jobs\Application\DTOs\BoardCard;
|
|
use App\Modules\Jobs\Application\DTOs\BoardFilter;
|
|
use App\Modules\Jobs\Application\DTOs\BoardTask;
|
|
use App\Modules\Jobs\Application\DTOs\TaskData;
|
|
use App\Modules\Jobs\Application\Services\BoardLayout;
|
|
use App\Modules\Jobs\Application\UseCases\AddTask;
|
|
use App\Modules\Jobs\Application\UseCases\ChangeTaskStatus;
|
|
use App\Modules\Jobs\Application\UseCases\MoveBoardCard;
|
|
use App\Modules\Jobs\Application\UseCases\PinTaskToBoard;
|
|
use App\Modules\Jobs\Application\UseCases\SaveBoardPreferences;
|
|
use App\Modules\Jobs\Domain\Enums\BoardColumn;
|
|
use App\Modules\Jobs\Domain\Enums\BoardDensity;
|
|
use App\Modules\Jobs\Domain\Enums\BoardView;
|
|
use App\Modules\Jobs\Domain\Enums\ColumnSort;
|
|
use App\Modules\Jobs\Domain\Enums\JobStatus;
|
|
use App\Modules\Jobs\Domain\Enums\TaskStatus;
|
|
use App\Modules\Jobs\Domain\Enums\UrgentThreshold;
|
|
use App\Modules\Jobs\Domain\Exceptions\CardCannotMoveThere;
|
|
use App\Modules\Jobs\Domain\Exceptions\CustomerJobNotFound;
|
|
use App\Modules\Jobs\Domain\Exceptions\TaskCannotBePinned;
|
|
use App\Modules\Jobs\Domain\Exceptions\TaskNotFound;
|
|
use App\Modules\Jobs\Domain\ValueObjects\BoardPreferences;
|
|
use App\Modules\Shared\Domain\Exceptions\DomainException;
|
|
use App\Modules\Shared\Domain\Exceptions\InvalidHexColor;
|
|
use App\Modules\Shared\Domain\ValueObjects\HexColor;
|
|
use App\Modules\Users\Application\Contracts\Clock;
|
|
use App\Modules\Users\Application\Contracts\UserAccountQueries;
|
|
use App\Modules\Users\Domain\Enums\Role;
|
|
use Illuminate\Support\Facades\Gate;
|
|
use Livewire\Attributes\Computed;
|
|
use Livewire\Attributes\On;
|
|
use Livewire\Attributes\Url;
|
|
use Livewire\Component;
|
|
|
|
/**
|
|
* The Kanban board (docs/ui-kanban-board.md): whose board, the pipeline
|
|
* view, quick filters and the card density in the toolbar; columns with
|
|
* the user's own colours and order; job cards with their tasks, continuing
|
|
* job cards and pinned task cards. Cards move by dragging (wire:sort); the
|
|
* keyboard alternative is the status choice in the job editor that opens
|
|
* from each card's title.
|
|
*/
|
|
new class extends Component
|
|
{
|
|
/** "mine", "person-<id>", "unit-<id>" or "all". */
|
|
#[Url(as: 'taulu', except: 'mine')]
|
|
public string $board = 'mine';
|
|
|
|
#[Url(as: 'nakyma', except: 'production')]
|
|
public string $view = 'production';
|
|
|
|
#[Url(as: 'kiire', except: false)]
|
|
public bool $onlyUrgent = false;
|
|
|
|
#[Url(as: 'myohassa', except: false)]
|
|
public bool $onlyLate = false;
|
|
|
|
public string $statusMessage = '';
|
|
|
|
/** @var array<int, string> new task titles typed on continuing job cards, by job id */
|
|
public array $newTaskTitles = [];
|
|
|
|
/** @var array<int, bool> "lift into the pipeline at once" on those cards, by job id */
|
|
public array $newTaskPins = [];
|
|
|
|
public function mount(): void
|
|
{
|
|
$this->authorize('jobs.view');
|
|
|
|
if (BoardView::tryFrom($this->view) === null) {
|
|
$this->view = BoardView::Production->value;
|
|
}
|
|
}
|
|
|
|
public function isSubcontractor(): bool
|
|
{
|
|
return auth()->user()?->role === Role::Subcontractor;
|
|
}
|
|
|
|
#[Computed]
|
|
public function preferences(): BoardPreferences
|
|
{
|
|
return app(JobBoardQueries::class)->preferencesOf((int) auth()->id());
|
|
}
|
|
|
|
public function boardView(): BoardView
|
|
{
|
|
return BoardView::tryFrom($this->view) ?? BoardView::Production;
|
|
}
|
|
|
|
/**
|
|
* @return list<BoardCard>
|
|
*/
|
|
#[Computed]
|
|
public function cards(): array
|
|
{
|
|
$userId = (int) auth()->id();
|
|
$board = $this->isSubcontractor() ? 'all' : $this->board;
|
|
$personId = null;
|
|
$unitId = null;
|
|
|
|
if ($board === 'mine') {
|
|
$personId = $userId;
|
|
} elseif (preg_match('/^person-(\d+)$/', $board, $matches) === 1) {
|
|
$personId = (int) $matches[1];
|
|
} elseif (preg_match('/^unit-(\d+)$/', $board, $matches) === 1) {
|
|
$unitId = (int) $matches[1];
|
|
}
|
|
|
|
return app(JobBoardQueries::class)->cards(new BoardFilter(
|
|
personUserId: $personId,
|
|
serviceUnitId: $unitId,
|
|
onlyMemberUserId: $this->isSubcontractor() ? $userId : null,
|
|
onlyUrgent: $this->onlyUrgent,
|
|
onlyLate: $this->onlyLate,
|
|
), app(Clock::class)->today()->format('Y-m-d'));
|
|
}
|
|
|
|
/**
|
|
* @return array<string, list<BoardCard>>
|
|
*/
|
|
#[Computed]
|
|
public function columns(): array
|
|
{
|
|
return app(BoardLayout::class)->arrange($this->cards, $this->boardView(), $this->preferences);
|
|
}
|
|
|
|
public function shownCardCount(): int
|
|
{
|
|
return array_sum(array_map('count', $this->columns));
|
|
}
|
|
|
|
public function quoteCount(): int
|
|
{
|
|
return count(array_filter($this->cards, fn (BoardCard $card): bool => ! $card->isTaskCard()
|
|
&& in_array($card->jobStatus, [JobStatus::Prospect, JobStatus::Tentative, JobStatus::QuoteRequest], true)));
|
|
}
|
|
|
|
/**
|
|
* @return array<string, string> board value => label
|
|
*/
|
|
#[Computed]
|
|
public function boardOptions(): array
|
|
{
|
|
$options = ['mine' => __('jobs.board.board_mine')];
|
|
|
|
foreach (app(UserAccountQueries::class)->activeUserOptions() as $user) {
|
|
if ($user->id !== (int) auth()->id() && $user->role !== Role::Subcontractor) {
|
|
$options['person-'.$user->id] = __('jobs.board.board_person', ['name' => $user->name]);
|
|
}
|
|
}
|
|
|
|
foreach (app(CatalogQueries::class)->activeServiceUnits() as $unit) {
|
|
$options['unit-'.$unit->id] = __('jobs.board.board_unit', ['name' => $unit->name]);
|
|
}
|
|
|
|
$options['all'] = __('jobs.board.board_all');
|
|
|
|
return $options;
|
|
}
|
|
|
|
/**
|
|
* Colours of a column: the header and its text, and the body and border
|
|
* tinted with the header colour in light and dark mode.
|
|
*
|
|
* @return array{header: string, text: string, light: bool, body: string, bodyDark: string, border: string, borderDark: string}
|
|
*/
|
|
public function columnStyle(BoardColumn $column): array
|
|
{
|
|
$color = $this->preferences->colorOf($column);
|
|
|
|
return [
|
|
'header' => $color->value,
|
|
'text' => $color->textColor(),
|
|
'light' => $color->isLight(),
|
|
'body' => $color->mixedInto(new HexColor('#f6f7f9'), 0.08)->value,
|
|
'bodyDark' => $color->mixedInto(new HexColor('#16160e'), 0.11)->value,
|
|
'border' => $color->mixedInto(new HexColor('#d1d5db'), 0.12)->value,
|
|
'borderDark' => $color->mixedInto(new HexColor('#2a2b23'), 0.15)->value,
|
|
];
|
|
}
|
|
|
|
public function openJob(int $jobId): void
|
|
{
|
|
$this->authorize('jobs.view-job', [$jobId]);
|
|
|
|
$this->dispatch('open-job-editor', jobId: $jobId);
|
|
}
|
|
|
|
/**
|
|
* A card was dropped (wire:sort): into another column, or to another
|
|
* place in its own column.
|
|
*/
|
|
public function moveDropped(string $key, int $position, string $columnValue, MoveBoardCard $move): void
|
|
{
|
|
$this->authorize('jobs.manage');
|
|
|
|
$column = BoardColumn::tryFrom($columnValue);
|
|
$card = $this->findCard($key);
|
|
|
|
if ($column === null || $card === null || ! in_array($column, $this->boardView()->columns(), true)) {
|
|
$this->statusMessage = __('jobs.board.not_moved');
|
|
$this->refreshBoard();
|
|
|
|
return;
|
|
}
|
|
|
|
$label = $card->number.' '.$card->title;
|
|
$columnName = __('jobs.board.column_names.'.$column->value);
|
|
|
|
if (! $card->isTaskCard()) {
|
|
$status = MoveBoardCard::statusAfterDrop($card->jobStatus, $column);
|
|
|
|
if ($status->isBillingStatus() && $status !== $card->jobStatus && ! Gate::allows('jobs.set-billing-status', [$card->billerUserId])) {
|
|
$this->statusMessage = __('jobs.board.billing_not_allowed', ['job' => $label, 'status' => __('jobs.statuses.'.$status->value)]);
|
|
$this->refreshBoard();
|
|
|
|
return;
|
|
}
|
|
|
|
if ($card->jobStatus->unlocksTo($status) && ! Gate::allows('jobs.unlock')) {
|
|
$this->statusMessage = __('jobs.board.unlock_not_allowed', ['job' => $label, 'status' => __('jobs.statuses.'.$status->value)]);
|
|
$this->refreshBoard();
|
|
|
|
return;
|
|
}
|
|
} elseif (! Gate::allows('jobs.update-task-status', [$card->jobId])) {
|
|
abort(403);
|
|
}
|
|
|
|
$keys = array_values(array_filter(
|
|
array_map(fn (BoardCard $other): string => $other->key(), $this->columns[$column->value] ?? []),
|
|
fn (string $other): bool => $other !== $key,
|
|
));
|
|
array_splice($keys, max(0, min($position, count($keys))), 0, [$key]);
|
|
|
|
$fromColumn = app(BoardLayout::class)->columnOf($card, $this->boardView(), $this->preferences);
|
|
$sortWasByDate = $this->preferences->sortOf($column) === ColumnSort::DueDate;
|
|
$threshold = $this->preferences->urgentThreshold;
|
|
|
|
try {
|
|
$move->execute($card->jobId, $card->taskId, $column, $keys, $threshold, (int) auth()->id());
|
|
} catch (CardCannotMoveThere) {
|
|
$this->statusMessage = __('jobs.board.cannot_move', ['column' => $columnName]);
|
|
$this->refreshBoard();
|
|
|
|
return;
|
|
} catch (CustomerJobNotFound|TaskNotFound) {
|
|
$this->statusMessage = __('jobs.board.not_moved');
|
|
$this->refreshBoard();
|
|
|
|
return;
|
|
}
|
|
|
|
if ($sortWasByDate) {
|
|
$this->savePreferences($this->preferences->withColumnSort($column, ColumnSort::Manual));
|
|
}
|
|
|
|
$this->refreshBoard();
|
|
$this->statusMessage = match (true) {
|
|
$sortWasByDate => __('jobs.board.switched_to_manual', ['column' => $columnName]),
|
|
$card->isTaskCard() => __('jobs.board.task_moved', ['task' => $card->title, 'column' => $columnName]),
|
|
$fromColumn === $column => __('jobs.board.reordered', ['column' => $columnName]),
|
|
$column === BoardColumn::InProductionUrgent && ! $threshold->includes($card->priority) => __('jobs.board.priority_raised', [
|
|
'job' => $label,
|
|
'priority' => __('jobs.priorities.'.$threshold->lowestPriority()->value),
|
|
]),
|
|
$column === BoardColumn::InProduction && $fromColumn === BoardColumn::InProductionUrgent => __('jobs.board.priority_lowered', ['job' => $label]),
|
|
default => __('jobs.board.moved', ['job' => $label, 'status' => __('jobs.statuses.'.MoveBoardCard::statusAfterDrop($card->jobStatus, $column)->value)]),
|
|
};
|
|
}
|
|
|
|
/**
|
|
* A task's checkbox on a card: done, or back to in progress.
|
|
*/
|
|
public function setTaskDone(int $jobId, int $taskId, bool $done, ChangeTaskStatus $changeStatus): void
|
|
{
|
|
$this->authorize('jobs.update-task-status', [$jobId]);
|
|
|
|
$task = $this->findTask($jobId, $taskId);
|
|
|
|
if ($task === null) {
|
|
$this->statusMessage = __('jobs.board.not_moved');
|
|
|
|
return;
|
|
}
|
|
|
|
try {
|
|
$changeStatus->execute($jobId, $taskId, $done ? TaskStatus::Done : TaskStatus::InProgress);
|
|
} catch (TaskNotFound) {
|
|
$this->statusMessage = __('jobs.board.not_moved');
|
|
|
|
return;
|
|
}
|
|
|
|
$this->refreshBoard();
|
|
$this->statusMessage = __($done ? 'jobs.board.task_done' : 'jobs.board.task_reopened', ['task' => $task->title]);
|
|
}
|
|
|
|
public function pinTask(int $jobId, int $taskId, bool $pinned, PinTaskToBoard $pin): void
|
|
{
|
|
$this->authorize('jobs.manage-tasks', [$jobId]);
|
|
|
|
$task = $this->findTask($jobId, $taskId);
|
|
|
|
try {
|
|
$pin->execute($jobId, $taskId, $pinned);
|
|
} catch (CustomerJobNotFound|TaskNotFound|TaskCannotBePinned) {
|
|
$this->statusMessage = __('jobs.board.not_moved');
|
|
|
|
return;
|
|
}
|
|
|
|
$this->refreshBoard();
|
|
$this->statusMessage = __($pinned ? 'jobs.board.task_pinned' : 'jobs.board.task_unpinned', ['task' => $task->title ?? '']);
|
|
}
|
|
|
|
/**
|
|
* Quick add on a continuing job's card: the title only, for the job's
|
|
* responsible person, with the first work type of the job's service units.
|
|
*/
|
|
public function addTask(int $jobId, AddTask $addTask, PinTaskToBoard $pin): void
|
|
{
|
|
$this->authorize('jobs.manage-tasks', [$jobId]);
|
|
|
|
$field = 'newTaskTitles.'.$jobId;
|
|
$title = trim((string) ($this->newTaskTitles[$jobId] ?? ''));
|
|
|
|
if ($title === '') {
|
|
$this->addError($field, __('jobs.board.task_title_required'));
|
|
|
|
return;
|
|
}
|
|
|
|
$details = app(CustomerJobQueries::class)->findDetails($jobId);
|
|
|
|
if ($details === null) {
|
|
$this->statusMessage = __('jobs.board.not_moved');
|
|
|
|
return;
|
|
}
|
|
|
|
$workTypeId = $this->firstWorkTypeId(array_map(fn ($unit): int => $unit->id, $details->serviceUnits));
|
|
|
|
if ($workTypeId === null) {
|
|
$this->addError($field, __('jobs.board.no_work_type'));
|
|
|
|
return;
|
|
}
|
|
|
|
try {
|
|
$taskId = $addTask->execute($jobId, new TaskData($title, $workTypeId, TaskStatus::Waiting->value, assigneeUserId: $details->responsible->id), (int) auth()->id());
|
|
|
|
if ($this->newTaskPins[$jobId] ?? false) {
|
|
$pin->execute($jobId, $taskId, true);
|
|
}
|
|
} catch (DomainException) {
|
|
$this->addError($field, __('jobs.board.not_moved'));
|
|
|
|
return;
|
|
}
|
|
|
|
unset($this->newTaskTitles[$jobId], $this->newTaskPins[$jobId]);
|
|
$this->refreshBoard();
|
|
$this->statusMessage = __('jobs.board.task_added', ['task' => $title, 'job' => $details->number]);
|
|
}
|
|
|
|
public function setCustomerColor(int $customerId, ?string $color, ChangeCustomerHeaderColor $changeColor): void
|
|
{
|
|
$this->authorize('customers.use');
|
|
|
|
$card = collect($this->cards)->first(fn (BoardCard $card): bool => $card->customerId === $customerId);
|
|
|
|
try {
|
|
$changeColor->execute($customerId, $color);
|
|
} catch (InvalidHexColor|CustomerNotFound) {
|
|
$this->statusMessage = __('jobs.board.invalid_color');
|
|
|
|
return;
|
|
}
|
|
|
|
$this->refreshBoard();
|
|
$this->statusMessage = __('jobs.board.customer_color_saved', ['customer' => $card->customerName ?? '']);
|
|
}
|
|
|
|
public function setColumnColor(string $columnValue, ?string $color): void
|
|
{
|
|
$column = BoardColumn::tryFrom($columnValue);
|
|
|
|
try {
|
|
$hex = $color === null ? null : new HexColor($color);
|
|
} catch (InvalidHexColor) {
|
|
$hex = false;
|
|
}
|
|
|
|
if ($column === null || $hex === false) {
|
|
$this->statusMessage = __('jobs.board.invalid_color');
|
|
|
|
return;
|
|
}
|
|
|
|
$this->savePreferences($this->preferences->withColumnColor($column, $hex));
|
|
$this->statusMessage = __($hex === null ? 'jobs.board.color_reset' : 'jobs.board.color_saved', ['column' => __('jobs.board.column_names.'.$column->value)]);
|
|
}
|
|
|
|
public function setColumnSort(string $columnValue, string $sortValue): void
|
|
{
|
|
$column = BoardColumn::tryFrom($columnValue);
|
|
$sort = ColumnSort::tryFrom($sortValue);
|
|
|
|
if ($column === null || $sort === null) {
|
|
return;
|
|
}
|
|
|
|
$this->savePreferences($this->preferences->withColumnSort($column, $sort));
|
|
$this->statusMessage = __('jobs.board.sort_saved', ['column' => __('jobs.board.column_names.'.$column->value), 'sort' => __('jobs.board.sorts.'.$sort->value)]);
|
|
}
|
|
|
|
public function setUrgentThreshold(string $value): void
|
|
{
|
|
$threshold = UrgentThreshold::tryFrom($value);
|
|
|
|
if ($threshold === null) {
|
|
return;
|
|
}
|
|
|
|
$this->savePreferences($this->preferences->withUrgentThreshold($threshold));
|
|
$this->statusMessage = __('jobs.board.threshold_saved', ['threshold' => __('jobs.board.thresholds.'.$threshold->value)]);
|
|
}
|
|
|
|
public function setDensity(string $value): void
|
|
{
|
|
$density = BoardDensity::tryFrom($value);
|
|
|
|
if ($density === null) {
|
|
return;
|
|
}
|
|
|
|
$this->savePreferences($this->preferences->withDensity($density));
|
|
$this->statusMessage = __('jobs.board.density_saved', ['density' => __('jobs.board.density_'.$density->value)]);
|
|
}
|
|
|
|
public function setView(string $value): void
|
|
{
|
|
$this->view = (BoardView::tryFrom($value) ?? BoardView::Production)->value;
|
|
$this->refreshBoard();
|
|
}
|
|
|
|
public function updated(string $property): void
|
|
{
|
|
if (in_array($property, ['board', 'onlyUrgent', 'onlyLate'], true)) {
|
|
$this->refreshBoard();
|
|
}
|
|
}
|
|
|
|
#[On('job-saved')]
|
|
public function refreshBoard(): void
|
|
{
|
|
unset($this->cards, $this->columns);
|
|
}
|
|
|
|
#[On('job-editor-saved')]
|
|
public function editorSaved(string $message): void
|
|
{
|
|
$this->refreshBoard();
|
|
$this->statusMessage = $message;
|
|
}
|
|
|
|
/**
|
|
* A job created in the quick intake dialog: tentative jobs and quote
|
|
* requests show up in the sales view.
|
|
*/
|
|
#[On('quick-job-created')]
|
|
public function quickJobCreated(string $status): void
|
|
{
|
|
if (in_array($status, [JobStatus::Tentative->value, JobStatus::QuoteRequest->value], true) && $this->boardView() === BoardView::Production) {
|
|
$this->view = BoardView::Sales->value;
|
|
}
|
|
|
|
$this->refreshBoard();
|
|
}
|
|
|
|
public function render(): mixed
|
|
{
|
|
return $this->view()->title(__('jobs.board.title'));
|
|
}
|
|
|
|
private function savePreferences(BoardPreferences $preferences): void
|
|
{
|
|
app(SaveBoardPreferences::class)->execute((int) auth()->id(), $preferences);
|
|
unset($this->preferences, $this->columns);
|
|
}
|
|
|
|
/**
|
|
* The first active work type of the job's own service units (their
|
|
* services included), else of the shared unit.
|
|
*
|
|
* @param list<int> $serviceUnitIds
|
|
*/
|
|
private function firstWorkTypeId(array $serviceUnitIds): ?int
|
|
{
|
|
$shared = null;
|
|
|
|
foreach (app(CatalogQueries::class)->activeWorkTypesFor($serviceUnitIds) as $node) {
|
|
$workTypes = [...$node->workTypes, ...array_merge([], ...array_map(fn ($service): array => $service->workTypes, $node->services))];
|
|
$first = $workTypes[0]->id ?? null;
|
|
|
|
if ($first === null) {
|
|
continue;
|
|
}
|
|
|
|
if (in_array($node->serviceUnit->id, $serviceUnitIds, true)) {
|
|
return $first;
|
|
}
|
|
|
|
$shared ??= $first;
|
|
}
|
|
|
|
return $shared;
|
|
}
|
|
|
|
private function findCard(string $key): ?BoardCard
|
|
{
|
|
foreach ($this->cards as $card) {
|
|
if ($card->key() === $key) {
|
|
return $card;
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
private function findTask(int $jobId, int $taskId): ?BoardTask
|
|
{
|
|
foreach ($this->cards as $card) {
|
|
if ($card->jobId !== $jobId || $card->isTaskCard()) {
|
|
continue;
|
|
}
|
|
|
|
foreach ($card->tasks as $task) {
|
|
if ($task->id === $taskId) {
|
|
return $task;
|
|
}
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
};
|
|
?>
|
|
|
|
@php
|
|
$canMove = Gate::allows('jobs.manage');
|
|
$canColor = Gate::allows('customers.use');
|
|
$compact = $this->preferences->density === BoardDensity::Compact;
|
|
$boardView = $this->boardView();
|
|
@endphp
|
|
|
|
<div class="flex min-h-full flex-col">
|
|
<h1 class="sr-only">{{ __('jobs.board.heading') }}</h1>
|
|
|
|
{{-- Toolbar: whose board, pipeline view, quick filters, density, new job --}}
|
|
<section aria-label="{{ __('jobs.board.toolbar') }}" class="border-b border-neutral-300 bg-white/95 px-3 py-2 shadow-xs sm:px-5 dark:border-[#36393f] dark:bg-[#222427]">
|
|
<div class="flex flex-wrap items-center justify-between gap-2">
|
|
<div class="flex flex-wrap items-center gap-2">
|
|
@unless ($this->isSubcontractor())
|
|
<div class="flex items-center gap-1.5">
|
|
<label for="board-select" class="text-xs font-semibold text-neutral-700 dark:text-neutral-200">{{ __('jobs.board.board_label') }}:</label>
|
|
<select
|
|
id="board-select"
|
|
wire:model.live="board"
|
|
class="rounded-lg border border-neutral-400 bg-neutral-100 py-1.5 pr-8 pl-2.5 text-xs font-bold text-neutral-900 focus-visible:outline-2 focus-visible:outline-primary-600 dark:border-[#6b7079] dark:bg-[#18191b] dark:text-white dark:focus-visible:outline-primary-300"
|
|
>
|
|
@foreach ($this->boardOptions as $value => $label)
|
|
<option value="{{ $value }}">{{ $label }}</option>
|
|
@endforeach
|
|
</select>
|
|
</div>
|
|
@endunless
|
|
|
|
<div class="inline-flex flex-wrap rounded-lg border border-neutral-400 bg-neutral-100 p-0.5 dark:border-[#6b7079] dark:bg-[#18191b]" role="group" aria-label="{{ __('jobs.board.view_label') }}">
|
|
@foreach (BoardView::cases() as $option)
|
|
<button
|
|
type="button"
|
|
wire:click="setView('{{ $option->value }}')"
|
|
aria-pressed="{{ $option === $boardView ? 'true' : 'false' }}"
|
|
@class([
|
|
'inline-flex min-h-6 items-center gap-1 rounded-md px-2.5 py-1 text-xs transition focus-visible:outline-2 focus-visible:outline-primary-600 dark:focus-visible:outline-primary-300',
|
|
'bg-white font-bold text-neutral-900 shadow-2xs dark:bg-[#2f3237] dark:text-white' => $option === $boardView,
|
|
'font-medium text-neutral-700 hover:text-neutral-900 dark:text-neutral-200 dark:hover:text-white' => $option !== $boardView,
|
|
])
|
|
>
|
|
<span>{{ __('jobs.board.views.'.$option->value) }}</span>
|
|
@if ($option === BoardView::Sales)
|
|
<span class="rounded-full bg-indigo-100 px-1.5 text-[10px] font-bold text-indigo-900 dark:bg-indigo-950 dark:text-indigo-100">
|
|
<span aria-hidden="true">{{ $this->quoteCount() }}</span>
|
|
<span class="sr-only">{{ trans_choice('jobs.board.quote_count', $this->quoteCount(), ['count' => $this->quoteCount()]) }}</span>
|
|
</span>
|
|
@endif
|
|
</button>
|
|
@endforeach
|
|
</div>
|
|
|
|
<button
|
|
type="button"
|
|
wire:click="$toggle('onlyUrgent')"
|
|
aria-pressed="{{ $onlyUrgent ? 'true' : 'false' }}"
|
|
@class([
|
|
'inline-flex min-h-6 items-center gap-1.5 rounded-lg border border-neutral-400 px-2.5 py-1.5 text-xs font-semibold transition focus-visible:outline-2 focus-visible:outline-primary-600 dark:border-[#6b7079] dark:focus-visible:outline-primary-300',
|
|
'bg-red-50 text-red-900 ring-2 ring-red-600 dark:bg-red-950/60 dark:text-red-100' => $onlyUrgent,
|
|
'bg-neutral-50 text-neutral-800 hover:bg-neutral-100 dark:bg-[#18191b] dark:text-neutral-100 dark:hover:bg-[#2c2f34]' => ! $onlyUrgent,
|
|
])
|
|
>
|
|
<span class="size-2 rounded-full bg-red-600" aria-hidden="true"></span>
|
|
<span>{{ __('jobs.board.only_urgent') }}</span>
|
|
</button>
|
|
|
|
<button
|
|
type="button"
|
|
wire:click="$toggle('onlyLate')"
|
|
aria-pressed="{{ $onlyLate ? 'true' : 'false' }}"
|
|
@class([
|
|
'inline-flex min-h-6 items-center gap-1.5 rounded-lg border border-neutral-400 px-2.5 py-1.5 text-xs font-semibold transition focus-visible:outline-2 focus-visible:outline-primary-600 dark:border-[#6b7079] dark:focus-visible:outline-primary-300',
|
|
'bg-amber-50 text-amber-900 ring-2 ring-amber-600 dark:bg-amber-950/60 dark:text-amber-100' => $onlyLate,
|
|
'bg-neutral-50 text-neutral-800 hover:bg-neutral-100 dark:bg-[#18191b] dark:text-neutral-100 dark:hover:bg-[#2c2f34]' => ! $onlyLate,
|
|
])
|
|
>
|
|
<x-icon name="clock" class="size-3.5 text-amber-700 dark:text-amber-300" aria-hidden="true" />
|
|
<span>{{ __('jobs.board.only_late') }}</span>
|
|
</button>
|
|
|
|
<span role="status" class="pl-0.5 text-[11px] font-medium text-neutral-700 dark:text-neutral-200">{{ trans_choice('jobs.board.showing', $this->shownCardCount(), ['count' => $this->shownCardCount()]) }}</span>
|
|
</div>
|
|
|
|
<div class="flex flex-wrap items-center gap-2">
|
|
<x-link :href="route('jobs.index')" navigate class="text-xs">{{ __('jobs.board.show_list') }}</x-link>
|
|
|
|
<div class="inline-flex rounded-lg border border-neutral-400 bg-neutral-100 p-0.5 dark:border-[#6b7079] dark:bg-[#18191b]" role="group" aria-label="{{ __('jobs.board.density') }}">
|
|
@foreach (BoardDensity::cases() as $option)
|
|
<button
|
|
type="button"
|
|
wire:click="setDensity('{{ $option->value }}')"
|
|
aria-pressed="{{ $option === $this->preferences->density ? 'true' : 'false' }}"
|
|
@class([
|
|
'min-h-6 rounded-md px-2.5 py-1 text-xs transition focus-visible:outline-2 focus-visible:outline-primary-600 dark:focus-visible:outline-primary-300',
|
|
'bg-white font-bold text-neutral-900 shadow-2xs dark:bg-[#2f3237] dark:text-white' => $option === $this->preferences->density,
|
|
'font-medium text-neutral-700 hover:text-neutral-900 dark:text-neutral-200 dark:hover:text-white' => $option !== $this->preferences->density,
|
|
])
|
|
>{{ __('jobs.board.density_'.$option->value) }}</button>
|
|
@endforeach
|
|
</div>
|
|
|
|
@can('jobs.manage')
|
|
<button
|
|
type="button"
|
|
x-on:click="document.getElementById('quick-intake-dialog')?.showModal()"
|
|
class="inline-flex min-h-6 items-center gap-1.5 rounded-lg bg-primary-600 px-3 py-1.5 text-xs font-bold text-white shadow-sm transition hover:bg-primary-700 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-600 dark:focus-visible:outline-primary-300"
|
|
>
|
|
<x-icon name="plus" class="size-3.5" aria-hidden="true" />
|
|
<span>{{ __('jobs.board.new_job') }}</span>
|
|
</button>
|
|
@endcan
|
|
</div>
|
|
</div>
|
|
|
|
<p role="status" aria-live="polite" class="mt-1 min-h-4 text-xs font-medium text-neutral-800 dark:text-neutral-100">{{ $statusMessage }}</p>
|
|
</section>
|
|
|
|
{{-- Columns: side by side from lg up (horizontal scroll), stacked on phones --}}
|
|
<div
|
|
role="region"
|
|
aria-label="{{ __('jobs.board.columns') }}"
|
|
tabindex="0"
|
|
class="kanban-scroll flex-1 p-3 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-primary-600 sm:p-4 lg:overflow-x-auto dark:focus-visible:outline-primary-300"
|
|
>
|
|
<div class="flex flex-col gap-2.5 pb-6 lg:min-h-[calc(100vh-12rem)] lg:flex-row lg:items-start">
|
|
@foreach ($this->columns as $columnValue => $cards)
|
|
@php
|
|
$column = BoardColumn::from($columnValue);
|
|
$style = $this->columnStyle($column);
|
|
$sort = $this->preferences->sortOf($column);
|
|
$width = $compact ? ($column->isOngoing() ? 'lg:w-[250px]' : 'lg:w-[234px]') : ($column->isOngoing() ? 'lg:w-[268px]' : 'lg:w-[252px]');
|
|
$columnName = __('jobs.board.column_names.'.$columnValue);
|
|
@endphp
|
|
<section
|
|
id="column-{{ $columnValue }}"
|
|
wire:key="column-{{ $columnValue }}"
|
|
aria-labelledby="column-{{ $columnValue }}-heading"
|
|
style="--col-body: {{ $style['body'] }}; --col-body-dark: {{ $style['bodyDark'] }}; --col-border: {{ $style['border'] }}; --col-border-dark: {{ $style['borderDark'] }}"
|
|
class="relative flex w-full shrink-0 flex-col rounded-xl border border-(--col-border) bg-(--col-body) shadow-md transition-colors dark:border-(--col-border-dark) dark:bg-(--col-body-dark) {{ $width }}"
|
|
>
|
|
<div
|
|
style="background-color: {{ $style['header'] }}; color: {{ $style['text'] }}"
|
|
@class(['relative flex h-10 items-center justify-between gap-1.5 rounded-t-[11px] border-b px-2.5 select-none', 'border-black/15' => $style['light'], 'border-white/20' => ! $style['light']])
|
|
>
|
|
<div class="flex min-w-0 items-center gap-1.5">
|
|
<x-icon :name="$column->icon()" class="size-4 shrink-0" aria-hidden="true" />
|
|
<h2 id="column-{{ $columnValue }}-heading" class="truncate text-[13px] font-bold tracking-tight">{{ $columnName }}</h2>
|
|
</div>
|
|
|
|
<div class="flex shrink-0 items-center gap-0.5">
|
|
@if ($column->isUrgentLane())
|
|
<x-jobs.board.menu
|
|
id="threshold-menu"
|
|
:label="__('jobs.board.threshold_button')"
|
|
:heading="__('jobs.board.threshold_heading')"
|
|
:options="collect(UrgentThreshold::cases())->mapWithKeys(fn ($threshold) => [$threshold->value => __('jobs.board.thresholds.'.$threshold->value)])->all()"
|
|
:current="$this->preferences->urgentThreshold->value"
|
|
method="setUrgentThreshold"
|
|
>
|
|
<x-icon name="chevron-down" class="size-3.5" aria-hidden="true" />
|
|
</x-jobs.board.menu>
|
|
@endif
|
|
|
|
<x-jobs.board.menu
|
|
:id="'sort-menu-'.$columnValue"
|
|
:label="__('jobs.board.sort_button', ['column' => $columnName, 'sort' => __('jobs.board.sorts.'.$sort->value)])"
|
|
:heading="__('jobs.board.sort_heading')"
|
|
:options="collect(ColumnSort::cases())->mapWithKeys(fn ($option) => [$option->value => __('jobs.board.sorts.'.$option->value)])->all()"
|
|
:current="$sort->value"
|
|
method="setColumnSort"
|
|
:args="[$columnValue]"
|
|
:active="$sort === ColumnSort::DueDate"
|
|
>
|
|
<x-icon :name="$sort === ColumnSort::DueDate ? 'calendar' : 'arrows-up-down'" class="size-3.5" aria-hidden="true" />
|
|
</x-jobs.board.menu>
|
|
|
|
<button
|
|
type="button"
|
|
x-on:click="$dispatch('color-picker:open', {{ Js::from([
|
|
'id' => 'colour-picker',
|
|
'title' => __('jobs.board.color_title', ['column' => $columnName]),
|
|
'color' => $style['header'],
|
|
'method' => 'setColumnColor',
|
|
'args' => [$columnValue],
|
|
'resettable' => $this->preferences->hasOwnColor($column),
|
|
]) }})"
|
|
aria-label="{{ __('jobs.board.color_button', ['column' => $columnName]) }}"
|
|
title="{{ __('jobs.board.color_button', ['column' => $columnName]) }}"
|
|
class="inline-flex size-6 items-center justify-center rounded transition hover:bg-black/15 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-current dark:hover:bg-white/15"
|
|
>
|
|
<x-icon name="swatch" class="size-3.5" aria-hidden="true" />
|
|
</button>
|
|
|
|
<span @class(['ml-0.5 inline-flex h-5 min-w-5 items-center justify-center rounded-full border px-1.5 text-[11px] font-extrabold', 'border-black/20 bg-black/10' => $style['light'], 'border-white/30 bg-white/20' => ! $style['light']])>
|
|
<span aria-hidden="true">{{ count($cards) }}</span>
|
|
<span class="sr-only">{{ trans_choice('jobs.board.card_count', count($cards), ['count' => count($cards)]) }}</span>
|
|
</span>
|
|
</div>
|
|
</div>
|
|
|
|
<ul
|
|
@if ($canMove)
|
|
wire:sort="moveDropped"
|
|
wire:sort:group="board"
|
|
wire:sort:group-id="{{ $columnValue }}"
|
|
@endif
|
|
@class(['flex min-h-[120px] flex-1 flex-col', 'gap-1.5 p-1.5' => $compact, 'gap-2 p-2' => ! $compact])
|
|
>
|
|
@foreach ($cards as $card)
|
|
<li wire:key="card-{{ $card->key() }}" @if ($canMove) wire:sort:item="{{ $card->key() }}" @endif>
|
|
@if ($card->isTaskCard())
|
|
<x-jobs.board.task-card :card="$card" :compact="$compact" :can-move="$canMove" :can-manage="Gate::allows('jobs.manage-tasks', [$card->jobId])" />
|
|
@elseif ($card->isOngoing())
|
|
<x-jobs.board.ongoing-card
|
|
:card="$card"
|
|
:compact="$compact"
|
|
:can-move="$canMove"
|
|
:can-color="$canColor"
|
|
:can-check="Gate::allows('jobs.update-task-status', [$card->jobId])"
|
|
:can-manage="Gate::allows('jobs.manage-tasks', [$card->jobId])"
|
|
/>
|
|
@else
|
|
<x-jobs.board.job-card
|
|
:card="$card"
|
|
:compact="$compact"
|
|
:can-move="$canMove"
|
|
:can-color="$canColor"
|
|
:can-check="Gate::allows('jobs.update-task-status', [$card->jobId])"
|
|
/>
|
|
@endif
|
|
</li>
|
|
@endforeach
|
|
|
|
@if ($cards === [])
|
|
<li wire:key="empty-{{ $columnValue }}" wire:sort:ignore class="rounded-lg border border-dashed border-neutral-500/50 p-3 text-center text-[11px] text-neutral-700 dark:border-[#6b7079] dark:text-neutral-200">{{ __('jobs.board.empty') }}</li>
|
|
@endif
|
|
</ul>
|
|
</section>
|
|
@endforeach
|
|
</div>
|
|
</div>
|
|
|
|
<livewire:jobs::job-editor />
|
|
|
|
@can('jobs.manage')
|
|
<x-work-dialog id="quick-intake-dialog" :title="__('jobs.quick.dialog_title')" width="max-w-xl">
|
|
<livewire:jobs::quick :in-dialog="true" />
|
|
</x-work-dialog>
|
|
@endcan
|
|
|
|
<x-color-picker />
|
|
</div>
|