setup viste
This commit is contained in:
@@ -55,7 +55,42 @@ class EventoController extends Controller
|
||||
$gruppi = Gruppo::orderBy('nome')->get();
|
||||
$allTags = Tag::orderBy('name')->get();
|
||||
|
||||
return view('eventi.index', compact('eventi', 'gruppi', 'allTags'));
|
||||
$vista = \App\Models\VistaReport::where('user_id', auth()->id())
|
||||
->where('tipo', 'eventi')
|
||||
->where('is_default', true)
|
||||
->first();
|
||||
|
||||
$userVistas = \App\Models\VistaReport::where('user_id', auth()->id())
|
||||
->where('tipo', 'eventi')
|
||||
->orderBy('is_default', 'desc')
|
||||
->orderBy('nome')
|
||||
->get();
|
||||
|
||||
$allColumnDefs = [
|
||||
['key' => 'nome_evento', 'label' => 'Nome Evento'],
|
||||
['key' => 'descrizione_evento', 'label' => 'Descrizione'],
|
||||
['key' => 'tipo_evento', 'label' => 'Tipologia'],
|
||||
['key' => 'tipo_recorrenza', 'label' => 'Ricorrenza'],
|
||||
['key' => 'gruppi', 'label' => 'Gruppi'],
|
||||
['key' => 'responsabili', 'label' => 'Responsabili'],
|
||||
['key' => 'tag', 'label' => 'Tag'],
|
||||
['key' => 'data_specifica', 'label' => 'Data'],
|
||||
['key' => 'created_at', 'label' => 'Creato'],
|
||||
];
|
||||
$defaultVisible = ['nome_evento', 'descrizione_evento', 'tipo_evento', 'tipo_recorrenza', 'gruppi', 'responsabili', '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 = 'eventi';
|
||||
$columnWidths = $vista && $vista->colonne_larghezze ? $vista->colonne_larghezze : [];
|
||||
|
||||
return view('eventi.index', compact('eventi', 'gruppi', 'allTags', 'vista', 'visibleColumns', 'tableColumns', 'entityType', 'columnWidths', 'userVistas'));
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
|
||||
Reference in New Issue
Block a user