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:
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Jobs\Domain\Contracts;
|
||||
|
||||
use App\Modules\Jobs\Domain\ValueObjects\BoardPreferences;
|
||||
|
||||
/**
|
||||
* Kanban board state that is not part of a job's details: card order,
|
||||
* tasks pinned to the board and each user's board settings. None of it is
|
||||
* recorded in a job's change history.
|
||||
*/
|
||||
interface BoardRepository
|
||||
{
|
||||
/**
|
||||
* @param array<int, int> $positions board position by job id
|
||||
*/
|
||||
public function setJobPositions(array $positions): void;
|
||||
|
||||
/**
|
||||
* @param array<int, int> $positions board position by task id
|
||||
*/
|
||||
public function setTaskPositions(array $positions): void;
|
||||
|
||||
public function setTaskPinned(int $taskId, bool $pinned): void;
|
||||
|
||||
public function preferencesOf(int $userId): BoardPreferences;
|
||||
|
||||
public function savePreferences(int $userId, BoardPreferences $preferences): void;
|
||||
}
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace App\Modules\Jobs\Domain\Entities;
|
||||
|
||||
use App\Modules\Jobs\Domain\Enums\JobStatus;
|
||||
use App\Modules\Jobs\Domain\Enums\Priority;
|
||||
use App\Modules\Jobs\Domain\ValueObjects\FieldChange;
|
||||
use App\Modules\Jobs\Domain\ValueObjects\JobDetails;
|
||||
use App\Modules\Jobs\Domain\ValueObjects\JobNumber;
|
||||
@@ -87,6 +88,14 @@ final class CustomerJob
|
||||
return $this->changeDetails($this->details->withStatus($status));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<FieldChange>
|
||||
*/
|
||||
public function changePriority(Priority $priority): array
|
||||
{
|
||||
return $this->changeDetails($this->details->withPriority($priority));
|
||||
}
|
||||
|
||||
public function id(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Jobs\Domain\Enums;
|
||||
|
||||
/**
|
||||
* A column of the Kanban board (docs/ui-kanban-board.md 2–3). Most columns
|
||||
* are one job status; "Tarjoukset" gathers the three sales statuses, and
|
||||
* jobs in production are split into a normal and an urgent column by the
|
||||
* user's urgent threshold. Continuing jobs have a column of their own.
|
||||
*/
|
||||
enum BoardColumn: string
|
||||
{
|
||||
case Quotes = 'quotes';
|
||||
case Prospect = 'prospect';
|
||||
case Tentative = 'tentative';
|
||||
case QuoteRequest = 'quote_request';
|
||||
case Order = 'order';
|
||||
case InProduction = 'in_production';
|
||||
case InProductionUrgent = 'in_production_urgent';
|
||||
case OnHold = 'on_hold';
|
||||
case Done = 'done';
|
||||
case Invoiced = 'invoiced';
|
||||
case Billed = 'billed';
|
||||
case Ongoing = 'ongoing';
|
||||
|
||||
/**
|
||||
* @return list<JobStatus>
|
||||
*/
|
||||
public function statuses(): array
|
||||
{
|
||||
return match ($this) {
|
||||
self::Quotes => [JobStatus::Prospect, JobStatus::Tentative, JobStatus::QuoteRequest],
|
||||
self::InProduction, self::InProductionUrgent => [JobStatus::InProduction],
|
||||
default => [JobStatus::from($this->value)],
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* The status a card gets when it is dropped into this column from
|
||||
* another one.
|
||||
*/
|
||||
public function targetStatus(): JobStatus
|
||||
{
|
||||
return match ($this) {
|
||||
self::Quotes => JobStatus::QuoteRequest,
|
||||
self::InProduction, self::InProductionUrgent => JobStatus::InProduction,
|
||||
default => JobStatus::from($this->value),
|
||||
};
|
||||
}
|
||||
|
||||
public function isOngoing(): bool
|
||||
{
|
||||
return $this === self::Ongoing;
|
||||
}
|
||||
|
||||
public function isUrgentLane(): bool
|
||||
{
|
||||
return $this === self::InProductionUrgent;
|
||||
}
|
||||
|
||||
public function isNormalProductionLane(): bool
|
||||
{
|
||||
return $this === self::InProduction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether a promoted (pinned) task card may be in or dropped into this
|
||||
* column: its column follows the task's status.
|
||||
*/
|
||||
public function acceptsTasks(): bool
|
||||
{
|
||||
return in_array($this, [self::Order, self::InProduction, self::Done], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* The column header colour before the user picks one (the design's
|
||||
* default palette).
|
||||
*/
|
||||
public function defaultColor(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Quotes, self::Tentative => '#4338ca',
|
||||
self::Prospect => '#374151',
|
||||
self::QuoteRequest => '#6d28d9',
|
||||
self::Order => '#23476a',
|
||||
self::InProduction, self::InProductionUrgent => '#1d4ed8',
|
||||
self::OnHold => '#78350f',
|
||||
self::Done => '#14532d',
|
||||
self::Invoiced => '#0f5c63',
|
||||
self::Billed => '#065f46',
|
||||
self::Ongoing => '#3b2d5e',
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* A Heroicon name for the column header.
|
||||
*/
|
||||
public function icon(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Quotes, self::QuoteRequest => 'document-text',
|
||||
self::Prospect => 'light-bulb',
|
||||
self::Tentative => 'pencil-square',
|
||||
self::Order => 'inbox-stack',
|
||||
self::InProduction => 'play-circle',
|
||||
self::InProductionUrgent => 'fire',
|
||||
self::OnHold => 'clock',
|
||||
self::Done => 'check-circle',
|
||||
self::Invoiced => 'credit-card',
|
||||
self::Billed => 'check-badge',
|
||||
self::Ongoing => 'arrow-path',
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* The column a job card stands in. A sales status is in "Tarjoukset" in
|
||||
* views that gather them, in its own column otherwise.
|
||||
*/
|
||||
public static function forJob(JobStatus $status, Priority $priority, UrgentThreshold $threshold, bool $gatherQuotes): ?self
|
||||
{
|
||||
return match ($status) {
|
||||
JobStatus::Prospect, JobStatus::Tentative, JobStatus::QuoteRequest => $gatherQuotes ? self::Quotes : self::from($status->value),
|
||||
JobStatus::InProduction => $threshold->includes($priority) ? self::InProductionUrgent : self::InProduction,
|
||||
JobStatus::Archived => null,
|
||||
default => self::from($status->value),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* The column a promoted task card stands in, by the task's status.
|
||||
*/
|
||||
public static function forTask(TaskStatus $status): self
|
||||
{
|
||||
return match ($status) {
|
||||
TaskStatus::Waiting => self::Order,
|
||||
TaskStatus::InProgress, TaskStatus::InReview => self::InProduction,
|
||||
TaskStatus::Done => self::Done,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* The task status a promoted task card gets when dropped here.
|
||||
*/
|
||||
public function taskStatus(): ?TaskStatus
|
||||
{
|
||||
return match ($this) {
|
||||
self::Order => TaskStatus::Waiting,
|
||||
self::InProduction => TaskStatus::InProgress,
|
||||
self::Done => TaskStatus::Done,
|
||||
default => null,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Jobs\Domain\Enums;
|
||||
|
||||
/**
|
||||
* Card density of a user's Kanban board: normal cards or three-row
|
||||
* compact cards (docs/ui-kanban-board.md 1.1).
|
||||
*/
|
||||
enum BoardDensity: string
|
||||
{
|
||||
case Normal = 'normal';
|
||||
case Compact = 'compact';
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Jobs\Domain\Enums;
|
||||
|
||||
/**
|
||||
* Näkymäputki of the Kanban board (docs/ui-kanban-board.md 2.2).
|
||||
*/
|
||||
enum BoardView: string
|
||||
{
|
||||
/** Päivittäinen työputki: quotes gathered, production, continuing jobs. */
|
||||
case Production = 'production';
|
||||
|
||||
/** Myynti & Tarjoukset: the three sales statuses apart. */
|
||||
case Sales = 'sales';
|
||||
|
||||
/** Täysi tilaputki: every status from prospect to billed, plus continuing jobs. */
|
||||
case Full = 'full';
|
||||
|
||||
/**
|
||||
* @return list<BoardColumn>
|
||||
*/
|
||||
public function columns(): array
|
||||
{
|
||||
return match ($this) {
|
||||
self::Production => [
|
||||
BoardColumn::Quotes, BoardColumn::Order, BoardColumn::InProduction, BoardColumn::InProductionUrgent,
|
||||
BoardColumn::OnHold, BoardColumn::Done, BoardColumn::Ongoing,
|
||||
],
|
||||
self::Sales => [BoardColumn::Prospect, BoardColumn::Tentative, BoardColumn::QuoteRequest],
|
||||
self::Full => [
|
||||
BoardColumn::Prospect, BoardColumn::Tentative, BoardColumn::QuoteRequest, BoardColumn::Order,
|
||||
BoardColumn::InProduction, BoardColumn::InProductionUrgent, BoardColumn::OnHold, BoardColumn::Done,
|
||||
BoardColumn::Invoiced, BoardColumn::Billed, BoardColumn::Ongoing,
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
public function gathersQuotes(): bool
|
||||
{
|
||||
return $this === self::Production;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Jobs\Domain\Enums;
|
||||
|
||||
/**
|
||||
* Order of cards in one Kanban column: the user's own drag order, or by due
|
||||
* date with the earliest (most overdue) on top and cards without one last.
|
||||
*/
|
||||
enum ColumnSort: string
|
||||
{
|
||||
case Manual = 'manual';
|
||||
case DueDate = 'due_date';
|
||||
}
|
||||
@@ -19,6 +19,7 @@ enum JobStatus: string
|
||||
case Done = 'done';
|
||||
case Invoiced = 'invoiced';
|
||||
case Billed = 'billed';
|
||||
case Ongoing = 'ongoing';
|
||||
case Archived = 'archived';
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Jobs\Domain\Enums;
|
||||
|
||||
/**
|
||||
* Which priorities lift a job in production into the "Työn alla • Kiire"
|
||||
* column of the Kanban board (docs/ui-kanban-board.md 3.1). Each user
|
||||
* chooses it for their own board.
|
||||
*/
|
||||
enum UrgentThreshold: string
|
||||
{
|
||||
case Immediate = 'immediate';
|
||||
case Urgent = 'urgent';
|
||||
case First = 'first';
|
||||
|
||||
/**
|
||||
* The lowest priority that is urgent at this threshold.
|
||||
*/
|
||||
public function lowestPriority(): Priority
|
||||
{
|
||||
return match ($this) {
|
||||
self::Immediate => Priority::Immediate,
|
||||
self::Urgent => Priority::Urgent,
|
||||
self::First => Priority::First,
|
||||
};
|
||||
}
|
||||
|
||||
public function includes(Priority $priority): bool
|
||||
{
|
||||
return self::rank($priority) >= self::rank($this->lowestPriority());
|
||||
}
|
||||
|
||||
/**
|
||||
* Waiting 1, Normal 2, First 3, Urgent 4, Immediate 5.
|
||||
*/
|
||||
public static function rank(Priority $priority): int
|
||||
{
|
||||
return match ($priority) {
|
||||
Priority::Waiting => 1,
|
||||
Priority::Normal => 2,
|
||||
Priority::First => 3,
|
||||
Priority::Urgent => 4,
|
||||
Priority::Immediate => 5,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Jobs\Domain\Exceptions;
|
||||
|
||||
use App\Modules\Shared\Domain\Exceptions\DomainException;
|
||||
|
||||
/**
|
||||
* A Kanban card was dropped into a column it cannot stand in: a continuing
|
||||
* job outside "Jatkuvat & Kausi", another job into it, or a pinned task
|
||||
* outside Jonossa, Työn alla and Valmis.
|
||||
*/
|
||||
final class CardCannotMoveThere extends DomainException
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('The card cannot be moved to that column.');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Jobs\Domain\Exceptions;
|
||||
|
||||
use App\Modules\Shared\Domain\Exceptions\DomainException;
|
||||
|
||||
/**
|
||||
* Only tasks of continuing jobs (status "Jatkuvat / Kausi") can be lifted
|
||||
* onto the Kanban board as cards of their own.
|
||||
*/
|
||||
final class TaskCannotBePinned extends DomainException
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('Only tasks of continuing jobs can be pinned to the board.');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Jobs\Domain\ValueObjects;
|
||||
|
||||
use App\Modules\Jobs\Domain\Enums\BoardColumn;
|
||||
use App\Modules\Jobs\Domain\Enums\BoardDensity;
|
||||
use App\Modules\Jobs\Domain\Enums\ColumnSort;
|
||||
use App\Modules\Jobs\Domain\Enums\UrgentThreshold;
|
||||
use App\Modules\Shared\Domain\ValueObjects\HexColor;
|
||||
|
||||
/**
|
||||
* One user's Kanban board settings: card density, the urgent threshold,
|
||||
* and their own colour and order for each column. A column without a
|
||||
* colour of its own uses the design's default colour.
|
||||
*/
|
||||
final readonly class BoardPreferences
|
||||
{
|
||||
/**
|
||||
* @param array<string, HexColor> $columnColors by BoardColumn value
|
||||
* @param array<string, ColumnSort> $columnSorts by BoardColumn value
|
||||
*/
|
||||
public function __construct(
|
||||
public BoardDensity $density = BoardDensity::Normal,
|
||||
public UrgentThreshold $urgentThreshold = UrgentThreshold::Urgent,
|
||||
public array $columnColors = [],
|
||||
public array $columnSorts = [],
|
||||
) {}
|
||||
|
||||
public static function defaults(): self
|
||||
{
|
||||
return new self;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuilds stored settings, dropping unknown columns and invalid values
|
||||
* so a bad stored value never breaks the board.
|
||||
*
|
||||
* @param array<array-key, mixed> $colors
|
||||
* @param array<array-key, mixed> $sorts
|
||||
*/
|
||||
public static function fromStored(?string $density, ?string $threshold, array $colors, array $sorts): self
|
||||
{
|
||||
$columnColors = [];
|
||||
|
||||
foreach ($colors as $column => $color) {
|
||||
if (BoardColumn::tryFrom((string) $column) !== null && is_string($color) && preg_match('/^#[0-9a-f]{6}$/i', $color) === 1) {
|
||||
$columnColors[(string) $column] = new HexColor($color);
|
||||
}
|
||||
}
|
||||
|
||||
$columnSorts = [];
|
||||
|
||||
foreach ($sorts as $column => $sort) {
|
||||
$parsed = is_string($sort) ? ColumnSort::tryFrom($sort) : null;
|
||||
|
||||
if (BoardColumn::tryFrom((string) $column) !== null && $parsed !== null) {
|
||||
$columnSorts[(string) $column] = $parsed;
|
||||
}
|
||||
}
|
||||
|
||||
return new self(
|
||||
BoardDensity::tryFrom((string) $density) ?? BoardDensity::Normal,
|
||||
UrgentThreshold::tryFrom((string) $threshold) ?? UrgentThreshold::Urgent,
|
||||
$columnColors,
|
||||
$columnSorts,
|
||||
);
|
||||
}
|
||||
|
||||
public function colorOf(BoardColumn $column): HexColor
|
||||
{
|
||||
return $this->columnColors[$column->value] ?? new HexColor($column->defaultColor());
|
||||
}
|
||||
|
||||
public function hasOwnColor(BoardColumn $column): bool
|
||||
{
|
||||
return isset($this->columnColors[$column->value]);
|
||||
}
|
||||
|
||||
public function sortOf(BoardColumn $column): ColumnSort
|
||||
{
|
||||
return $this->columnSorts[$column->value] ?? ColumnSort::Manual;
|
||||
}
|
||||
|
||||
public function withDensity(BoardDensity $density): self
|
||||
{
|
||||
return new self($density, $this->urgentThreshold, $this->columnColors, $this->columnSorts);
|
||||
}
|
||||
|
||||
public function withUrgentThreshold(UrgentThreshold $threshold): self
|
||||
{
|
||||
return new self($this->density, $threshold, $this->columnColors, $this->columnSorts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Null returns the column to its default colour.
|
||||
*/
|
||||
public function withColumnColor(BoardColumn $column, ?HexColor $color): self
|
||||
{
|
||||
$colors = $this->columnColors;
|
||||
|
||||
if ($color === null) {
|
||||
unset($colors[$column->value]);
|
||||
} else {
|
||||
$colors[$column->value] = $color;
|
||||
}
|
||||
|
||||
return new self($this->density, $this->urgentThreshold, $colors, $this->columnSorts);
|
||||
}
|
||||
|
||||
public function withColumnSort(BoardColumn $column, ColumnSort $sort): self
|
||||
{
|
||||
$sorts = $this->columnSorts;
|
||||
$sorts[$column->value] = $sort;
|
||||
|
||||
return new self($this->density, $this->urgentThreshold, $this->columnColors, $sorts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function colorValues(): array
|
||||
{
|
||||
return array_map(fn (HexColor $color): string => $color->value, $this->columnColors);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function sortValues(): array
|
||||
{
|
||||
return array_map(fn (ColumnSort $sort): string => $sort->value, $this->columnSorts);
|
||||
}
|
||||
}
|
||||
@@ -102,6 +102,18 @@ final readonly class JobDetails
|
||||
);
|
||||
}
|
||||
|
||||
public function withPriority(Priority $priority): self
|
||||
{
|
||||
return new self(
|
||||
$this->name, $this->description, $this->customerId, $this->serviceUnitIds,
|
||||
$this->startsOn, $this->dueOn, $this->plannedFrom, $this->plannedTo,
|
||||
$this->kind, $this->status, $priority, $this->paymentBasis, $this->estimatedHours,
|
||||
$this->customerReference, $this->instructions, $this->responsibleUserId, $this->contactUserId,
|
||||
$this->customerContactId, $this->billerUserId, $this->billingUnitId, $this->memberUserIds,
|
||||
$this->tags, $this->links, $this->quotedAmount, $this->monthlyFee,
|
||||
);
|
||||
}
|
||||
|
||||
public function withServiceUnit(int $serviceUnitId): self
|
||||
{
|
||||
return new self(
|
||||
|
||||
Reference in New Issue
Block a user