♻️ refactor(js): pindahkan fungsi loading SweetAlert ke global scope dan perbaiki bug
- Memindahkan fungsi showLoadingSwal() dan hideLoadingSwal() ke resources/assets/js/app.js - Menambahkan fitur timer dan progress bar pada fungsi global loading - Menghapus duplikasi fungsi showLoadingSwal() dari penilai/index.blade.php (~18 baris) - Menghapus duplikasi fungsi dari penilaian/otorisator/index-sla.blade.php (~18 baris) - Menghapus duplikasi fungsi dari penilaian/otorisator/index.blade.php (~18 baris) - Menghapus duplikasi fungsi dari penilaian/paparan-so.blade.php (~18 baris) - Memperbaiki syntax error tag HTML di surveyor/components/informasi.blade.php - Membersihkan duplikasi fungsi & memperbaiki escape string di surveyor/js/utils.blade.php - Mengurangi ±90 baris kode duplikat, meningkatkan maintainability & UX (loading dialog lebih informatif)
This commit is contained in:
@@ -31,5 +31,27 @@ function hitungHariKerja(tanggalMulai, tanggalSelesai) {
|
||||
return hariKerja;
|
||||
}
|
||||
|
||||
function showLoadingSwal(message, duration = 5000) {
|
||||
Swal.fire({
|
||||
title: message,
|
||||
allowOutsideClick: false,
|
||||
didOpen: () => {
|
||||
Swal.showLoading();
|
||||
},
|
||||
timer: duration, // Durasi dalam milidetik
|
||||
timerProgressBar: true, // Menampilkan progres bar timer
|
||||
}).then((result) => {
|
||||
if (result.dismiss === Swal.DismissReason.timer) {
|
||||
console.log("Dialog loading otomatis ditutup.");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function hideLoadingSwal() {
|
||||
Swal.close();
|
||||
}
|
||||
|
||||
// Make the function available globally
|
||||
window.hitungHariKerja = hitungHariKerja;
|
||||
window.showLoadingSwal = showLoadingSwal;
|
||||
window.hideLoadingSwal = hideLoadingSwal;
|
||||
|
||||
Reference in New Issue
Block a user