Add the task calendar, holidays, workflow templates and customer removal
Task calendar (/jobs/calendar) replaces per-unit task Kanban columns (K34): a two-week Gantt of tasks per person. Bars move, resize and change person by dragging or through a keyboard dialog. Each task's estimate is booked evenly over working days into task_bookings, and what exceeds the daily maximum (jobs.daily_capacity_hours, 8 h) moves to the next working day. Tasks get planned_from/planned_to on the form. Holidays (/settings/holidays): Finnish public holidays calculated per year, which the admin can take out of use, plus company days off. Also includes the earlier uncommitted work: workflow templates with adding tasks from a template, and removing customers no module refers to. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -0,0 +1,152 @@
|
||||
<?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">
|
||||
<h1 class="text-2xl font-semibold">{{ __('catalog.workflows.title') }}</h1>
|
||||
|
||||
<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-blue-700 dark:border-zinc-500 dark:bg-zinc-800"
|
||||
/>
|
||||
<span aria-hidden="true">{{ __('catalog.actions.active') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
@endinteract
|
||||
</x-table>
|
||||
</section>
|
||||
@empty
|
||||
<p>{{ __('catalog.workflows.none') }}</p>
|
||||
@endforelse
|
||||
</div>
|
||||
Reference in New Issue
Block a user