Darken the dark canvas, add customer colours, the ongoing status and the board model

- 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]>
This commit is contained in:
2026-11-30 06:11:49 +02:00
co-authored by Claude Opus 5.5
parent de168619b3
commit f4b58f6b1d
140 changed files with 2845 additions and 170 deletions
@@ -0,0 +1,39 @@
<?php
declare(strict_types=1);
namespace App\Modules\Jobs\Application\UseCases;
use App\Modules\Jobs\Domain\Contracts\CustomerJobRepository;
use App\Modules\Jobs\Domain\Enums\Priority;
use App\Modules\Jobs\Domain\Exceptions\CustomerJobNotFound;
use App\Modules\Shared\Application\Contracts\TransactionManager;
/**
* Changes a job's priority (e.g. in the board's job editor) and records it.
*/
final class ChangeJobPriority
{
public function __construct(
private CustomerJobRepository $jobs,
private TransactionManager $transactions,
) {}
/**
* @throws CustomerJobNotFound
*/
public function execute(int $jobId, Priority $priority, int $actorUserId): void
{
$this->transactions->run(function () use ($jobId, $priority, $actorUserId): void {
$job = $this->jobs->findById($jobId) ?? throw new CustomerJobNotFound($jobId);
$changes = $job->changePriority($priority);
if ($changes === []) {
return;
}
$this->jobs->save($job);
$this->jobs->recordChanges($jobId, $actorUserId, $changes);
});
}
}
@@ -0,0 +1,145 @@
<?php
declare(strict_types=1);
namespace App\Modules\Jobs\Application\UseCases;
use App\Modules\Jobs\Domain\Contracts\BoardRepository;
use App\Modules\Jobs\Domain\Contracts\CustomerJobRepository;
use App\Modules\Jobs\Domain\Contracts\TaskRepository;
use App\Modules\Jobs\Domain\Enums\BoardColumn;
use App\Modules\Jobs\Domain\Enums\JobStatus;
use App\Modules\Jobs\Domain\Enums\Priority;
use App\Modules\Jobs\Domain\Enums\TaskStatus;
use App\Modules\Jobs\Domain\Enums\UrgentThreshold;
use App\Modules\Jobs\Domain\Events\TaskCompleted;
use App\Modules\Jobs\Domain\Exceptions\CardCannotMoveThere;
use App\Modules\Jobs\Domain\Exceptions\CustomerJobNotFound;
use App\Modules\Jobs\Domain\Exceptions\TaskNotFound;
use App\Modules\Shared\Application\Contracts\EventDispatcher;
use App\Modules\Shared\Application\Contracts\TransactionManager;
use App\Modules\Users\Application\Contracts\Clock;
/**
* A Kanban card dropped into a column (docs/ui-kanban-board.md 3):
*
* - a job dropped into another status's column gets that status;
* - a job dropped into "Työn alla • Kiire" gets at least the threshold's
* priority, and one dropped into the normal "Työn alla" with an urgent
* priority gets the normal priority;
* - a pinned task card gets the status of its new column;
* - the column's cards get positions in the dropped order.
*
* Who may set a billing status or open a lock is checked by the caller.
*/
final class MoveBoardCard
{
public function __construct(
private CustomerJobRepository $jobs,
private TaskRepository $tasks,
private BoardRepository $board,
private TransactionManager $transactions,
private EventDispatcher $events,
private Clock $clock,
) {}
/**
* @param list<string> $orderedKeys the target column's card keys ("job-12", "task-34") in their new order
*
* @throws CustomerJobNotFound
* @throws TaskNotFound
* @throws CardCannotMoveThere
*/
public function execute(int $jobId, ?int $taskId, BoardColumn $target, array $orderedKeys, UrgentThreshold $threshold, int $actorUserId): void
{
$this->transactions->run(function () use ($jobId, $taskId, $target, $orderedKeys, $threshold, $actorUserId): void {
if ($taskId === null) {
$this->moveJob($jobId, $target, $threshold, $actorUserId);
} else {
$this->moveTask($jobId, $taskId, $target);
}
$this->reorder($orderedKeys);
});
}
/**
* The status a job gets when dropped into the column: its own when the
* column already holds it (e.g. moving between the quote statuses in
* "Tarjoukset"), the column's otherwise.
*/
public static function statusAfterDrop(JobStatus $current, BoardColumn $target): JobStatus
{
return in_array($current, $target->statuses(), true) ? $current : $target->targetStatus();
}
private function moveJob(int $jobId, BoardColumn $target, UrgentThreshold $threshold, int $actorUserId): void
{
$job = $this->jobs->findById($jobId) ?? throw new CustomerJobNotFound($jobId);
$current = $job->details()->status;
if (($current === JobStatus::Ongoing) !== $target->isOngoing()) {
throw new CardCannotMoveThere;
}
$changes = $job->changeStatus(self::statusAfterDrop($current, $target));
$priority = $job->details()->priority;
if ($target->isUrgentLane() && ! $threshold->includes($priority)) {
$changes = [...$changes, ...$job->changePriority($threshold->lowestPriority())];
} elseif ($target->isNormalProductionLane() && $threshold->includes($priority)) {
$changes = [...$changes, ...$job->changePriority(Priority::Normal)];
}
$job->recordCompletion($this->clock->now());
if ($changes !== []) {
$this->jobs->save($job);
$this->jobs->recordChanges($jobId, $actorUserId, $changes);
}
}
private function moveTask(int $jobId, int $taskId, BoardColumn $target): void
{
$status = $target->taskStatus() ?? throw new CardCannotMoveThere;
$task = $this->tasks->findForJob($jobId, $taskId) ?? throw new TaskNotFound($jobId, $taskId);
$wasDone = $task->status() === TaskStatus::Done;
if ($task->status() === $status || ($status === TaskStatus::InProgress && $task->status() === TaskStatus::InReview)) {
return;
}
$task->changeStatus($status);
$this->tasks->save($task);
if (! $wasDone && $status === TaskStatus::Done) {
$this->events->dispatch(new TaskCompleted($taskId, $jobId));
}
}
/**
* @param list<string> $orderedKeys
*/
private function reorder(array $orderedKeys): void
{
$jobPositions = [];
$taskPositions = [];
foreach (array_values($orderedKeys) as $index => $key) {
if (preg_match('/^(job|task)-(\d+)$/', $key, $matches) !== 1) {
continue;
}
$position = ($index + 1) * 10;
if ($matches[1] === 'job') {
$jobPositions[(int) $matches[2]] = $position;
} else {
$taskPositions[(int) $matches[2]] = $position;
}
}
$this->board->setJobPositions($jobPositions);
$this->board->setTaskPositions($taskPositions);
}
}
@@ -0,0 +1,47 @@
<?php
declare(strict_types=1);
namespace App\Modules\Jobs\Application\UseCases;
use App\Modules\Jobs\Domain\Contracts\BoardRepository;
use App\Modules\Jobs\Domain\Contracts\CustomerJobRepository;
use App\Modules\Jobs\Domain\Contracts\TaskRepository;
use App\Modules\Jobs\Domain\Enums\JobStatus;
use App\Modules\Jobs\Domain\Exceptions\CustomerJobNotFound;
use App\Modules\Jobs\Domain\Exceptions\TaskCannotBePinned;
use App\Modules\Jobs\Domain\Exceptions\TaskNotFound;
use App\Modules\Shared\Application\Contracts\TransactionManager;
/**
* Lifts a task of a continuing job onto the Kanban board as a card of its
* own ("Nosta putkeen"), or releases it back under the job's card.
*/
final class PinTaskToBoard
{
public function __construct(
private CustomerJobRepository $jobs,
private TaskRepository $tasks,
private BoardRepository $board,
private TransactionManager $transactions,
) {}
/**
* @throws CustomerJobNotFound
* @throws TaskNotFound
* @throws TaskCannotBePinned
*/
public function execute(int $jobId, int $taskId, bool $pinned): void
{
$this->transactions->run(function () use ($jobId, $taskId, $pinned): void {
$job = $this->jobs->findById($jobId) ?? throw new CustomerJobNotFound($jobId);
$this->tasks->findForJob($jobId, $taskId) ?? throw new TaskNotFound($jobId, $taskId);
if ($pinned && $job->details()->status !== JobStatus::Ongoing) {
throw new TaskCannotBePinned;
}
$this->board->setTaskPinned($taskId, $pinned);
});
}
}
@@ -0,0 +1,25 @@
<?php
declare(strict_types=1);
namespace App\Modules\Jobs\Application\UseCases;
use App\Modules\Jobs\Domain\Contracts\BoardRepository;
use App\Modules\Jobs\Domain\ValueObjects\BoardPreferences;
use App\Modules\Shared\Application\Contracts\TransactionManager;
/**
* Stores one user's Kanban settings. They never change anyone else's board.
*/
final class SaveBoardPreferences
{
public function __construct(
private BoardRepository $board,
private TransactionManager $transactions,
) {}
public function execute(int $userId, BoardPreferences $preferences): void
{
$this->transactions->run(fn () => $this->board->savePreferences($userId, $preferences));
}
}