update
This commit is contained in:
122
resources/views/crud/generated/permissions/action.blade.php
Normal file
122
resources/views/crud/generated/permissions/action.blade.php
Normal file
@ -0,0 +1,122 @@
|
||||
<div class="row gy-4">
|
||||
|
||||
@foreach ($permissionLists as $key => $permission)
|
||||
{{-- @dd($permissionLists); --}}
|
||||
<div class="col-lg-4">
|
||||
{{-- <p class="justify-center text-soft-success"> --}}
|
||||
<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>
|
||||
{{-- {{ Str::ucfirst($key) }}
|
||||
</p> --}}
|
||||
<fieldset class="rounded-2 p-3">
|
||||
<legend class="fs-5">Permissions</legend>
|
||||
<div class="row">
|
||||
|
||||
@foreach ($permission as $index => $item)
|
||||
<div class="col-lg-12">
|
||||
<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)) }} --}}
|
||||
<a href="javascript:void(0);"
|
||||
data-link="{{ route('permissions.destroy', $index) }}"
|
||||
data-id="{{ $index }}"
|
||||
class="link-danger fs-15 remove-item-btn"><i
|
||||
class="ri-delete-bin-line"></i></a>
|
||||
{{ html()->label(Str::ucfirst($item))->for('permission_' . $index)->class('form-check-label ms-2') }}
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
|
||||
|
||||
@push('js')
|
||||
<script type="text/javascript">
|
||||
// $(document).ready(function() {
|
||||
|
||||
// // Cache selectors
|
||||
// const childCheckboxes = $('.child-checkbox');
|
||||
// const parentSwitches = $('.parent-switch');
|
||||
// const allCheck = $('#all-check');
|
||||
|
||||
// // Initial selection (optional, can be removed if not needed)
|
||||
// childCheckboxes.trigger('change');
|
||||
|
||||
// // Parent switch and child checkbox change handler (combined)
|
||||
// $('.child-checkbox, .parent-switch').change(function() {
|
||||
// const currentCol = $(this).closest('.col-lg-4');
|
||||
// const currentSwitch = currentCol.find('.parent-switch');
|
||||
// const currentChildren = currentCol.find(childCheckboxes);
|
||||
|
||||
// let allChecked = true;
|
||||
// currentChildren.each(function() {
|
||||
// if (!$(this).prop('checked')) {
|
||||
// allChecked = false;
|
||||
// return false;
|
||||
// }
|
||||
// });
|
||||
|
||||
// currentSwitch.prop('checked', allChecked);
|
||||
// allCheck.prop('checked', childCheckboxes.prop(
|
||||
// 'checked')); // Check all checkbox state
|
||||
// });
|
||||
|
||||
// // "all-check" change handler
|
||||
// allCheck.change(function() {
|
||||
// childCheckboxes.prop('checked', this.checked).trigger('change');
|
||||
// });
|
||||
|
||||
// });
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$('.child-checkbox').trigger('change');
|
||||
|
||||
$('.parent-switch').change(function() {
|
||||
let childCheckboxes = $(this).closest('.col-lg-4').find('.child-checkbox');
|
||||
childCheckboxes.prop('checked', this.checked);
|
||||
});
|
||||
|
||||
$('.child-checkbox').change(function() {
|
||||
let parentSwitch = $(this).closest('.col-lg-4').find('.parent-switch');
|
||||
let childCheckboxes = $(this).closest('.col-lg-4').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
|
@ -1,17 +0,0 @@
|
||||
@extends('backend.template')
|
||||
@section('content')
|
||||
<div class='card'>
|
||||
<div class='card-header d-flex justify-content-between align-items-center'>
|
||||
<h2 class="">{{ label('Add Permissions') }}</h2>
|
||||
<?php createButton("btn-primary btn-cancel","","Cancel",route('permissions.index')); ?>
|
||||
|
||||
</div>
|
||||
<div class='card-body'>
|
||||
<form action="{{route('permissions.store')}}" id="storeCustomForm" method="POST">
|
||||
@csrf
|
||||
<div class="row"><div class="col-lg-6">{{createText("name","name","Name")}}
|
||||
</div><div class="col-lg-6">{{createText("guard_name","guard_name","Guard Name")}}
|
||||
</div> <br> <div class="col-md-12"><?php createButton("btn-primary btn-store","","Submit"); ?>
|
||||
<?php createButton("btn-primary btn-cancel","","Cancel",route('permissions.index')); ?>
|
||||
</div> </form></div></div>
|
||||
@endsection
|
@ -1,25 +0,0 @@
|
||||
@extends('backend.template')
|
||||
@section('content')
|
||||
<div class='card'>
|
||||
<div class='card-header d-flex justify-content-between align-items-center'>
|
||||
<h2 class="">{{ label('Edit Permissions') }}</h2>
|
||||
<?php createButton('btn-primary btn-cancel', '', 'Cancel', route('permissions.index')); ?>
|
||||
|
||||
</div>
|
||||
<div class='card-body'>
|
||||
<form action="{{ route('permissions.update', [$data->id]) }}" id="updateCustomForm" method="POST">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
<input type=hidden name='id' value='{{ $data->id }}' />
|
||||
<div class="row">
|
||||
<div class="col-lg-6">{{ createText('name', 'name', 'Name', '', $data->name) }}
|
||||
</div>
|
||||
<div class="col-lg-6">{{ createText('guard_name', 'guard_name', 'Guard Name', '', $data->guard_name) }}
|
||||
</div>
|
||||
<div class="col-md-12"><?php createButton('btn-primary btn-update', '', 'Submit'); ?>
|
||||
<?php createButton('btn-primary btn-cancel', '', 'Cancel', route('permissions.index')); ?>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
@ -1,185 +1,59 @@
|
||||
@extends('backend.template')
|
||||
@section('content')
|
||||
<div class="card">
|
||||
<div class="card-header d-flex justify-content-between align-items-center">
|
||||
<h2>{{ label('Permissions List') }}</h2>
|
||||
<a href="{{ route('permissions.create') }}" class="btn btn-primary"><span>{{ label('Create New') }}</span></a>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<table class="table dataTable" id="tbl_permissions">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th class="tb-col"><span class="overline-title">{{ label('Sn.') }}</span></th>
|
||||
<th class="tb-col"><span class="overline-title">{{ label('name') }}</span></th>
|
||||
<th class="tb-col"><span class="overline-title">{{ label('guard_name') }}</span></th>
|
||||
<th class="tb-col" data-sortable="false"><span class="overline-title">{{ label('Action') }}</span>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@php
|
||||
$i = 1;
|
||||
@endphp
|
||||
@foreach ($data as $item)
|
||||
<tr data-id="{{ $item->id }}" data-display_order="{{ $item->display_order }}"
|
||||
class="draggable-row <?php echo $item->status == 0 ? 'bg-light bg-danger' : ''; ?>">
|
||||
<td class="tb-col">{{ $i++ }}</td>
|
||||
<td class="tb-col">{{ $item->name }}</td>
|
||||
<td class="tb-col">{{ $item->guard_name }}</td>
|
||||
<td class="tb-col">
|
||||
<div class="dropdown d-inline-block">
|
||||
<button class="btn btn-soft-secondary btn-sm dropdown" type="button"
|
||||
data-bs-toggle="dropdown" aria-expanded="false">
|
||||
<i class="ri-more-fill align-middle"></i>
|
||||
</button>
|
||||
<ul class="dropdown-menu dropdown-menu-end">
|
||||
<li><a href="{{ route('permissions.show', [$item->id]) }}" class="dropdown-item"><i
|
||||
class="ri-eye-fill align-bottom me-2 text-muted"></i>
|
||||
{{ label('View') }}</a></li>
|
||||
<li><a href="{{ route('permissions.edit', [$item->id]) }}"
|
||||
class="dropdown-item edit-item-btn"><i
|
||||
class="ri-pencil-fill align-bottom me-2 text-muted"></i>
|
||||
{{ label('Edit') }}</a></li>
|
||||
<li>
|
||||
<a href="{{ route('permissions.destroy', [$item->id]) }}"
|
||||
class="dropdown-item remove-item-btn" onclick="confirmDelete(this.href)">
|
||||
<i class="ri-delete-bin-fill align-bottom me-2 text-muted"></i>
|
||||
{{ label('Delete') }}
|
||||
</a>
|
||||
<div class="page-content">
|
||||
<div class="container-fluid">
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="page-title-box d-sm-flex align-items-center justify-content-between">
|
||||
<h4 class="mb-sm-0">{{ $title }}</h4>
|
||||
|
||||
<div class="page-title-right">
|
||||
<ol class="breadcrumb m-0">
|
||||
<li class="breadcrumb-item"><a href="javascript: void(0);">Dashboards</a></li>
|
||||
<li class="breadcrumb-item active">{{ $title }}</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
<!-- end page title -->
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="card">
|
||||
<div class="card-header align-items-center d-flex">
|
||||
<h5 class="card-title flex-grow-1 mb-0">{{ $title }}</h5>
|
||||
<div class="flex-shrink-0">
|
||||
<a href="{{ route('permission.generatePermissionFromRoutes') }}"
|
||||
class="btn btn-success waves-effect waves-light"><i
|
||||
class="ri-add-fill me-1 align-bottom"></i>Generate Permissions</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
||||
@include('crud.generated.permissions.action')
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('css')
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/1.13.5/css/dataTables.bootstrap4.min.css">
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/rowreorder/1.4.0/css/rowReorder.dataTables.min.css">
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/1.11.5/css/dataTables.bootstrap5.min.css" />
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/responsive/2.2.9/css/responsive.bootstrap.min.css" />
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/2.2.2/css/buttons.dataTables.min.css">
|
||||
@endpush
|
||||
|
||||
@push('js')
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.68/pdfmake.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.68/vfs_fonts.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/1.13.5/js/jquery.dataTables.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/2.4.1/js/buttons.html5.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/rowreorder/1.4.0/js/dataTables.rowReorder.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||
|
||||
|
||||
<script>
|
||||
$(document).ready(function(e) {
|
||||
var mytable = $(".dataTable").DataTable({
|
||||
ordering: true,
|
||||
rowReorder: {
|
||||
//selector: 'tr'
|
||||
},
|
||||
});
|
||||
|
||||
var isRowReorderComplete = false;
|
||||
|
||||
mytable.on('row-reorder', function(e, diff, edit) {
|
||||
isRowReorderComplete = true;
|
||||
});
|
||||
|
||||
mytable.on('draw', function() {
|
||||
if (isRowReorderComplete) {
|
||||
var url = mytable.table().node().getAttribute('data-url');
|
||||
var ids = mytable.rows().nodes().map(function(node) {
|
||||
return $(node).data('id');
|
||||
}).toArray();
|
||||
|
||||
console.log(ids);
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: "POST",
|
||||
headers: {
|
||||
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr('content')
|
||||
},
|
||||
data: {
|
||||
id_order: ids
|
||||
},
|
||||
success: function(response) {
|
||||
console.log(response);
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error(error);
|
||||
}
|
||||
});
|
||||
isRowReorderComplete = false;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function confirmDelete(url) {
|
||||
event.preventDefault();
|
||||
Swal.fire({
|
||||
title: 'Are you sure?',
|
||||
text: 'You will not be able to recover this item!',
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: 'Delete',
|
||||
cancelButtonText: 'Cancel',
|
||||
reverseButtons: true
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: 'DELETE',
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
||||
},
|
||||
success: function(response) {
|
||||
Swal.fire('Deleted!', 'The item has been deleted.', 'success');
|
||||
location.reload();
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
Swal.fire('Error!', 'An error occurred while deleting the item.', 'error');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function confirmToggle(url) {
|
||||
event.preventDefault();
|
||||
Swal.fire({
|
||||
title: 'Are you sure?',
|
||||
text: 'Publish Status of Item will be changed!! if Unpublished, links will be dead!',
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: 'Proceed',
|
||||
cancelButtonText: 'Cancel',
|
||||
reverseButtons: true
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: 'GET',
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
||||
},
|
||||
success: function(response) {
|
||||
Swal.fire('Updated!', 'Publishing Status has been updated.', 'success');
|
||||
location.reload();
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
Swal.fire('Error!', 'An error occurred.', 'error');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<script src="https://cdn.datatables.net/1.11.5/js/jquery.dataTables.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/1.11.5/js/dataTables.bootstrap5.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/responsive/2.2.9/js/dataTables.responsive.min.js"></script>
|
||||
<script src="{{ asset('assets/js/pages/datatables.init.js') }}"></script>
|
||||
@endpush
|
||||
|
@ -1,28 +0,0 @@
|
||||
@extends('backend.template')
|
||||
@section('content')
|
||||
<div class='card'>
|
||||
<div class='card-header d-flex justify-content-between align-items-center'>
|
||||
<h2><?php echo label('View Details'); ?></h2>
|
||||
<?php createButton("btn-primary btn-cancel","","Back to List",route('permissions.index')); ?>
|
||||
|
||||
</div>
|
||||
<div class='card-body'>
|
||||
|
||||
|
||||
|
||||
<p><b>Name : </b> <span>{{$data->name}}</span></p><p><b>Guard Name : </b> <span>{{$data->guard_name}}</span></p><div class="d-flex justify-content-between">
|
||||
<div>
|
||||
<p><b>Created On :</b> <span>{{$data->created_at}}</span></p>
|
||||
<p><b>Created By :</b> <span>{{$data->createdBy}}</span></p>
|
||||
</div>
|
||||
<div>
|
||||
<p><b>Updated On :</b> <span>{{$data->updated_at}}</span></p>
|
||||
<p><b>Updated By :</b> <span>{{$data->updatedBy}}</span></p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@endSection
|
Reference in New Issue
Block a user