From dd094e393b551943e7e260082dff62115fc72e6a Mon Sep 17 00:00:00 2001 From: Sam Lau Date: Thu, 11 Jul 2024 16:03:26 +0000 Subject: [PATCH] Bug 32581: Add confirmation modal This patch makes changing the expiration date optional, by providing a modal when switching a patron category. Confirming the modal will change the expiration date to the default and cancelling will keep the same expiration date. To test: 1) Same plan as before except now there is a modal when changing the patron category. - Attempt confirming the modal: expiration date should change to default. - Attempt canceling the modal: expiration date should stay the same --- .../prog/en/modules/members/memberentrygen.tt | 20 +++++++++++++++++++ koha-tmpl/intranet-tmpl/prog/js/members.js | 19 +++++++++++------- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt index eb2f49b32b..6ec4835565 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt @@ -1752,6 +1752,26 @@ legend.collapsed i.fa.fa-caret-down::before { [% END %] + + + + [% MACRO jsinclude BLOCK %] [% Asset.js("lib/hc-sticky/hc-sticky.js") | $raw %] [% INCLUDE 'calendar.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/members.js b/koha-tmpl/intranet-tmpl/prog/js/members.js index 9afce16e7b..48e87f8478 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/members.js +++ b/koha-tmpl/intranet-tmpl/prog/js/members.js @@ -84,13 +84,18 @@ function update_category_code(category_code) { // Change patron's expiration date $('#categorycode_entry').change(function() { - var fp = $("#to").flatpickr(); - var expiryDate = $('select'+category_selector+' option:selected').data('expiryDate'); - // Check if expiryDate is available and format it to YYYY-MM-DD - if (expiryDate) { - var formattedDate = expiryDate.split('T')[0]; - fp.setDate(formattedDate); - } + $('#expirationDateModal').modal('show'); + // Handle confirmation Yes button click + $('#expirationDateConfirmBtn').on('click', function() { + var fp = $("#to").flatpickr(); + var expiryDate = $('select'+category_selector+' option:selected').data('expiryDate'); + // Check if expiryDate is available and format it to YYYY-MM-DD + if (expiryDate) { + var formattedDate = expiryDate.split('T')[0]; + fp.setDate(formattedDate); + } + $('#expirationDateModal').modal('hide'); + }); }); } -- 2.39.2