update
This commit is contained in:
@@ -76,6 +76,18 @@ class ProductCategoryController extends Controller
|
|||||||
return redirect()->route('products.group.trash')->with('success', 'Force Delete Group Success');
|
return redirect()->route('products.group.trash')->with('success', 'Force Delete Group Success');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function bulkDelete(Request $request)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'ids' => 'required|array',
|
||||||
|
'ids.*' => 'exists:product_categories,id'
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->productCategoryService->bulkDelete($request->ids);
|
||||||
|
|
||||||
|
return response()->json(['message' => 'Selected product groups deleted successfully.']);
|
||||||
|
}
|
||||||
|
|
||||||
public function datatable(Request $request)
|
public function datatable(Request $request)
|
||||||
{
|
{
|
||||||
$query = $this->productCategoryRepository->filter(
|
$query = $this->productCategoryRepository->filter(
|
||||||
@@ -102,7 +114,13 @@ class ProductCategoryController extends Controller
|
|||||||
return view('administrator.pages.product.categories.datatable.status', ['row' => $d])->render();
|
return view('administrator.pages.product.categories.datatable.status', ['row' => $d])->render();
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
->rawColumns(['action', 'is_active'])
|
->addColumn(
|
||||||
|
'checkbox',
|
||||||
|
function ($d) {
|
||||||
|
return '<div class="form-check d-flex align-items-center justify-content-center"><input class="form-check-input dt-checkbox" type="checkbox" value="' . $d->id . '"></div>';
|
||||||
|
}
|
||||||
|
)
|
||||||
|
->rawColumns(['action', 'is_active', 'checkbox'])
|
||||||
->make(true);
|
->make(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -39,4 +39,9 @@ class ProductCategoryService implements ProductCategoryServiceInterface
|
|||||||
{
|
{
|
||||||
return $this->repository->forceDelete($id);
|
return $this->repository->forceDelete($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function bulkDelete(array $ids)
|
||||||
|
{
|
||||||
|
return $this->repository->bulkDelete($ids);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -10,4 +10,6 @@ interface ProductCategoryServiceInterface {
|
|||||||
public function restore(int $id);
|
public function restore(int $id);
|
||||||
|
|
||||||
public function forceDelete(int $id);
|
public function forceDelete(int $id);
|
||||||
|
|
||||||
|
public function bulkDelete(array $ids);
|
||||||
}
|
}
|
||||||
@@ -81,4 +81,9 @@ class ProductCategoryRepository extends BaseRepository implements ProductCategor
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function bulkDelete(array $ids)
|
||||||
|
{
|
||||||
|
return $this->model->whereIn('id', $ids)->delete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,4 +17,6 @@ interface ProductCategoryRepositoryInterface extends BaseRepositoryInterface
|
|||||||
public function restore(int $id);
|
public function restore(int $id);
|
||||||
|
|
||||||
public function forceDelete(int $id);
|
public function forceDelete(int $id);
|
||||||
|
|
||||||
|
public function bulkDelete(array $ids);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,15 +11,29 @@ class DataTable extends Component
|
|||||||
public string $id;
|
public string $id;
|
||||||
public string $ajax;
|
public string $ajax;
|
||||||
public array $columns;
|
public array $columns;
|
||||||
|
public ?string $bulkDeleteUrl;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
string $id,
|
string $id,
|
||||||
string $ajax,
|
string $ajax,
|
||||||
array $columns
|
array $columns,
|
||||||
|
?string $bulkDeleteUrl = null
|
||||||
) {
|
) {
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
$this->ajax = $ajax;
|
$this->ajax = $ajax;
|
||||||
$this->columns = $columns;
|
$this->columns = $columns;
|
||||||
|
$this->bulkDeleteUrl = $bulkDeleteUrl;
|
||||||
|
|
||||||
|
if ($this->bulkDeleteUrl) {
|
||||||
|
array_unshift($this->columns, [
|
||||||
|
'key' => 'checkbox',
|
||||||
|
'label' => '<div class="form-check d-flex align-items-center justify-content-center"><input class="form-check-input" type="checkbox" id="dt-master-checkbox"></div>',
|
||||||
|
'orderable' => false,
|
||||||
|
'searchable' => false,
|
||||||
|
'className' => 'text-center align-middle',
|
||||||
|
'width' => '30px'
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -16,18 +16,6 @@
|
|||||||
</form>
|
</form>
|
||||||
|
|
||||||
<ul class="navbar-nav">
|
<ul class="navbar-nav">
|
||||||
<li class="theme-switcher-wrapper nav-item">
|
|
||||||
<input type="checkbox" value="" id="theme-switcher">
|
|
||||||
<label for="theme-switcher">
|
|
||||||
<div class="box">
|
|
||||||
<div class="ball"></div>
|
|
||||||
<div class="icons">
|
|
||||||
<i class="link-icon" data-lucide="sun"></i>
|
|
||||||
<i class="link-icon" data-lucide="moon"></i>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</label>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item dropdown">
|
<li class="nav-item dropdown">
|
||||||
<a class="nav-link dropdown-toggle" href="#" id="appsDropdown" role="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
<a class="nav-link dropdown-toggle" href="#" id="appsDropdown" role="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||||
<i data-lucide="layout-grid"></i>
|
<i data-lucide="layout-grid"></i>
|
||||||
|
|||||||
@@ -7,28 +7,28 @@
|
|||||||
|
|
||||||
@section('breadcrumb')
|
@section('breadcrumb')
|
||||||
@php
|
@php
|
||||||
$breadcrumbItems = [
|
$breadcrumbItems = [
|
||||||
['label' => 'Product'],
|
['label' => 'Product'],
|
||||||
['label' => 'Product Group'],
|
['label' => 'Product Group'],
|
||||||
['label' => 'Product Group List', 'active' => true]
|
['label' => 'Product Group List', 'active' => true]
|
||||||
];
|
];
|
||||||
@endphp
|
@endphp
|
||||||
<x-admin-breadcrumb :items="$breadcrumbItems" />
|
<x-admin-breadcrumb :items="$breadcrumbItems" />
|
||||||
@endsection
|
@endsection
|
||||||
@section('tab')
|
@section('tab')
|
||||||
@php
|
@php
|
||||||
$tabs = [
|
$tabs = [
|
||||||
[
|
[
|
||||||
'label' => 'Product',
|
'label' => 'Product',
|
||||||
'route' => 'products.index',
|
'route' => 'products.index',
|
||||||
'icon' => 'server',
|
'icon' => 'server',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'label' => 'Product Group',
|
'label' => 'Product Group',
|
||||||
'route' => 'products.group.index',
|
'route' => 'products.group.index',
|
||||||
'icon' => 'server',
|
'icon' => 'server',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
@endphp
|
@endphp
|
||||||
<x-admin-tab :items="$tabs" />
|
<x-admin-tab :items="$tabs" />
|
||||||
@endsection
|
@endsection
|
||||||
@@ -39,12 +39,13 @@
|
|||||||
@include('administrator.pages.block.product.btn')
|
@include('administrator.pages.block.product.btn')
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<x-datatable id="productTable" ajax="{{ route('products.group.datatable') }}" :columns="[
|
<x-datatable id="productTable" ajax="{{ route('products.group.datatable') }}"
|
||||||
['key' => 'name', 'label' => 'Group'],
|
bulkDeleteUrl="{{ route('products.group.bulkDelete') }}" :columns="[
|
||||||
['key' => 'slug', 'label' => 'Slug'],
|
['key' => 'name', 'label' => 'Group'],
|
||||||
['key' => 'is_active', 'label' => 'Status'],
|
['key' => 'slug', 'label' => 'Slug'],
|
||||||
['key' => 'action', 'label' => 'Action', 'searchable' => false],
|
['key' => 'is_active', 'label' => 'Status'],
|
||||||
]" />
|
['key' => 'action', 'label' => 'Action', 'searchable' => false],
|
||||||
|
]" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
@props(['id', 'columns', 'ajax'])
|
@props(['id', 'columns', 'ajax', 'bulkDeleteUrl' => null])
|
||||||
|
|
||||||
@php
|
@php
|
||||||
$dtColumns = collect($columns)->map(function ($c) {
|
$dtColumns = collect($columns)->map(function ($c) {
|
||||||
@@ -11,18 +11,84 @@ $dtColumns = collect($columns)->map(function ($c) {
|
|||||||
];
|
];
|
||||||
})->values();
|
})->values();
|
||||||
@endphp
|
@endphp
|
||||||
<div class="data-table-wrapper rounded-3 overflow-hidden border border-light">
|
@if($bulkDeleteUrl)
|
||||||
<table id="{{ $id }}" class="table table-hover align-middle mb-0 bg-white"
|
<div class="d-flex justify-content-start mb-3 align-items-center" id="{{ $id }}-bulk-actions"
|
||||||
style="width:100%; border-collapse: separate; border-spacing: 0;">
|
style="display: none !important;">
|
||||||
<thead class="bg-light">
|
<div class="bg-danger-subtle text-danger px-4 py-2 rounded-3 d-flex align-items-center gap-3">
|
||||||
<tr>
|
<div class="d-flex align-items-center gap-2">
|
||||||
@foreach($columns as $col)
|
<i data-lucide="alert-circle" width="16" height="16"></i>
|
||||||
<th class="text-uppercase text-secondary text-xxs font-weight-bolder opacity-7 ps-3 py-3 border-bottom"
|
<span class="fw-medium"><span id="{{ $id }}-selected-count">0</span> items selected</span>
|
||||||
style="font-size: 0.75rem; letter-spacing: 0.5px;">
|
</div>
|
||||||
|
<div class="vr bg-danger opacity-25"></div>
|
||||||
|
<x-button-c-r-m type="button" variant="danger" size="sm" icon="trash-2" id="{{ $id }}-bulk-delete-opener-btn"
|
||||||
|
class="shadow-sm">
|
||||||
|
Delete Selected
|
||||||
|
</x-button-c-r-m>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Bulk Delete Confirmation Modal (Bootstrap 5) --}}
|
||||||
|
<div class="modal fade" id="{{ $id }}-bulk-delete-modal" tabindex="-1" aria-hidden="true">
|
||||||
|
<div class="modal-dialog modal-dialog-centered">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title h5" id="{{ $id }}-bulk-delete-modal-title">
|
||||||
|
Confirm Bulk Delete
|
||||||
|
</h5>
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<p>Are you sure you want to delete <span id="{{ $id }}-bulk-delete-count-display" class="fw-bold"></span>
|
||||||
|
selected items?</p>
|
||||||
|
<p class="text-danger mt-2 mb-0">This action cannot be undone.</p>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<x-button-c-r-m type="button" variant="danger" id="{{ $id }}-confirm-bulk-delete-btn">
|
||||||
|
Delete
|
||||||
|
</x-button-c-r-m>
|
||||||
|
|
||||||
|
<x-button-c-r-m type="button" variant="secondary" data-bs-dismiss="modal">
|
||||||
|
Cancel
|
||||||
|
</x-button-c-r-m>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
<div class="data-table-wrapper rounded-3 overflow-hidden border border-light position-relative">
|
||||||
|
{{-- Loading Process Indicator --}}
|
||||||
|
<div class="loading-process" id="{{ $id }}-loading" style="display: none;">
|
||||||
|
<div class="loading-bar"></div>
|
||||||
|
<div class="loading-overlay"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<table id="{{ $id }}" class="table table-hover align-middle mb-0 bg-white"
|
||||||
|
style="width:100%; border-collapse: separate; border-spacing: 0;">
|
||||||
|
<thead class="bg-light">
|
||||||
|
<tr>
|
||||||
|
@foreach($columns as $col)
|
||||||
|
<th
|
||||||
|
class="text-uppercase text-secondary text-xxs font-weight-bolder opacity-7 ps-3 py-3 border-bottom position-relative"
|
||||||
|
style="font-size: 0.75rem; letter-spacing: 0.5px;">
|
||||||
|
<div
|
||||||
|
class="d-flex align-items-center {{ $col['key'] === 'checkbox' ? 'justify-content-center' : 'justify-content-between' }}">
|
||||||
|
<span>
|
||||||
|
@if($col['key'] === 'checkbox')
|
||||||
|
{!! $col['label'] !!}
|
||||||
|
@else
|
||||||
{{ $col['label'] }}
|
{{ $col['label'] }}
|
||||||
</th>
|
@endif
|
||||||
@endforeach
|
</span>
|
||||||
</tr>
|
@if($col['key'] !== 'checkbox' && ($col['orderable'] ?? true))
|
||||||
|
<div class="sort-icons d-flex flex-column ms-2">
|
||||||
|
<i data-lucide="arrow-up" class="sort-icon-asc" width="10" height="10"></i>
|
||||||
|
<i data-lucide="arrow-down" class="sort-icon-desc" width="10" height="10" style="margin-top: -2px;"></i>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
</th>
|
||||||
|
@endforeach
|
||||||
|
</tr>
|
||||||
<tr class="filter-row bg-light">
|
<tr class="filter-row bg-light">
|
||||||
@foreach($columns as $col)
|
@foreach($columns as $col)
|
||||||
<th class="p-2 border-bottom">
|
<th class="p-2 border-bottom">
|
||||||
@@ -36,225 +102,479 @@ $dtColumns = collect($columns)->map(function ($c) {
|
|||||||
placeholder="Filter..." data-column="{{ $loop->index }}" style="font-size: 0.8125rem;">
|
placeholder="Filter..." data-column="{{ $loop->index }}" style="font-size: 0.8125rem;">
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
</th>
|
</th>
|
||||||
@endforeach
|
@endforeach
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{{-- DataTables will populate this --}}
|
{{-- DataTables will populate this --}}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
@push('custom-scripts')
|
@push('custom-scripts')
|
||||||
<script>
|
<script>
|
||||||
document.addEventListener('DOMContentLoaded', function () {
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
$.fn.DataTable.ext.pager.numbers_length = 7;
|
$.fn.DataTable.ext.pager.numbers_length = 7;
|
||||||
|
|
||||||
var table = $('#{{ $id }}').DataTable({
|
var table = $('#{{ $id }}').DataTable({
|
||||||
processing: true,
|
processing: true,
|
||||||
serverSide: true,
|
serverSide: true,
|
||||||
ajax: '{{ $ajax }}',
|
ajax: '{{ $ajax }}',
|
||||||
columns: @json($dtColumns),
|
columns: @json($dtColumns),
|
||||||
orderCellsTop: true,
|
orderCellsTop: true,
|
||||||
fixedHeader: false,
|
fixedHeader: false,
|
||||||
pagingType: 'full_numbers',
|
stateSave: true,
|
||||||
language: {
|
pagingType: 'full_numbers',
|
||||||
processing: '<div class="spinner-border text-primary" role="status" style="width: 2rem; height: 2rem;"><span class="visually-hidden">Loading...</span></div>',
|
language: {
|
||||||
searchPlaceholder: "Search...",
|
loadingRecords: '<div class="d-flex flex-column align-items-center justify-content-center py-5"><div class="spinner-border text-primary mb-3" role="status"></div><h6 class="text-secondary fw-medium">Đang tải dữ liệu...</h6></div>',
|
||||||
search: "",
|
searchPlaceholder: "Tìm kiếm...",
|
||||||
lengthMenu: "_MENU_",
|
search: "",
|
||||||
info: "Showing <span class='fw-bold'>_START_</span> to <span class='fw-bold'>_END_</span> of <span class='fw-bold'>_TOTAL_</span> entries",
|
lengthMenu: "_MENU_",
|
||||||
paginate: {
|
info: "Showing <span class='fw-bold'>_START_</span> to <span class='fw-bold'>_END_</span> of <span class='fw-bold'>_TOTAL_</span> entries",
|
||||||
first: '<span class="d-flex align-items-center justify-content-center"><i data-lucide="chevrons-left" width="16" height="16"></i></span>',
|
paginate: {
|
||||||
last: '<span class="d-flex align-items-center justify-content-center"><i data-lucide="chevrons-right" width="16" height="16"></i></span>',
|
first: '<span class="d-flex align-items-center justify-content-center"><i data-lucide="chevrons-left" width="16" height="16"></i></span>',
|
||||||
next: '<span class="d-flex align-items-center justify-content-center"><i data-lucide="chevron-right" width="16" height="16"></i></span>',
|
last: '<span class="d-flex align-items-center justify-content-center"><i data-lucide="chevrons-right" width="16" height="16"></i></span>',
|
||||||
previous: '<span class="d-flex align-items-center justify-content-center"><i data-lucide="chevron-left" width="16" height="16"></i></span>'
|
next: '<span class="d-flex align-items-center justify-content-center"><i data-lucide="chevron-right" width="16" height="16"></i></span>',
|
||||||
},
|
previous: '<span class="d-flex align-items-center justify-content-center"><i data-lucide="chevron-left" width="16" height="16"></i></span>'
|
||||||
zeroRecords: '<div class="d-flex flex-column align-items-center justify-content-center py-5"><div class="text-secondary mb-3"><i data-lucide="inbox" width="28" height="28" stroke-width="1.5"></i></div><h6 class="text-secondary fw-medium">No matching records found</h6></div>',
|
},
|
||||||
emptyTable: '<div class="d-flex flex-column align-items-center justify-content-center py-5"><div class="text-secondary mb-3"><i data-lucide="inbox" width="28" height="28" stroke-width="1.5"></i></div><h6 class="text-secondary fw-medium">No data available</h6></div>'
|
zeroRecords: '<div class="d-flex flex-column align-items-center justify-content-center py-5"><div class="text-secondary mb-3"><i data-lucide="inbox" width="28" height="28" stroke-width="1.5"></i></div><h6 class="text-secondary fw-medium">No matching records found</h6></div>',
|
||||||
},
|
emptyTable: '<div class="d-flex flex-column align-items-center justify-content-center py-5"><div class="text-secondary mb-3"><i data-lucide="inbox" width="28" height="28" stroke-width="1.5"></i></div><h6 class="text-secondary fw-medium">No data available</h6></div>'
|
||||||
dom: "<'row p-3'<'col-sm-12'tr>>" +
|
},
|
||||||
"<'row px-3 pb-3 pt-1 align-items-center'<'col-sm-12 col-md-5 text-muted small'i><'col-sm-12 col-md-7 d-flex align-items-center justify-content-end gap-2'lp>>",
|
dom: "<'row p-3'<'col-sm-12'tr>>" +
|
||||||
initComplete: function () {
|
"<'row px-3 pb-3 pt-1 align-items-center'<'col-sm-12 col-md-5 text-muted small'i><'col-sm-12 col-md-7 d-flex align-items-center justify-content-end gap-2'lp>>",
|
||||||
// Initialize select2 with custom styling
|
initComplete: function () {
|
||||||
$('.dataTables_length select').select2({
|
// Initialize select2 with custom styling
|
||||||
minimumResultsForSearch: Infinity,
|
$('.dataTables_length select').select2({
|
||||||
width: '80px',
|
minimumResultsForSearch: Infinity,
|
||||||
dropdownCssClass: 'small-select-dropdown',
|
width: '80px',
|
||||||
selectionCssClass: 'small-select-selection'
|
dropdownCssClass: 'small-select-dropdown',
|
||||||
});
|
selectionCssClass: 'small-select-selection'
|
||||||
|
});
|
||||||
|
|
||||||
// Debounced search for column inputs
|
// Debounced search for column inputs (ERP Standard: Reduce server load)
|
||||||
this.api().columns().every(function () {
|
let searchTimeouts = {};
|
||||||
var that = this;
|
this.api().columns().every(function () {
|
||||||
$('input', this.header()).on('keyup change clear', function () {
|
var that = this;
|
||||||
if (that.search() !== this.value) {
|
$('input', this.header()).on('keyup change clear', function () {
|
||||||
that.search(this.value).draw();
|
const colIdx = that.index();
|
||||||
|
const value = this.value;
|
||||||
|
|
||||||
|
clearTimeout(searchTimeouts[colIdx]);
|
||||||
|
searchTimeouts[colIdx] = setTimeout(function () {
|
||||||
|
if (that.search() !== value) {
|
||||||
|
that.search(value).draw();
|
||||||
|
}
|
||||||
|
}, 400); // 400ms delay
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
drawCallback: function () {
|
||||||
|
// Re-initialize Select2 on draw (if lost)
|
||||||
|
if ($('.dataTables_length select').data('select2')) {
|
||||||
|
$('.dataTables_length select').select2('destroy');
|
||||||
|
}
|
||||||
|
$('.dataTables_length select').select2({
|
||||||
|
minimumResultsForSearch: Infinity,
|
||||||
|
width: '80px'
|
||||||
|
});
|
||||||
|
|
||||||
|
// Re-initialize icons with slight delay to ensuring DOM is ready
|
||||||
|
setTimeout(function () {
|
||||||
|
if (window.lucide) {
|
||||||
|
lucide.createIcons();
|
||||||
|
}
|
||||||
|
}, 50);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
|
||||||
},
|
// ERP Standard: Double click row to edit
|
||||||
drawCallback: function () {
|
$('#{{ $id }} tbody').on('dblclick', 'tr', function () {
|
||||||
// Re-initialize Select2 on draw (if lost)
|
// Try to find an edit link in the row
|
||||||
if ($('.dataTables_length select').data('select2')) {
|
const editLink = $(this).find('a.btn-outline-primary, a[href*="edit"]').first();
|
||||||
$('.dataTables_length select').select2('destroy');
|
if (editLink.length && editLink.attr('href')) {
|
||||||
}
|
window.location.href = editLink.attr('href');
|
||||||
$('.dataTables_length select').select2({
|
}
|
||||||
minimumResultsForSearch: Infinity,
|
});
|
||||||
width: '80px'
|
|
||||||
|
// Custom Loading Process Logic
|
||||||
|
table.on('processing.dt', function (e, settings, processing) {
|
||||||
|
const loadingEl = $('#{{ $id }}-loading');
|
||||||
|
if (processing) {
|
||||||
|
loadingEl.fadeIn(100);
|
||||||
|
} else {
|
||||||
|
loadingEl.fadeOut(200);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Prevent sorting when clicking on the input
|
||||||
|
$('#{{ $id }} thead tr:eq(1) th').on('click', function (e) {
|
||||||
|
e.stopPropagation();
|
||||||
|
});
|
||||||
|
|
||||||
|
// External trigger for column search (redundant but kept for manual binding if needed)
|
||||||
|
$('#{{ $id }} .column-search').on('keyup change', function () {
|
||||||
|
var columnIndex = $(this).data('column');
|
||||||
|
table.column(columnIndex).search(this.value).draw();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Re-initialize icons with slight delay to ensuring DOM is ready
|
@if($bulkDeleteUrl)
|
||||||
setTimeout(function () {
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
if (window.lucide) {
|
const tableId = '#{{ $id }}';
|
||||||
lucide.createIcons();
|
const bulkActions = $('#{{ $id }}-bulk-actions');
|
||||||
}
|
const deleteBtn = $('#{{ $id }}-bulk-delete-btn');
|
||||||
}, 50);
|
const selectedCount = $('#{{ $id }}-selected-count');
|
||||||
}
|
const masterCheckbox = $('#dt-master-checkbox');
|
||||||
});
|
let selectedIds = [];
|
||||||
|
|
||||||
// Prevent sorting when clicking on the input
|
// Handle Master Checkbox
|
||||||
$('#{{ $id }} thead tr:eq(1) th').on('click', function (e) {
|
$(document).on('change', '#dt-master-checkbox', function () {
|
||||||
e.stopPropagation();
|
const isChecked = $(this).is(':checked');
|
||||||
});
|
$('.dt-checkbox').prop('checked', isChecked).trigger('change');
|
||||||
|
});
|
||||||
|
|
||||||
// External trigger for column search (redundant but kept for manual binding if needed)
|
// Handle Individual Checkbox
|
||||||
$('#{{ $id }} .column-search').on('keyup change', function () {
|
$(document).on('change', '.dt-checkbox', function () {
|
||||||
var columnIndex = $(this).data('column');
|
const id = $(this).val();
|
||||||
table.column(columnIndex).search(this.value).draw();
|
if ($(this).is(':checked')) {
|
||||||
});
|
if (!selectedIds.includes(id)) selectedIds.push(id);
|
||||||
});
|
} else {
|
||||||
</script>
|
selectedIds = selectedIds.filter(item => item !== id);
|
||||||
|
}
|
||||||
|
|
||||||
<style>
|
// Update UI
|
||||||
/* Custom SAAS DataTable Styles */
|
selectedCount.text(selectedIds.length);
|
||||||
.data-table-wrapper {
|
if (selectedIds.length > 0) {
|
||||||
background: #fff;
|
bulkActions.show();
|
||||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
|
bulkActions.removeClass('d-none').addClass('d-flex');
|
||||||
overflow-y: auto;
|
bulkActions.attr('style', ''); // Clear inline style
|
||||||
position: relative;
|
} else {
|
||||||
}
|
bulkActions.hide();
|
||||||
|
}
|
||||||
|
|
||||||
.pagination button.page-link {
|
// Update Master Checkbox state
|
||||||
height: 100%;
|
const allCheckboxes = $('.dt-checkbox').length;
|
||||||
}
|
const checkedCheckboxes = $('.dt-checkbox:checked').length;
|
||||||
|
|
||||||
.data-table-wrapper .table thead th {
|
if (allCheckboxes > 0 && allCheckboxes === checkedCheckboxes) {
|
||||||
border-color: #f1f5f9 !important;
|
masterCheckbox.prop('checked', true);
|
||||||
font-family: 'Inter', sans-serif;
|
masterCheckbox.prop('indeterminate', false);
|
||||||
vertical-align: middle;
|
} else if (checkedCheckboxes > 0) {
|
||||||
position: sticky;
|
masterCheckbox.prop('checked', false);
|
||||||
top: 0;
|
masterCheckbox.prop('indeterminate', true);
|
||||||
z-index: 5;
|
} else {
|
||||||
background-color: #f8f9fa;
|
masterCheckbox.prop('checked', false);
|
||||||
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
|
masterCheckbox.prop('indeterminate', false);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
.data-table-wrapper .table td:not(:last-child) {
|
// Reset selection on table draw
|
||||||
border-right: 1px solid #f1f5f9;
|
$('#{{ $id }}').on('draw.dt', function () {
|
||||||
}
|
selectedIds = [];
|
||||||
|
bulkActions.hide();
|
||||||
|
masterCheckbox.prop('checked', false);
|
||||||
|
masterCheckbox.prop('indeterminate', false);
|
||||||
|
});
|
||||||
|
|
||||||
/* Sticky for second row (filter inputs) if present */
|
// Handle Bulk Delete Opener
|
||||||
.data-table-wrapper .table thead tr:nth-child(2) th {
|
const modalId = '{{ $id }}-bulk-delete-modal';
|
||||||
top: 45px;
|
const modalEl = document.getElementById(modalId);
|
||||||
/* Adjust based on typical header height */
|
const openerBtn = $('#{{ $id }}-bulk-delete-opener-btn');
|
||||||
z-index: 4;
|
const confirmBtn = $('#{{ $id }}-confirm-bulk-delete-btn');
|
||||||
}
|
const countDisplay = $('#{{ $id }}-bulk-delete-count-display');
|
||||||
|
let bsModal = null;
|
||||||
|
|
||||||
.data-table-wrapper .input-group-text {
|
openerBtn.on('click', function () {
|
||||||
color: #94a3b8;
|
if (selectedIds.length === 0) return;
|
||||||
/* Slate 400 */
|
countDisplay.text(selectedIds.length);
|
||||||
}
|
|
||||||
|
|
||||||
.data-table-wrapper .form-control::placeholder {
|
if (!bsModal) {
|
||||||
color: #cbd5e1;
|
bsModal = new bootstrap.Modal(modalEl);
|
||||||
/* Slate 300 */
|
}
|
||||||
}
|
bsModal.show();
|
||||||
|
});
|
||||||
|
|
||||||
.dataTables_wrapper .pagination .page-item .page-link {
|
// Handle Confirm Delete
|
||||||
border: 1px solid transparent;
|
confirmBtn.on('click', function () {
|
||||||
border-radius: 6px;
|
$.ajax({
|
||||||
margin: 0 2px;
|
url: '{{ $bulkDeleteUrl }}',
|
||||||
color: #64748b;
|
type: 'DELETE',
|
||||||
padding: 0;
|
data: {
|
||||||
font-size: 0.875rem;
|
ids: selectedIds,
|
||||||
transition: all 0.2s ease;
|
_token: '{{ csrf_token() }}'
|
||||||
display: flex;
|
},
|
||||||
align-items: center;
|
beforeSend: function () {
|
||||||
justify-content: center;
|
confirmBtn.prop('disabled', true).text('Deleting...');
|
||||||
height: 38px;
|
},
|
||||||
min-width: 38px;
|
success: function (response) {
|
||||||
}
|
if (bsModal) bsModal.hide();
|
||||||
|
$('#{{ $id }}').DataTable().ajax.reload();
|
||||||
|
selectedIds = [];
|
||||||
|
bulkActions.hide();
|
||||||
|
|
||||||
.dataTables_wrapper .pagination .page-item.active .page-link {
|
// Show success toast
|
||||||
background-color: #0f172a;
|
if (typeof FuiToast !== 'undefined') {
|
||||||
/* Slate 900 or Primary Color */
|
FuiToast.success(response.message || 'Selected items have been deleted successfully.');
|
||||||
color: white;
|
}
|
||||||
font-weight: 500;
|
|
||||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
|
||||||
border-color: #0f172a;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dataTables_wrapper .pagination .page-item.disabled .page-link {
|
// Re-render icons after reload
|
||||||
color: #cbd5e1;
|
if (window.lucide) lucide.createIcons();
|
||||||
background-color: transparent;
|
},
|
||||||
}
|
error: function (xhr) {
|
||||||
|
const message = xhr.responseJSON?.message || 'Something went wrong.';
|
||||||
|
if (typeof FuiToast !== 'undefined') {
|
||||||
|
FuiToast.error(message);
|
||||||
|
} else {
|
||||||
|
alert(message);
|
||||||
|
}
|
||||||
|
if (bsModal) bsModal.hide();
|
||||||
|
},
|
||||||
|
complete: function () {
|
||||||
|
confirmBtn.prop('disabled', false).text('Delete');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
@endif
|
||||||
|
</script>
|
||||||
|
|
||||||
.dataTables_wrapper .pagination .page-item:not(.active) .page-link:hover {
|
<style>
|
||||||
background-color: #f8fafc;
|
/* Custom SAAS DataTable Styles */
|
||||||
color: #0f172a;
|
.data-table-wrapper {
|
||||||
border-color: #e2e8f0;
|
background: #fff;
|
||||||
}
|
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
|
||||||
|
overflow-y: auto;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
/* Select2 Customization for Table Length */
|
.pagination button.page-link {
|
||||||
.dataTables_length {
|
height: 100%;
|
||||||
margin-right: 1rem;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
.select2-container--default .select2-selection--single {
|
.data-table-wrapper .table thead th {
|
||||||
border: 1px solid #e2e8f0;
|
border-color: #f1f5f9 !important;
|
||||||
border-radius: 6px;
|
font-family: 'Inter', sans-serif;
|
||||||
height: 32px;
|
vertical-align: middle;
|
||||||
display: flex;
|
position: sticky;
|
||||||
align-items: center;
|
top: 0;
|
||||||
outline: none;
|
z-index: 10;
|
||||||
}
|
background-color: #f8f9fa;
|
||||||
|
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
|
||||||
|
}
|
||||||
|
|
||||||
.select2-container--default .select2-selection--single:focus {
|
/* Sticky Action Column (ERP Standard for wide tables) */
|
||||||
border-color: #94a3b8;
|
.table thead th:last-child,
|
||||||
}
|
.table tbody td:last-child {
|
||||||
|
position: sticky;
|
||||||
|
right: 0;
|
||||||
|
background: #fff;
|
||||||
|
z-index: 5;
|
||||||
|
border-left: 1px solid #f1f5f9;
|
||||||
|
box-shadow: -2px 0 5px rgba(0, 0, 0, 0.02);
|
||||||
|
}
|
||||||
|
|
||||||
.select2-container--default .select2-selection--single .select2-selection__arrow {
|
.table thead th:last-child {
|
||||||
height: 30px;
|
background: #f8f9fa;
|
||||||
}
|
z-index: 11;
|
||||||
|
}
|
||||||
|
|
||||||
.select2-container--default .select2-selection--single .select2-selection__rendered {
|
/* Sticky Checkbox Column */
|
||||||
color: #475569;
|
.table thead th:first-child,
|
||||||
font-size: 0.8125rem;
|
.table tbody td:first-child {
|
||||||
padding-left: 10px;
|
position: sticky;
|
||||||
line-height: normal;
|
left: 0;
|
||||||
}
|
background: #fff;
|
||||||
|
z-index: 5;
|
||||||
|
border-right: 1px solid #f1f5f9;
|
||||||
|
box-shadow: 2px 0 5px rgba(0, 0, 0, 0.02);
|
||||||
|
}
|
||||||
|
|
||||||
/* Processing Indicator with improved look - Centered */
|
.table thead th:first-child {
|
||||||
div.dataTables_processing {
|
background: #f8f9fa;
|
||||||
position: absolute;
|
z-index: 11;
|
||||||
top: 50% !important;
|
}
|
||||||
left: 50% !important;
|
|
||||||
transform: translate(-50%, -50%);
|
.table tbody tr:hover td {
|
||||||
width: auto !important;
|
background-color: #f8fafc !important;
|
||||||
margin: 0 !important;
|
cursor: pointer;
|
||||||
padding: 1rem 2rem;
|
}
|
||||||
text-align: center;
|
|
||||||
font-size: 1.2em;
|
.data-table-wrapper .table td:not(:last-child) {
|
||||||
background: rgba(255, 255, 255, 0.9);
|
border-right: 1px solid #f1f5f9;
|
||||||
border-radius: 8px;
|
}
|
||||||
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
|
|
||||||
z-index: 100;
|
/* Sticky for second row (filter inputs) if present */
|
||||||
display: flex;
|
.data-table-wrapper .table thead tr:nth-child(2) th {
|
||||||
align-items: center;
|
top: 45px;
|
||||||
justify-content: center;
|
/* Adjust based on typical header height */
|
||||||
border: 1px solid #e2e8f0;
|
z-index: 4;
|
||||||
color: #0f172a;
|
}
|
||||||
}
|
|
||||||
</style>
|
.data-table-wrapper .input-group-text {
|
||||||
@endpush
|
color: #94a3b8;
|
||||||
|
/* Slate 400 */
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-table-wrapper .form-control::placeholder {
|
||||||
|
color: #cbd5e1;
|
||||||
|
/* Slate 300 */
|
||||||
|
}
|
||||||
|
|
||||||
|
.dataTables_wrapper .pagination .page-item .page-link {
|
||||||
|
border: 1px solid transparent;
|
||||||
|
border-radius: 6px;
|
||||||
|
margin: 0 2px;
|
||||||
|
color: #64748b;
|
||||||
|
padding: 0;
|
||||||
|
font-size: 0.875rem;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
height: 38px;
|
||||||
|
min-width: 38px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dataTables_wrapper .pagination .page-item.active .page-link {
|
||||||
|
background-color: #0f172a;
|
||||||
|
/* Slate 900 or Primary Color */
|
||||||
|
color: white;
|
||||||
|
font-weight: 500;
|
||||||
|
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||||
|
border-color: #0f172a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dataTables_wrapper .pagination .page-item.disabled .page-link {
|
||||||
|
color: #cbd5e1;
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dataTables_wrapper .pagination .page-item:not(.active) .page-link:hover {
|
||||||
|
background-color: #f8fafc;
|
||||||
|
color: #0f172a;
|
||||||
|
border-color: #e2e8f0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Select2 Customization for Table Length */
|
||||||
|
.dataTables_length {
|
||||||
|
margin-right: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-container--default .select2-selection--single {
|
||||||
|
border: 1px solid #e2e8f0;
|
||||||
|
border-radius: 6px;
|
||||||
|
height: 32px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-container--default .select2-selection--single:focus {
|
||||||
|
border-color: #94a3b8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-container--default .select2-selection--single .select2-selection__arrow {
|
||||||
|
height: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-container--default .select2-selection--single .select2-selection__rendered {
|
||||||
|
color: #475569;
|
||||||
|
font-size: 0.8125rem;
|
||||||
|
padding-left: 10px;
|
||||||
|
line-height: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Loading Process Styles */
|
||||||
|
.loading-process {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
z-index: 1000;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.loading-bar {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
height: 3px;
|
||||||
|
width: 100%;
|
||||||
|
background: #f1f5f9;
|
||||||
|
overflow: hidden;
|
||||||
|
z-index: 1001;
|
||||||
|
}
|
||||||
|
|
||||||
|
.loading-bar::after {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
height: 100%;
|
||||||
|
width: 50%;
|
||||||
|
background: linear-gradient(90deg, transparent, #0f172a, transparent);
|
||||||
|
animation: loading-process-info 1.5s infinite linear;
|
||||||
|
}
|
||||||
|
|
||||||
|
.loading-overlay {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background: rgba(255, 255, 255, 0.5);
|
||||||
|
backdrop-filter: blur(1px);
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes loading-process-info {
|
||||||
|
0% {
|
||||||
|
transform: translateX(-100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
100% {
|
||||||
|
transform: translateX(200%);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Custom Sort Icons Styles */
|
||||||
|
.sort-icons {
|
||||||
|
opacity: 0.15;
|
||||||
|
transition: opacity 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
th:hover .sort-icons {
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
th.sorting_asc .sort-icons {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
th.sorting_asc .sort-icon-desc {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
th.sorting_desc .sort-icons {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
th.sorting_desc .sort-icon-asc {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Hide default DataTables icons */
|
||||||
|
table.dataTable thead .sorting:before,
|
||||||
|
table.dataTable thead .sorting:after,
|
||||||
|
table.dataTable thead .sorting_asc:before,
|
||||||
|
table.dataTable thead .sorting_asc:after,
|
||||||
|
table.dataTable thead .sorting_desc:before,
|
||||||
|
table.dataTable thead .sorting_desc:after {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Processing Indicator with improved look - Centered */
|
||||||
|
div.dataTables_processing {
|
||||||
|
display: none !important;
|
||||||
|
/* Hide default processing */
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
@endpush
|
||||||
@@ -142,6 +142,7 @@ Route::prefix('administrator')->group(function () {
|
|||||||
Route::get('view-group-item/{id}', 'edit')->name('edit');
|
Route::get('view-group-item/{id}', 'edit')->name('edit');
|
||||||
Route::put('view-group-item/{id}', 'update')->name('update');
|
Route::put('view-group-item/{id}', 'update')->name('update');
|
||||||
Route::delete('remove-group-item/{id}', 'destroy')->name('destroy');
|
Route::delete('remove-group-item/{id}', 'destroy')->name('destroy');
|
||||||
|
Route::delete('bulk-delete', 'bulkDelete')->name('bulkDelete');
|
||||||
Route::get('datatable', 'datatable')->name('datatable');
|
Route::get('datatable', 'datatable')->name('datatable');
|
||||||
Route::get('trash', 'trash')->name('trash');
|
Route::get('trash', 'trash')->name('trash');
|
||||||
Route::get('restore/{id}', 'restore')->name('restore');
|
Route::get('restore/{id}', 'restore')->name('restore');
|
||||||
|
|||||||
Reference in New Issue
Block a user