Files
Toiminnanohjaus/app/Modules/Catalog/Presentation/Livewire/⚡workflow-templates.blade.php
T
petriandClaude Opus 5.5 51b40b24fe Give the UI an indigo look with cards, status badges and empty states
- 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]>
2026-11-29 10:53:10 +02:00

153 lines
5.9 KiB
PHP

<?php
use App\Modules\Catalog\Application\Contracts\WorkflowTemplateQueries;
use App\Modules\Catalog\Application\DTOs\WorkflowTemplateSummary;
use App\Modules\Catalog\Application\UseCases\SetWorkflowTemplateActive;
use App\Modules\Catalog\Domain\Exceptions\WorkflowTemplateNotFound;
use Livewire\Attributes\Computed;
use Livewire\Component;
/**
* Workflow templates (työnkulkupohjat) grouped by service unit: adding,
* editing and taking out of use.
*/
new class extends Component
{
public string $statusMessage = '';
public function mount(): void
{
$this->authorize('catalog.manage');
}
/**
* @return array<string, list<WorkflowTemplateSummary>>
*/
#[Computed]
public function groups(): array
{
$groups = [];
foreach (app(WorkflowTemplateQueries::class)->all() as $template) {
$groups[$template->serviceUnitName][] = $template;
}
return $groups;
}
public function toggleActive(int $templateId, SetWorkflowTemplateActive $setActive): void
{
$this->authorize('catalog.manage');
$template = app(WorkflowTemplateQueries::class)->find($templateId);
if ($template === null) {
$this->statusMessage = __('catalog.status.not_found');
return;
}
try {
$setActive->execute($templateId, ! $template->isActive);
} catch (WorkflowTemplateNotFound) {
$this->statusMessage = __('catalog.status.not_found');
return;
}
unset($this->groups);
$this->statusMessage = __($template->isActive ? 'catalog.workflows.status.deactivated' : 'catalog.status.activated', ['name' => $template->name]);
}
/**
* @return list<array{index: string, label: string, sortable: bool}>
*/
public function headers(): array
{
return [
['index' => 'name', 'label' => __('catalog.fields.name'), 'sortable' => false],
['index' => 'work_type', 'label' => __('catalog.workflows.work_type'), 'sortable' => false],
['index' => 'steps', 'label' => __('catalog.workflows.step_count'), 'sortable' => false],
['index' => 'actions', 'label' => __('catalog.products.actions'), 'sortable' => false],
];
}
public function render(): mixed
{
return $this->view()->title(__('catalog.workflows.title'));
}
};
?>
<div class="mx-auto max-w-5xl space-y-6 p-4 sm:p-6">
<div class="flex flex-wrap items-center justify-between gap-4">
<x-page-title icon="queue-list">{{ __('catalog.workflows.title') }}</x-page-title>
<x-button :href="route('catalog.workflow-templates.create')" wire:navigate icon="plus" :text="__('catalog.workflows.add')" />
</div>
<div class="space-y-1 text-sm">
<p class="text-zinc-600 dark:text-zinc-300">{{ __('catalog.workflows.intro') }}</p>
<p><x-link :href="route('catalog.index')" navigate>{{ __('catalog.workflows.back_to_catalog') }}</x-link></p>
</div>
@if (session('status'))
<x-alert role="status" color="green" light icon="check-circle" :text="session('status')" />
@endif
<p role="status" aria-live="polite" class="text-sm">{{ $statusMessage }}</p>
@forelse ($this->groups as $unitName => $templates)
<section wire:key="unit-{{ $loop->index }}" aria-labelledby="unit-{{ $loop->index }}-heading" class="space-y-3">
<h2 id="unit-{{ $loop->index }}-heading" class="text-xl font-semibold break-words">{{ $unitName }}</h2>
<x-table :headers="$this->headers()" :rows="$templates">
@interact('column_name', $template)
<span class="font-medium break-words">{{ $template->name }}</span>
@unless ($template->isActive)
<span class="ml-1 text-sm">({{ __('catalog.inactive') }})</span>
@endunless
@endinteract
@interact('column_work_type', $template)
{{ $template->workTypeName }}
@endinteract
@interact('column_steps', $template)
{{ $template->stepCount }}
@endinteract
@interact('column_actions', $template)
<div class="flex flex-wrap items-center gap-2">
<x-button
:href="route('catalog.workflow-templates.edit', $template->id)"
wire:navigate
subtle
color="black"
sm
icon="pencil"
:text="__('catalog.actions.edit')"
:aria-label="__('catalog.actions.edit_named', ['name' => $template->name])"
/>
<label class="inline-flex min-h-6 cursor-pointer items-center gap-2 text-sm">
<input
type="checkbox"
id="active-template-{{ $template->id }}"
wire:click="toggleActive({{ $template->id }})"
@checked($template->isActive)
aria-label="{{ __('catalog.actions.active_named', ['name' => $template->name]) }}"
class="size-4 rounded border-zinc-400 text-primary-600 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-600 dark:focus-visible:outline-primary-300 dark:border-zinc-500 dark:bg-zinc-800"
/>
<span aria-hidden="true">{{ __('catalog.actions.active') }}</span>
</label>
</div>
@endinteract
</x-table>
</section>
@empty
<x-empty-state icon="tag">{{ __('catalog.workflows.none') }}</x-empty-state>
@endforelse
</div>