authorize('catalog.manage'); } /** * @return array> */ #[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 */ 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')); } }; ?>

{{ __('catalog.workflows.title') }}

{{ __('catalog.workflows.intro') }}

{{ __('catalog.workflows.back_to_catalog') }}

@if (session('status')) @endif

{{ $statusMessage }}

@forelse ($this->groups as $unitName => $templates)

{{ $unitName }}

@interact('column_name', $template) {{ $template->name }} @unless ($template->isActive) ({{ __('catalog.inactive') }}) @endunless @endinteract @interact('column_work_type', $template) {{ $template->workTypeName }} @endinteract @interact('column_steps', $template) {{ $template->stepCount }} @endinteract @interact('column_actions', $template)
@endinteract
@empty

{{ __('catalog.workflows.none') }}

@endforelse