From 62a7274766b912359b270e1e2fe6214aec89fdc2 Mon Sep 17 00:00:00 2001 From: Shi Yao Wang Date: Mon, 29 Apr 2024 12:26:06 -0400 Subject: [PATCH] Bug 32610: make date attributes repeatable Test plan: 1- create a patron attribute type with is a date and repeatable checked (administration -> patron attribute types) 2- add a couple of patron attribute of type date 3- Save 4- Edit to see if everything has been stored correctly Signed-off-by: Martin Renvoize Signed-off-by: Katrin Fischer --- .../en/modules/admin/patron-attr-types.tt | 19 ++++--------------- koha-tmpl/intranet-tmpl/prog/js/members.js | 9 +++++++++ 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt index b612f55b85..326d8edc86 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt @@ -148,17 +148,14 @@ If checked, attribute will be a unique identifier. If a value is given to a patron record, the same value cannot be given to a different record. - -
  • - - [% IF attribute_type.is_date %] +
  • + [% IF attribute_type AND attribute_type.is_date %] [% ELSE %] [% END %] If checked, attribute will be a date. Date attributes cannot be repeatable or linked to an authorised value category.
  • -
  • [% IF attribute_type AND attribute_type.opac_display %] @@ -443,17 +440,9 @@ $("#is_date").change( function() { if ( this.checked ) { - $("#repeatable, #authorised_value_category").attr('disabled', true).parent().attr('aria-disabled', 'true'); - } else { - $("#repeatable, #authorised_value_category").removeAttr('disabled').parent().removeAttr('aria-disabled'); - } - } ).change(); - - $("#repeatable").change( function() { - if ( this.checked ) { - $("#is_date").attr('disabled', true).parent().attr('aria-disabled', 'true'); + $("#authorised_value_category").attr('disabled', true).parent().attr('aria-disabled', 'true'); } else { - $("#is_date").removeAttr('disabled').parent().removeAttr('aria-disabled'); + $("#authorised_value_category").removeAttr('disabled').parent().removeAttr('aria-disabled'); } } ).change(); diff --git a/koha-tmpl/intranet-tmpl/prog/js/members.js b/koha-tmpl/intranet-tmpl/prog/js/members.js index d460b4c41e..7e4806fa23 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/members.js +++ b/koha-tmpl/intranet-tmpl/prog/js/members.js @@ -57,6 +57,15 @@ function clone_entry(node) { $("input#patron_attr_" + newId, clone).attr('value',''); $("select#patron_attr_" + newId, clone).attr('value',''); $(original).after(clone); + + // regenerate flatpickr calendars to add event listeners + $(`.flatpickr_wrapper`, clone).remove(); + var date = $("> .flatpickr", original).val(); + $(".flatpickr", clone).each(function(){ + apply_flatpickr(this); + }); + $(`.flatpickr_wrapper .flatpickr, #patron_attr_${newId}.flatpickr`, clone).val(date); + return false; } -- 2.39.5