feat: tree/list view toggle for labor catalog

ListLabors now has a toggle button (persistat în localStorage) care
comută între:
- Listă: tabelul Filament grupat pe categorii (existent)
- Arbore: accordion cu toate categoriile ca noduri colapsabile,
  fiecare cu tabelul manoperelor sale (Manoperă, Mod, Ore, Preț,
  Cost, link Editează); butoane Deschide tot / Închide tot

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-09-11 05:03:03 +00:00
parent 5a3275c2cf
commit 0180f29023
2 changed files with 170 additions and 1 deletions
@@ -3,6 +3,8 @@
namespace App\Filament\Tenant\Resources\LaborResource\Pages;
use App\Filament\Tenant\Resources\LaborResource;
use App\Models\Tenant\Labor;
use App\Models\Tenant\LaborCategory;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
@@ -10,5 +12,23 @@ class ListLabors extends ListRecords
{
protected static string $resource = LaborResource::class;
protected function getHeaderActions(): array { return [Actions\CreateAction::make()]; }
protected string $view = 'filament.tenant.resources.labor.list-labors';
protected function getHeaderActions(): array
{
return [Actions\CreateAction::make()];
}
public function getLaborTree(): \Illuminate\Support\Collection
{
$cats = LaborCategory::orderBy('sort_order')->get();
$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());
}
}