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,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Jobs\Application\Contracts;
|
||||
|
||||
use App\Modules\Jobs\Application\DTOs\BoardCard;
|
||||
use App\Modules\Jobs\Application\DTOs\BoardFilter;
|
||||
use App\Modules\Jobs\Domain\ValueObjects\BoardPreferences;
|
||||
|
||||
/**
|
||||
* Read side of the Kanban board.
|
||||
*/
|
||||
interface JobBoardQueries
|
||||
{
|
||||
/**
|
||||
* Every card the filter lets through: open and done jobs (not archived,
|
||||
* not the yearly quick-sale job) with their tasks, and tasks of
|
||||
* continuing jobs pinned to the board as cards of their own.
|
||||
*
|
||||
* @param string $today Y-m-d, for late jobs
|
||||
* @return list<BoardCard>
|
||||
*/
|
||||
public function cards(BoardFilter $filter, string $today): array;
|
||||
|
||||
/**
|
||||
* The user's board settings, or the defaults.
|
||||
*/
|
||||
public function preferencesOf(int $userId): BoardPreferences;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Jobs\Application\Contracts;
|
||||
|
||||
/**
|
||||
* Hours recorded on jobs and tasks, for the Kanban cards. The TimeTracking
|
||||
* module provides it; Jobs knows nothing about time entries.
|
||||
*/
|
||||
interface LoggedJobHours
|
||||
{
|
||||
/**
|
||||
* Recorded quarter-hours by job id (jobs without hours are left out).
|
||||
*
|
||||
* @param list<int> $jobIds
|
||||
* @return array<int, int>
|
||||
*/
|
||||
public function quartersByJobs(array $jobIds): array;
|
||||
|
||||
/**
|
||||
* Recorded quarter-hours by task id (tasks without hours are left out).
|
||||
*
|
||||
* @param list<int> $taskIds
|
||||
* @return array<int, int>
|
||||
*/
|
||||
public function quartersByTasks(array $taskIds): array;
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Jobs\Application\DTOs;
|
||||
|
||||
use App\Modules\Jobs\Domain\Enums\JobKind;
|
||||
use App\Modules\Jobs\Domain\Enums\JobStatus;
|
||||
use App\Modules\Jobs\Domain\Enums\Priority;
|
||||
use App\Modules\Jobs\Domain\Enums\TaskStatus;
|
||||
|
||||
/**
|
||||
* A card on the Kanban board: a customer job, or a task of a continuing
|
||||
* job that is pinned to the board as its own card ($taskId set).
|
||||
*/
|
||||
final readonly class BoardCard
|
||||
{
|
||||
/**
|
||||
* @param list<BoardTask> $tasks the job's tasks (empty on a task card)
|
||||
*/
|
||||
public function __construct(
|
||||
public int $jobId,
|
||||
public ?int $taskId,
|
||||
public string $number,
|
||||
public string $title,
|
||||
public string $jobName,
|
||||
public int $customerId,
|
||||
public string $customerName,
|
||||
public ?string $customerHeaderColor,
|
||||
public JobStatus $jobStatus,
|
||||
public ?TaskStatus $taskStatus,
|
||||
public Priority $priority,
|
||||
public JobKind $kind,
|
||||
public ?string $dueOn,
|
||||
public bool $isLate,
|
||||
public ?string $responsibleName,
|
||||
public ?string $serviceUnitName,
|
||||
public ?string $estimatedHours,
|
||||
public int $loggedQuarters,
|
||||
public int $boardPosition,
|
||||
public ?int $billerUserId,
|
||||
public array $tasks = [],
|
||||
) {}
|
||||
|
||||
public function isTaskCard(): bool
|
||||
{
|
||||
return $this->taskId !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stable key for wire:key and wire:sort:item: "job-12" or "task-34".
|
||||
*/
|
||||
public function key(): string
|
||||
{
|
||||
return $this->isTaskCard() ? 'task-'.$this->taskId : 'job-'.$this->jobId;
|
||||
}
|
||||
|
||||
public function isOngoing(): bool
|
||||
{
|
||||
return $this->jobStatus === JobStatus::Ongoing && ! $this->isTaskCard();
|
||||
}
|
||||
|
||||
public function doneTaskCount(): int
|
||||
{
|
||||
return count(array_filter($this->tasks, fn (BoardTask $task): bool => $task->isDone()));
|
||||
}
|
||||
|
||||
/**
|
||||
* The first open task of a continuing job ("Seuraava vuorossa").
|
||||
*/
|
||||
public function nextOpenTask(): ?BoardTask
|
||||
{
|
||||
foreach ($this->tasks as $task) {
|
||||
if (! $task->isDone()) {
|
||||
return $task;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function responsibleInitials(): string
|
||||
{
|
||||
if ($this->responsibleName === null || trim($this->responsibleName) === '') {
|
||||
return '?';
|
||||
}
|
||||
|
||||
$parts = preg_split('/\s+/', trim($this->responsibleName)) ?: [];
|
||||
$initials = '';
|
||||
|
||||
foreach (array_slice($parts, 0, 2) as $part) {
|
||||
$initials .= mb_strtoupper(mb_substr($part, 0, 1));
|
||||
}
|
||||
|
||||
return $initials;
|
||||
}
|
||||
|
||||
public function responsibleFirstName(): ?string
|
||||
{
|
||||
return $this->responsibleName === null ? null : explode(' ', trim($this->responsibleName))[0];
|
||||
}
|
||||
|
||||
public function loggedHours(): float
|
||||
{
|
||||
return $this->loggedQuarters / 4;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Jobs\Application\DTOs;
|
||||
|
||||
/**
|
||||
* Whose cards the Kanban board shows (docs/ui-kanban-board.md 2): one
|
||||
* person's jobs (their own board or another person's), one service line,
|
||||
* or the whole company. Subcontractors are always limited to their jobs.
|
||||
*/
|
||||
final readonly class BoardFilter
|
||||
{
|
||||
public function __construct(
|
||||
/** Jobs this user is responsible for, a member of or does a task of. */
|
||||
public ?int $personUserId = null,
|
||||
public ?int $serviceUnitId = null,
|
||||
/** Restricts everything to jobs the user is a member of (subcontractors). */
|
||||
public ?int $onlyMemberUserId = null,
|
||||
public bool $onlyUrgent = false,
|
||||
public bool $onlyLate = false,
|
||||
) {}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Jobs\Application\DTOs;
|
||||
|
||||
use App\Modules\Jobs\Domain\Enums\TaskStatus;
|
||||
|
||||
/**
|
||||
* A task row in a Kanban card's task list.
|
||||
*/
|
||||
final readonly class BoardTask
|
||||
{
|
||||
public function __construct(
|
||||
public int $id,
|
||||
public string $title,
|
||||
public TaskStatus $status,
|
||||
public ?string $assigneeName,
|
||||
public bool $pinnedToBoard,
|
||||
public ?string $dueOn = null,
|
||||
) {}
|
||||
|
||||
public function isDone(): bool
|
||||
{
|
||||
return $this->status === TaskStatus::Done;
|
||||
}
|
||||
|
||||
public function assigneeFirstName(): ?string
|
||||
{
|
||||
return $this->assigneeName === null ? null : explode(' ', trim($this->assigneeName))[0];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Jobs\Application\Services;
|
||||
|
||||
use App\Modules\Jobs\Application\DTOs\BoardCard;
|
||||
use App\Modules\Jobs\Domain\Enums\BoardColumn;
|
||||
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\ValueObjects\BoardPreferences;
|
||||
|
||||
/**
|
||||
* Places Kanban cards in the columns of a view and orders each column
|
||||
* (docs/ui-kanban-board.md 3–4):
|
||||
*
|
||||
* - jobs in production go to the urgent column when their priority meets
|
||||
* the user's threshold, to the normal one otherwise;
|
||||
* - continuing jobs only ever stand in "Jatkuvat & Kausi";
|
||||
* - a pinned task stands in Jonossa, Työn alla or Valmis by its status;
|
||||
* - a manual column is in drag order, a due-date column has the earliest
|
||||
* due date on top and cards without one last.
|
||||
*/
|
||||
final class BoardLayout
|
||||
{
|
||||
/**
|
||||
* @param list<BoardCard> $cards
|
||||
* @return array<string, list<BoardCard>> by BoardColumn value, in the view's column order
|
||||
*/
|
||||
public function arrange(array $cards, BoardView $view, BoardPreferences $preferences): array
|
||||
{
|
||||
$columns = [];
|
||||
|
||||
foreach ($view->columns() as $column) {
|
||||
$columns[$column->value] = [];
|
||||
}
|
||||
|
||||
foreach ($cards as $card) {
|
||||
$column = $this->columnOf($card, $view, $preferences);
|
||||
|
||||
if ($column !== null && array_key_exists($column->value, $columns)) {
|
||||
$columns[$column->value][] = $card;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($columns as $value => $columnCards) {
|
||||
$columns[$value] = $this->sorted($columnCards, $preferences->sortOf(BoardColumn::from($value)));
|
||||
}
|
||||
|
||||
return $columns;
|
||||
}
|
||||
|
||||
public function columnOf(BoardCard $card, BoardView $view, BoardPreferences $preferences): ?BoardColumn
|
||||
{
|
||||
if ($card->isTaskCard()) {
|
||||
return $card->taskStatus === null ? null : BoardColumn::forTask($card->taskStatus);
|
||||
}
|
||||
|
||||
if ($card->jobStatus === JobStatus::Ongoing) {
|
||||
return BoardColumn::Ongoing;
|
||||
}
|
||||
|
||||
return BoardColumn::forJob($card->jobStatus, $card->priority, $preferences->urgentThreshold, $view->gathersQuotes());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<BoardCard> $cards
|
||||
* @return list<BoardCard>
|
||||
*/
|
||||
private function sorted(array $cards, ColumnSort $sort): array
|
||||
{
|
||||
usort($cards, function (BoardCard $a, BoardCard $b) use ($sort): int {
|
||||
if ($sort === ColumnSort::DueDate) {
|
||||
$byDue = ($a->dueOn ?? '9999-12-31') <=> ($b->dueOn ?? '9999-12-31');
|
||||
|
||||
if ($byDue !== 0) {
|
||||
return $byDue;
|
||||
}
|
||||
}
|
||||
|
||||
return [$a->boardPosition, $a->isTaskCard() ? 1 : 0, $a->taskId ?? $a->jobId]
|
||||
<=> [$b->boardPosition, $b->isTaskCard() ? 1 : 0, $b->taskId ?? $b->jobId];
|
||||
});
|
||||
|
||||
return $cards;
|
||||
}
|
||||
}
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
@@ -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(
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\Jobs\Infrastructure;
|
||||
|
||||
use App\Modules\Jobs\Application\Contracts\LoggedJobHours;
|
||||
|
||||
/**
|
||||
* Default when no module records hours.
|
||||
*/
|
||||
class NoLoggedJobHours implements LoggedJobHours
|
||||
{
|
||||
public function quartersByJobs(array $jobIds): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function quartersByTasks(array $taskIds): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
* @property JobKind $kind
|
||||
* @property JobStatus $status
|
||||
* @property Priority $priority
|
||||
* @property int $board_position
|
||||
* @property PaymentBasis|null $payment_basis
|
||||
* @property string|null $estimated_hours
|
||||
* @property string|null $customer_reference
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\Jobs\Infrastructure\Persistence\Eloquent;
|
||||
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Attributes\Table;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* One user's Kanban board settings.
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $user_id
|
||||
* @property string $density
|
||||
* @property string $urgent_threshold
|
||||
* @property array<string, string>|null $column_colors
|
||||
* @property array<string, string>|null $column_sorts
|
||||
*/
|
||||
#[Table('job_board_preferences')]
|
||||
#[Fillable(['user_id', 'density', 'urgent_threshold', 'column_colors', 'column_sorts'])]
|
||||
class JobBoardPreferenceModel extends Model
|
||||
{
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'user_id' => 'integer',
|
||||
'column_colors' => 'array',
|
||||
'column_sorts' => 'array',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,8 @@ use Illuminate\Database\Eloquent\Model;
|
||||
* @property CarbonImmutable|null $planned_to
|
||||
* @property string|null $estimated_hours
|
||||
* @property int|null $assignee_user_id
|
||||
* @property bool $is_pinned_to_board
|
||||
* @property int $board_position
|
||||
* @property int $created_by
|
||||
*/
|
||||
#[Table('tasks')]
|
||||
@@ -50,6 +52,8 @@ class TaskModel extends Model
|
||||
'planned_from' => 'immutable_date',
|
||||
'planned_to' => 'immutable_date',
|
||||
'assignee_user_id' => 'integer',
|
||||
'is_pinned_to_board' => 'boolean',
|
||||
'board_position' => 'integer',
|
||||
'created_by' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\Jobs\Infrastructure\Persistence\Repositories;
|
||||
|
||||
use App\Modules\Jobs\Domain\Contracts\BoardRepository;
|
||||
use App\Modules\Jobs\Domain\ValueObjects\BoardPreferences;
|
||||
use App\Modules\Jobs\Infrastructure\Persistence\Eloquent\JobBoardPreferenceModel;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
/**
|
||||
* Card order and pins are plain column updates: they are board state, not
|
||||
* job details, so they bypass the job entity and its change history.
|
||||
*/
|
||||
class EloquentBoardRepository implements BoardRepository
|
||||
{
|
||||
public function setJobPositions(array $positions): void
|
||||
{
|
||||
foreach ($positions as $jobId => $position) {
|
||||
DB::table('customer_jobs')->where('id', $jobId)->update(['board_position' => $position]);
|
||||
}
|
||||
}
|
||||
|
||||
public function setTaskPositions(array $positions): void
|
||||
{
|
||||
foreach ($positions as $taskId => $position) {
|
||||
DB::table('tasks')->where('id', $taskId)->update(['board_position' => $position]);
|
||||
}
|
||||
}
|
||||
|
||||
public function setTaskPinned(int $taskId, bool $pinned): void
|
||||
{
|
||||
DB::table('tasks')->where('id', $taskId)->update(['is_pinned_to_board' => $pinned]);
|
||||
}
|
||||
|
||||
public function preferencesOf(int $userId): BoardPreferences
|
||||
{
|
||||
$model = JobBoardPreferenceModel::query()->where('user_id', $userId)->first();
|
||||
|
||||
return $model === null
|
||||
? BoardPreferences::defaults()
|
||||
: BoardPreferences::fromStored($model->density, $model->urgent_threshold, $model->column_colors ?? [], $model->column_sorts ?? []);
|
||||
}
|
||||
|
||||
public function savePreferences(int $userId, BoardPreferences $preferences): void
|
||||
{
|
||||
JobBoardPreferenceModel::query()->updateOrCreate(['user_id' => $userId], [
|
||||
'density' => $preferences->density->value,
|
||||
'urgent_threshold' => $preferences->urgentThreshold->value,
|
||||
'column_colors' => $preferences->colorValues(),
|
||||
'column_sorts' => $preferences->sortValues(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -197,7 +197,7 @@ class EloquentCustomerJobQueries implements CustomerJobQueries
|
||||
{
|
||||
return array_values($this->billingInfo(CustomerJobModel::query()
|
||||
->where('payment_basis', PaymentBasis::MonthlyFee)
|
||||
->whereIn('status', [JobStatus::Order, JobStatus::InProduction, JobStatus::OnHold, JobStatus::Done])
|
||||
->whereIn('status', [JobStatus::Order, JobStatus::InProduction, JobStatus::OnHold, JobStatus::Done, JobStatus::Ongoing])
|
||||
->orderBy('number')
|
||||
->get()));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,220 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\Jobs\Infrastructure\Persistence\Repositories;
|
||||
|
||||
use App\Modules\Catalog\Application\Contracts\CatalogQueries;
|
||||
use App\Modules\Customers\Application\Contracts\CustomerQueries;
|
||||
use App\Modules\Jobs\Application\Contracts\JobBoardQueries;
|
||||
use App\Modules\Jobs\Application\Contracts\LoggedJobHours;
|
||||
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\Domain\Contracts\BoardRepository;
|
||||
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\ValueObjects\BoardPreferences;
|
||||
use App\Modules\Jobs\Infrastructure\Persistence\Eloquent\CustomerJobModel;
|
||||
use App\Modules\Jobs\Infrastructure\Persistence\Eloquent\TaskModel;
|
||||
use App\Modules\Jobs\Infrastructure\Persistence\JobInvolvement;
|
||||
use App\Modules\Users\Application\Contracts\UserAccountQueries;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
/**
|
||||
* Customer, user and service unit names and customer colours come from
|
||||
* those modules' query contracts; recorded hours from LoggedJobHours.
|
||||
*/
|
||||
class EloquentJobBoardQueries implements JobBoardQueries
|
||||
{
|
||||
public function __construct(
|
||||
private CustomerQueries $customers,
|
||||
private UserAccountQueries $users,
|
||||
private CatalogQueries $catalog,
|
||||
private LoggedJobHours $hours,
|
||||
private BoardRepository $board,
|
||||
) {}
|
||||
|
||||
public function cards(BoardFilter $filter, string $today): array
|
||||
{
|
||||
$jobs = $this->filteredJobs($filter, $today)->get();
|
||||
|
||||
if ($jobs->isEmpty()) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$jobIds = $jobs->pluck('id')->map(fn ($id): int => (int) $id)->all();
|
||||
$tasks = TaskModel::query()
|
||||
->whereIn('customer_job_id', $jobIds)
|
||||
->orderByRaw('status = ?', [TaskStatus::Done->value])
|
||||
->orderByRaw('due_on IS NULL')
|
||||
->orderBy('due_on')
|
||||
->orderBy('board_position')
|
||||
->orderBy('id')
|
||||
->get();
|
||||
|
||||
$customerIds = $jobs->pluck('customer_id')->unique()->values()->all();
|
||||
$customerNames = $this->customers->namesByIds($customerIds);
|
||||
$customerColors = $this->customers->headerColorsByIds($customerIds);
|
||||
$userNames = $this->users->namesByIds($jobs->pluck('responsible_user_id')
|
||||
->merge($tasks->pluck('assignee_user_id')->filter())
|
||||
->map(fn ($id): int => (int) $id)->unique()->values()->all());
|
||||
$jobQuarters = $this->hours->quartersByJobs($jobIds);
|
||||
$pinnedTasks = $tasks->filter(fn (TaskModel $task): bool => (bool) $task->is_pinned_to_board);
|
||||
$taskQuarters = $this->hours->quartersByTasks($pinnedTasks->pluck('id')->map(fn ($id): int => (int) $id)->values()->all());
|
||||
$serviceUnitNames = $this->firstServiceUnitNames($jobIds);
|
||||
$tasksByJob = $tasks->groupBy('customer_job_id');
|
||||
|
||||
$cards = [];
|
||||
|
||||
foreach ($jobs as $job) {
|
||||
$jobTasks = $tasksByJob->get($job->id) ?? collect();
|
||||
$common = [
|
||||
'customerName' => $customerNames[$job->customer_id] ?? '',
|
||||
'customerColor' => $customerColors[$job->customer_id] ?? null,
|
||||
'serviceUnit' => $serviceUnitNames[$job->id] ?? null,
|
||||
];
|
||||
|
||||
$cards[] = new BoardCard(
|
||||
jobId: $job->id,
|
||||
taskId: null,
|
||||
number: $job->number,
|
||||
title: $job->name,
|
||||
jobName: $job->name,
|
||||
customerId: $job->customer_id,
|
||||
customerName: $common['customerName'],
|
||||
customerHeaderColor: $common['customerColor'],
|
||||
jobStatus: $job->status,
|
||||
taskStatus: null,
|
||||
priority: $job->priority,
|
||||
kind: $job->kind,
|
||||
dueOn: $job->due_on?->format('Y-m-d'),
|
||||
isLate: $this->isLate($job->status, $job->due_on?->format('Y-m-d'), $today),
|
||||
responsibleName: $userNames[$job->responsible_user_id] ?? null,
|
||||
serviceUnitName: $common['serviceUnit'],
|
||||
estimatedHours: $this->hoursText($job->estimated_hours),
|
||||
loggedQuarters: $jobQuarters[$job->id] ?? 0,
|
||||
boardPosition: (int) $job->board_position,
|
||||
billerUserId: $job->biller_user_id,
|
||||
tasks: $jobTasks->map(fn (TaskModel $task): BoardTask => new BoardTask(
|
||||
$task->id,
|
||||
$task->title,
|
||||
$task->status,
|
||||
$task->assignee_user_id === null ? null : ($userNames[$task->assignee_user_id] ?? null),
|
||||
(bool) $task->is_pinned_to_board,
|
||||
$task->due_on?->format('Y-m-d'),
|
||||
))->values()->all(),
|
||||
);
|
||||
|
||||
if ($job->status !== JobStatus::Ongoing) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($jobTasks as $task) {
|
||||
if (! $task->is_pinned_to_board) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$cards[] = new BoardCard(
|
||||
jobId: $job->id,
|
||||
taskId: $task->id,
|
||||
number: $job->number,
|
||||
title: $task->title,
|
||||
jobName: $job->name,
|
||||
customerId: $job->customer_id,
|
||||
customerName: $common['customerName'],
|
||||
customerHeaderColor: $common['customerColor'],
|
||||
jobStatus: $job->status,
|
||||
taskStatus: $task->status,
|
||||
priority: Priority::Normal,
|
||||
kind: $job->kind,
|
||||
dueOn: $task->due_on?->format('Y-m-d'),
|
||||
isLate: $task->status !== TaskStatus::Done && $task->due_on !== null && $task->due_on->format('Y-m-d') < $today,
|
||||
responsibleName: $task->assignee_user_id === null ? null : ($userNames[$task->assignee_user_id] ?? null),
|
||||
serviceUnitName: $common['serviceUnit'],
|
||||
estimatedHours: $this->hoursText($task->estimated_hours),
|
||||
loggedQuarters: $taskQuarters[$task->id] ?? 0,
|
||||
boardPosition: (int) $task->board_position,
|
||||
billerUserId: $job->biller_user_id,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $cards;
|
||||
}
|
||||
|
||||
public function preferencesOf(int $userId): BoardPreferences
|
||||
{
|
||||
return $this->board->preferencesOf($userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Builder<CustomerJobModel>
|
||||
*/
|
||||
private function filteredJobs(BoardFilter $filter, string $today): Builder
|
||||
{
|
||||
$query = CustomerJobModel::query()
|
||||
->where('status', '!=', JobStatus::Archived->value)
|
||||
->whereNull('quick_sale_year');
|
||||
|
||||
foreach (array_filter([$filter->personUserId, $filter->onlyMemberUserId]) as $userId) {
|
||||
JobInvolvement::restrict($query, $userId);
|
||||
}
|
||||
|
||||
if ($filter->serviceUnitId !== null) {
|
||||
$query->whereIn('id', DB::table('customer_job_service_unit')->select('customer_job_id')->where('service_unit_id', $filter->serviceUnitId));
|
||||
}
|
||||
|
||||
if ($filter->onlyUrgent) {
|
||||
$query->whereIn('priority', [Priority::Urgent->value, Priority::Immediate->value]);
|
||||
}
|
||||
|
||||
if ($filter->onlyLate) {
|
||||
$query->whereNotNull('due_on')
|
||||
->where('due_on', '<', $today)
|
||||
->whereIn('status', array_map(
|
||||
fn (JobStatus $status): string => $status->value,
|
||||
array_values(array_filter(JobStatus::openStatuses(), fn (JobStatus $status): bool => $status !== JobStatus::Ongoing)),
|
||||
));
|
||||
}
|
||||
|
||||
return $query->orderBy('board_position')->orderBy('id');
|
||||
}
|
||||
|
||||
/**
|
||||
* A continuing job runs past its due date by nature, so it is never late.
|
||||
*/
|
||||
private function isLate(JobStatus $status, ?string $dueOn, string $today): bool
|
||||
{
|
||||
return $dueOn !== null && $dueOn < $today && $status->isOpen() && $status !== JobStatus::Ongoing;
|
||||
}
|
||||
|
||||
private function hoursText(?string $hours): ?string
|
||||
{
|
||||
return $hours === null ? null : rtrim(rtrim($hours, '0'), '.');
|
||||
}
|
||||
|
||||
/**
|
||||
* The first service unit's name of each job.
|
||||
*
|
||||
* @param list<int> $jobIds
|
||||
* @return array<int, string>
|
||||
*/
|
||||
private function firstServiceUnitNames(array $jobIds): array
|
||||
{
|
||||
/** @var Collection<int, object{customer_job_id: int, service_unit_id: int}> $rows */
|
||||
$rows = DB::table('customer_job_service_unit')
|
||||
->whereIn('customer_job_id', $jobIds)
|
||||
->orderBy('service_unit_id')
|
||||
->get(['customer_job_id', 'service_unit_id']);
|
||||
$names = $this->catalog->serviceUnitNames($rows->pluck('service_unit_id')->map(fn ($id): int => (int) $id)->unique()->values()->all());
|
||||
$first = [];
|
||||
|
||||
foreach ($rows as $row) {
|
||||
$first[(int) $row->customer_job_id] ??= $names[(int) $row->service_unit_id] ?? null;
|
||||
}
|
||||
|
||||
return array_filter($first, fn (?string $name): bool => $name !== null);
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,9 @@ use App\Modules\Customers\Application\Contracts\CustomerReferences;
|
||||
use App\Modules\Customers\Application\Contracts\CustomerRowUsage;
|
||||
use App\Modules\Jobs\Application\Contracts\ChecklistQueries;
|
||||
use App\Modules\Jobs\Application\Contracts\CustomerJobQueries;
|
||||
use App\Modules\Jobs\Application\Contracts\JobBoardQueries;
|
||||
use App\Modules\Jobs\Application\Contracts\JobOverviewQueries;
|
||||
use App\Modules\Jobs\Application\Contracts\LoggedJobHours;
|
||||
use App\Modules\Jobs\Application\Contracts\TaskCalendarQueries;
|
||||
use App\Modules\Jobs\Application\Contracts\TaskCommentQueries;
|
||||
use App\Modules\Jobs\Application\Contracts\TaskImageFiles;
|
||||
@@ -15,6 +17,7 @@ use App\Modules\Jobs\Application\Contracts\TaskImageQueries;
|
||||
use App\Modules\Jobs\Application\Contracts\TaskQueries;
|
||||
use App\Modules\Jobs\Application\Contracts\TaskUsage;
|
||||
use App\Modules\Jobs\Application\Contracts\UpcomingTasks;
|
||||
use App\Modules\Jobs\Domain\Contracts\BoardRepository;
|
||||
use App\Modules\Jobs\Domain\Contracts\ChecklistItemRepository;
|
||||
use App\Modules\Jobs\Domain\Contracts\CustomerJobRepository;
|
||||
use App\Modules\Jobs\Domain\Contracts\JobNumberSequence;
|
||||
@@ -25,12 +28,15 @@ use App\Modules\Jobs\Domain\Contracts\TaskRepository;
|
||||
use App\Modules\Jobs\Infrastructure\CustomerReferencesFromJobs;
|
||||
use App\Modules\Jobs\Infrastructure\CustomerRowUsageFromJobs;
|
||||
use App\Modules\Jobs\Infrastructure\Files\GdTaskImageFiles;
|
||||
use App\Modules\Jobs\Infrastructure\NoLoggedJobHours;
|
||||
use App\Modules\Jobs\Infrastructure\NothingUsesTasks;
|
||||
use App\Modules\Jobs\Infrastructure\Persistence\DatabaseJobNumberSequence;
|
||||
use App\Modules\Jobs\Infrastructure\Persistence\Repositories\EloquentBoardRepository;
|
||||
use App\Modules\Jobs\Infrastructure\Persistence\Repositories\EloquentChecklistItemRepository;
|
||||
use App\Modules\Jobs\Infrastructure\Persistence\Repositories\EloquentChecklistQueries;
|
||||
use App\Modules\Jobs\Infrastructure\Persistence\Repositories\EloquentCustomerJobQueries;
|
||||
use App\Modules\Jobs\Infrastructure\Persistence\Repositories\EloquentCustomerJobRepository;
|
||||
use App\Modules\Jobs\Infrastructure\Persistence\Repositories\EloquentJobBoardQueries;
|
||||
use App\Modules\Jobs\Infrastructure\Persistence\Repositories\EloquentJobOverviewQueries;
|
||||
use App\Modules\Jobs\Infrastructure\Persistence\Repositories\EloquentTaskBookingRepository;
|
||||
use App\Modules\Jobs\Infrastructure\Persistence\Repositories\EloquentTaskCalendarQueries;
|
||||
@@ -75,6 +81,10 @@ class JobsServiceProvider extends ServiceProvider
|
||||
UpcomingTasks::class => EloquentUpcomingTasks::class,
|
||||
// Replaced by the TimeTracking module, which knows which tasks have time entries.
|
||||
TaskUsage::class => NothingUsesTasks::class,
|
||||
BoardRepository::class => EloquentBoardRepository::class,
|
||||
JobBoardQueries::class => EloquentJobBoardQueries::class,
|
||||
// Replaced by the TimeTracking module, which records the hours.
|
||||
LoggedJobHours::class => NoLoggedJobHours::class,
|
||||
];
|
||||
|
||||
public function register(): void
|
||||
|
||||
@@ -175,7 +175,7 @@ new class extends Component
|
||||
</x-select.native>
|
||||
|
||||
@if ($this->isSubcontractor())
|
||||
<p class="text-sm text-zinc-600 dark:text-zinc-300">{{ __('jobs.list.subcontractor_note') }}</p>
|
||||
<p class="text-sm text-zinc-600 dark:text-zinc-200">{{ __('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')" />
|
||||
@@ -209,6 +209,7 @@ new class extends Component
|
||||
'in_production' => 'border-t-primary-500',
|
||||
'on_hold' => 'border-t-amber-500',
|
||||
'done', 'billed' => 'border-t-emerald-500',
|
||||
'ongoing' => 'border-t-teal-500',
|
||||
default => 'border-t-zinc-400',
|
||||
}])
|
||||
>
|
||||
@@ -245,7 +246,7 @@ new class extends Component
|
||||
</x-link>
|
||||
</h3>
|
||||
|
||||
<p class="break-words text-zinc-700 dark:text-zinc-300">{{ $job->customerName }}</p>
|
||||
<p class="break-words text-zinc-700 dark:text-zinc-200">{{ $job->customerName }}</p>
|
||||
|
||||
<div class="flex flex-wrap gap-x-4 gap-y-1">
|
||||
<x-jobs.priority :priority="$job->priority" />
|
||||
|
||||
@@ -509,7 +509,7 @@ new class extends Component
|
||||
<div class="mx-auto max-w-[120rem] space-y-6 p-4 sm:p-6">
|
||||
<div class="space-y-1">
|
||||
<x-page-title icon="calendar-days">{{ __('jobs.calendar.title') }}</x-page-title>
|
||||
<p class="max-w-3xl text-sm text-zinc-600 dark:text-zinc-300">{{ __('jobs.calendar.intro') }}</p>
|
||||
<p class="max-w-3xl text-sm text-zinc-600 dark:text-zinc-200">{{ __('jobs.calendar.intro') }}</p>
|
||||
</div>
|
||||
|
||||
<div class="card flex flex-wrap items-end gap-4">
|
||||
@@ -530,7 +530,7 @@ new class extends Component
|
||||
</div>
|
||||
|
||||
@if ($this->isSubcontractor())
|
||||
<p class="pb-2 text-sm text-zinc-600 dark:text-zinc-300">{{ __('jobs.calendar.subcontractor_note') }}</p>
|
||||
<p class="pb-2 text-sm text-zinc-600 dark:text-zinc-200">{{ __('jobs.calendar.subcontractor_note') }}</p>
|
||||
@else
|
||||
<div class="pb-2">
|
||||
<x-checkbox id="calendar-only-mine" wire:model.live="mine" :label="__('jobs.calendar.only_mine')" />
|
||||
@@ -623,7 +623,7 @@ new class extends Component
|
||||
@class([
|
||||
'pointer-events-none px-1 pt-1 text-right text-xs whitespace-nowrap',
|
||||
'font-semibold text-amber-900 dark:text-amber-200' => $booked > $this->capacityMinutes,
|
||||
'text-zinc-600 dark:text-zinc-300' => $booked === 0,
|
||||
'text-zinc-600 dark:text-zinc-200' => $booked === 0,
|
||||
])
|
||||
style="grid-column: {{ $index + 2 }}; grid-row: 1;"
|
||||
>
|
||||
@@ -751,7 +751,7 @@ new class extends Component
|
||||
<h3 id="agenda-{{ $rowKey }}-name" class="font-semibold break-words">{{ $row->name }}</h3>
|
||||
|
||||
@if ($row->bars === [])
|
||||
<p class="text-sm text-zinc-600 dark:text-zinc-300">{{ __('jobs.calendar.no_tasks') }}</p>
|
||||
<p class="text-sm text-zinc-600 dark:text-zinc-200">{{ __('jobs.calendar.no_tasks') }}</p>
|
||||
@else
|
||||
<ul class="space-y-2">
|
||||
@foreach ($row->bars as $bar)
|
||||
@@ -793,7 +793,7 @@ new class extends Component
|
||||
@if ($this->unscheduled === [])
|
||||
<x-empty-state icon="calendar-days">{{ __('jobs.calendar.unscheduled_none') }}</x-empty-state>
|
||||
@else
|
||||
<p class="text-sm text-zinc-600 dark:text-zinc-300">{{ __('jobs.calendar.unscheduled_intro') }}</p>
|
||||
<p class="text-sm text-zinc-600 dark:text-zinc-200">{{ __('jobs.calendar.unscheduled_intro') }}</p>
|
||||
|
||||
<ul class="grid gap-2 sm:grid-cols-2 xl:grid-cols-4">
|
||||
@foreach ($this->unscheduled as $task)
|
||||
|
||||
@@ -470,7 +470,7 @@ new class extends Component
|
||||
|
||||
<p id="tags-label" class="text-sm font-semibold text-gray-700 dark:text-dark-300">{{ __('jobs.fields.tags') }}</p>
|
||||
@if ($form->tags === [])
|
||||
<p class="text-sm text-zinc-600 dark:text-zinc-300">{{ __('jobs.tags.none') }}</p>
|
||||
<p class="text-sm text-zinc-600 dark:text-zinc-200">{{ __('jobs.tags.none') }}</p>
|
||||
@else
|
||||
<ul aria-labelledby="tags-label" class="flex flex-wrap gap-2">
|
||||
@foreach ($form->tags as $index => $tag)
|
||||
@@ -498,7 +498,7 @@ new class extends Component
|
||||
<p class="text-sm font-semibold text-gray-700 dark:text-dark-300">{{ __('jobs.fields.links') }}</p>
|
||||
|
||||
@if ($form->links === [])
|
||||
<p class="text-sm text-zinc-600 dark:text-zinc-300">{{ __('jobs.links.none') }}</p>
|
||||
<p class="text-sm text-zinc-600 dark:text-zinc-200">{{ __('jobs.links.none') }}</p>
|
||||
@endif
|
||||
|
||||
@foreach ($form->links as $index => $link)
|
||||
|
||||
@@ -114,7 +114,7 @@ new class extends Component
|
||||
@endif
|
||||
|
||||
@if ($this->isSubcontractor())
|
||||
<p class="text-sm text-zinc-600 dark:text-zinc-300">{{ __('jobs.list.subcontractor_note') }}</p>
|
||||
<p class="text-sm text-zinc-600 dark:text-zinc-200">{{ __('jobs.list.subcontractor_note') }}</p>
|
||||
@endif
|
||||
|
||||
<div class="grid gap-4 rounded-xl border border-zinc-200 bg-white p-4 shadow-sm md:grid-cols-2 xl:grid-cols-4 dark:border-zinc-700 dark:bg-zinc-900">
|
||||
@@ -158,7 +158,7 @@ new class extends Component
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p role="status" aria-live="polite" aria-atomic="true" class="text-sm text-zinc-600 dark:text-zinc-300">
|
||||
<p role="status" aria-live="polite" aria-atomic="true" class="text-sm text-zinc-600 dark:text-zinc-100">
|
||||
{{ trans_choice('jobs.list.result_count', $this->jobs->total(), ['count' => $this->jobs->total()]) }}
|
||||
@if ($mine && ! $this->isSubcontractor())
|
||||
– {{ __('jobs.list.only_mine_description') }}
|
||||
|
||||
@@ -104,7 +104,7 @@ new class extends Component
|
||||
<div class="mx-auto max-w-lg space-y-6 p-4 sm:p-6">
|
||||
<div class="space-y-1">
|
||||
<x-page-title icon="bolt">{{ __('jobs.quick.title') }}</x-page-title>
|
||||
<p class="text-sm text-zinc-600 dark:text-zinc-300">{{ __('jobs.quick.intro') }}</p>
|
||||
<p class="text-sm text-zinc-600 dark:text-zinc-200">{{ __('jobs.quick.intro') }}</p>
|
||||
</div>
|
||||
|
||||
<div id="quick-created" tabindex="-1" role="status" aria-live="polite" class="focus:outline-none">
|
||||
|
||||
@@ -209,11 +209,11 @@ new class extends Component
|
||||
<div class="space-y-4">
|
||||
<div class="flex flex-wrap items-start justify-between gap-4">
|
||||
<div class="min-w-0 flex-1 space-y-1">
|
||||
<a href="{{ route('jobs.index') }}" wire:navigate class="inline-flex min-h-6 items-center gap-1 rounded-md text-sm font-medium text-primary-700 underline-offset-4 hover:underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-600 dark:text-primary-300 dark:focus-visible:outline-primary-300">
|
||||
<a href="{{ route('jobs.index') }}" wire:navigate class="inline-flex min-h-6 items-center gap-1 rounded-md text-sm font-medium text-primary-700 underline-offset-4 hover:underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-600 dark:text-primary-100 dark:focus-visible:outline-primary-300">
|
||||
<x-icon name="arrow-left" class="size-4" aria-hidden="true" />{{ __('jobs.title') }}
|
||||
</a>
|
||||
<h1 class="text-2xl font-semibold break-words">
|
||||
<span class="whitespace-nowrap text-primary-700 dark:text-primary-300">{{ $job->number }}</span> {{ $job->name }}
|
||||
<span class="whitespace-nowrap text-primary-700 dark:text-primary-100">{{ $job->number }}</span> {{ $job->name }}
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
@@ -349,7 +349,7 @@ new class extends Component
|
||||
|
||||
@can('jobs.manage-tasks', $job->id)
|
||||
@unless ($job->status->allowsTasks())
|
||||
<p class="text-sm text-zinc-600 dark:text-zinc-300">{{ __('jobs.tasks.not_allowed_yet') }}</p>
|
||||
<p class="text-sm text-zinc-600 dark:text-zinc-200">{{ __('jobs.tasks.not_allowed_yet') }}</p>
|
||||
@endunless
|
||||
@endcan
|
||||
|
||||
@@ -588,7 +588,7 @@ new class extends Component
|
||||
<h2 id="links-heading" class="text-xl font-semibold">{{ __('jobs.sections.links') }}</h2>
|
||||
|
||||
@if ($job->links === [])
|
||||
<p class="text-sm text-zinc-600 dark:text-zinc-300">{{ __('jobs.links.none') }}</p>
|
||||
<p class="text-sm text-zinc-600 dark:text-zinc-200">{{ __('jobs.links.none') }}</p>
|
||||
@else
|
||||
<ul class="list-disc space-y-1 pl-5 text-sm">
|
||||
@foreach ($job->links as $link)
|
||||
@@ -626,7 +626,7 @@ new class extends Component
|
||||
|
||||
<div id="history-panel" x-show="open" x-cloak>
|
||||
@if ($this->changes === [])
|
||||
<p class="text-sm text-zinc-600 dark:text-zinc-300">{{ __('jobs.history.empty') }}</p>
|
||||
<p class="text-sm text-zinc-600 dark:text-zinc-200">{{ __('jobs.history.empty') }}</p>
|
||||
@else
|
||||
<ol class="space-y-2 text-sm">
|
||||
@foreach ($this->changes as $change)
|
||||
@@ -643,7 +643,7 @@ new class extends Component
|
||||
<span class="font-medium">{{ __('jobs.history.unlocked') }}</span>
|
||||
@endif
|
||||
@endif
|
||||
<span class="block text-zinc-600 dark:text-zinc-300">
|
||||
<span class="block text-zinc-600 dark:text-zinc-200">
|
||||
{{ __('jobs.history.by', ['user' => $change->userName, 'time' => CarbonImmutable::parse($change->changedAt)->format('j.n.Y H.i')]) }}
|
||||
</span>
|
||||
</li>
|
||||
|
||||
@@ -276,7 +276,7 @@ new class extends Component
|
||||
<p role="status" aria-live="polite" class="text-sm">{{ $message }}</p>
|
||||
|
||||
@if ($this->items === [])
|
||||
<p class="text-zinc-600 dark:text-zinc-300">{{ __('jobs.tasks.checklist.empty') }}</p>
|
||||
<p class="text-zinc-600 dark:text-zinc-200">{{ __('jobs.tasks.checklist.empty') }}</p>
|
||||
@else
|
||||
<ul class="space-y-2" aria-label="{{ __('jobs.tasks.checklist.list_of', ['title' => $taskTitle]) }}">
|
||||
@foreach ($this->items as $item)
|
||||
@@ -304,7 +304,7 @@ new class extends Component
|
||||
@else
|
||||
<span class="min-w-0 grow break-words">
|
||||
<span @class(['line-through' => $item->done])>{{ $item->text }}</span>
|
||||
<span class="text-zinc-600 dark:text-zinc-300">({{ $item->done ? __('jobs.tasks.checklist.done') : __('jobs.tasks.checklist.not_done') }})</span>
|
||||
<span class="text-zinc-600 dark:text-zinc-200">({{ $item->done ? __('jobs.tasks.checklist.done') : __('jobs.tasks.checklist.not_done') }})</span>
|
||||
</span>
|
||||
@endif
|
||||
|
||||
|
||||
@@ -289,7 +289,7 @@ new class extends Component
|
||||
<p role="status" aria-live="polite" class="text-sm">{{ $message }}</p>
|
||||
|
||||
@if ($this->comments === [])
|
||||
<p class="text-zinc-600 dark:text-zinc-300">{{ __('jobs.tasks.comments.empty') }}</p>
|
||||
<p class="text-zinc-600 dark:text-zinc-200">{{ __('jobs.tasks.comments.empty') }}</p>
|
||||
@else
|
||||
<ol class="space-y-3">
|
||||
@foreach ($this->comments as $comment)
|
||||
@@ -298,7 +298,7 @@ new class extends Component
|
||||
<li wire:key="task-comment-{{ $comment->id }}" class="space-y-1 rounded-md bg-zinc-50 p-3 dark:bg-zinc-800">
|
||||
<p class="flex flex-wrap gap-x-2">
|
||||
<span class="font-medium">{{ $this->authorName($comment) }}</span>
|
||||
<span class="text-zinc-600 dark:text-zinc-300">
|
||||
<span class="text-zinc-600 dark:text-zinc-200">
|
||||
<time datetime="{{ str_replace(' ', 'T', $comment->createdAt) }}">{{ $at }}</time>
|
||||
@if ($comment->editedAt !== null)
|
||||
({{ __('jobs.tasks.comments.edited', ['at' => $this->formatTime($comment->editedAt)]) }})
|
||||
|
||||
@@ -172,7 +172,7 @@ new class extends Component
|
||||
<div class="mx-auto max-w-2xl space-y-6 p-4 sm:p-6">
|
||||
<div class="space-y-1">
|
||||
<x-page-title icon="clipboard-document-list">{{ $this->heading() }}</x-page-title>
|
||||
<p class="text-sm text-zinc-600 dark:text-zinc-300">
|
||||
<p class="text-sm text-zinc-600 dark:text-zinc-200">
|
||||
{{ __('jobs.tasks.job_label') }}:
|
||||
<x-link :href="route('jobs.show', $jobId)" navigate>{{ $jobTitle }}</x-link>
|
||||
</p>
|
||||
@@ -228,7 +228,7 @@ new class extends Component
|
||||
|
||||
<fieldset class="space-y-2">
|
||||
<legend class="text-sm font-semibold">{{ __('jobs.tasks.schedule') }}</legend>
|
||||
<p class="text-sm text-zinc-600 dark:text-zinc-300">{{ __('jobs.tasks.fields.planned_hint') }}</p>
|
||||
<p class="text-sm text-zinc-600 dark:text-zinc-200">{{ __('jobs.tasks.fields.planned_hint') }}</p>
|
||||
<div class="grid gap-6 sm:grid-cols-2">
|
||||
<x-input wire:model="form.planned_from" type="date" :label="__('jobs.tasks.fields.planned_from')" />
|
||||
<x-input wire:model="form.planned_to" type="date" :label="__('jobs.tasks.fields.planned_to')" />
|
||||
|
||||
@@ -338,7 +338,7 @@ new class extends Component
|
||||
</p>
|
||||
|
||||
@if ($this->images === [])
|
||||
<p class="text-zinc-600 dark:text-zinc-300">{{ __('jobs.tasks.images.empty') }}</p>
|
||||
<p class="text-zinc-600 dark:text-zinc-200">{{ __('jobs.tasks.images.empty') }}</p>
|
||||
@else
|
||||
<ul class="grid grid-cols-1 gap-4 min-[360px]:grid-cols-2 lg:grid-cols-3">
|
||||
@foreach ($this->images as $index => $image)
|
||||
@@ -367,7 +367,7 @@ new class extends Component
|
||||
@if ($image->caption !== null)
|
||||
<span class="block">{{ $image->caption }}</span>
|
||||
@endif
|
||||
<span class="block text-zinc-600 dark:text-zinc-300">
|
||||
<span class="block text-zinc-600 dark:text-zinc-200">
|
||||
{{ $this->uploaderName($image) }}, <time datetime="{{ str_replace(' ', 'T', $image->uploadedAt) }}">{{ $this->formatTime($image->uploadedAt) }}</time>
|
||||
</span>
|
||||
</figcaption>
|
||||
@@ -422,8 +422,8 @@ new class extends Component
|
||||
@if ($canUpload)
|
||||
<form wire:submit="add" class="space-y-3">
|
||||
<div class="space-y-1">
|
||||
<label for="image-new-{{ $taskId }}" class="block text-sm font-semibold text-zinc-700 dark:text-zinc-300">{{ __('jobs.tasks.images.new') }}</label>
|
||||
<p id="image-new-{{ $taskId }}-hint" class="text-sm text-zinc-600 dark:text-zinc-300">{{ __('jobs.tasks.images.hint', ['size' => $this::MAX_KILOBYTES / 1024]) }}</p>
|
||||
<label for="image-new-{{ $taskId }}" class="block text-sm font-semibold text-zinc-700 dark:text-zinc-200">{{ __('jobs.tasks.images.new') }}</label>
|
||||
<p id="image-new-{{ $taskId }}-hint" class="text-sm text-zinc-600 dark:text-zinc-200">{{ __('jobs.tasks.images.hint', ['size' => $this::MAX_KILOBYTES / 1024]) }}</p>
|
||||
<input
|
||||
type="file"
|
||||
id="image-new-{{ $taskId }}"
|
||||
|
||||
@@ -215,7 +215,7 @@ new class extends Component
|
||||
<div class="mx-auto max-w-2xl space-y-6 p-4 sm:p-6">
|
||||
<div class="space-y-1">
|
||||
<x-page-title icon="queue-list">{{ __('jobs.tasks.from_template.title') }}</x-page-title>
|
||||
<p class="text-sm text-zinc-600 dark:text-zinc-300">{{ __('jobs.tasks.job_label') }}: {{ $jobTitle }}</p>
|
||||
<p class="text-sm text-zinc-600 dark:text-zinc-200">{{ __('jobs.tasks.job_label') }}: {{ $jobTitle }}</p>
|
||||
</div>
|
||||
|
||||
<p class="text-sm">{{ __('jobs.tasks.from_template.intro') }}</p>
|
||||
@@ -241,7 +241,7 @@ new class extends Component
|
||||
@if (($template = $this->selectedTemplate) !== null)
|
||||
{{-- An input grid is a form, so a native table rather than <x-table>. --}}
|
||||
<div class="space-y-2">
|
||||
<p class="text-sm text-zinc-600 dark:text-zinc-300">{{ __('jobs.tasks.from_template.schedule_help') }}</p>
|
||||
<p class="text-sm text-zinc-600 dark:text-zinc-200">{{ __('jobs.tasks.from_template.schedule_help') }}</p>
|
||||
|
||||
{{-- Below sm the rows stack (each cell on its own line, with its own visible label) so that the page reflows at 320 px. --}}
|
||||
<table class="w-full border-collapse text-sm">
|
||||
@@ -259,7 +259,7 @@ new class extends Component
|
||||
<tr wire:key="row-{{ $template->id }}-{{ $index }}" class="border-b border-zinc-200 align-top max-sm:block max-sm:py-2 dark:border-zinc-700">
|
||||
<th scope="row" class="py-2 pr-2 text-left font-normal break-words max-sm:block max-sm:py-0">
|
||||
<span class="font-medium">{{ $step->title }}</span>
|
||||
<span class="block text-xs text-zinc-600 dark:text-zinc-300">{{ $step->workTypeName }}</span>
|
||||
<span class="block text-xs text-zinc-600 dark:text-zinc-200">{{ $step->workTypeName }}</span>
|
||||
</th>
|
||||
<td class="px-1 py-2 max-sm:block max-sm:px-0 max-sm:py-1">
|
||||
<span class="block text-xs font-medium sm:hidden" aria-hidden="true">{{ __('jobs.tasks.fields.due_on') }}</span>
|
||||
@@ -317,7 +317,7 @@ new class extends Component
|
||||
aria-describedby="schedule-to-due-dates-hint"
|
||||
:label="__('jobs.tasks.from_template.schedule_to_due')"
|
||||
/>
|
||||
<p id="schedule-to-due-dates-hint" class="text-sm text-zinc-600 dark:text-zinc-300">{{ __('jobs.tasks.from_template.schedule_to_due_hint') }}</p>
|
||||
<p id="schedule-to-due-dates-hint" class="text-sm text-zinc-600 dark:text-zinc-200">{{ __('jobs.tasks.from_template.schedule_to_due_hint') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
Reference in New Issue
Block a user