Ffix(surveyor/penilai): perbaikkan edit foto dan call report

This commit is contained in:
majid
2025-03-01 10:25:50 +07:00
parent 025cb3d5b8
commit f65b9bec23
10 changed files with 375 additions and 166 deletions

View File

@@ -5,8 +5,6 @@
@endsection
@section('content')
<link rel="stylesheet" href="https://unpkg.com/dropzone@5/dist/min/dropzone.min.css" type="text/css" />
{{-- <link rel="stylesheet" href="https://uicdn.toast.com/tui-image-editor/latest/tui-image-editor.css" /> --}}
<style>
.dropzone {
border: 2px dashed #3498db;
@@ -266,9 +264,6 @@
@include('lpj::surveyor.js.fotojs')
@include('lpj::surveyor.js.utils')
@push('scripts')
<script src="https://unpkg.com/dropzone@5/dist/min/dropzone.min.js"></script>
<script src="https://scaleflex.cloudimg.io/v7/plugins/filerobot-image-editor/latest/filerobot-image-editor.min.js">
</script>
<script>
let jsonDataContoh = @json($formFoto);
Dropzone.autoDiscover = false;
@@ -609,7 +604,7 @@
e.preventDefault();
// Get the file path from hidden input
const filePath = document.getElementById('editDataFilePath').value;
if (filePath) {
openFilerobotEditor(filePath);
} else {
@@ -632,20 +627,9 @@
const config = {
source: imagePath || '',
onSave: (editedImageObject, designState) => {
console.log('Image saved', editedImageObject);
// Save the edited image
saveEditedImage(editedImageObject, document.getElementById('editDataFilePath').value);
window.FilerobotImageEditor.terminate();
// Close the editor
FilerobotImageEditor.terminate();
// Hide the modal
document.getElementById('modal_10').setAttribute('data-modal-dismiss', 'true');
// Update the preview if needed
updateImagePreview(editedImageObject.imageBase64 || editedImageObject.imageCanvas.toDataURL());
},
annotationsCommon: {
fill: '#ff0000'
@@ -681,17 +665,29 @@
config
);
// Render the editor
filerobotImageEditor.render({
onClose: (closingReason) => {
console.log('Editor closed:', closingReason);
filerobotImageEditor.terminate();
// Hide the modal
document.querySelector('#modal_10').setAttribute('data-modal-dismiss', 'true');
let closeButton = document.getElementById('modal_10');
if (!closeButton) {
closeButton = document.createElement('button');
closeButton.setAttribute('data-modal-dismiss', 'true');
closeButton.setAttribute('type', 'button');
closeButton.setAttribute('class', 'btn btn-primary');
closeButton.setAttribute('data-modal-toggle', '#modal_10');
document.body.appendChild(closeButton);
}
closeButton.click();
console.log('Modal closed via close button simulation');
}
});
}
window.addEditAndDeleteButtons = function(file, response) {
@@ -828,16 +824,23 @@
formData.append('original_path', originalFilePath);
formData.forEach((value, key) => {
console.log(`${key}:`, value);
});
console.log(`${key}:`, value);
});
fetch('/api/save-edited-image', {
method: 'POST',
body: formData
})
.then(response => response.json())
.then(data => {
$.ajax({
url: `{{ route('surveyor.saveEditedImage') }}`,
type: 'POST',
headers: {
'X-CSRF-TOKEN': '{{ csrf_token() }}'
},
data: {
edited_image: imageData,
original_path: originalFilePath,
nomor_registrasi: '{{ $permohonan->nomor_registrasi }}'
},
success: function(response) {
Swal.fire({
icon: 'success',
title: 'Perubahan Disimpan',
@@ -848,17 +851,23 @@
window.location.reload();
}
});;
})
.catch(error => {
});
},
error: function(xhr) {
const errorMessage = xhr.responseJSON?.message || 'Terjadi kesalahan';
Swal.fire({
icon: 'error',
title: 'Gagal Menyimpan',
text: errorMessage,
}).then((response) => {
if (response.isConfirmed) {
window.location.reload();
}
});
});
}
});
}
</script>
@endpush