- 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]>
153 lines
5.9 KiB
PHP
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-200">{{ __('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>
|