From 0629a621f27c5b2e8c82ce8e7ede1f7e4af6d07b Mon Sep 17 00:00:00 2001 From: Peichun Zhou Date: Sat, 20 Aug 2022 00:11:52 +1000 Subject: [PATCH] OE-13322- Fixed issue that user cannot remove an unsaved block when all the meds are administered (#8319) --- .../OphCiExamination/widgets/js/DrugAdministration.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/protected/modules/OphCiExamination/widgets/js/DrugAdministration.js b/protected/modules/OphCiExamination/widgets/js/DrugAdministration.js index b14979b245..14143cb707 100644 --- a/protected/modules/OphCiExamination/widgets/js/DrugAdministration.js +++ b/protected/modules/OphCiExamination/widgets/js/DrugAdministration.js @@ -165,7 +165,13 @@ OpenEyes.OphCiExamination = OpenEyes.OphCiExamination || {}; } if(!add_meds_btn_disabled && !add_preset_btn_disabled){ $(parent_selector).each(function(i, section){ - if(controller.isAllMedicationAdministered($(this))) { + // if the assignment_id has value, that means it is a saved record + const has_assignment_id_value = $(section).find('input[name$="[assignment_id]"]').val() ? true : false; + + const is_all_meds_administered = controller.isAllMedicationAdministered($(this)); + + // hide the after confirm elements only when it is a saved record and its medications are administered + if(has_assignment_id_value && is_all_meds_administered) { $(this).find('.js-after-confirm').hide(); } else { $(this).find('.js-after-confirm').show(); @@ -178,6 +184,7 @@ OpenEyes.OphCiExamination = OpenEyes.OphCiExamination || {}; $(add_meds_btn_ctn_selector).find('button#js-add-preset-order').prop('disabled', add_preset_btn_disabled); $(add_meds_btn_ctn_selector).find('button#js-add-medications').prop('disabled', add_meds_btn_disabled); } + DrugAdministrationController.prototype.isAllMedicationAdministered = function($parent_block) { const administer_btn_selector = `.${this.options.administerBtnClass}`; return $parent_block.find('tbody tr').length === $parent_block.find(`tbody tr ${administer_btn_selector}:checked`).length