53 lines
1.6 KiB
JavaScript
53 lines
1.6 KiB
JavaScript
import * as bootstrap from 'bootstrap';
|
|
import DataTable from 'datatables.net-bs5';
|
|
import 'datatables.net-responsive-bs5';
|
|
import flatpickr from 'flatpickr';
|
|
import $ from 'jquery';
|
|
import Swal from 'sweetalert2';
|
|
import TomSelect from 'tom-select';
|
|
|
|
window.$ = window.jQuery = $;
|
|
window.bootstrap = bootstrap;
|
|
window.DataTable = DataTable;
|
|
window.flatpickr = flatpickr;
|
|
window.Swal = Swal;
|
|
window.TomSelect = TomSelect;
|
|
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
|
|
|
|
document.querySelectorAll('[data-confirm]').forEach((form) => {
|
|
form.addEventListener('submit', (event) => {
|
|
event.preventDefault();
|
|
|
|
Swal.fire({
|
|
title: form.dataset.confirmTitle || 'Sahkan tindakan',
|
|
text: form.dataset.confirmText || 'Tindakan ini akan direkodkan.',
|
|
icon: 'warning',
|
|
showCancelButton: true,
|
|
confirmButtonText: form.dataset.confirmButton || 'Ya, teruskan',
|
|
cancelButtonText: 'Batal',
|
|
confirmButtonColor: '#123c69',
|
|
}).then((result) => {
|
|
if (result.isConfirmed) {
|
|
form.submit();
|
|
}
|
|
});
|
|
});
|
|
});
|
|
|
|
document.querySelectorAll('[data-flatpickr]').forEach((input) => {
|
|
flatpickr(input, {
|
|
enableTime: input.dataset.enableTime === 'true',
|
|
dateFormat: input.dataset.dateFormat || 'Y-m-d',
|
|
});
|
|
});
|
|
|
|
document.querySelectorAll('[data-tom-select]').forEach((select) => {
|
|
new TomSelect(select, {
|
|
create: false,
|
|
plugins: ['dropdown_input'],
|
|
});
|
|
});
|
|
});
|