first change
This commit is contained in:
97
Modules/User/resources/views/role/partials/form.blade.php
Normal file
97
Modules/User/resources/views/role/partials/form.blade.php
Normal file
@@ -0,0 +1,97 @@
|
||||
<div class="row gy-4">
|
||||
|
||||
<div class="col-lg-4">
|
||||
{{ html()->label('Name')->class('form-label') }}
|
||||
{{ html()->text('name')->class('form-control')->placeholder('Enter Role Name')->required() }}
|
||||
</div>
|
||||
|
||||
<div class="col-lg-4">
|
||||
{{ html()->label('Guard Name')->class('form-label') }}
|
||||
{{ html()->text('guard_name', 'web')->class('form-control bg-primary-subtle')->isReadonly(true) }}
|
||||
</div>
|
||||
|
||||
<div class="col-lg-2">
|
||||
<div class="form-check form-switch form-switch-lg mt-3">
|
||||
{{ html()->checkbox('all_permissions_check')->class('form-check-input')->id('all-check') }}
|
||||
{{ html()->label('Select All')->class('form-check-label')->for('all-check') }}
|
||||
</div>
|
||||
{{ html()->p()->text('Enable all Permissions for this role')->class('fs-6 text-muted mt-1 text-nowrap') }}
|
||||
</div>
|
||||
|
||||
<div class="col-lg-2">
|
||||
<x-form-buttons :editable=$editable label='Assign' :href="route('role.index')" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="d-flex flex-row flex-wrap gap-2">
|
||||
@foreach ($permissionLists as $key => $permission)
|
||||
<div class="card card-body w-20 bg-white">
|
||||
<div class="form-check form-switch form-switch-custom form-switch-success mb-3">
|
||||
<input class="form-check-input parent-switch" type="checkbox" role="switch" id="check_{{ $key }}">
|
||||
<label class="form-check-label ms-2" for="{check_{$key}}">{{ Str::ucfirst($key) }}</label>
|
||||
</div>
|
||||
<fieldset class="rounded-2">
|
||||
<div class="list-group">
|
||||
@foreach ($permission as $index => $item)
|
||||
<div class="form-check form-check-success">
|
||||
{{ html()->checkbox('permissions[]')->id('permission_' . $index)->value($index)->class('form-check-input child-checkbox')->checked($editable && in_array($index, $permissionIDsArray)) }}
|
||||
{{ html()->label(Str::ucfirst($item))->for('permission_' . $index)->class('form-check-label ms-2') }}
|
||||
</div>
|
||||
@endforeach
|
||||
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
|
||||
|
||||
@push('js')
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
|
||||
$('.child-checkbox').trigger('change');
|
||||
|
||||
$('.parent-switch').change(function() {
|
||||
let childCheckboxes = $(this).closest('.card').find('.child-checkbox');
|
||||
childCheckboxes.prop('checked', this.checked);
|
||||
});
|
||||
|
||||
$('.child-checkbox').change(function() {
|
||||
let parentSwitch = $(this).closest('.card').find('.parent-switch');
|
||||
let childCheckboxes = $(this).closest('.card').find('.child-checkbox');
|
||||
let allChecked = true;
|
||||
childCheckboxes.each(function() {
|
||||
if (!$(this).prop('checked')) {
|
||||
allChecked = false;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
parentSwitch.prop('checked', allChecked);
|
||||
});
|
||||
|
||||
$('#all-check').change(function() {
|
||||
let childCheckboxes = $('.child-checkbox');
|
||||
childCheckboxes.prop('checked', this.checked);
|
||||
|
||||
childCheckboxes.prop('checked', this.checked).trigger('change');
|
||||
});
|
||||
|
||||
$('.child-checkbox, .parent-switch').change(function() {
|
||||
let allCheck = $('#all-check');
|
||||
let childCheckboxes = $('.child-checkbox');
|
||||
let allChecked = true;
|
||||
|
||||
childCheckboxes.each((index, checkBox) => {
|
||||
if (!$(checkBox).prop('checked')) {
|
||||
allChecked = false;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
allCheck.prop('checked', allChecked);
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
@endpush
|
Reference in New Issue
Block a user