From 32082610671480af12e273cc100ce22850f88d36 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Wed, 5 Feb 2025 13:08:02 +0000 Subject: [PATCH] Bug 39038: Grep for exact matches for collapsed fields This patch splits the CollapseFieldsPatronAddForm system preference into a list in the template and then uses grep to find exact matches for each field. Test plan: 1. Edit CollapseFieldsPatronAddForm system preference and check the Non-patron guarantor and a few other fields, but not Guarantor. 2. Go to add a patron that can have a guarantor. 3. Note both guarantor fields are collapsed. 4. Apply patch, reload/ 5. Note only expected fields are collapsed. 6. Confirm other fields continue to work as expected. Signed-off-by: David Nind --- .../prog/en/modules/members/memberentrygen.tt | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 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 27f7d0e0f2..d7b206b9fc 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt @@ -224,11 +224,11 @@ legend.collapsed i.fa.fa-caret-down::before { [% END %] - [% SET fieldstohide = Koha.Preference('CollapseFieldsPatronAddForm') %] + [% SET fieldstohide = Koha.Preference('CollapseFieldsPatronAddForm').split(',') %] [% IF Koha.Preference('CollapseFieldsPatronAddForm') %][% UNLESS step %]

- [% FOREACH field IN fieldstohide.split(',') %] + [% FOREACH field IN fieldstohide %] [% SWITCH field %] [% CASE 'identity' %] Patron identity | [% CASE 'guarantor' %] Guarantor information | @@ -1802,74 +1802,74 @@ legend.collapsed i.fa.fa-caret-down::before { function showHideFields(){ $("#messaging_prefs_loading, #guarantor_template").hide(); [% UNLESS step == 1 %] - [% IF fieldstohide.match('identity') %] + [% IF fieldstohide.grep('^identity$').size %] togglePanel( $("#identity_lgd") ); [% END %] [% IF show_guarantor || guarantor %] - [% IF fieldstohide.match('guarantor') %] + [% IF fieldstohide.grep('^guarantor$').size %] togglePanel( $("#patron_guarantor_lgd") ); [% END %] - [% IF fieldstohide.match('nonpatron_guarantor') %] + [% IF fieldstohide.grep('^nonpatron_guarantor$').size %] togglePanel( $("#non_patron_guarantor_lgd") ); [% END %] [% END %] - [% IF fieldstohide.match('primary_address') %] + [% IF fieldstohide.grep('^primary_address$').size %] togglePanel( $("#main_address_lgd") ); [% END %] - [% IF fieldstohide.match('primary_contact') %] + [% IF fieldstohide.grep('^primary_contact$').size %] togglePanel( $("#contact_lgd") ); [% END %] [% END %] [% UNLESS step == 6 %] - [% IF fieldstohide.match('alt_address') %] + [% IF fieldstohide.grep('^alt_address$').size %] togglePanel( $("#alt_address_lgd") ); [% END %] [% END %] [% UNLESS step == 2 %] - [% IF fieldstohide.match('alt_contact') %] + [% IF fieldstohide.grep('^alt_contact$').size %] togglePanel( $("#alt_contact_lgd") ); [% END %] [% END %] [% UNLESS step == 3 %] - [% IF fieldstohide.match('lib_mgmt') %] + [% IF fieldstohide.grep('^lib_mgmt$').size %] togglePanel( $("#library_management_lgd") ); [% END %] [% UNLESS nodateenrolled && noopacnote && noborrowernotes %] - [% IF fieldstohide.match('lib_setup') %] + [% IF fieldstohide.grep('^lib_setup$').size %] togglePanel( $("#library_setup_lgd") ); [% END %] [% END %] [% UNLESS nouserid && nopassword %] - [% IF fieldstohide.match('login') %] + [% IF fieldstohide.grep('^login$').size %] togglePanel( $("#opac_staff_login_lgd") ); [% END %] [% END %] [% UNLESS ( op == 'add_form' || op == 'duplicate' ) %] - [% IF fieldstohide.match('flags') %] + [% IF fieldstohide.grep('^flags$').size %] togglePanel( $("#account_flags_lgd") ); [% END %] [% END %] - [% IF fieldstohide.match('debarments') %] + [% IF fieldstohide.grep('^debarments$').size %] togglePanel( $("#restrictions_lgd") ); [% END %] [% END %] [% UNLESS step == 7 %] [% IF Koha.Preference('HouseboundModule') %] - [% IF fieldstohide.match('housebound') %] + [% IF fieldstohide.grep('^housebound$').size %] togglePanel( $("#housebound_roles") ); [% END %] [% END %] [% END %] [% UNLESS step == 4 %] [% IF Koha.Preference('ExtendedPatronAttributes') %] - [% IF fieldstohide.match('additional') %] + [% IF fieldstohide.grep('^additional$').size %] togglePanel( $("#patron_attributes_lgd") ); [% END %] [% END %] [% END %] [% UNLESS step == 5 %] [% IF Koha.Preference('EnhancedMessagingPreferences') %] - [% IF fieldstohide.match('messaging') %] + [% IF fieldstohide.grep('^messaging$').size %] togglePanel( $("#patron_messaging_prefs_lgd") ); $("#messaging_prefs_loading").toggle(); [% END %] -- 2.39.5