setup viste
This commit is contained in:
@@ -92,11 +92,45 @@ class DocumentoController extends Controller
|
||||
'children' => $f->children->map(fn($c) => ['id' => $c->id, 'nome' => $c->nome]),
|
||||
]);
|
||||
|
||||
$vista = \App\Models\VistaReport::where('user_id', auth()->id())
|
||||
->where('tipo', 'documenti')
|
||||
->where('is_default', true)
|
||||
->first();
|
||||
|
||||
$userVistas = \App\Models\VistaReport::where('user_id', auth()->id())
|
||||
->where('tipo', 'documenti')
|
||||
->orderBy('is_default', 'desc')
|
||||
->orderBy('nome')
|
||||
->get();
|
||||
|
||||
$allColumnDefs = [
|
||||
['key' => 'nome_file', 'label' => 'Nome'],
|
||||
['key' => 'tipologia', 'label' => 'Tipologia'],
|
||||
['key' => 'dimensione', 'label' => 'Dimensione'],
|
||||
['key' => 'visibilita', 'label' => 'Contesto'],
|
||||
['key' => 'tag', 'label' => 'Tag'],
|
||||
['key' => 'created_at', 'label' => 'Data'],
|
||||
];
|
||||
$defaultVisible = ['nome_file', 'tipologia', 'dimensione', 'visibilita', 'tag', 'created_at'];
|
||||
$visibleColumns = $vista && !empty($vista->colonne_visibili)
|
||||
? $vista->colonne_visibili
|
||||
: $defaultVisible;
|
||||
|
||||
$tableColumns = array_map(fn($col) => [
|
||||
'key' => $col['key'],
|
||||
'label' => $col['label'],
|
||||
'visible' => in_array($col['key'], $visibleColumns),
|
||||
], $allColumnDefs);
|
||||
$entityType = 'documenti';
|
||||
$columnWidths = $vista && $vista->colonne_larghezze ? $vista->colonne_larghezze : [];
|
||||
|
||||
return view('documenti.index', compact(
|
||||
'documenti', 'cartelle', 'currentFolder', 'breadcrumb', 'sottoCartelle',
|
||||
'currentRepo', 'repositories',
|
||||
'individui', 'gruppi', 'eventi', 'mailingLists', 'tipologie',
|
||||
'cartelleMoveOptions', 'allTags'
|
||||
'cartelleMoveOptions', 'allTags',
|
||||
'vista', 'visibleColumns', 'tableColumns', 'entityType', 'columnWidths',
|
||||
'userVistas'
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user