feat(roles/users): add-user form on role view + per-user direct permissions form
1. Role view (Details tab): a small form to add users to the role (select of users not yet in the role + Add) and a per-row remove button. Uses assignRole/removeRole. 2. User view (Permissions tab): the same grouped, collapsible permissions form with switches — operating on the user's DIRECT permissions (givePermissionTo/revokePermissionTo). Permissions inherited from a role show as checked+disabled with a 'from role' tag; per-group All/None too. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -130,7 +130,7 @@
|
||||
<div class="py-6">
|
||||
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8 space-y-4">
|
||||
|
||||
<div role="tablist" class="tabs tabs-bordered">
|
||||
<div role="tablist" class="tabs tabs-bordered gap-4">
|
||||
<button role="tab" wire:click="setTab('permissions')"
|
||||
class="tab gap-2 {{ $activeTab === 'permissions' ? 'tab-active font-semibold' : '' }}">
|
||||
<x-heroicon-o-shield-check class="w-4 h-4" />
|
||||
@@ -270,6 +270,68 @@
|
||||
</div>
|
||||
@endif
|
||||
|
||||
{{-- Permisos directos del usuario --}}
|
||||
<div class="card bg-base-100 shadow md:col-span-2">
|
||||
<div class="card-body p-6">
|
||||
<h3 class="font-semibold text-base flex items-center gap-2 mb-1">
|
||||
<x-heroicon-o-key class="w-5 h-5 text-primary" />
|
||||
Permisos
|
||||
</h3>
|
||||
<p class="text-xs text-gray-400 mb-4">
|
||||
Los permisos heredados de un rol aparecen marcados y bloqueados. Aquí puedes conceder permisos extra directamente a este usuario.
|
||||
</p>
|
||||
|
||||
<div class="space-y-3">
|
||||
@forelse($grouped as $section => $perms)
|
||||
<div x-data="{ open: true }" class="border border-base-200 rounded-lg overflow-hidden">
|
||||
<div class="flex items-center justify-between px-4 py-2.5 bg-base-200/60">
|
||||
<button type="button" @click="open = !open" class="flex items-center gap-2 flex-1 text-left">
|
||||
<span class="transition-transform duration-200" :class="open ? 'rotate-90' : ''">
|
||||
<x-heroicon-o-chevron-right class="w-4 h-4 text-gray-500" />
|
||||
</span>
|
||||
<span class="font-semibold text-gray-700">{{ $section }}</span>
|
||||
<span class="badge badge-ghost badge-sm">{{ $perms->count() }}</span>
|
||||
</button>
|
||||
<div class="flex items-center gap-1 shrink-0">
|
||||
<button wire:click="setUserGroup('{{ $section }}', true)" class="btn btn-xs btn-ghost gap-1" title="{{ __('Check all') }}">
|
||||
<x-heroicon-o-check class="w-3.5 h-3.5" /> {{ __('All') }}
|
||||
</button>
|
||||
<button wire:click="setUserGroup('{{ $section }}', false)" class="btn btn-xs btn-ghost gap-1" title="{{ __('Uncheck all') }}">
|
||||
<x-heroicon-o-x-mark class="w-3.5 h-3.5" /> {{ __('None') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div x-show="open" x-transition.opacity class="divide-y divide-base-200">
|
||||
@foreach($perms as $perm)
|
||||
@php
|
||||
$viaRole = in_array($perm->name, $rolePerms, true);
|
||||
$direct = in_array($perm->name, $directPerms, true);
|
||||
@endphp
|
||||
<label class="flex items-center justify-between gap-3 px-4 py-2.5 {{ $viaRole ? 'opacity-70' : 'cursor-pointer hover:bg-base-100' }}">
|
||||
<div class="min-w-0">
|
||||
<span class="text-sm font-medium">{{ $perm->name }}</span>
|
||||
@if($viaRole)<span class="badge badge-ghost badge-xs ml-1">{{ __('from role') }}</span>@endif
|
||||
@if($perm->description)
|
||||
<p class="text-xs text-gray-400 leading-tight">{{ $perm->description }}</p>
|
||||
@endif
|
||||
</div>
|
||||
<input type="checkbox"
|
||||
class="toggle toggle-primary toggle-sm shrink-0"
|
||||
wire:key="uperm-{{ $user->id }}-{{ $perm->id }}"
|
||||
@checked($viaRole || $direct)
|
||||
@disabled($viaRole)
|
||||
@if(! $viaRole) wire:click="togglePermission('{{ $perm->name }}')" @endif />
|
||||
</label>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
@empty
|
||||
<p class="text-sm text-gray-400">{{ __('No permissions') }}</p>
|
||||
@endforelse
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@@ -496,7 +558,7 @@
|
||||
TAB: NOTAS
|
||||
════════════════════════════════════════════════════════════════════ --}}
|
||||
@if($activeTab === 'notes')
|
||||
<div class="card bg-base-100 shadow max-w-2xl">
|
||||
<div class="card bg-base-100 shadow max-w-7xl">
|
||||
<div class="card-body p-6">
|
||||
<div class="flex items-center justify-between mb-4">
|
||||
<h3 class="font-semibold text-base flex items-center gap-2">
|
||||
|
||||
Reference in New Issue
Block a user