diff --git a/app/Filament/Tenant/Resources/LaborResource/Pages/ListLabors.php b/app/Filament/Tenant/Resources/LaborResource/Pages/ListLabors.php index 4554550..e5a8f86 100644 --- a/app/Filament/Tenant/Resources/LaborResource/Pages/ListLabors.php +++ b/app/Filament/Tenant/Resources/LaborResource/Pages/ListLabors.php @@ -7,6 +7,7 @@ use App\Models\Tenant\Labor; use App\Models\Tenant\LaborCategory; use Filament\Actions; use Filament\Resources\Pages\ListRecords; +use Livewire\Attributes\Url; class ListLabors extends ListRecords { @@ -14,6 +15,14 @@ class ListLabors extends ListRecords protected string $view = 'filament.tenant.resources.labor.list-labors'; + #[Url(as: 'view')] + public string $viewMode = 'list'; + + public function setViewMode(string $mode): void + { + $this->viewMode = in_array($mode, ['list', 'tree']) ? $mode : 'list'; + } + protected function getHeaderActions(): array { return [Actions\CreateAction::make()]; @@ -25,10 +34,9 @@ class ListLabors extends ListRecords $labors = Labor::orderBy('name_ro')->get()->groupBy('category'); return $cats->map(fn ($cat) => (object) [ - 'id' => $cat->id, 'label' => $cat->label(), 'name' => $cat->name, 'items' => $labors->get($cat->name, collect()), - ])->filter(fn ($c) => $c->items->isNotEmpty()); + ])->filter(fn ($c) => $c->items->isNotEmpty())->values(); } } diff --git a/resources/views/filament/tenant/resources/labor/list-labors.blade.php b/resources/views/filament/tenant/resources/labor/list-labors.blade.php index 5889697..33b910f 100644 --- a/resources/views/filament/tenant/resources/labor/list-labors.blade.php +++ b/resources/views/filament/tenant/resources/labor/list-labors.blade.php @@ -1,149 +1,145 @@ -
- - {{-- ── View toggle bar ── --}} -
- - {{-- Expand / Collapse all (only in tree mode) --}} - - - - - - {{-- Toggle buttons --}} -
- - -
+{{-- ── Toggle bar ── --}} +
+
+ +
- - {{-- ── LIST mode: standard Filament table ── --}} -
- {{ $this->table }} -
- - {{-- ── TREE mode: category accordion ── --}} -
- - @php $tree = $this->getLaborTree(); @endphp - - @forelse ($tree as $cat) -
- - {{-- Category header --}} - - - {{-- Labor items --}} -
- - - - - - - - - - - - - @foreach ($cat->items as $labor) - - - - - - - - - @endforeach - -
{{ __('Manoperă') }}{{ __('Mod') }}{{ __('Ore') }}{{ __('Preț') }}{{ __('Cost') }}
- {{ $labor->label() }} - @if ($labor->code) - {{ $labor->code }} - @endif - @if (! $labor->is_active) - {{ __('Inactiv') }} - @endif - - - {{ $labor->pricing_mode === 'fixed' ? __('Fix') : __('Pe oră') }} - - - {{ $labor->pricing_mode === 'hourly' ? rtrim(rtrim(number_format((float)$labor->hours, 2), '0'), '.') : '—' }} - - {{ number_format((float)($labor->pricing_mode === 'fixed' ? $labor->fixed_price : $labor->price), 2, '.', ' ') }} MDL - - {{ $labor->cost_price > 0 ? number_format((float)$labor->cost_price, 2, '.', ' ') . ' MDL' : '—' }} - - - {{ __('Editează') }} - -
-
-
- @empty -
{{ __('Nicio manoperă găsită.') }}
- @endforelse -
-
+{{-- ── LIST mode ── --}} +@if ($this->viewMode === 'list') + {{ $this->table }} +@endif + +{{-- ── TREE mode ── --}} +@if ($this->viewMode === 'tree') + @php $tree = $this->getLaborTree(); @endphp + +
implode('; ') }}"> + + {{-- Open/close all --}} +
+ + +
+ + {{-- Category panels --}} +
+ @foreach ($tree as $i => $cat) +
+ + {{-- Header --}} + + + {{-- Items table --}} +
+ + + + + + + + + + + + + @foreach ($cat->items as $labor) + + + + + + + + + @endforeach + +
{{ __('Denumire') }}{{ __('Mod') }}{{ __('Ore') }}{{ __('Preț') }}{{ __('Cost') }}
+ {{ $labor->label() }} + @if ($labor->code) + {{ $labor->code }} + @endif + @if (! $labor->is_active) + {{ __('Inactiv') }} + @endif + + + {{ $labor->pricing_mode === 'fixed' ? __('Fix') : __('Pe oră') }} + + + {{ $labor->pricing_mode === 'hourly' + ? rtrim(rtrim(number_format((float)$labor->hours, 2), '0'), '.') + : '—' }} + + {{ number_format((float)($labor->pricing_mode === 'fixed' ? $labor->fixed_price : $labor->price), 2, '.', ' ') }} MDL + + {{ $labor->cost_price > 0 ? number_format((float)$labor->cost_price, 2, '.', ' ') . ' MDL' : '—' }} + + + {{ __('Editează') }} + +
+
+
+ @endforeach +
+
+@endif +