Feat: add "Select All" and "Revoke All" permissions functionality in user access management
- Introduced methods `selectAllPermissions` and `revokeAllPermissions` in Livewire component. - Updated permissions section UI with buttons for selecting and revoking all permissions. - Enhanced user experience by simplifying bulk permission management.
This commit is contained in:
parent
42737a6a2f
commit
4fe1765525
@ -123,6 +123,24 @@ public function clearRoles(): void
|
||||
$this->hydratePermissionInForm();
|
||||
}
|
||||
|
||||
public function selectAllPermissions(): void
|
||||
{
|
||||
$allPermissionIds = [];
|
||||
if ($this->roleWithPermission) {
|
||||
foreach ($this->roleWithPermission->items() as $role) {
|
||||
foreach ($role->permissions->items() as $permission) {
|
||||
$allPermissionIds[] = $permission->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->form->permissions = array_values(array_unique($allPermissionIds));
|
||||
}
|
||||
|
||||
public function revokeAllPermissions(): void
|
||||
{
|
||||
$this->form->permissions = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the deactivated permissions represented as DTOs containing the role ID and permission ID.
|
||||
*
|
||||
@ -273,9 +291,30 @@ class="btn-sm btn-circle btn-error btn-soft"
|
||||
/>
|
||||
|
||||
@if ($roleWithPermission)
|
||||
<fieldset class="mt-5 space-y-4">
|
||||
<legend class="flex items-center gap-2">
|
||||
<label class="text-xs font-bold">Permissions</label>
|
||||
<fieldset class="mt-5 space-y-4 w-full">
|
||||
<legend class="flex w-full items-center justify-between gap-4">
|
||||
<p class="text-xs font-bold">Permissions</p>
|
||||
<div class="flex items-center gap-2 font-bold">
|
||||
|
||||
<label class="flex cursor-pointer items-center gap-1 text-xs text-primary">
|
||||
<button
|
||||
type="button"
|
||||
wire:click="selectAllPermissions()"
|
||||
>
|
||||
Select All
|
||||
</button>
|
||||
</label>
|
||||
<label class="flex cursor-pointer items-center gap-1 text-xs text-error">
|
||||
<button
|
||||
type="button"
|
||||
class="text-error"
|
||||
wire:click="revokeAllPermissions()"
|
||||
>
|
||||
Revoke All
|
||||
</button>
|
||||
</label>
|
||||
|
||||
</div>
|
||||
</legend>
|
||||
|
||||
@foreach ($roleWithPermission?->items() as $role)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user