From 66f023a243b23e07ae261936a3d65a9f17441d01 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 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Jan Kissig Signed-off-by: Tomás Cohen Arazi --- .../prog/en/modules/members/memberentrygen.tt | 19 +++++++++++++++++++ koha-tmpl/intranet-tmpl/prog/js/members.js | 19 ++++++++++++------- 2 files changed, 31 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 b5e0beee4e2..6a21fb145e2 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt @@ -1661,6 +1661,25 @@ + + + [% MACRO jsinclude BLOCK %] [% INCLUDE 'calendar.inc' %] [% INCLUDE 'str/members-menu.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/members.js b/koha-tmpl/intranet-tmpl/prog/js/members.js index 55cffbc5044..b3b77c54909 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/members.js +++ b/koha-tmpl/intranet-tmpl/prog/js/members.js @@ -91,13 +91,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.51.2