♻️ 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;
|
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
|
// Make the function available globally
|
||||||
window.hitungHariKerja = hitungHariKerja;
|
window.hitungHariKerja = hitungHariKerja;
|
||||||
|
window.showLoadingSwal = showLoadingSwal;
|
||||||
|
window.hideLoadingSwal = hideLoadingSwal;
|
||||||
|
|||||||
@@ -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>
|
</script>
|
||||||
@endpush
|
@endpush
|
||||||
|
|||||||
@@ -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>
|
</script>
|
||||||
@endpush
|
@endpush
|
||||||
|
|||||||
@@ -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>
|
</script>
|
||||||
@endpush
|
@endpush
|
||||||
|
|||||||
@@ -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>
|
</script>
|
||||||
@endpush
|
@endpush
|
||||||
|
|||||||
@@ -238,7 +238,6 @@
|
|||||||
alt="Foto Argis Region" class="mt-2 max-w-full h-auto"
|
alt="Foto Argis Region" class="mt-2 max-w-full h-auto"
|
||||||
style="{{ $argisRegionPath ? '' : 'display: none;' }} max-width: 30rem;">
|
style="{{ $argisRegionPath ? '' : 'display: none;' }} max-width: 30rem;">
|
||||||
</div>
|
</div>
|
||||||
< </div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- Upload Photo Button -->
|
<!-- Upload Photo Button -->
|
||||||
|
|||||||
@@ -1,18 +1,4 @@
|
|||||||
<script>
|
<script>
|
||||||
function showLoadingSwal(message) {
|
|
||||||
Swal.fire({
|
|
||||||
title: message,
|
|
||||||
allowOutsideClick: false,
|
|
||||||
didOpen: () => {
|
|
||||||
Swal.showLoading();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function hideLoadingSwal() {
|
|
||||||
Swal.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
function previewImage(input, imageId) {
|
function previewImage(input, imageId) {
|
||||||
const preview = document.getElementById(imageId);
|
const preview = document.getElementById(imageId);
|
||||||
if (input.files && input.files[0]) {
|
if (input.files && input.files[0]) {
|
||||||
@@ -413,7 +399,8 @@
|
|||||||
const addressInput = document.getElementById('address');
|
const addressInput = document.getElementById('address');
|
||||||
|
|
||||||
if (status === 'sesuai') {
|
if (status === 'sesuai') {
|
||||||
addressInput.value = "{{ $dokumen->address ?? '' }}";
|
addressInput.value = {!! json_encode($dokumen->address ?? '') !!};
|
||||||
|
|
||||||
inputs.forEach(element => {
|
inputs.forEach(element => {
|
||||||
if (element.tagName === 'INPUT') {
|
if (element.tagName === 'INPUT') {
|
||||||
element.setAttribute('readonly', true);
|
element.setAttribute('readonly', true);
|
||||||
|
|||||||
Reference in New Issue
Block a user