Files
petriandClaude Opus 5.5 f4b58f6b1d Darken the dark canvas, add customer colours, the ongoing status and the board model
- 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]>
2026-11-30 06:11:49 +02:00

140 lines
5.5 KiB
PHP

<?php
use App\Modules\Catalog\Application\Contracts\CatalogQueries;
use App\Modules\Machines\Application\Contracts\MachineQueries;
use App\Modules\Machines\Application\DTOs\MachineSummary;
use Illuminate\Support\Facades\Gate;
use Livewire\Attributes\Computed;
use Livewire\Attributes\Url;
use Livewire\Component;
/**
* Machines grouped by service unit (spec 19.4), filtered by unit. Each
* machine links to its page with the work list.
*/
new class extends Component
{
#[Url(as: 'yksikko', except: '')]
public string $unit = '';
public bool $includeInactive = false;
public function mount(): void
{
$this->authorize('machines.use');
}
/**
* @return array<int, string> Service units that use stock or have machines.
*/
#[Computed]
public function units(): array
{
$ids = array_unique(array_merge(
app(CatalogQueries::class)->stockServiceUnitIds(),
...array_map(fn (MachineSummary $machine): array => $machine->serviceUnitIds, $this->machines),
));
return app(CatalogQueries::class)->serviceUnitNames(array_values($ids));
}
/**
* @return list<MachineSummary>
*/
#[Computed]
public function machines(): array
{
return app(MachineQueries::class)->machines($this->includeInactive && Gate::allows('machines.manage'));
}
/**
* Machines by unit name; a shared machine is under each of its units.
*
* @return array<string, list<MachineSummary>>
*/
public function grouped(): array
{
$groups = [];
foreach ($this->units as $unitId => $unitName) {
if ($this->unit !== '' && (int) $this->unit !== $unitId) {
continue;
}
$machines = array_values(array_filter($this->machines, fn (MachineSummary $machine): bool => in_array($unitId, $machine->serviceUnitIds, true)));
if ($machines !== []) {
$groups[$unitName] = $machines;
}
}
return $groups;
}
public function updated(): void
{
$this->authorize('machines.use');
unset($this->machines, $this->units);
}
public function render(): mixed
{
return $this->view()->title(__('machines.index.title'));
}
};
?>
<div class="mx-auto max-w-5xl space-y-6 p-4 sm:p-6">
<div class="space-y-2">
<x-page-title icon="cpu-chip">{{ __('machines.index.title') }}</x-page-title>
<p class="text-sm text-zinc-600 dark:text-zinc-200">{{ __('machines.index.intro') }}</p>
@can('machines.manage')
<p><x-button :href="route('machines.create')" wire:navigate icon="plus" :text="__('machines.index.new')" /></p>
@endcan
</div>
<div class="flex flex-wrap items-end gap-4">
<div class="w-full max-w-xs">
{{-- TallStackUI's native select does not tie its label to the control, so aria-label names it. --}}
<x-select.native id="machine-unit" wire:model.live="unit" :label="__('machines.index.unit')" :aria-label="__('machines.index.unit')">
<option value="">{{ __('machines.index.all_units') }}</option>
@foreach ($this->units as $unitId => $unitName)
<option value="{{ $unitId }}">{{ $unitName }}</option>
@endforeach
</x-select.native>
</div>
@can('machines.manage')
<x-checkbox id="include-inactive-machines" wire:model.live="includeInactive" :label="__('machines.index.include_inactive')" />
@endcan
</div>
@forelse ($this->grouped() as $unitName => $machines)
<section wire:key="unit-{{ md5($unitName) }}" aria-label="{{ $unitName }}" class="card space-y-2">
<h2 class="text-lg font-semibold">{{ $unitName }}</h2>
<ul class="divide-y divide-zinc-200 rounded-lg border border-zinc-300 dark:divide-zinc-700 dark:border-zinc-600">
@foreach ($machines as $machine)
<li wire:key="machine-{{ md5($unitName) }}-{{ $machine->id }}" class="flex flex-wrap items-center justify-between gap-3 p-3">
<div class="min-w-0 space-y-1">
<p class="font-medium break-words">
<x-link :href="route('machines.show', $machine->id)" navigate :aria-label="__('machines.index.open_named', ['name' => $machine->name])">{{ $machine->name }}</x-link>
</p>
<p class="text-sm text-zinc-700 dark:text-zinc-200">
{{ __('machines.types.'.$machine->type->value) }}
@if ($machine->responsibleName !== null)
· {{ __('machines.index.responsible', ['name' => $machine->responsibleName]) }}
@endif
@unless ($machine->isActive)
· {{ __('machines.index.inactive') }}
@endunless
</p>
</div>
<x-link :href="route('console.handoff', ['to' => route('machines.console', $machine->id)])" blank class="text-sm">{{ __('machines.index.console_named', ['name' => $machine->name]) }}<span class="sr-only"> ({{ __('layout.opens_in_new_window') }})</span></x-link>
</li>
@endforeach
</ul>
</section>
@empty
<x-empty-state icon="cpu-chip">{{ __('machines.index.none') }}</x-empty-state>
@endforelse
</div>