From bbc3aa7e04af842d3c868b09247410dff7031ad0 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Thu, 26 Jun 2025 18:44:06 +0530 Subject: [PATCH] FIX_VEHICAL_MODAL_CLIENT_MODAL : RV --- .../policy_transaction_inception_form.php | 41 ++++++++++++++++--- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/app/Views/policy_transaction_inception_form.php b/app/Views/policy_transaction_inception_form.php index b378d5cb..7de082a9 100644 --- a/app/Views/policy_transaction_inception_form.php +++ b/app/Views/policy_transaction_inception_form.php @@ -1172,16 +1172,45 @@ $(document).ready(function(){ // keyboard: false // }) + isClientFormSubmitting = true; + $('#upload_enrollment_model').on('hide.bs.modal', function (e) { - if (!isClientFormSubmitting) { - // Ask for confirmation - if (confirm("Are you sure you want to close? Unsaved changes will be lost.")) { - // If confirmed, reset the form + console.log('Attempting to hide #upload_enrollment_model modal'); + + let policy_type_id = $('#policy_type_id').val(); + 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(); + 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 { - // If not confirmed, prevent the modal from closing - e.preventDefault(); + console.log('User cancelled closing. Preventing modal from hiding.'); + e.preventDefault(); // stops modal from closing } + + } else { + console.log('policy_type_id is not 8 — proceeding with default modal behavior.'); } });