Feature #2 : Role With Permission Selection
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
const selectAll = document.querySelector('#select_all');
|
||||
|
||||
if (selectAll) {
|
||||
const allCheckboxes = document.querySelectorAll('[type="checkbox"]');
|
||||
|
||||
// Handle check state
|
||||
selectAll.addEventListener('change', e => {
|
||||
// Apply check state to all checkboxes
|
||||
allCheckboxes.forEach(c => {
|
||||
c.checked = e.target.checked;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@
|
||||
function deleteData(data) {
|
||||
Swal.fire({
|
||||
title: 'Are you sure?',
|
||||
text: "You won't be able to revert this!" + data,
|
||||
text: "You won't be able to revert this!" ,
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
|
||||
@@ -7,42 +7,80 @@
|
||||
@section('content')
|
||||
<div class="w-full grid gap-5 lg:gap-7.5 mx-auto">
|
||||
@if(isset($role->id))
|
||||
<form action="{{ route('users.roles.update', $role->id) }}" method="POST">
|
||||
<form action="{{ route('users.roles.update', $role->id) }}" method="POST" id="role_form">
|
||||
<input type="hidden" name="id" value="{{ $role->id }}">
|
||||
@method('PUT')
|
||||
@else
|
||||
<form method="POST" action="{{ route('users.roles.store') }}">
|
||||
@endif
|
||||
@csrf
|
||||
<div class="card pb-2.5">
|
||||
<div class="card-header" id="basic_settings">
|
||||
<h3 class="card-title">
|
||||
{{ isset($role->id) ? 'Edit' : 'Add' }} Role
|
||||
</h3>
|
||||
<div class="flex items-center gap-2">
|
||||
<a href="{{ route('users.roles.index') }}" class="btn btn-xs btn-info">Back</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body grid gap-5">
|
||||
@method('PUT')
|
||||
@else
|
||||
<form method="POST" action="{{ route('users.roles.store') }}">
|
||||
@endif
|
||||
@csrf
|
||||
<div class="card pb-2.5">
|
||||
<div class="card-header" id="basic_settings">
|
||||
<h3 class="card-title">
|
||||
{{ isset($role->id) ? 'Edit' : 'Add' }} Role
|
||||
</h3>
|
||||
<div class="flex items-center gap-2">
|
||||
<a href="{{ route('users.roles.index') }}" class="btn btn-xs btn-info">Back</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body grid gap-5">
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
Name
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<input class="input @error('name') border-danger @enderror" type="text" name="name" value="{{ $role->name ?? '' }}">
|
||||
@error('name')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
Administrator/Superuser Access
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<label class="switch">
|
||||
<input name="check" id="select_all" type="checkbox" value="1"/>
|
||||
<span class="switch-label">
|
||||
Select All
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
@foreach($permissiongroups as $group)
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
{{ ucwords($group->name) }}
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full gap-2.5">
|
||||
@foreach($group->getpermissionsByGroupId($group->id) as $permission)
|
||||
<label class="switch">
|
||||
@if(isset($role))
|
||||
<input type="checkbox" value="{{ $permission->id }}" name="permissions[]" {{ $role->hasPermissionTo($permission->name) ? 'checked' : null }} />
|
||||
@else
|
||||
<input type="checkbox" value="{{ $permission->id }}" name="permissions[]"/>
|
||||
@endif
|
||||
@php
|
||||
$permission_name = explode('.',$permission->name);
|
||||
@endphp
|
||||
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
Name
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<input class="input @error('name') border-danger @enderror" type="text" name="name" value="{{ $role->name ?? '' }}">
|
||||
@error('name')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@enderror
|
||||
<span class="switch-label">
|
||||
{{ ucwords($permission_name[1]) }}
|
||||
</span>
|
||||
</label>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
|
||||
<div class="flex justify-end">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
Save
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-end">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
Save
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</form>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@@ -88,7 +88,7 @@
|
||||
function deleteData(data) {
|
||||
Swal.fire({
|
||||
title: 'Are you sure?',
|
||||
text: "You won't be able to revert this!" + data,
|
||||
text: "You won't be able to revert this!" ,
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
|
||||
@@ -92,7 +92,7 @@
|
||||
function deleteData(data) {
|
||||
Swal.fire({
|
||||
title: 'Are you sure?',
|
||||
text: "You won't be able to revert this!" + data,
|
||||
text: "You won't be able to revert this!" ,
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
|
||||
Reference in New Issue
Block a user