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:
@@ -47,7 +47,7 @@ Accessibility is a contractual acceptance criterion. It covers the whole UI: nav
|
|||||||
- **Personal identity codes** (*henkilötunnus*, consumer customers) are sensitive personal data: stored encrypted (`encrypted` cast, `$hidden`) with an HMAC blind index for duplicates, never in `CustomerSummary`, search, logs, exception messages or Livewire public properties, and shown in full only behind `customers.view-personal-identity-code` (admin, management) via `CustomerQueries::personalIdentityCodeOf()`; everyone else sees `masked()`.
|
- **Personal identity codes** (*henkilötunnus*, consumer customers) are sensitive personal data: stored encrypted (`encrypted` cast, `$hidden`) with an HMAC blind index for duplicates, never in `CustomerSummary`, search, logs, exception messages or Livewire public properties, and shown in full only behind `customers.view-personal-identity-code` (admin, management) via `CustomerQueries::personalIdentityCodeOf()`; everyone else sees `masked()`.
|
||||||
- Never convey meaning by colour alone. Statuses, priorities (e.g. *kiire* = red), errors and warnings always also have visible text or an icon with text.
|
- Never convey meaning by colour alone. Statuses, priorities (e.g. *kiire* = red), errors and warnings always also have visible text or an icon with text.
|
||||||
- Announce dynamic changes: put status text in `role="status"` / `aria-live="polite"` (errors: `role="alert"`), or a TallStackUI toast (`<x-toast />` must then be added to the layout). Keep button names stable instead of putting changing state in them.
|
- Announce dynamic changes: put status text in `role="status"` / `aria-live="polite"` (errors: `role="alert"`), or a TallStackUI toast (`<x-toast />` must then be added to the layout). Keep button names stable instead of putting changing state in them.
|
||||||
- Make everything work with the keyboard alone, with a visible focus indicator and no focus traps. Use `<x-confirm-dialog>` for dialogs (not `<x-modal>`, see above) and check that focus moves in and returns.
|
- Make everything work with the keyboard alone, with a visible focus indicator and no focus traps. Use `<x-confirm-dialog>` for dialogs (not `<x-modal>`, see above) and check that focus moves in and returns. Drag and drop uses Livewire's `wire:sort` (see `jobs::board`), and every drag has a keyboard alternative (e.g. a status select on each card).
|
||||||
- The layout (`resources/views/layouts/app.blade.php`) provides a skip link and a `<main id="main-content">` landmark. Keep them, and add `<nav aria-label="…">` for navigation.
|
- The layout (`resources/views/layouts/app.blade.php`) provides a skip link and a `<main id="main-content">` landmark. Keep them, and add `<nav aria-label="…">` for navigation.
|
||||||
- One `h1` per page, logical heading order, and a descriptive page `#[Title]` on every page component.
|
- One `h1` per page, logical heading order, and a descriptive page `#[Title]` on every page component.
|
||||||
- Data tables use `<x-table>` with `headers` (custom cells with `@interact('column_<index>', $row)`). Icon-only buttons need an `aria-label` (a `tooltip` alone is not a name). Decorative images get `alt=""`.
|
- Data tables use `<x-table>` with `headers` (custom cells with `@interact('column_<index>', $row)`). Icon-only buttons need an `aria-label` (a `tooltip` alone is not a name). Decorative images get `alt=""`.
|
||||||
|
|||||||
@@ -23,6 +23,14 @@ interface CustomerJobQueries
|
|||||||
*/
|
*/
|
||||||
public function paginate(JobListFilter $filter, int $perPage = 25): LengthAwarePaginator;
|
public function paginate(JobListFilter $filter, int $perPage = 25): LengthAwarePaginator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Kanban board: every Kanban status (archived left out) with its
|
||||||
|
* jobs by due date, empty statuses included.
|
||||||
|
*
|
||||||
|
* @return array<string, list<CustomerJobSummary>>
|
||||||
|
*/
|
||||||
|
public function board(JobListFilter $filter, int $limitPerStatus = 100): array;
|
||||||
|
|
||||||
public function findDetails(int $id): ?CustomerJobDetails;
|
public function findDetails(int $id): ?CustomerJobDetails;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -22,5 +22,6 @@ final readonly class CustomerJobSummary
|
|||||||
public Priority $priority,
|
public Priority $priority,
|
||||||
public ?string $dueOn,
|
public ?string $dueOn,
|
||||||
public string $responsibleName,
|
public string $responsibleName,
|
||||||
|
public ?int $billerUserId = null,
|
||||||
) {}
|
) {}
|
||||||
}
|
}
|
||||||
|
|||||||
+49
-3
@@ -15,6 +15,7 @@ use App\Modules\Jobs\Infrastructure\Persistence\Eloquent\CustomerJobModel;
|
|||||||
use App\Modules\Users\Application\Contracts\UserAccountQueries;
|
use App\Modules\Users\Application\Contracts\UserAccountQueries;
|
||||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -37,11 +38,55 @@ class EloquentCustomerJobQueries implements CustomerJobQueries
|
|||||||
->orderByDesc('id')
|
->orderByDesc('id')
|
||||||
->paginate($perPage);
|
->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());
|
$customerNames = $this->customers->namesByIds($models->pluck('customer_id')->unique()->values()->all());
|
||||||
$userNames = $this->users->namesByIds($models->pluck('responsible_user_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->id,
|
||||||
$model->number,
|
$model->number,
|
||||||
$model->name,
|
$model->name,
|
||||||
@@ -51,7 +96,8 @@ class EloquentCustomerJobQueries implements CustomerJobQueries
|
|||||||
$model->priority,
|
$model->priority,
|
||||||
$model->due_on?->format('Y-m-d'),
|
$model->due_on?->format('Y-m-d'),
|
||||||
$userNames[$model->responsible_user_id] ?? '',
|
$userNames[$model->responsible_user_id] ?? '',
|
||||||
));
|
$model->biller_user_id,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function findDetails(int $id): ?CustomerJobDetails
|
public function findDetails(int $id): ?CustomerJobDetails
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ namespace App\Modules\Jobs\Infrastructure\Providers;
|
|||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Modules\Customers\Application\Contracts\CustomerRowUsage;
|
use App\Modules\Customers\Application\Contracts\CustomerRowUsage;
|
||||||
use App\Modules\Jobs\Application\Contracts\CustomerJobQueries;
|
use App\Modules\Jobs\Application\Contracts\CustomerJobQueries;
|
||||||
use App\Modules\Jobs\Application\DTOs\CustomerJobDetails;
|
|
||||||
use App\Modules\Jobs\Domain\Contracts\CustomerJobRepository;
|
use App\Modules\Jobs\Domain\Contracts\CustomerJobRepository;
|
||||||
use App\Modules\Jobs\Domain\Contracts\JobNumberSequence;
|
use App\Modules\Jobs\Domain\Contracts\JobNumberSequence;
|
||||||
use App\Modules\Jobs\Infrastructure\CustomerRowUsageFromJobs;
|
use App\Modules\Jobs\Infrastructure\CustomerRowUsageFromJobs;
|
||||||
@@ -57,7 +56,8 @@ class JobsServiceProvider extends ServiceProvider
|
|||||||
Gate::define('jobs.archive', $isManager);
|
Gate::define('jobs.archive', $isManager);
|
||||||
|
|
||||||
// "Lasku luotu" and "Laskutettu" are set when invoicing: management or the job's biller.
|
// "Lasku luotu" and "Laskutettu" are set when invoicing: management or the job's biller.
|
||||||
Gate::define('jobs.set-billing-status', fn (User $user, ?CustomerJobDetails $job = null): bool => $isManager($user)
|
// The argument is the job's biller (user id), when known.
|
||||||
|| ($job !== null && $job->biller?->id === $user->id));
|
Gate::define('jobs.set-billing-status', fn (User $user, ?int $billerUserId = null): bool => $isManager($user)
|
||||||
|
|| ($billerUserId !== null && $billerUserId === $user->id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,263 @@
|
|||||||
|
<?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\Application\UseCases\ChangeJobStatus;
|
||||||
|
use App\Modules\Jobs\Domain\Enums\JobStatus;
|
||||||
|
use App\Modules\Jobs\Domain\Enums\Priority;
|
||||||
|
use App\Modules\Jobs\Domain\Exceptions\CustomerJobNotFound;
|
||||||
|
use App\Modules\Users\Domain\Enums\Role;
|
||||||
|
use Illuminate\Support\Facades\Gate;
|
||||||
|
use Livewire\Attributes\Computed;
|
||||||
|
use Livewire\Attributes\Url;
|
||||||
|
use Livewire\Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The customer job Kanban board: one column per status, one card per job.
|
||||||
|
* A card moves by dragging (wire:sort) or with its status select, which
|
||||||
|
* works with the keyboard and a screen reader.
|
||||||
|
*/
|
||||||
|
new class extends Component
|
||||||
|
{
|
||||||
|
#[Url(except: true)]
|
||||||
|
public bool $mine = true;
|
||||||
|
|
||||||
|
#[Url(except: '')]
|
||||||
|
public string $priority = '';
|
||||||
|
|
||||||
|
#[Url(as: 'unit', except: '')]
|
||||||
|
public string $serviceUnit = '';
|
||||||
|
|
||||||
|
public string $statusMessage = '';
|
||||||
|
|
||||||
|
public function mount(): void
|
||||||
|
{
|
||||||
|
$this->authorize('jobs.view');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isSubcontractor(): bool
|
||||||
|
{
|
||||||
|
return auth()->user()?->role === Role::Subcontractor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, list<CustomerJobSummary>>
|
||||||
|
*/
|
||||||
|
#[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<JobStatus>
|
||||||
|
*/
|
||||||
|
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]),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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'))
|
||||||
|
|
||||||
|
<div class="mx-auto max-w-[120rem] space-y-6 p-4 sm:p-6">
|
||||||
|
<div class="flex flex-wrap items-center justify-between gap-4">
|
||||||
|
<h1 class="text-2xl font-semibold">{{ __('jobs.board.title') }}</h1>
|
||||||
|
|
||||||
|
<x-link :href="route('jobs.index')" navigate>{{ __('jobs.board.show_list') }}</x-link>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
|
||||||
|
{{-- TallStackUI's native select does not tie its label to the control, so aria-label names it. --}}
|
||||||
|
<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>
|
||||||
|
|
||||||
|
@if ($this->isSubcontractor())
|
||||||
|
<p class="text-sm text-zinc-600 dark:text-zinc-300">{{ __('jobs.list.subcontractor_note') }}</p>
|
||||||
|
@else
|
||||||
|
<div class="flex items-end pb-2">
|
||||||
|
<x-checkbox id="board-only-mine" wire:model.live="mine" :label="__('jobs.list.only_mine')" />
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p role="status" aria-live="polite" class="min-h-5 text-sm font-medium">{{ $statusMessage }}</p>
|
||||||
|
|
||||||
|
<nav aria-label="{{ __('jobs.board.columns') }}">
|
||||||
|
<ul class="flex flex-wrap gap-x-4 gap-y-1 text-sm">
|
||||||
|
@foreach ($this->board as $status => $jobs)
|
||||||
|
<li>
|
||||||
|
<x-link :href="'#column-'.$status">
|
||||||
|
{{ __('jobs.statuses.'.$status) }} ({{ count($jobs) }})
|
||||||
|
</x-link>
|
||||||
|
</li>
|
||||||
|
@endforeach
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<div class="grid gap-4 [grid-template-columns:repeat(auto-fill,minmax(15rem,1fr))]">
|
||||||
|
@foreach ($this->board as $status => $jobs)
|
||||||
|
<section
|
||||||
|
id="column-{{ $status }}"
|
||||||
|
wire:key="column-{{ $status }}"
|
||||||
|
aria-labelledby="column-{{ $status }}-heading"
|
||||||
|
class="flex min-w-0 flex-col rounded-lg bg-zinc-100 p-3 dark:bg-zinc-800"
|
||||||
|
>
|
||||||
|
<h2 id="column-{{ $status }}-heading" class="mb-3 flex items-baseline justify-between gap-2 text-base font-semibold">
|
||||||
|
{{ __('jobs.statuses.'.$status) }}
|
||||||
|
<span class="text-sm font-normal">{{ trans_choice('jobs.board.count', count($jobs), ['count' => count($jobs)]) }}</span>
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
<ul
|
||||||
|
@if ($canMove)
|
||||||
|
wire:sort="moveDropped"
|
||||||
|
wire:sort:group="jobs"
|
||||||
|
wire:sort:group-id="{{ $status }}"
|
||||||
|
@endif
|
||||||
|
class="flex min-h-16 flex-1 flex-col gap-3"
|
||||||
|
>
|
||||||
|
@forelse ($jobs as $job)
|
||||||
|
<li wire:key="job-card-{{ $job->id }}" @if ($canMove) wire:sort:item="{{ $job->id }}" @endif>
|
||||||
|
<article
|
||||||
|
aria-labelledby="job-card-{{ $job->id }}-title"
|
||||||
|
class="space-y-2 rounded-md border border-zinc-200 bg-white p-3 text-sm shadow-sm dark:border-zinc-600 dark:bg-zinc-900"
|
||||||
|
>
|
||||||
|
<div class="flex items-start justify-between gap-2">
|
||||||
|
<h3 id="job-card-{{ $job->id }}-title" class="min-w-0 font-medium break-words" wire:sort:ignore>
|
||||||
|
<x-link :href="route('jobs.show', $job->id)" navigate>
|
||||||
|
<span class="whitespace-nowrap">{{ $job->number }}</span> {{ $job->name }}
|
||||||
|
</x-link>
|
||||||
|
</h3>
|
||||||
|
@if ($canMove)
|
||||||
|
<x-icon name="bars-3" class="size-5 shrink-0 cursor-grab text-zinc-500 dark:text-zinc-400" aria-hidden="true" />
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p class="break-words text-zinc-700 dark:text-zinc-300">{{ $job->customerName }}</p>
|
||||||
|
|
||||||
|
<div class="flex flex-wrap gap-x-4 gap-y-1">
|
||||||
|
<x-jobs.priority :priority="$job->priority" />
|
||||||
|
<x-jobs.due-date :date="$job->dueOn" :status="$job->status" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@if ($canMove)
|
||||||
|
<div wire:sort:ignore>
|
||||||
|
<x-select.native
|
||||||
|
id="job-status-{{ $job->id }}"
|
||||||
|
wire:change="moveJob({{ $job->id }}, $event.target.value)"
|
||||||
|
:label="__('jobs.fields.status')"
|
||||||
|
:aria-label="__('jobs.board.status_of', ['job' => $job->number.' '.$job->name])"
|
||||||
|
>
|
||||||
|
@foreach ($this->statusesFor($job) as $option)
|
||||||
|
<option value="{{ $option->value }}" @selected($option === $job->status)>{{ __('jobs.statuses.'.$option->value) }}</option>
|
||||||
|
@endforeach
|
||||||
|
</x-select.native>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
</article>
|
||||||
|
</li>
|
||||||
|
@empty
|
||||||
|
<li wire:key="empty-{{ $status }}" class="text-sm text-zinc-600 dark:text-zinc-300">{{ __('jobs.board.empty') }}</li>
|
||||||
|
@endforelse
|
||||||
|
</ul>
|
||||||
|
</section>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -249,7 +249,7 @@ new class extends Component
|
|||||||
if ($status->isBillingStatus()) {
|
if ($status->isBillingStatus()) {
|
||||||
$details = $this->jobId === null ? null : app(CustomerJobQueries::class)->findDetails($this->jobId);
|
$details = $this->jobId === null ? null : app(CustomerJobQueries::class)->findDetails($this->jobId);
|
||||||
|
|
||||||
return Gate::allows('jobs.set-billing-status', [$details]);
|
return Gate::allows('jobs.set-billing-status', [$details?->biller?->id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -99,7 +99,10 @@ new class extends Component
|
|||||||
|
|
||||||
<div class="mx-auto max-w-7xl space-y-6 p-4 sm:p-6">
|
<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-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>
|
<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')
|
@can('jobs.manage')
|
||||||
<div class="flex flex-wrap gap-2">
|
<div class="flex flex-wrap gap-2">
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ Route::middleware(['web', 'auth', 'can:jobs.view'])
|
|||||||
Route::livewire('/', 'jobs::index')->name('index');
|
Route::livewire('/', 'jobs::index')->name('index');
|
||||||
Route::livewire('/create', 'jobs::form')->middleware('can:jobs.manage')->name('create');
|
Route::livewire('/create', 'jobs::form')->middleware('can:jobs.manage')->name('create');
|
||||||
Route::livewire('/quick', 'jobs::quick')->middleware('can:jobs.manage')->name('quick');
|
Route::livewire('/quick', 'jobs::quick')->middleware('can:jobs.manage')->name('quick');
|
||||||
|
Route::livewire('/board', 'jobs::board')->name('board');
|
||||||
Route::livewire('/{job}', 'jobs::show')->whereNumber('job')->name('show');
|
Route::livewire('/{job}', 'jobs::show')->whereNumber('job')->name('show');
|
||||||
Route::livewire('/{job}/edit', 'jobs::form')->whereNumber('job')->middleware('can:jobs.manage')->name('edit');
|
Route::livewire('/{job}/edit', 'jobs::form')->whereNumber('job')->middleware('can:jobs.manage')->name('edit');
|
||||||
});
|
});
|
||||||
|
|||||||
+4
-2
@@ -224,7 +224,9 @@ Kevyt käteis- ja pankkikorttimyynti kuluttajille ilman täyttä asiakastyötä
|
|||||||
- Sarakkeet ovat asiakastyön tilat (5.3), arkistoitu pois lukien. Kortti on asiakastyö.
|
- Sarakkeet ovat asiakastyön tilat (5.3), arkistoitu pois lukien. Kortti on asiakastyö.
|
||||||
- Oletuksena näytetään käyttäjän omat työt (5.6); suodattimella kaikki (alihankkijalle vain liitetyt).
|
- Oletuksena näytetään käyttäjän omat työt (5.6); suodattimella kaikki (alihankkijalle vain liitetyt).
|
||||||
- Kortilla: numero, nimi, asiakas, prioriteetti (teksti + väri), määräaika ja myöhässä-ilmaisin (teksti + kuvake).
|
- Kortilla: numero, nimi, asiakas, prioriteetti (teksti + väri), määräaika ja myöhässä-ilmaisin (teksti + kuvake).
|
||||||
- Kortin siirto toiseen sarakkeeseen vaihtaa tilan. Siirto toimii myös näppäimistöllä (tilan valinta kortin valikosta).
|
- Kortin siirto toiseen sarakkeeseen vaihtaa tilan ja kirjataan muutoshistoriaan. Kortin voi vetää hiirellä tai kosketuksella, tai valita tilan kortin Tila-valinnasta (näppäimistö, ruudunlukija).
|
||||||
|
- Laskutustiloihin (Lasku luotu, Laskutettu) voi siirtää vain johto tai työn laskuttaja; arkistointi tehdään työn muokkaussivulla.
|
||||||
|
- Sivun alussa on linkit jokaiseen sarakkeeseen korttimäärineen. Sarakkeet rivittyvät näytön leveyden mukaan, joten sivulla ei ole vaakavieritystä.
|
||||||
|
|
||||||
### 8.2 Tehtävät
|
### 8.2 Tehtävät
|
||||||
|
|
||||||
@@ -415,7 +417,7 @@ Jokainen sivu täyttää saavutettavuusvaatimukset ja saa selaintestin (vaalea/t
|
|||||||
### 16.5 Pikavastaanotto
|
### 16.5 Pikavastaanotto
|
||||||
- *(valmis)* Puhelimella (320 px) yksi lomake: asiakas, nimi, lyhyt kuvaus, palveluyksikkö, vastuuhenkilö ja alkutila. Tallennuksen jälkeen ilmoitus työn numerosta ja linkit työhön; fokus siirtyy ilmoitukseen.
|
- *(valmis)* Puhelimella (320 px) yksi lomake: asiakas, nimi, lyhyt kuvaus, palveluyksikkö, vastuuhenkilö ja alkutila. Tallennuksen jälkeen ilmoitus työn numerosta ja linkit työhön; fokus siirtyy ilmoitukseen.
|
||||||
|
|
||||||
### 16.6 Kanban
|
### 16.6 Kanban *(valmis)*
|
||||||
- Sarakkeet tiloittain, arkistoitu pois. Kortin tila vaihdetaan vetämällä tai kortin valikosta (näppäimistö). Muutos ilmoitetaan `aria-live`-alueella.
|
- Sarakkeet tiloittain, arkistoitu pois. Kortin tila vaihdetaan vetämällä tai kortin valikosta (näppäimistö). Muutos ilmoitetaan `aria-live`-alueella.
|
||||||
- Puhelimella sarakkeet allekkain tai yksi sarake kerrallaan, ei vaakavieritystä sivulla.
|
- Puhelimella sarakkeet allekkain tai yksi sarake kerrallaan, ei vaakavieritystä sivulla.
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,19 @@ return [
|
|||||||
'late' => 'Myöhässä',
|
'late' => 'Myöhässä',
|
||||||
'opens_in_new_tab' => 'avautuu uuteen välilehteen',
|
'opens_in_new_tab' => 'avautuu uuteen välilehteen',
|
||||||
|
|
||||||
|
'board' => [
|
||||||
|
'title' => 'Kanban',
|
||||||
|
'link' => 'Näytä Kanban-näkymänä',
|
||||||
|
'show_list' => 'Näytä listana',
|
||||||
|
'columns' => 'Kanban-sarakkeet',
|
||||||
|
'count' => '{0} ei töitä|{1} :count työ|[2,*] :count työtä',
|
||||||
|
'empty' => 'Ei töitä tässä tilassa.',
|
||||||
|
'status_of' => 'Tila: :job',
|
||||||
|
'moved' => 'Työ :job siirretty tilaan :status.',
|
||||||
|
'not_moved' => 'Työtä ei siirretty. Päivitä sivu ja yritä uudelleen.',
|
||||||
|
'billing_not_allowed' => 'Työtä :job ei siirretty: tilan :status voi asettaa vain johto tai työn laskuttaja.',
|
||||||
|
],
|
||||||
|
|
||||||
'quick' => [
|
'quick' => [
|
||||||
'title' => 'Pikavastaanotto',
|
'title' => 'Pikavastaanotto',
|
||||||
'intro' => 'Kirjaa uusi työ nopeasti. Muut tiedot voi täydentää myöhemmin työn sivulla.',
|
'intro' => 'Kirjaa uusi työ nopeasti. Muut tiedot voi täydentää myöhemmin työn sivulla.',
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ return [
|
|||||||
'home' => 'Etusivu',
|
'home' => 'Etusivu',
|
||||||
'jobs' => 'Asiakastyöt',
|
'jobs' => 'Asiakastyöt',
|
||||||
'quick_intake' => 'Pikavastaanotto',
|
'quick_intake' => 'Pikavastaanotto',
|
||||||
|
'board' => 'Kanban',
|
||||||
'customers' => 'Asiakkaat',
|
'customers' => 'Asiakkaat',
|
||||||
'users' => 'Käyttäjät',
|
'users' => 'Käyttäjät',
|
||||||
'catalog' => 'Pohjatiedot',
|
'catalog' => 'Pohjatiedot',
|
||||||
|
|||||||
@@ -57,6 +57,8 @@
|
|||||||
<nav aria-label="{{ __('layout.main_menu') }}" class="flex flex-1 flex-wrap items-center gap-1">
|
<nav aria-label="{{ __('layout.main_menu') }}" class="flex flex-1 flex-wrap items-center gap-1">
|
||||||
@include('partials.nav-item', ['route' => 'jobs.index', 'pattern' => ['jobs.index', 'jobs.show', 'jobs.create', 'jobs.edit'], 'label' => __('layout.jobs')])
|
@include('partials.nav-item', ['route' => 'jobs.index', 'pattern' => ['jobs.index', 'jobs.show', 'jobs.create', 'jobs.edit'], 'label' => __('layout.jobs')])
|
||||||
|
|
||||||
|
@include('partials.nav-item', ['route' => 'jobs.board', 'pattern' => 'jobs.board', 'label' => __('layout.board')])
|
||||||
|
|
||||||
@can('jobs.manage')
|
@can('jobs.manage')
|
||||||
@include('partials.nav-item', ['route' => 'jobs.quick', 'pattern' => 'jobs.quick', 'label' => __('layout.quick_intake')])
|
@include('partials.nav-item', ['route' => 'jobs.quick', 'pattern' => 'jobs.quick', 'label' => __('layout.quick_intake')])
|
||||||
@endcan
|
@endcan
|
||||||
|
|||||||
@@ -104,3 +104,44 @@ it('takes in a job on a phone with the keyboard alone', function () {
|
|||||||
->assertScript('document.activeElement.id', 'quick-created')
|
->assertScript('document.activeElement.id', 'quick-created')
|
||||||
->assertNoAccessibilityIssues(level: 2);
|
->assertNoAccessibilityIssues(level: 2);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('has no accessibility issues on the Kanban board and no sideways scrolling on a phone', function (string $device, string $colorScheme) {
|
||||||
|
CustomerJobModel::factory()->create(['name' => 'Tilattu työ', 'status' => 'order', 'responsible_user_id' => $this->user->id, 'customer_id' => $this->customer->id]);
|
||||||
|
|
||||||
|
$visit = visit(route('jobs.board'));
|
||||||
|
$visit = $device === 'mobile' ? $visit->on()->mobile() : $visit->on()->desktop();
|
||||||
|
$visit = $colorScheme === 'dark' ? $visit->inDarkMode() : $visit->inLightMode();
|
||||||
|
|
||||||
|
$visit->assertSee('Tilattu työ')
|
||||||
|
->assertScript('document.documentElement.scrollWidth <= window.innerWidth', true)
|
||||||
|
->assertNoJavaScriptErrors()
|
||||||
|
->assertNoAccessibilityIssues(level: 2);
|
||||||
|
})->with([
|
||||||
|
'desktop, light' => ['desktop', 'light'],
|
||||||
|
'desktop, dark' => ['desktop', 'dark'],
|
||||||
|
'mobile, light' => ['mobile', 'light'],
|
||||||
|
'mobile, dark' => ['mobile', 'dark'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
it('moves a card to another column with the keyboard', function () {
|
||||||
|
$select = '#job-status-'.$this->job->id;
|
||||||
|
|
||||||
|
visit(route('jobs.board'))
|
||||||
|
->assertScript('document.querySelector("#column-tentative").textContent.includes("Messuvideo")', true)
|
||||||
|
->select($select, 'order')
|
||||||
|
->assertSee('Työ '.$this->job->number.' Messuvideo siirretty tilaan Tilaus.')
|
||||||
|
->assertScript('document.querySelector("#column-order").textContent.includes("Messuvideo")', true)
|
||||||
|
->assertScript('document.activeElement.id', 'job-status-'.$this->job->id)
|
||||||
|
->assertNoAccessibilityIssues(level: 2);
|
||||||
|
|
||||||
|
expect($this->job->fresh()->status->value)->toBe('order');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('moves a card by dragging it to another column', function () {
|
||||||
|
visit(route('jobs.board'))
|
||||||
|
->on()->desktop()
|
||||||
|
->drag('[wire\:sort\:item="'.$this->job->id.'"]', '#column-order ul')
|
||||||
|
->assertSee('siirretty tilaan Tilaus.');
|
||||||
|
|
||||||
|
expect($this->job->fresh()->status->value)->toBe('order');
|
||||||
|
});
|
||||||
|
|||||||
@@ -0,0 +1,92 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Modules\Jobs\Infrastructure\Persistence\Eloquent\CustomerJobModel;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Livewire\Livewire;
|
||||||
|
|
||||||
|
uses(RefreshDatabase::class);
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
$this->employee = User::factory()->create();
|
||||||
|
$this->actingAs($this->employee);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('shows the Kanban columns in order with my jobs, without archived ones', function () {
|
||||||
|
CustomerJobModel::factory()->create(['name' => 'Tilattu työ', 'status' => 'order', 'responsible_user_id' => $this->employee->id]);
|
||||||
|
CustomerJobModel::factory()->create(['name' => 'Arkistoitu työ', 'status' => 'archived', 'responsible_user_id' => $this->employee->id]);
|
||||||
|
CustomerJobModel::factory()->create(['name' => 'Muiden työ', 'status' => 'order']);
|
||||||
|
|
||||||
|
$board = Livewire::test('jobs::board')
|
||||||
|
->assertSee('Tilattu työ')
|
||||||
|
->assertDontSee('Arkistoitu työ')
|
||||||
|
->assertDontSee('Muiden työ')
|
||||||
|
->assertSeeInOrder(['Prospekti', 'Alustava', 'Tarjouspyyntö', 'Tilaus', 'Tuotannossa', 'Keskeytetty', 'Valmis', 'Lasku luotu', 'Laskutettu'])
|
||||||
|
->set('mine', false)
|
||||||
|
->assertSee('Muiden työ');
|
||||||
|
|
||||||
|
expect(array_keys($board->instance()->board))->not->toContain('archived')
|
||||||
|
->and(array_map(fn ($job) => $job->name, $board->instance()->board['order']))->toContain('Tilattu työ', 'Muiden työ');
|
||||||
|
|
||||||
|
$this->get(route('jobs.board'))->assertOk()->assertSee('Kanban');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('moves a job with the select or by dropping it, and records the change', function () {
|
||||||
|
$job = CustomerJobModel::factory()->create(['name' => 'Messuvideo', 'status' => 'tentative', 'responsible_user_id' => $this->employee->id]);
|
||||||
|
|
||||||
|
Livewire::test('jobs::board')
|
||||||
|
->call('moveJob', $job->id, 'order')
|
||||||
|
->assertSee('Työ '.$job->number.' Messuvideo siirretty tilaan Tilaus.')
|
||||||
|
->call('moveDropped', (string) $job->id, 0, 'in_production')
|
||||||
|
->assertSee('siirretty tilaan Tuotannossa.');
|
||||||
|
|
||||||
|
expect($job->fresh()->status->value)->toBe('in_production')
|
||||||
|
->and(DB::table('customer_job_changes')->where('customer_job_id', $job->id)->where('field', 'status')->count())->toBe(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('lets only management and the biller move a job to a billing status', function () {
|
||||||
|
$job = CustomerJobModel::factory()->create(['status' => 'done', 'responsible_user_id' => $this->employee->id]);
|
||||||
|
|
||||||
|
Livewire::test('jobs::board')
|
||||||
|
->call('moveJob', $job->id, 'invoiced')
|
||||||
|
->assertSee('voi asettaa vain johto tai työn laskuttaja');
|
||||||
|
expect($job->fresh()->status->value)->toBe('done');
|
||||||
|
|
||||||
|
$job->update(['biller_user_id' => $this->employee->id]);
|
||||||
|
|
||||||
|
Livewire::test('jobs::board')->call('moveJob', $job->id, 'invoiced');
|
||||||
|
expect($job->fresh()->status->value)->toBe('invoiced');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('ignores unknown statuses, archiving and jobs not on the board', function () {
|
||||||
|
$job = CustomerJobModel::factory()->create(['status' => 'order', 'responsible_user_id' => $this->employee->id]);
|
||||||
|
$other = CustomerJobModel::factory()->create(['status' => 'order']);
|
||||||
|
|
||||||
|
Livewire::test('jobs::board')
|
||||||
|
->call('moveJob', $job->id, 'nonsense')
|
||||||
|
->assertSee('Työtä ei siirretty.')
|
||||||
|
->call('moveJob', $job->id, 'archived')
|
||||||
|
->call('moveJob', $other->id, 'done')
|
||||||
|
->call('moveJob', 999, 'done');
|
||||||
|
|
||||||
|
expect($job->fresh()->status->value)->toBe('order')
|
||||||
|
->and($other->fresh()->status->value)->toBe('order');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('shows a subcontractor only their cards, without moving', function () {
|
||||||
|
$subcontractor = User::factory()->subcontractor()->create();
|
||||||
|
$theirs = CustomerJobModel::factory()->withMembers([$subcontractor->id])->create(['name' => 'Alihankintatyö', 'status' => 'order']);
|
||||||
|
CustomerJobModel::factory()->create(['name' => 'Muu työ', 'status' => 'order']);
|
||||||
|
|
||||||
|
$this->actingAs($subcontractor);
|
||||||
|
|
||||||
|
Livewire::test('jobs::board')
|
||||||
|
->assertSee('Alihankintatyö')
|
||||||
|
->assertDontSee('Muu työ')
|
||||||
|
->assertDontSeeHtml('wire:sort=')
|
||||||
|
->call('moveJob', $theirs->id, 'done')
|
||||||
|
->assertForbidden();
|
||||||
|
|
||||||
|
expect($theirs->fresh()->status->value)->toBe('order');
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user