Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev
This commit is contained in:
commit
1d67995251
@ -1172,16 +1172,45 @@ $(document).ready(function(){
|
|||||||
// keyboard: false
|
// keyboard: false
|
||||||
// })
|
// })
|
||||||
|
|
||||||
|
isClientFormSubmitting = true;
|
||||||
|
|
||||||
$('#upload_enrollment_model').on('hide.bs.modal', function (e) {
|
$('#upload_enrollment_model').on('hide.bs.modal', function (e) {
|
||||||
if (!isClientFormSubmitting) {
|
console.log('Attempting to hide #upload_enrollment_model modal');
|
||||||
// Ask for confirmation
|
|
||||||
if (confirm("Are you sure you want to close? Unsaved changes will be lost.")) {
|
let policy_type_id = $('#policy_type_id').val();
|
||||||
// If confirmed, reset the form
|
console.log('policy_type_id:', policy_type_id);
|
||||||
|
|
||||||
|
// Only handle custom behavior for policy_type_id = 8
|
||||||
|
if (policy_type_id == 8) {
|
||||||
|
console.log('policy_type_id is 8 — custom handling begins.');
|
||||||
|
|
||||||
|
const shouldClose = confirm("Are you sure you want to close? Unsaved changes will be lost.");
|
||||||
|
// const shouldClose = true; // Always true, can be changed to confirm() if needed
|
||||||
|
console.log('User confirmation result:', shouldClose);
|
||||||
|
|
||||||
|
if (shouldClose) {
|
||||||
|
console.log('User confirmed closing. Resetting #client_form.');
|
||||||
|
|
||||||
$('#client_form')[0].reset();
|
$('#client_form')[0].reset();
|
||||||
|
console.log('#client_form reset successfully.');
|
||||||
|
|
||||||
|
$('#client_form').removeAttr('data-id');
|
||||||
|
console.log('data-id attribute removed from #client_form.');
|
||||||
|
|
||||||
|
console.log('Opening #vehicle_modal.');
|
||||||
|
const vehicleModal = new bootstrap.Modal(document.getElementById('vehicle_modal'));
|
||||||
|
vehicleModal.show();
|
||||||
|
|
||||||
|
console.log('Setting form data for #vehicle_form from localStorage.');
|
||||||
|
setFormDataFromLocalStorage("#vehicle_form", "vehicleFormData");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// If not confirmed, prevent the modal from closing
|
console.log('User cancelled closing. Preventing modal from hiding.');
|
||||||
e.preventDefault();
|
e.preventDefault(); // stops modal from closing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
console.log('policy_type_id is not 8 — proceeding with default modal behavior.');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user