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'
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -28,7 +28,27 @@ class GruppoController extends Controller
|
||||
->where('is_default', true)
|
||||
->first();
|
||||
|
||||
$allColumns = ['nome', 'descrizione', 'diocesi', 'livello', 'padre', 'membri', 'responsabili', 'indirizzo', 'citta', 'telefono', 'email', 'tag'];
|
||||
$userVistas = \App\Models\VistaReport::where('user_id', $user->id)
|
||||
->where('tipo', 'gruppi')
|
||||
->orderBy('is_default', 'desc')
|
||||
->orderBy('nome')
|
||||
->get();
|
||||
|
||||
$allColumnDefs = [
|
||||
['key' => 'nome', 'label' => 'Nome'],
|
||||
['key' => 'descrizione', 'label' => 'Descrizione'],
|
||||
['key' => 'diocesi', 'label' => 'Diocesi'],
|
||||
['key' => 'livello', 'label' => 'Livello'],
|
||||
['key' => 'padre', 'label' => 'Gruppo Padre'],
|
||||
['key' => 'membri', 'label' => 'Membri'],
|
||||
['key' => 'responsabili', 'label' => 'Responsabili'],
|
||||
['key' => 'indirizzo', 'label' => 'Indirizzo'],
|
||||
['key' => 'citta', 'label' => 'Città'],
|
||||
['key' => 'telefono', 'label' => 'Telefono'],
|
||||
['key' => 'email', 'label' => 'Email'],
|
||||
['key' => 'tag', 'label' => 'Tag'],
|
||||
];
|
||||
$allColumns = array_column($allColumnDefs, 'key');
|
||||
$defaultVisible = ['nome', 'livello', 'padre', 'membri', 'responsabili', 'tag'];
|
||||
|
||||
if ($vista && !empty($vista->colonne_visibili)) {
|
||||
@@ -37,6 +57,14 @@ class GruppoController extends Controller
|
||||
$visibleColumns = $defaultVisible;
|
||||
}
|
||||
|
||||
$tableColumns = array_map(fn($col) => [
|
||||
'key' => $col['key'],
|
||||
'label' => $col['label'],
|
||||
'visible' => in_array($col['key'], $visibleColumns),
|
||||
], $allColumnDefs);
|
||||
$entityType = 'gruppi';
|
||||
$columnWidths = $vista && $vista->colonne_larghezze ? $vista->colonne_larghezze : [];
|
||||
|
||||
$gruppiQuery = Gruppo::with(['diocesi', 'parent', 'children', 'individui', 'avatar', 'tags']);
|
||||
|
||||
if (request()->filled('tag')) {
|
||||
@@ -79,7 +107,11 @@ class GruppoController extends Controller
|
||||
'visibleColumns',
|
||||
'viewMode',
|
||||
'vista',
|
||||
'allTags'
|
||||
'allTags',
|
||||
'tableColumns',
|
||||
'entityType',
|
||||
'columnWidths',
|
||||
'userVistas'
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -5,14 +5,15 @@ namespace App\Http\Controllers;
|
||||
use App\Models\Individuo;
|
||||
use App\Models\Contatto;
|
||||
use App\Models\Documento;
|
||||
use App\Models\Gruppo;
|
||||
use App\Models\Comune;
|
||||
use App\Models\Diocesi;
|
||||
use App\Models\Tag;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
use App\Models\Gruppo;
|
||||
use App\Models\Comune;
|
||||
use App\Models\Diocesi;
|
||||
use App\Models\Tag;
|
||||
use App\Models\VistaReport;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
|
||||
class IndividuoController extends Controller
|
||||
{
|
||||
@@ -50,9 +51,20 @@ class IndividuoController extends Controller
|
||||
['key' => 'codice', 'label' => 'Codice'],
|
||||
['key' => 'cognome', 'label' => 'Cognome'],
|
||||
['key' => 'nome', 'label' => 'Nome'],
|
||||
['key' => 'data_nascita', 'label' => 'Data Nascita'],
|
||||
['key' => 'genere', 'label' => 'Genere'],
|
||||
['key' => 'indirizzo', 'label' => 'Indirizzo'],
|
||||
['key' => 'cap', 'label' => 'CAP'],
|
||||
['key' => 'citta', 'label' => 'Città'],
|
||||
['key' => 'provincia', 'label' => 'Provincia'],
|
||||
['key' => 'tipo_documento', 'label' => 'Tipo Documento'],
|
||||
['key' => 'numero_documento', 'label' => 'Numero Documento'],
|
||||
['key' => 'scadenza_documento', 'label' => 'Scadenza Documento'],
|
||||
['key' => 'email', 'label' => 'Email'],
|
||||
['key' => 'telefono', 'label' => 'Telefono'],
|
||||
['key' => 'note', 'label' => 'Note'],
|
||||
['key' => 'tag', 'label' => 'Tag'],
|
||||
['key' => 'created_at', 'label' => 'Creato il'],
|
||||
];
|
||||
|
||||
$defaultVisible = ['codice', 'cognome', 'nome', 'email', 'telefono', 'tag'];
|
||||
@@ -60,8 +72,22 @@ class IndividuoController extends Controller
|
||||
? $vista->colonne_visibili
|
||||
: $defaultVisible;
|
||||
|
||||
$entityType = 'individui';
|
||||
$tableColumns = array_map(fn($col) => [
|
||||
'key' => $col['key'],
|
||||
'label' => $col['label'],
|
||||
'visible' => in_array($col['key'], $visibleColumns),
|
||||
], $allColumns);
|
||||
$columnWidths = $vista && $vista->colonne_larghezze ? $vista->colonne_larghezze : [];
|
||||
|
||||
$userVistas = VistaReport::where('user_id', auth()->id())
|
||||
->where('tipo', 'individui')
|
||||
->orderBy('is_default', 'desc')
|
||||
->orderBy('nome')
|
||||
->get();
|
||||
|
||||
$gruppi = Gruppo::orderBy('nome')->get(['id', 'nome']);
|
||||
return view('individui.index', compact('individui', 'vista', 'allColumns', 'visibleColumns', 'allTags', 'gruppi'));
|
||||
return view('individui.index', compact('individui', 'vista', 'allColumns', 'visibleColumns', 'allTags', 'gruppi', 'entityType', 'tableColumns', 'columnWidths', 'userVistas'));
|
||||
}
|
||||
|
||||
public function exportCSV(Request $request)
|
||||
|
||||
@@ -20,7 +20,40 @@ class MailingListController extends Controller
|
||||
|
||||
$mailingLists = $query->orderBy('nome')->get();
|
||||
$allTags = Tag::orderBy('name')->get();
|
||||
return view('mailing-liste.index', compact('mailingLists', 'allTags'));
|
||||
|
||||
$vista = \App\Models\VistaReport::where('user_id', auth()->id())
|
||||
->where('tipo', 'mailing-liste')
|
||||
->where('is_default', true)
|
||||
->first();
|
||||
|
||||
$userVistas = \App\Models\VistaReport::where('user_id', auth()->id())
|
||||
->where('tipo', 'mailing-liste')
|
||||
->orderBy('is_default', 'desc')
|
||||
->orderBy('nome')
|
||||
->get();
|
||||
|
||||
$allColumnDefs = [
|
||||
['key' => 'nome', 'label' => 'Nome'],
|
||||
['key' => 'descrizione', 'label' => 'Descrizione'],
|
||||
['key' => 'contatti_count', 'label' => 'Contatti'],
|
||||
['key' => 'tag', 'label' => 'Tag'],
|
||||
['key' => 'attiva', 'label' => 'Stato'],
|
||||
['key' => 'created_at', 'label' => 'Creata il'],
|
||||
];
|
||||
$defaultVisible = ['nome', 'descrizione', 'contatti_count', 'tag', 'attiva', '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 = 'mailing-liste';
|
||||
$columnWidths = $vista && $vista->colonne_larghezze ? $vista->colonne_larghezze : [];
|
||||
|
||||
return view('mailing-liste.index', compact('mailingLists', 'allTags', 'vista', 'visibleColumns', 'tableColumns', 'entityType', 'columnWidths', 'userVistas'));
|
||||
}
|
||||
|
||||
public function create()
|
||||
|
||||
@@ -33,9 +33,11 @@ class VistaReportController extends Controller
|
||||
$this->authorizeWrite('viste');
|
||||
$data = $request->validate([
|
||||
'nome' => 'required|string|max:255',
|
||||
'tipo' => 'required|in:individui,gruppi,documenti,eventi',
|
||||
'tipo' => 'required|in:individui,gruppi,documenti,eventi,mailing-liste',
|
||||
'colonne_visibili' => 'nullable|array',
|
||||
'colonne_ordinamento' => 'nullable|array',
|
||||
'colonne_larghezze' => 'nullable|array',
|
||||
'colonne_ordine' => 'nullable|array',
|
||||
'filtri' => 'nullable|array',
|
||||
'ricerca' => 'nullable|string',
|
||||
'is_default' => 'nullable|boolean',
|
||||
@@ -55,6 +57,8 @@ class VistaReportController extends Controller
|
||||
'tipo' => $data['tipo'],
|
||||
'colonne_visibili' => $data['colonne_visibili'] ?? null,
|
||||
'colonne_ordinamento' => $data['colonne_ordinamento'] ?? null,
|
||||
'colonne_larghezze' => $data['colonne_larghezze'] ?? null,
|
||||
'colonne_ordine' => $data['colonne_ordine'] ?? null,
|
||||
'filtri' => $data['filtri'] ?? null,
|
||||
'ricerca' => $data['ricerca'] ?? null,
|
||||
'is_default' => $isDefault,
|
||||
@@ -78,6 +82,8 @@ class VistaReportController extends Controller
|
||||
'nome' => 'required|string|max:255',
|
||||
'colonne_visibili' => 'nullable|array',
|
||||
'colonne_ordinamento' => 'nullable|array',
|
||||
'colonne_larghezze' => 'nullable|array',
|
||||
'colonne_ordine' => 'nullable|array',
|
||||
'filtri' => 'nullable|array',
|
||||
'ricerca' => 'nullable|string',
|
||||
'is_default' => 'nullable|boolean',
|
||||
@@ -92,6 +98,10 @@ class VistaReportController extends Controller
|
||||
|
||||
$vistaReport->update($data);
|
||||
|
||||
if ($request->expectsJson()) {
|
||||
return response()->json(['success' => true, 'message' => 'Vista aggiornata.']);
|
||||
}
|
||||
|
||||
return back()->with('success', 'Vista aggiornata.');
|
||||
}
|
||||
|
||||
|
||||
@@ -10,13 +10,16 @@ class VistaReport extends Model
|
||||
protected $table = 'viste_report';
|
||||
protected $fillable = [
|
||||
'user_id', 'nome', 'tipo', 'colonne_visibili',
|
||||
'colonne_ordinamento', 'filtri', 'ricerca', 'is_default'
|
||||
'colonne_ordinamento', 'filtri', 'ricerca', 'is_default',
|
||||
'colonne_larghezze', 'colonne_ordine',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'colonne_visibili' => 'array',
|
||||
'colonne_ordinamento' => 'array',
|
||||
'filtri' => 'array',
|
||||
'colonne_larghezze' => 'array',
|
||||
'colonne_ordine' => 'array',
|
||||
];
|
||||
|
||||
public function user(): BelongsTo
|
||||
|
||||
Reference in New Issue
Block a user