Files
Toiminnanohjaus/app/Modules/Catalog/Presentation/Livewire/⚡service-form.blade.php
T
petriandClaude Opus 5.5 f4b58f6b1d 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]>
2026-11-30 06:11:49 +02:00

105 lines
3.4 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
use App\Modules\Catalog\Application\Contracts\CatalogQueries;
use App\Modules\Catalog\Application\UseCases\AddService;
use App\Modules\Catalog\Application\UseCases\RenameCatalogItem;
use App\Modules\Catalog\Domain\Enums\CatalogLevel;
use App\Modules\Catalog\Domain\Exceptions\CatalogItemNotFound;
use App\Modules\Catalog\Presentation\Livewire\Forms\CatalogItemForm;
use App\Modules\Shared\Domain\Exceptions\DomainException;
use Livewire\Attributes\Locked;
use Livewire\Component;
/**
* Add page (with {serviceUnit}) and edit page (with {service}) of a service.
*/
new class extends Component
{
#[Locked]
public ?int $serviceUnitId = null;
#[Locked]
public ?int $serviceId = null;
#[Locked]
public string $unitName = '';
public CatalogItemForm $form;
public function mount(CatalogQueries $catalogQueries, ?int $serviceUnit = null, ?int $service = null): void
{
$this->authorize('catalog.manage');
if ($service !== null) {
$summary = $catalogQueries->findService($service);
abort_if($summary === null, 404);
$this->serviceId = $summary->id;
$this->form->name = $summary->name;
$serviceUnit = $summary->serviceUnitId;
}
$unit = $serviceUnit === null ? null : $catalogQueries->findServiceUnit($serviceUnit);
abort_if($unit === null || ($unit->isShared && $this->serviceId === null), 404);
$this->serviceUnitId = $unit->id;
$this->unitName = $unit->name;
}
public function save(AddService $addService, RenameCatalogItem $renameItem): void
{
$this->authorize('catalog.manage');
$name = $this->form->validatedName();
try {
if ($this->serviceId === null) {
$addService->execute((int) $this->serviceUnitId, $name);
session()->flash('status', __('catalog.status.created', ['name' => trim($name)]));
} else {
$renameItem->execute(CatalogLevel::Service, $this->serviceId, $name);
session()->flash('status', __('catalog.status.updated', ['name' => trim($name)]));
}
} catch (CatalogItemNotFound) {
abort(404);
} catch (DomainException $exception) {
$this->form->showDomainError($exception);
return;
}
$this->redirectRoute('catalog.index', navigate: true);
}
public function heading(): string
{
return __($this->serviceId === null ? 'catalog.services.create_title' : 'catalog.services.edit_title');
}
public function render(): mixed
{
return $this->view()->title($this->heading().' – '.$this->unitName);
}
};
?>
<div class="mx-auto max-w-2xl space-y-6 p-4 sm:p-6">
<div class="space-y-1">
<x-page-title icon="rectangle-stack">{{ $this->heading() }}</x-page-title>
@if ($unitName !== '')
<p class="text-sm text-zinc-600 dark:text-zinc-200">{{ __('catalog.fields.service_unit') }}: {{ $unitName }}</p>
@endif
</div>
<form wire:submit="save" class="card space-y-6" novalidate>
<x-input wire:model="form.name" :label="__('catalog.fields.name')" autocomplete="off" required />
<div class="flex flex-wrap gap-3">
<x-button submit :text="__('catalog.save')" />
<x-button :href="route('catalog.index')" wire:navigate subtle color="black" :text="__('catalog.cancel')" />
</div>
</form>
</div>