♻️ 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:
Daeng Deni Mardaeni
2025-09-19 09:01:20 +07:00
parent 6d137ad51c
commit 17f7482080
7 changed files with 25 additions and 84 deletions

View File

@@ -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;

View File

@@ -336,21 +336,5 @@
});
}
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.');
}
});
}
</script>
@endpush

View File

@@ -291,22 +291,5 @@
}
});
}
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.');
}
});
}
</script>
@endpush

View File

@@ -361,22 +361,5 @@
}
});
}
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.');
}
});
}
</script>
@endpush

View File

@@ -348,22 +348,5 @@
}
});
}
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.');
}
});
}
</script>
@endpush

View File

@@ -238,7 +238,6 @@
alt="Foto Argis Region" class="mt-2 max-w-full h-auto"
style="{{ $argisRegionPath ? '' : 'display: none;' }} max-width: 30rem;">
</div>
< </div>
</div>
</div>
<!-- Upload Photo Button -->

View File

@@ -1,18 +1,4 @@
<script>
function showLoadingSwal(message) {
Swal.fire({
title: message,
allowOutsideClick: false,
didOpen: () => {
Swal.showLoading();
}
});
}
function hideLoadingSwal() {
Swal.close();
}
function previewImage(input, imageId) {
const preview = document.getElementById(imageId);
if (input.files && input.files[0]) {
@@ -413,8 +399,9 @@
const addressInput = document.getElementById('address');
if (status === 'sesuai') {
addressInput.value = "{{ $dokumen->address ?? '' }}";
inputs.forEach(element => {
addressInput.value = {!! json_encode($dokumen->address ?? '') !!};
inputs.forEach(element => {
if (element.tagName === 'INPUT') {
element.setAttribute('readonly', true);
} else if (element.tagName === 'SELECT') {