feat(roles): collapsible permission groups with check/uncheck-all + single-column switches
Permissions tab in the role view: 1. Each section is now a collapsible card (Alpine, chevron rotates). 2. Section header has 'All' / 'None' buttons (setGroup grants/revokes every permission of that group for the role; Admin keeps 'manage all'). 3. Permissions render in a single column: name+description on the left, control on the right. 4. Controls are DaisyUI toggle switches. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -51,6 +51,23 @@ class RoleView extends Component
|
||||
$this->dispatch('notify', 'Permisos actualizados');
|
||||
}
|
||||
|
||||
public function setGroup(string $group, bool $enabled): void
|
||||
{
|
||||
$names = Permission::where('group', $group)->pluck('name');
|
||||
|
||||
foreach ($names as $name) {
|
||||
// Admin must always keep the core permission
|
||||
if (! $enabled && $this->role->name === 'Admin' && $name === self::CORE_PERMISSION) {
|
||||
continue;
|
||||
}
|
||||
$enabled ? $this->role->givePermissionTo($name) : $this->role->revokePermissionTo($name);
|
||||
}
|
||||
|
||||
app(PermissionRegistrar::class)->forgetCachedPermissions();
|
||||
$this->role->load('permissions');
|
||||
$this->dispatch('notify', $enabled ? 'Permisos del grupo activados' : 'Permisos del grupo desactivados');
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
if (in_array($this->role->name, self::PROTECTED_ROLES, true)) {
|
||||
|
||||
Reference in New Issue
Block a user