151 lines
9.8 KiB
PHP
Executable File
151 lines
9.8 KiB
PHP
Executable File
<x-filament-panels::page>
|
|
@php
|
|
$matrix = $this->roleMatrixData();
|
|
$rwRows = $this->rwMatrixData();
|
|
@endphp
|
|
<div class="space-y-6">
|
|
<div class="rounded-xl border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-900">
|
|
Qui governi la visibilita dei programmi a livello globale per ruolo e con eccezioni per singolo utente.
|
|
Gli override utente vincono sui default del ruolo.
|
|
</div>
|
|
|
|
<div x-data="{ tab: 'hub' }" class="space-y-4">
|
|
<div class="flex flex-wrap items-center gap-2">
|
|
<button type="button" class="rounded-lg px-3 py-1.5 text-sm font-medium transition"
|
|
:class="tab === 'hub' ? 'bg-sky-600 text-white' : 'bg-slate-100 text-slate-700'"
|
|
x-on:click="tab = 'hub'">
|
|
HUB visibilita
|
|
</button>
|
|
<button type="button" class="rounded-lg px-3 py-1.5 text-sm font-medium transition"
|
|
:class="tab === 'rw' ? 'bg-sky-600 text-white' : 'bg-slate-100 text-slate-700'"
|
|
x-on:click="tab = 'rw'">
|
|
Permessi R/W
|
|
</button>
|
|
<button type="button" class="rounded-lg px-3 py-1.5 text-sm font-medium transition"
|
|
:class="tab === 'manuale' ? 'bg-sky-600 text-white' : 'bg-slate-100 text-slate-700'"
|
|
x-on:click="tab = 'manuale'">
|
|
Scheda esistente
|
|
</button>
|
|
</div>
|
|
|
|
<div x-show="tab === 'hub'" class="space-y-4">
|
|
<div class="rounded-xl border border-slate-200 bg-white p-4 shadow-sm">
|
|
<div class="flex flex-wrap items-start justify-between gap-3">
|
|
<div>
|
|
<div class="text-sm font-semibold text-slate-900">Matrice programmi per ruolo</div>
|
|
<div class="mt-1 text-xs text-slate-600">Checkbox attivo = programma visibile. Reset riporta il ruolo al comportamento di default del catalogo.</div>
|
|
</div>
|
|
<div class="text-xs text-slate-500">Ruoli gestibili: {{ implode(', ', $matrix['roles']) !== '' ? implode(', ', $matrix['roles']) : 'nessuno' }}</div>
|
|
</div>
|
|
|
|
<div class="mt-4 overflow-x-auto">
|
|
<table class="min-w-full divide-y divide-slate-200 text-sm">
|
|
<thead class="bg-slate-50">
|
|
<tr>
|
|
<th class="px-3 py-2 text-left font-semibold text-slate-600">Programma</th>
|
|
@foreach ($matrix['roles'] as $role)
|
|
<th class="px-3 py-2 text-center font-semibold text-slate-600">{{ $role }}</th>
|
|
@endforeach
|
|
</tr>
|
|
</thead>
|
|
<tbody class="divide-y divide-slate-100 bg-white">
|
|
@foreach ($matrix['programs'] as $program)
|
|
<tr>
|
|
<td class="px-3 py-3 align-top">
|
|
<div class="font-medium text-slate-900">{{ $program['label'] }}</div>
|
|
<div class="mt-1 text-xs text-slate-500">{{ $program['key'] }}</div>
|
|
@if (! empty($program['description']))
|
|
<div class="mt-1 text-xs text-slate-500">{{ $program['description'] }}</div>
|
|
@endif
|
|
</td>
|
|
@foreach ($matrix['roles'] as $role)
|
|
@php
|
|
$state = $program['states'][$role] ?? ['visible' => false, 'source' => 'default'];
|
|
$sourceLabel = match ($state['source']) {
|
|
'allow' => 'override on',
|
|
'deny' => 'override off',
|
|
default => 'default',
|
|
};
|
|
@endphp
|
|
<td class="px-3 py-3 align-top text-center">
|
|
<div class="flex flex-col items-center gap-2">
|
|
<input
|
|
type="checkbox"
|
|
class="h-4 w-4 rounded border-slate-300 text-primary-600 focus:ring-primary-500"
|
|
@checked($state['visible'])
|
|
wire:change="setRoleProgramVisibility('{{ $role }}', '{{ $program['key'] }}', $event.target.checked)"
|
|
>
|
|
<span class="rounded-full px-2 py-0.5 text-[11px] {{ $state['source'] === 'allow' ? 'bg-emerald-100 text-emerald-700' : ($state['source'] === 'deny' ? 'bg-rose-100 text-rose-700' : 'bg-slate-100 text-slate-600') }}">{{ $sourceLabel }}</span>
|
|
<button
|
|
type="button"
|
|
class="text-[11px] font-medium text-slate-500 hover:text-slate-700"
|
|
wire:click="resetRoleProgramVisibility('{{ $role }}', '{{ $program['key'] }}')"
|
|
>
|
|
Reset
|
|
</button>
|
|
</div>
|
|
</td>
|
|
@endforeach
|
|
</tr>
|
|
@endforeach
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div x-show="tab === 'rw'" class="space-y-4">
|
|
<div class="rounded-xl border border-slate-200 bg-white p-4 shadow-sm">
|
|
<div class="text-sm font-semibold text-slate-900">Matrice R/W per gruppi principali</div>
|
|
<div class="mt-1 text-xs text-slate-600">Questa scheda mostra il baseline attuale dei menu e delle azioni per ruolo derivato dalla configurazione applicativa. Il backend dedicato per salvare override granulari R/W non e ancora separato da quello di visibilita programmi.</div>
|
|
|
|
<div class="mt-4 overflow-x-auto">
|
|
<table class="min-w-full divide-y divide-slate-200 text-sm">
|
|
<thead class="bg-slate-50">
|
|
<tr>
|
|
<th class="px-3 py-2 text-left font-semibold text-slate-600">Ruolo</th>
|
|
<th class="px-3 py-2 text-left font-semibold text-slate-600">Gruppo / menu</th>
|
|
<th class="px-3 py-2 text-left font-semibold text-slate-600">Azioni</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="divide-y divide-slate-100 bg-white">
|
|
@forelse ($rwRows as $row)
|
|
<tr>
|
|
<td class="px-3 py-2 font-medium text-slate-900">{{ $row['role'] }}</td>
|
|
<td class="px-3 py-2 text-slate-700">{{ $row['menu'] }}</td>
|
|
<td class="px-3 py-2">
|
|
<div class="flex flex-wrap gap-1">
|
|
@forelse ($row['actions'] as $action)
|
|
<span class="rounded-full bg-slate-100 px-2 py-0.5 text-xs text-slate-700">{{ $action }}</span>
|
|
@empty
|
|
<span class="text-xs text-slate-400">nessuna azione configurata</span>
|
|
@endforelse
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
@empty
|
|
<tr>
|
|
<td colspan="3" class="px-3 py-6 text-center text-sm text-slate-500">Nessun gruppo R/W disponibile per i ruoli gestibili.</td>
|
|
</tr>
|
|
@endforelse
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div x-show="tab === 'manuale'">
|
|
<form class="space-y-6">
|
|
{{ $this->getSchema('form') }}
|
|
|
|
<div class="flex flex-wrap gap-3">
|
|
<x-filament::button type="button" color="gray" wire:click="loadRoleRules">Carica ACL ruolo</x-filament::button>
|
|
<x-filament::button type="button" wire:click="saveRoleRules">Salva ACL ruolo</x-filament::button>
|
|
<x-filament::button type="button" color="gray" wire:click="loadUserRules">Carica ACL utente</x-filament::button>
|
|
<x-filament::button type="button" wire:click="saveUserRules">Salva ACL utente</x-filament::button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</x-filament-panels::page> |