Files
Toiminnanohjaus/app/Modules/Inventory/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

170 lines
6.6 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
use App\Modules\Inventory\Application\Contracts\StockQueries;
use App\Modules\Inventory\Application\DTOs\StockGroupSummary;
use App\Modules\Inventory\Application\DTOs\StockItemSummary;
use App\Modules\Inventory\Presentation\Livewire\Concerns\FormatsStock;
use Illuminate\Support\Facades\Gate;
use Livewire\Attributes\Computed;
use Livewire\Attributes\Url;
use Livewire\Component;
/**
* The stock list (spec 19.1): items with their balances, searched by name
* or code and filtered by group and "only items to order". Management also
* sees the average costs and the stock value.
*/
new class extends Component
{
use FormatsStock;
#[Url(as: 'haku', except: '')]
public string $search = '';
#[Url(as: 'ryhma', except: '')]
public string $group = '';
#[Url(as: 'tilattavat', except: false)]
public bool $onlyReorder = false;
public bool $includeInactive = false;
public function mount(): void
{
$this->authorize('inventory.view');
}
/**
* @return list<StockItemSummary>
*/
#[Computed]
public function items(): array
{
return app(StockQueries::class)->items(
$this->search,
$this->group === '' ? null : (int) $this->group,
$this->onlyReorder,
$this->includeInactive && Gate::allows('inventory.manage'),
);
}
/**
* @return list<StockGroupSummary>
*/
#[Computed]
public function groups(): array
{
return app(StockQueries::class)->groups(includeInactive: false);
}
public function updated(): void
{
$this->authorize('inventory.view');
unset($this->items);
}
/**
* @return list<array{index: string, label: string, sortable: bool, align?: string}>
*/
public function headers(): array
{
$headers = [
['index' => 'name', 'label' => __('inventory.columns.name'), 'sortable' => false],
['index' => 'group', 'label' => __('inventory.columns.group'), 'sortable' => false],
['index' => 'balance', 'label' => __('inventory.columns.balance'), 'sortable' => false, 'align' => 'right'],
['index' => 'reorder', 'label' => __('inventory.columns.reorder_level'), 'sortable' => false, 'align' => 'right'],
['index' => 'status', 'label' => __('inventory.columns.status'), 'sortable' => false],
];
if (Gate::allows('inventory.see-value')) {
$headers[] = ['index' => 'cost', 'label' => __('inventory.columns.average_cost'), 'sortable' => false, 'align' => 'right'];
$headers[] = ['index' => 'value', 'label' => __('inventory.columns.value'), 'sortable' => false, 'align' => 'right'];
}
return $headers;
}
public function render(): mixed
{
return $this->view()->title(__('inventory.index.title'));
}
};
?>
<div class="mx-auto max-w-6xl space-y-6 p-4 sm:p-6">
<div class="space-y-2">
<x-page-title icon="archive-box">{{ __('inventory.index.title') }}</x-page-title>
<p class="text-sm text-zinc-600 dark:text-zinc-300">{{ __('inventory.index.intro') }}</p>
@can('inventory.manage')
<div class="flex flex-wrap gap-3">
<x-button :href="route('inventory.items.create')" wire:navigate icon="plus" :text="__('inventory.index.new_item')" />
<x-button :href="route('inventory.groups')" wire:navigate subtle color="black" icon="folder" :text="__('inventory.index.groups')" />
</div>
@endcan
</div>
<div class="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
<x-input id="stock-search" wire:model.live.debounce.300ms="search" type="search" icon="magnifying-glass" :label="__('inventory.index.search')" autocomplete="off" />
{{-- TallStackUI's native select does not tie its label to the control, so aria-label names it. --}}
<x-select.native id="stock-group" wire:model.live="group" :label="__('inventory.index.group')" :aria-label="__('inventory.index.group')">
<option value="">{{ __('inventory.index.all_groups') }}</option>
@foreach ($this->groups as $option)
<option value="{{ $option->id }}">{{ $option->name }}</option>
@endforeach
</x-select.native>
<div class="flex flex-col justify-end gap-2">
<x-checkbox id="only-reorder" wire:model.live="onlyReorder" :label="__('inventory.index.only_reorder')" />
@can('inventory.manage')
<x-checkbox id="include-inactive" wire:model.live="includeInactive" :label="__('inventory.index.include_inactive')" />
@endcan
</div>
</div>
<p role="status" aria-live="polite" class="text-sm font-medium">
{{ trans_choice('inventory.index.count', count($this->items), ['count' => count($this->items)]) }}
</p>
@if ($this->items === [])
<x-empty-state icon="archive-box">{{ __('inventory.index.none') }}</x-empty-state>
@else
<x-table :headers="$this->headers()" :rows="$this->items">
@interact('column_name', $item)
<x-link :href="route('inventory.items.show', $item->id)" navigate class="whitespace-normal">{{ $item->name }}</x-link>
@if ($item->code !== null)
<span class="block text-xs text-zinc-600 dark:text-zinc-300">{{ $item->code }}</span>
@endif
@endinteract
@interact('column_group', $item)
<span class="whitespace-normal">{{ $item->groupName }}</span>
@endinteract
@interact('column_balance', $item)
<span class="whitespace-nowrap">{{ $this->quantity($item->balanceMilli, $item->unit) }}</span>
@endinteract
@interact('column_reorder', $item)
<span class="whitespace-nowrap">{{ $item->reorderLevelMilli === null ? '–' : $this->quantity($item->reorderLevelMilli, $item->unit) }}</span>
@endinteract
@interact('column_status', $item)
<x-inventory.stock-status :item="$item" />
@endinteract
@interact('column_cost', $item)
<span class="whitespace-nowrap">{{ $this->unitCost($item->averageCostHundredths) }}</span>
@endinteract
@interact('column_value', $item)
<span class="whitespace-nowrap">{{ $this->money($item->valueCents) }}</span>
@endinteract
</x-table>
@can('inventory.see-value')
<p class="text-right font-semibold">{{ __('inventory.index.total_value', ['value' => $this->money(array_sum(array_map(fn ($item) => $item->valueCents, $this->items)))]) }}</p>
@endcan
@endif
</div>