update
This commit is contained in:
@@ -4,11 +4,13 @@
|
|||||||
data-bs-toggle="modal" data-bs-target="#deleteModal-{{ $row->id }}" />
|
data-bs-toggle="modal" data-bs-target="#deleteModal-{{ $row->id }}" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@include('administrator.pages.product.categories.datatable.modal', [
|
@push('modals')
|
||||||
'deleteRoute' => 'products.group.destroy',
|
@include('administrator.pages.product.categories.datatable.modal', [
|
||||||
'itemLabel' => 'Product Group',
|
'deleteRoute' => 'products.group.destroy',
|
||||||
'itemId' => $row->id,
|
'itemLabel' => 'Product Group',
|
||||||
'itemName' => $row->name,
|
'itemId' => $row->id,
|
||||||
'modalId' => 'deleteModal-' . $row->id
|
'itemName' => $row->name,
|
||||||
])
|
'modalId' => 'deleteModal-' . $row->id
|
||||||
|
])
|
||||||
|
@endpush
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<!-- Delete Confirmation Modal -->
|
<!-- Delete Confirmation Modal -->
|
||||||
<div class="modal fade" id="{{ $modalId ?? 'deleteModal' }}" tabindex="-1"
|
<div class="modal fade" id="{{ $modalId ?? 'deleteModal' }}" tabindex="-1"
|
||||||
aria-labelledby="deleteModalLabel-{{ $modalId ?? 'deleteModal' }}" aria-hidden="true">
|
aria-labelledby="deleteModalLabel-{{ $modalId ?? 'deleteModal' }}" aria-hidden="true" data-bs-backdrop="true">
|
||||||
<div class="modal-dialog modal-dialog-centered modal-sm">
|
<div class="modal-dialog modal-dialog-centered modal-sm">
|
||||||
<div class="modal-content shadow-lg border-0">
|
<div class="modal-content shadow-lg border-0">
|
||||||
<div class="modal-header bg-danger text-white py-2">
|
<div class="modal-header bg-danger text-white py-2">
|
||||||
@@ -9,8 +9,8 @@
|
|||||||
Xác nhận xóa
|
Xác nhận xóa
|
||||||
</h6>
|
</h6>
|
||||||
<button type="button" class="btn-close btn-close-white shadow-none" data-bs-dismiss="modal" aria-label="Close"></button>
|
<button type="button" class="btn-close btn-close-white shadow-none" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body py-4">
|
<div class="modal-body py-4">
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<i data-lucide="alert-triangle" class="text-warning" style="width: 54px; height: 54px;"></i>
|
<i data-lucide="alert-triangle" class="text-warning" style="width: 54px; height: 54px;"></i>
|
||||||
@@ -21,11 +21,11 @@
|
|||||||
<div class="px-3 py-2 bg-danger-subtle rounded-3">
|
<div class="px-3 py-2 bg-danger-subtle rounded-3">
|
||||||
<p class="text-danger small mb-0 fw-medium">Hành động này không thể hoàn tác!</p>
|
<p class="text-danger small mb-0 fw-medium">Hành động này không thể hoàn tác!</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer bg-light border-0 py-2 d-flex justify-content-center gap-2">
|
<div class="modal-footer bg-light border-0 py-2 d-flex justify-content-center gap-2">
|
||||||
<x-button-c-r-m type="button" variant="secondary" size="sm" icon="x" data-bs-dismiss="modal">Hủy bỏ</x-button-c-r-m>
|
<x-button-c-r-m type="button" variant="secondary" size="sm" icon="x" data-bs-dismiss="modal">Hủy bỏ</x-button-c-r-m>
|
||||||
<form action="{{ route($deleteRoute, ['id' => $itemId ?? 0]) }}" method="POST" class="d-inline m-0">
|
<form action="{{ route($deleteRoute, ['id' => $itemId ?? 0]) }}" method="POST" class="d-inline m-0">
|
||||||
@csrf
|
@csrf
|
||||||
@method('DELETE')
|
@method('DELETE')
|
||||||
<x-button-c-r-m type="submit" variant="danger" size="sm" icon="trash-2">Xác nhận xóa</x-button-c-r-m>
|
<x-button-c-r-m type="submit" variant="danger" size="sm" icon="trash-2">Xác nhận xóa</x-button-c-r-m>
|
||||||
|
|||||||
@@ -64,8 +64,55 @@ $tabs = [
|
|||||||
@push('custom-scripts')
|
@push('custom-scripts')
|
||||||
<script>
|
<script>
|
||||||
document.addEventListener('DOMContentLoaded', function () {
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
// DataTable is already initialized in components/datatable
|
// Re-initialize Lucide icons after DataTable draws
|
||||||
// If we need custom behavior here, we can add it.
|
$('#productTable').on('draw.dt', function() {
|
||||||
|
setTimeout(function() {
|
||||||
|
if (typeof lucide !== 'undefined') {
|
||||||
|
lucide.createIcons();
|
||||||
|
}
|
||||||
|
}, 100);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@endpush
|
@endpush
|
||||||
|
|
||||||
|
@push('custom-styles')
|
||||||
|
<style>
|
||||||
|
/* Fix Bootstrap 5 modal z-index to be above DataTable and all other elements */
|
||||||
|
.modal-backdrop {
|
||||||
|
z-index: 9998 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal {
|
||||||
|
z-index: 9999 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Override datatable wrapper overflow to prevent clipping modals */
|
||||||
|
.data-table-wrapper {
|
||||||
|
overflow: visible !important;
|
||||||
|
overflow-x: auto !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Reduce z-index of sticky elements to be below modal */
|
||||||
|
.data-table-wrapper .table thead th {
|
||||||
|
z-index: 3 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table thead th:last-child,
|
||||||
|
.table tbody td:last-child {
|
||||||
|
z-index: 2 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table thead th:first-child,
|
||||||
|
.table tbody td:first-child {
|
||||||
|
z-index: 2 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table thead th:nth-child(2) {
|
||||||
|
z-index: 4 !important;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
@endpush
|
||||||
|
|
||||||
|
{{-- Render all modals outside datatable wrapper --}}
|
||||||
|
@stack('modals')
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
@props(['id', 'columns', 'ajax', 'bulkDeleteUrl' => null])
|
@props(['id', 'columns', 'ajax', 'bulkDeleteUrl' => null])
|
||||||
|
|
||||||
@php
|
@php
|
||||||
$dtColumns = collect($columns)
|
$dtColumns = collect($columns)
|
||||||
->map(function ($c) {
|
->map(function ($c) {
|
||||||
return [
|
return [
|
||||||
'data' => $c['key'],
|
'data' => $c['key'],
|
||||||
'name' => $c['key'],
|
'name' => $c['key'],
|
||||||
'orderable' => $c['orderable'] ?? true,
|
'orderable' => $c['orderable'] ?? true,
|
||||||
'searchable' => $c['searchable'] ?? true,
|
'searchable' => $c['searchable'] ?? true,
|
||||||
'className' => $c['className'] ?? '',
|
'className' => $c['className'] ?? '',
|
||||||
];
|
];
|
||||||
})
|
})
|
||||||
->values();
|
->values();
|
||||||
@endphp
|
@endphp
|
||||||
@if ($bulkDeleteUrl)
|
@if ($bulkDeleteUrl)
|
||||||
<div class="d-flex justify-content-start align-items-center mb-3" id="{{ $id }}-bulk-actions"
|
<div class="d-flex justify-content-start align-items-center mb-3" id="{{ $id }}-bulk-actions"
|
||||||
@@ -116,473 +116,473 @@
|
|||||||
</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,
|
||||||
stateSave: true,
|
stateSave: true,
|
||||||
pagingType: 'full_numbers',
|
pagingType: 'full_numbers',
|
||||||
language: {
|
language: {
|
||||||
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>',
|
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>',
|
||||||
searchPlaceholder: "Tìm kiếm...",
|
searchPlaceholder: "Tìm kiếm...",
|
||||||
search: "",
|
search: "",
|
||||||
lengthMenu: "_MENU_",
|
lengthMenu: "_MENU_",
|
||||||
info: "Showing <span class='fw-bold'>_START_</span> to <span class='fw-bold'>_END_</span> of <span class='fw-bold'>_TOTAL_</span> entries",
|
info: "Showing <span class='fw-bold'>_START_</span> to <span class='fw-bold'>_END_</span> of <span class='fw-bold'>_TOTAL_</span> entries",
|
||||||
paginate: {
|
paginate: {
|
||||||
first: '<span class="d-flex align-items-center justify-content-center"><i data-lucide="chevrons-left" 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>',
|
||||||
last: '<span class="d-flex align-items-center justify-content-center"><i data-lucide="chevrons-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>',
|
||||||
next: '<span class="d-flex align-items-center justify-content-center"><i data-lucide="chevron-right" 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>'
|
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>',
|
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>'
|
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>>" +
|
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>>",
|
"<'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>>",
|
||||||
initComplete: function() {
|
initComplete: function() {
|
||||||
// Initialize select2 with custom styling
|
// Initialize select2 with custom styling
|
||||||
$('.dataTables_length select').select2({
|
$('.dataTables_length select').select2({
|
||||||
minimumResultsForSearch: Infinity,
|
minimumResultsForSearch: Infinity,
|
||||||
width: '80px',
|
width: '80px',
|
||||||
dropdownCssClass: 'small-select-dropdown',
|
dropdownCssClass: 'small-select-dropdown',
|
||||||
selectionCssClass: 'small-select-selection'
|
selectionCssClass: 'small-select-selection'
|
||||||
});
|
});
|
||||||
|
|
||||||
// Debounced search for column inputs (ERP Standard: Reduce server load)
|
// Debounced search for column inputs (ERP Standard: Reduce server load)
|
||||||
let searchTimeouts = {};
|
let searchTimeouts = {};
|
||||||
this.api().columns().every(function() {
|
this.api().columns().every(function() {
|
||||||
var that = this;
|
var that = this;
|
||||||
$('input', this.header()).on('keyup change clear', function() {
|
$('input', this.header()).on('keyup change clear', function() {
|
||||||
const colIdx = that.index();
|
const colIdx = that.index();
|
||||||
const value = this.value;
|
const value = this.value;
|
||||||
|
|
||||||
clearTimeout(searchTimeouts[colIdx]);
|
clearTimeout(searchTimeouts[colIdx]);
|
||||||
searchTimeouts[colIdx] = setTimeout(function() {
|
searchTimeouts[colIdx] = setTimeout(function() {
|
||||||
if (that.search() !== value) {
|
if (that.search() !== value) {
|
||||||
that.search(value).draw();
|
that.search(value).draw();
|
||||||
}
|
}
|
||||||
}, 400); // 400ms delay
|
}, 400); // 400ms delay
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
drawCallback: function() {
|
drawCallback: function() {
|
||||||
// Re-initialize Select2 on draw (if lost)
|
// Re-initialize Select2 on draw (if lost)
|
||||||
if ($('.dataTables_length select').data('select2')) {
|
if ($('.dataTables_length select').data('select2')) {
|
||||||
$('.dataTables_length select').select2('destroy');
|
$('.dataTables_length select').select2('destroy');
|
||||||
}
|
}
|
||||||
$('.dataTables_length select').select2({
|
$('.dataTables_length select').select2({
|
||||||
minimumResultsForSearch: Infinity,
|
minimumResultsForSearch: Infinity,
|
||||||
width: '80px'
|
width: '80px'
|
||||||
});
|
});
|
||||||
|
|
||||||
// Re-initialize icons with slight delay to ensuring DOM is ready
|
// Re-initialize icons with slight delay to ensuring DOM is ready
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
if (window.lucide) {
|
if (window.lucide) {
|
||||||
lucide.createIcons();
|
lucide.createIcons();
|
||||||
}
|
}
|
||||||
}, 50);
|
}, 50);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// ERP Standard: Double click row to edit
|
// ERP Standard: Double click row to edit
|
||||||
$('#{{ $id }} tbody').on('dblclick', 'tr', function() {
|
$('#{{ $id }} tbody').on('dblclick', 'tr', function() {
|
||||||
// Try to find an edit link in the row
|
// Try to find an edit link in the row
|
||||||
const editLink = $(this).find('a.btn-outline-primary, a[href*="edit"]').first();
|
const editLink = $(this).find('a.btn-outline-primary, a[href*="edit"]').first();
|
||||||
if (editLink.length && editLink.attr('href')) {
|
if (editLink.length && editLink.attr('href')) {
|
||||||
window.location.href = editLink.attr('href');
|
window.location.href = editLink.attr('href');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Custom Loading Process Logic
|
// Custom Loading Process Logic
|
||||||
table.on('processing.dt', function(e, settings, processing) {
|
table.on('processing.dt', function(e, settings, processing) {
|
||||||
const loadingEl = $('#{{ $id }}-loading');
|
const loadingEl = $('#{{ $id }}-loading');
|
||||||
if (processing) {
|
if (processing) {
|
||||||
loadingEl.fadeIn(100);
|
loadingEl.fadeIn(100);
|
||||||
} else {
|
} else {
|
||||||
loadingEl.fadeOut(200);
|
loadingEl.fadeOut(200);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Prevent sorting when clicking on the input
|
// Prevent sorting when clicking on the input
|
||||||
$('#{{ $id }} thead tr:eq(1) th').on('click', function(e) {
|
$('#{{ $id }} thead tr:eq(1) th').on('click', function(e) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
});
|
});
|
||||||
|
|
||||||
// External trigger for column search (redundant but kept for manual binding if needed)
|
// External trigger for column search (redundant but kept for manual binding if needed)
|
||||||
$('#{{ $id }} .column-search').on('keyup change', function() {
|
$('#{{ $id }} .column-search').on('keyup change', function() {
|
||||||
var columnIndex = $(this).data('column');
|
var columnIndex = $(this).data('column');
|
||||||
table.column(columnIndex).search(this.value).draw();
|
table.column(columnIndex).search(this.value).draw();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@if ($bulkDeleteUrl)
|
@if ($bulkDeleteUrl)
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
const tableId = '#{{ $id }}';
|
const tableId = '#{{ $id }}';
|
||||||
const bulkActions = $('#{{ $id }}-bulk-actions');
|
const bulkActions = $('#{{ $id }}-bulk-actions');
|
||||||
const deleteBtn = $('#{{ $id }}-bulk-delete-btn');
|
const deleteBtn = $('#{{ $id }}-bulk-delete-btn');
|
||||||
const selectedCount = $('#{{ $id }}-selected-count');
|
const selectedCount = $('#{{ $id }}-selected-count');
|
||||||
const masterCheckbox = $('#dt-master-checkbox');
|
const masterCheckbox = $('#dt-master-checkbox');
|
||||||
let selectedIds = [];
|
let selectedIds = [];
|
||||||
|
|
||||||
// Handle Master Checkbox
|
// Handle Master Checkbox
|
||||||
$(document).on('change', '#dt-master-checkbox', function() {
|
$(document).on('change', '#dt-master-checkbox', function() {
|
||||||
const isChecked = $(this).is(':checked');
|
const isChecked = $(this).is(':checked');
|
||||||
$('.dt-checkbox').prop('checked', isChecked).trigger('change');
|
$('.dt-checkbox').prop('checked', isChecked).trigger('change');
|
||||||
});
|
});
|
||||||
|
|
||||||
// Handle Individual Checkbox
|
// Handle Individual Checkbox
|
||||||
$(document).on('change', '.dt-checkbox', function() {
|
$(document).on('change', '.dt-checkbox', function() {
|
||||||
const id = $(this).val();
|
const id = $(this).val();
|
||||||
if ($(this).is(':checked')) {
|
if ($(this).is(':checked')) {
|
||||||
if (!selectedIds.includes(id)) selectedIds.push(id);
|
if (!selectedIds.includes(id)) selectedIds.push(id);
|
||||||
} else {
|
} else {
|
||||||
selectedIds = selectedIds.filter(item => item !== id);
|
selectedIds = selectedIds.filter(item => item !== id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update UI
|
// Update UI
|
||||||
selectedCount.text(selectedIds.length);
|
selectedCount.text(selectedIds.length);
|
||||||
if (selectedIds.length > 0) {
|
if (selectedIds.length > 0) {
|
||||||
bulkActions.show();
|
bulkActions.show();
|
||||||
bulkActions.removeClass('d-none').addClass('d-flex');
|
bulkActions.removeClass('d-none').addClass('d-flex');
|
||||||
bulkActions.attr('style', ''); // Clear inline style
|
bulkActions.attr('style', ''); // Clear inline style
|
||||||
} else {
|
} else {
|
||||||
bulkActions.hide();
|
bulkActions.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update Master Checkbox state
|
// Update Master Checkbox state
|
||||||
const allCheckboxes = $('.dt-checkbox').length;
|
const allCheckboxes = $('.dt-checkbox').length;
|
||||||
const checkedCheckboxes = $('.dt-checkbox:checked').length;
|
const checkedCheckboxes = $('.dt-checkbox:checked').length;
|
||||||
|
|
||||||
if (allCheckboxes > 0 && allCheckboxes === checkedCheckboxes) {
|
if (allCheckboxes > 0 && allCheckboxes === checkedCheckboxes) {
|
||||||
masterCheckbox.prop('checked', true);
|
masterCheckbox.prop('checked', true);
|
||||||
masterCheckbox.prop('indeterminate', false);
|
masterCheckbox.prop('indeterminate', false);
|
||||||
} else if (checkedCheckboxes > 0) {
|
} else if (checkedCheckboxes > 0) {
|
||||||
masterCheckbox.prop('checked', false);
|
masterCheckbox.prop('checked', false);
|
||||||
masterCheckbox.prop('indeterminate', true);
|
masterCheckbox.prop('indeterminate', true);
|
||||||
} else {
|
} else {
|
||||||
masterCheckbox.prop('checked', false);
|
masterCheckbox.prop('checked', false);
|
||||||
masterCheckbox.prop('indeterminate', false);
|
masterCheckbox.prop('indeterminate', false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Reset selection on table draw
|
// Reset selection on table draw
|
||||||
$('#{{ $id }}').on('draw.dt', function() {
|
$('#{{ $id }}').on('draw.dt', function() {
|
||||||
selectedIds = [];
|
selectedIds = [];
|
||||||
bulkActions.hide();
|
bulkActions.hide();
|
||||||
masterCheckbox.prop('checked', false);
|
masterCheckbox.prop('checked', false);
|
||||||
masterCheckbox.prop('indeterminate', false);
|
masterCheckbox.prop('indeterminate', false);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Handle Bulk Delete Opener
|
// Handle Bulk Delete Opener
|
||||||
const modalId = '{{ $id }}-bulk-delete-modal';
|
const modalId = '{{ $id }}-bulk-delete-modal';
|
||||||
const modalEl = document.getElementById(modalId);
|
const modalEl = document.getElementById(modalId);
|
||||||
const openerBtn = $('#{{ $id }}-bulk-delete-opener-btn');
|
const openerBtn = $('#{{ $id }}-bulk-delete-opener-btn');
|
||||||
const confirmBtn = $('#{{ $id }}-confirm-bulk-delete-btn');
|
const confirmBtn = $('#{{ $id }}-confirm-bulk-delete-btn');
|
||||||
const countDisplay = $('#{{ $id }}-bulk-delete-count-display');
|
const countDisplay = $('#{{ $id }}-bulk-delete-count-display');
|
||||||
let bsModal = null;
|
let bsModal = null;
|
||||||
|
|
||||||
openerBtn.on('click', function() {
|
openerBtn.on('click', function() {
|
||||||
if (selectedIds.length === 0) return;
|
if (selectedIds.length === 0) return;
|
||||||
countDisplay.text(selectedIds.length);
|
countDisplay.text(selectedIds.length);
|
||||||
|
|
||||||
if (!bsModal) {
|
if (!bsModal) {
|
||||||
bsModal = new bootstrap.Modal(modalEl);
|
bsModal = new bootstrap.Modal(modalEl);
|
||||||
}
|
}
|
||||||
bsModal.show();
|
bsModal.show();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Handle Confirm Delete
|
// Handle Confirm Delete
|
||||||
confirmBtn.on('click', function() {
|
confirmBtn.on('click', function() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '{{ $bulkDeleteUrl }}',
|
url: '{{ $bulkDeleteUrl }}',
|
||||||
type: 'DELETE',
|
type: 'DELETE',
|
||||||
data: {
|
data: {
|
||||||
ids: selectedIds,
|
ids: selectedIds,
|
||||||
_token: '{{ csrf_token() }}'
|
_token: '{{ csrf_token() }}'
|
||||||
},
|
},
|
||||||
beforeSend: function() {
|
beforeSend: function() {
|
||||||
confirmBtn.prop('disabled', true).text('Deleting...');
|
confirmBtn.prop('disabled', true).text('Deleting...');
|
||||||
},
|
},
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
if (bsModal) bsModal.hide();
|
if (bsModal) bsModal.hide();
|
||||||
$('#{{ $id }}').DataTable().ajax.reload();
|
$('#{{ $id }}').DataTable().ajax.reload();
|
||||||
selectedIds = [];
|
selectedIds = [];
|
||||||
bulkActions.hide();
|
bulkActions.hide();
|
||||||
|
|
||||||
// Show success toast
|
// Show success toast
|
||||||
if (typeof FuiToast !== 'undefined') {
|
if (typeof FuiToast !== 'undefined') {
|
||||||
FuiToast.success(response.message ||
|
FuiToast.success(response.message ||
|
||||||
'Selected items have been deleted successfully.');
|
'Selected items have been deleted successfully.');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Re-render icons after reload
|
// Re-render icons after reload
|
||||||
if (window.lucide) lucide.createIcons();
|
if (window.lucide) lucide.createIcons();
|
||||||
},
|
},
|
||||||
error: function(xhr) {
|
error: function(xhr) {
|
||||||
const message = xhr.responseJSON?.message ||
|
const message = xhr.responseJSON?.message ||
|
||||||
'Something went wrong.';
|
'Something went wrong.';
|
||||||
if (typeof FuiToast !== 'undefined') {
|
if (typeof FuiToast !== 'undefined') {
|
||||||
FuiToast.error(message);
|
FuiToast.error(message);
|
||||||
} else {
|
} else {
|
||||||
alert(message);
|
alert(message);
|
||||||
}
|
}
|
||||||
if (bsModal) bsModal.hide();
|
if (bsModal) bsModal.hide();
|
||||||
},
|
},
|
||||||
complete: function() {
|
complete: function() {
|
||||||
confirmBtn.prop('disabled', false).text('Delete');
|
confirmBtn.prop('disabled', false).text('Delete');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@endif
|
@endif
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
/* Custom SAAS DataTable Styles */
|
/* Custom SAAS DataTable Styles */
|
||||||
.data-table-wrapper {
|
.data-table-wrapper {
|
||||||
background: #fff;
|
background: #fff;
|
||||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
|
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pagination button.page-link {
|
.pagination button.page-link {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.data-table-wrapper .table thead th {
|
.data-table-wrapper .table thead th {
|
||||||
border-color: #f1f5f9 !important;
|
border-color: #f1f5f9 !important;
|
||||||
font-family: 'Inter', sans-serif;
|
font-family: 'Inter', sans-serif;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
position: sticky;
|
position: sticky;
|
||||||
top: 0;
|
top: 0;
|
||||||
z-index: 10;
|
z-index: 3; {{-- Lowered from 10 --}}
|
||||||
background-color: #f8f9fa;
|
background-color: #f8f9fa;
|
||||||
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
|
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sticky Action Column (ERP Standard for wide tables) */
|
/* Sticky Action Column (ERP Standard for wide tables) */
|
||||||
.table thead th:last-child,
|
.table thead th:last-child,
|
||||||
.table tbody td:last-child {
|
.table tbody td:last-child {
|
||||||
position: sticky;
|
position: sticky;
|
||||||
right: 0;
|
right: 0;
|
||||||
background: #fff;
|
background: #fff;
|
||||||
z-index: 5;
|
z-index: 2; {{-- Lowered from 5 --}}
|
||||||
border-left: 1px solid #f1f5f9;
|
border-left: 1px solid #f1f5f9;
|
||||||
box-shadow: -2px 0 5px rgba(0, 0, 0, 0.02);
|
box-shadow: -2px 0 5px rgba(0, 0, 0, 0.02);
|
||||||
}
|
}
|
||||||
|
|
||||||
.table thead th:last-child {
|
.table thead th:last-child {
|
||||||
background: #f8f9fa;
|
background: #f8f9fa;
|
||||||
z-index: 11;
|
z-index: 4; {{-- Lowered from 11 --}}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sticky Checkbox Column */
|
/* Sticky Checkbox Column */
|
||||||
.table thead th:first-child,
|
.table thead th:first-child,
|
||||||
.table tbody td:first-child {
|
.table tbody td:first-child {
|
||||||
position: sticky;
|
position: sticky;
|
||||||
left: 0;
|
left: 0;
|
||||||
background: #fff;
|
background: #fff;
|
||||||
z-index: 5;
|
z-index: 2; {{-- Lowered from 5 --}}
|
||||||
border-right: 1px solid #f1f5f9;
|
border-right: 1px solid #f1f5f9;
|
||||||
box-shadow: 2px 0 5px rgba(0, 0, 0, 0.02);
|
box-shadow: 2px 0 5px rgba(0, 0, 0, 0.02);
|
||||||
}
|
}
|
||||||
|
|
||||||
.table thead th:first-child {
|
.table thead th:first-child {
|
||||||
background: #f8f9fa;
|
background: #f8f9fa;
|
||||||
z-index: 11;
|
z-index: 4; {{-- Lowered from 11 --}}
|
||||||
}
|
}
|
||||||
|
|
||||||
.table tbody tr:hover td {
|
.table tbody tr:hover td {
|
||||||
background-color: #f8fafc !important;
|
background-color: #f8fafc !important;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.data-table-wrapper .table td:not(:last-child) {
|
.data-table-wrapper .table td:not(:last-child) {
|
||||||
border-right: 1px solid #f1f5f9;
|
border-right: 1px solid #f1f5f9;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sticky for second row (filter inputs) if present */
|
/* Sticky for second row (filter inputs) if present */
|
||||||
.data-table-wrapper .table thead tr:nth-child(2) th {
|
.data-table-wrapper .table thead tr:nth-child(2) th {
|
||||||
top: 45px;
|
top: 45px;
|
||||||
/* Adjust based on typical header height */
|
/* Adjust based on typical header height */
|
||||||
z-index: 4;
|
z-index: 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
.data-table-wrapper .input-group-text {
|
.data-table-wrapper .input-group-text {
|
||||||
color: #94a3b8;
|
color: #94a3b8;
|
||||||
/* Slate 400 */
|
/* Slate 400 */
|
||||||
}
|
}
|
||||||
|
|
||||||
.data-table-wrapper .form-control::placeholder {
|
.data-table-wrapper .form-control::placeholder {
|
||||||
color: #cbd5e1;
|
color: #cbd5e1;
|
||||||
/* Slate 300 */
|
/* Slate 300 */
|
||||||
}
|
}
|
||||||
|
|
||||||
.dataTables_wrapper .pagination .page-item .page-link {
|
.dataTables_wrapper .pagination .page-item .page-link {
|
||||||
border: 1px solid transparent;
|
border: 1px solid transparent;
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
margin: 0 2px;
|
margin: 0 2px;
|
||||||
color: #64748b;
|
color: #64748b;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
font-size: 0.875rem;
|
font-size: 0.875rem;
|
||||||
transition: all 0.2s ease;
|
transition: all 0.2s ease;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
height: 38px;
|
height: 38px;
|
||||||
min-width: 38px;
|
min-width: 38px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dataTables_wrapper .pagination .page-item.active .page-link {
|
.dataTables_wrapper .pagination .page-item.active .page-link {
|
||||||
background-color: #0f172a;
|
background-color: #0f172a;
|
||||||
/* Slate 900 or Primary Color */
|
/* Slate 900 or Primary Color */
|
||||||
color: white;
|
color: white;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||||
border-color: #0f172a;
|
border-color: #0f172a;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dataTables_wrapper .pagination .page-item.disabled .page-link {
|
.dataTables_wrapper .pagination .page-item.disabled .page-link {
|
||||||
color: #cbd5e1;
|
color: #cbd5e1;
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dataTables_wrapper .pagination .page-item:not(.active) .page-link:hover {
|
.dataTables_wrapper .pagination .page-item:not(.active) .page-link:hover {
|
||||||
background-color: #f8fafc;
|
background-color: #f8fafc;
|
||||||
color: #0f172a;
|
color: #0f172a;
|
||||||
border-color: #e2e8f0;
|
border-color: #e2e8f0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Select2 Customization for Table Length */
|
/* Select2 Customization for Table Length */
|
||||||
.dataTables_length {
|
.dataTables_length {
|
||||||
margin-right: 1rem;
|
margin-right: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.select2-container--default .select2-selection--single {
|
.select2-container--default .select2-selection--single {
|
||||||
border: 1px solid #e2e8f0;
|
border: 1px solid #e2e8f0;
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
height: 32px;
|
height: 32px;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
outline: none;
|
outline: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.select2-container--default .select2-selection--single:focus {
|
.select2-container--default .select2-selection--single:focus {
|
||||||
border-color: #94a3b8;
|
border-color: #94a3b8;
|
||||||
}
|
}
|
||||||
|
|
||||||
.select2-container--default .select2-selection--single .select2-selection__arrow {
|
.select2-container--default .select2-selection--single .select2-selection__arrow {
|
||||||
height: 30px;
|
height: 30px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.select2-container--default .select2-selection--single .select2-selection__rendered {
|
.select2-container--default .select2-selection--single .select2-selection__rendered {
|
||||||
color: #475569;
|
color: #475569;
|
||||||
font-size: 0.8125rem;
|
font-size: 0.8125rem;
|
||||||
padding-left: 10px;
|
padding-left: 10px;
|
||||||
line-height: normal;
|
line-height: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Loading Process Styles */
|
/* Loading Process Styles */
|
||||||
.loading-process {
|
.loading-process {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
right: 0;
|
right: 0;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
z-index: 1000;
|
z-index: 5; {{-- Lowered from 1000 --}}
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.loading-bar {
|
.loading-bar {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
height: 3px;
|
height: 3px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
background: #f1f5f9;
|
background: #f1f5f9;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
z-index: 1001;
|
z-index: 6; {{-- Lowered from 1001 --}}
|
||||||
}
|
}
|
||||||
|
|
||||||
.loading-bar::after {
|
.loading-bar::after {
|
||||||
content: '';
|
content: '';
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 50%;
|
width: 50%;
|
||||||
background: linear-gradient(90deg, transparent, #0f172a, transparent);
|
background: linear-gradient(90deg, transparent, #0f172a, transparent);
|
||||||
animation: loading-process-info 1.5s infinite linear;
|
animation: loading-process-info 1.5s infinite linear;
|
||||||
}
|
}
|
||||||
|
|
||||||
.loading-overlay {
|
.loading-overlay {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
background: rgba(255, 255, 255, 0.5);
|
background: rgba(255, 255, 255, 0.5);
|
||||||
backdrop-filter: blur(1px);
|
backdrop-filter: blur(1px);
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes loading-process-info {
|
@keyframes loading-process-info {
|
||||||
0% {
|
0% {
|
||||||
transform: translateX(-100%);
|
transform: translateX(-100%);
|
||||||
}
|
}
|
||||||
|
|
||||||
100% {
|
100% {
|
||||||
transform: translateX(200%);
|
transform: translateX(200%);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Custom Sort Icons Styles */
|
/* Custom Sort Icons Styles */
|
||||||
.sort-icons {
|
.sort-icons {
|
||||||
opacity: 0.15;
|
opacity: 0.15;
|
||||||
transition: opacity 0.2s;
|
transition: opacity 0.2s;
|
||||||
}
|
}
|
||||||
|
|
||||||
th:hover .sort-icons {
|
th:hover .sort-icons {
|
||||||
opacity: 0.5;
|
opacity: 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
th.sorting_asc .sort-icons {
|
th.sorting_asc .sort-icons {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
th.sorting_asc .sort-icon-desc {
|
th.sorting_asc .sort-icon-desc {
|
||||||
display: none !important;
|
display: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
th.sorting_desc .sort-icons {
|
th.sorting_desc .sort-icons {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
th.sorting_desc .sort-icon-asc {
|
th.sorting_desc .sort-icon-asc {
|
||||||
display: none !important;
|
display: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Hide default DataTables icons */
|
/* Hide default DataTables icons */
|
||||||
table.dataTable thead .sorting:before,
|
table.dataTable thead .sorting:before,
|
||||||
table.dataTable thead .sorting:after,
|
table.dataTable thead .sorting:after,
|
||||||
table.dataTable thead .sorting_asc:before,
|
table.dataTable thead .sorting_asc:before,
|
||||||
table.dataTable thead .sorting_asc:after,
|
table.dataTable thead .sorting_asc:after,
|
||||||
table.dataTable thead .sorting_desc:before,
|
table.dataTable thead .sorting_desc:before,
|
||||||
table.dataTable thead .sorting_desc:after {
|
table.dataTable thead .sorting_desc:after {
|
||||||
display: none !important;
|
display: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Processing Indicator with improved look - Centered */
|
/* Processing Indicator with improved look - Centered */
|
||||||
div.dataTables_processing {
|
div.dataTables_processing {
|
||||||
display: none !important;
|
display: none !important;
|
||||||
/* Hide default processing */
|
/* Hide default processing */
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@endpush
|
@endpush
|
||||||
|
|||||||
Reference in New Issue
Block a user