Files
Toiminnanohjaus/app/Modules/Machines/Presentation/Livewire/⚡index.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

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-300">{{ __('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-300">
{{ __('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>