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:
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user