Add catalog module for service units, services and work types

Phase 1, item 3: the hierarchy customer jobs, tasks and time entries
will refer to.

- New Catalog module: service unit > optional service > work type.
  Names are unique per level (case-insensitive); items are never
  deleted, only deactivated, and foreign keys restrict deletes.
- Pohjatiedot page (/catalog, admins and management): add, rename,
  reorder with move up/down buttons (keyboard-friendly, focus kept and
  announced) and an "in use" checkbox per row. Work types can move to
  another service of the same unit.
- A migration inserts the starting catalog from the specification when
  the tables are empty, so every installation has it.
- CatalogQueries gives other modules the active service units and the
  work types of chosen units plus the shared ones.
- Spec and CLAUDE.md updated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-11-23 18:27:58 +02:00
co-authored by Claude Opus 5.5
parent e0b8f4970f
commit 51b2d4a252
62 changed files with 3196 additions and 7 deletions
@@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
namespace App\Modules\Catalog\Domain\Contracts;
use App\Modules\Catalog\Domain\Entities\Service;
use App\Modules\Catalog\Domain\Enums\MoveDirection;
/**
* Siblings are the services of one unit.
*/
interface ServiceRepository
{
public function findById(int $id): ?Service;
/**
* Inserts a new item or updates a stored one, and returns the stored item.
*/
public function save(Service $service): Service;
/**
* Whether a sibling other than $exceptId has this name, ignoring case.
*/
public function isNameTaken(int $serviceUnitId, string $name, ?int $exceptId = null): bool;
/**
* The sort order that puts a new item last among its siblings.
*/
public function nextSortOrder(int $serviceUnitId): int;
/**
* The sibling just before or after the item, or null at either end.
*/
public function neighbour(Service $service, MoveDirection $direction): ?Service;
}
@@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
namespace App\Modules\Catalog\Domain\Contracts;
use App\Modules\Catalog\Domain\Entities\ServiceUnit;
use App\Modules\Catalog\Domain\Enums\MoveDirection;
/**
* Siblings are all service units.
*/
interface ServiceUnitRepository
{
public function findById(int $id): ?ServiceUnit;
/**
* Inserts a new item or updates a stored one, and returns the stored item.
*/
public function save(ServiceUnit $serviceUnit): ServiceUnit;
/**
* Whether a sibling other than $exceptId has this name, ignoring case.
*/
public function isNameTaken(string $name, ?int $exceptId = null): bool;
/**
* The sort order that puts a new item last among its siblings.
*/
public function nextSortOrder(): int;
/**
* The sibling just before or after the item, or null at either end.
*/
public function neighbour(ServiceUnit $serviceUnit, MoveDirection $direction): ?ServiceUnit;
}
@@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
namespace App\Modules\Catalog\Domain\Contracts;
use App\Modules\Catalog\Domain\Entities\WorkType;
use App\Modules\Catalog\Domain\Enums\MoveDirection;
/**
* Siblings are the work types under one service, or directly under the unit when $serviceId is null.
*/
interface WorkTypeRepository
{
public function findById(int $id): ?WorkType;
/**
* Inserts a new item or updates a stored one, and returns the stored item.
*/
public function save(WorkType $workType): WorkType;
/**
* Whether a sibling other than $exceptId has this name, ignoring case.
*/
public function isNameTaken(int $serviceUnitId, ?int $serviceId, string $name, ?int $exceptId = null): bool;
/**
* The sort order that puts a new item last among its siblings.
*/
public function nextSortOrder(int $serviceUnitId, ?int $serviceId): int;
/**
* The sibling just before or after the item, or null at either end.
*/
public function neighbour(WorkType $workType, MoveDirection $direction): ?WorkType;
}