- Dark indigo header and tinted page background; the mobile main menu gets its own row, in the same order as the keyboard reaches it. - Page titles with an icon chip (x-page-title, x-page, x-page-header) and card sections (x-panel, the card utility); x-table styled as a card with an indigo header row in AppServiceProvider::styleTables(). - Job and task statuses, late work, unapproved hours and stock states as badges with icon and text (x-status-badge, x-jobs.status, x-jobs.task-status), never colour alone. - Empty lists as x-empty-state; dashboard quick link tiles, week hour bars and trend arrows; Kanban columns and task cards edged by status; calendar today column and bar accents; quick sale, reports and machine console restyled; signed-out pages show the app name. - Focus rings use the primary colour in both themes (white in the header). - Document the components in CLAUDE.md; test the status badges. Co-Authored-By: Claude Opus 5.5 <[email protected]>
112 lines
3.8 KiB
PHP
112 lines
3.8 KiB
PHP
<?php
|
|
|
|
use App\Modules\Catalog\Application\Contracts\CatalogQueries;
|
|
use App\Modules\Catalog\Application\UseCases\AddServiceUnit;
|
|
use App\Modules\Catalog\Application\UseCases\RenameCatalogItem;
|
|
use App\Modules\Catalog\Application\UseCases\SetServiceUnitUsesStock;
|
|
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 (no {serviceUnit}) and edit page (with {serviceUnit}) of a service unit:
|
|
* its name and whether stock and machine features are used in it (spec 19).
|
|
*/
|
|
new class extends Component
|
|
{
|
|
#[Locked]
|
|
public ?int $serviceUnitId = null;
|
|
|
|
#[Locked]
|
|
public string $unitName = '';
|
|
|
|
#[Locked]
|
|
public bool $isShared = false;
|
|
|
|
public bool $usesStock = false;
|
|
|
|
public CatalogItemForm $form;
|
|
|
|
public function mount(CatalogQueries $catalogQueries, ?int $serviceUnit = null): void
|
|
{
|
|
$this->authorize('catalog.manage');
|
|
|
|
if ($serviceUnit === null) {
|
|
return;
|
|
}
|
|
|
|
$summary = $catalogQueries->findServiceUnit($serviceUnit);
|
|
|
|
abort_if($summary === null, 404);
|
|
|
|
$this->serviceUnitId = $summary->id;
|
|
$this->form->name = $summary->name;
|
|
$this->isShared = $summary->isShared;
|
|
$this->usesStock = $summary->usesStock;
|
|
}
|
|
|
|
public function save(AddServiceUnit $addServiceUnit, RenameCatalogItem $renameItem, SetServiceUnitUsesStock $setUsesStock): void
|
|
{
|
|
$this->authorize('catalog.manage');
|
|
|
|
$name = $this->form->validatedName();
|
|
|
|
try {
|
|
if ($this->serviceUnitId === null) {
|
|
$id = $addServiceUnit->execute($name);
|
|
$setUsesStock->execute($id, $this->usesStock);
|
|
session()->flash('status', __('catalog.status.created', ['name' => trim($name)]));
|
|
} else {
|
|
$renameItem->execute(CatalogLevel::ServiceUnit, $this->serviceUnitId, $name);
|
|
$setUsesStock->execute($this->serviceUnitId, $this->usesStock && ! $this->isShared);
|
|
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->serviceUnitId === null ? 'catalog.service_units.create_title' : 'catalog.service_units.edit_title');
|
|
}
|
|
|
|
public function render(): mixed
|
|
{
|
|
return $this->view()->title($this->heading());
|
|
}
|
|
};
|
|
?>
|
|
|
|
<div class="mx-auto max-w-2xl space-y-6 p-4 sm:p-6">
|
|
<div class="space-y-1">
|
|
<x-page-title icon="building-office">{{ $this->heading() }}</x-page-title>
|
|
|
|
</div>
|
|
|
|
<form wire:submit="save" class="card space-y-6" novalidate>
|
|
<x-input wire:model="form.name" :label="__('catalog.fields.name')" autocomplete="off" required />
|
|
|
|
@unless ($isShared)
|
|
<div class="space-y-1">
|
|
<x-checkbox id="uses-stock" wire:model="usesStock" :label="__('catalog.service_units.uses_stock')" />
|
|
<p class="text-sm text-zinc-600 dark:text-zinc-300">{{ __('catalog.service_units.uses_stock_hint') }}</p>
|
|
</div>
|
|
@endunless
|
|
|
|
<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>
|