From 815cf3f96fb5242d51a27db52b744addc499d629 Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Fri, 7 Feb 2020 02:57:40 +0000 Subject: [PATCH] Bug 3137: HideFieldsPatronAddForm syspref This patches adds a syspref - HideFieldsAddPatronFrom - that controls which fieldsets are hidden by default in the add patron form. To test: 1) Apply patch and update database 2) Go to System preferences and confirm HideFieldsPatronAddForm has no fields selected 3) Go to add a patron / edit an existing patron (any patron category). confirm everything still works as expected. 4) Tick some of the fields in the syspref to hide them in the form 5) Go back to add patron form. 6) Confirm these fields are hidden and listed at the top of the page 7) Toggle the checkbox and confirm the hidden fields show or hide as expected. 8) Go back to the HideFieldsPatronAddForm system preference and ensure the Main address option is checked to be hidden 9) Go to the patron's details page 10) Click to edit the Contact Information section 11) Confirm the Main address option shows and the checkbox to show hidden fields is not present. 12) Confirm you can click the legend of each section to show and hide sections Sponsored-by: Catalyst IT Signed-off-by: David Nind Signed-off-by: David Nind Signed-off-by: David Nind Signed-off-by: Katrin Fischer --- ...g_3137-add_HideFieldsPatronAddForm_syspref.perl | 7 ++ installer/data/mysql/sysprefs.sql | 1 + .../prog/en/modules/admin/preferences/patrons.pref | 18 ++++ .../prog/en/modules/members/memberentrygen.tt | 117 ++++++++++++++++++++- 4 files changed, 141 insertions(+), 2 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_3137-add_HideFieldsPatronAddForm_syspref.perl diff --git a/installer/data/mysql/atomicupdate/bug_3137-add_HideFieldsPatronAddForm_syspref.perl b/installer/data/mysql/atomicupdate/bug_3137-add_HideFieldsPatronAddForm_syspref.perl new file mode 100644 index 0000000000..92cbe40aec --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_3137-add_HideFieldsPatronAddForm_syspref.perl @@ -0,0 +1,7 @@ +$DBversion = 'XXX'; # will be replaced by the RM +if( CheckVersion( $DBversion ) ) { + $dbh->do(q{INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('HideFieldsPatronAddForm','',NULL,'Hide these fields by default when adding a new patron. These fields can still be expanded.','Multiple') }); + + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug XXXXX - description)\n"; +} diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index fc6cb8830b..b213986ff5 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -211,6 +211,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('GoogleOpenIDConnectDefaultBranch', '','','This branch code will be used to create Google OpenID Connect patrons.','Textarea'), ('GoogleOpenIDConnectDefaultCategory','','','This category code will be used to create Google OpenID Connect patrons.','Textarea'), ('GoogleOpenIDConnectDomain', '', NULL, 'Restrict Google OpenID Connect to this domain (or subdomains of this domain). Leave blank for all Google domains', 'Free'), +('HideFieldsPatronAddForm','',NULL,'Hide these fields by default when adding a new patron. These fields can still be expanded.','Multiple'), ('hidelostitems','0','','If ON, disables display of\"lost\" items in OPAC.','YesNo'), ('HidePatronName','0','','If this is switched on, patron\'s cardnumber will be shown instead of their name on the holds and catalog screens','YesNo'), ('hide_marc','0',NULL,'If ON, disables display of MARC fields, subfield codes & indicators (still shows data)','YesNo'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref index 99ea6bdfbc..8509b6e386 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref @@ -1,6 +1,24 @@ Patrons: General: - + - When adding new patrons or editing existing patrons, hide the following fields from the full form (can still be expanded later) + - pref: HideFieldsPatronAddForm + multiple: + identity: "a. Organization/Patron identity" + guarantor: "b. Guarantor information" + primary_address: "c. Main address" + primary_contact: "d. Contact information" + alt_address: "e. Alternate address" + alt_contact: "f. Alternate contact" + lib_mgmt: "g. Library management" + lib_setup: "h. Library setup" + login: "i. OPAC/Staff login" + flags: "j. Patron account flags (existing patrons)" + debarments: "k. Patron restrictions (existing patrons)" + housebound: "l. Housebound roles" + additional: "m. Additional attributes and identifiers" + messaging: "n. Patron messaging preferences" + - - pref: AutoEmailOpacUser choices: yes: Send 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 d4db2e37b3..d64eeaa91e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt @@ -20,7 +20,12 @@ [% IF categoryname %]([% categoryname | html %])[% END %] [% END %] - [% INCLUDE 'doc-head-close.inc' %] + +[% INCLUDE 'doc-head-close.inc' %] @@ -161,6 +166,31 @@ [% END %] + [% SET fieldstohide = Koha.Preference('HideFieldsPatronAddForm') %] + [% IF Koha.Preference('HideFieldsPatronAddForm') %][% UNLESS step %] +

+ Show hidden fields: + [% FOREACH field IN fieldstohide.split(',') %] + [% SWITCH field %] + [% CASE 'identity' %] Organization/Patron identity | + [% CASE 'guarantor' %] Guarantor information | + [% CASE 'primary_address' %] Main address | + [% CASE 'primary_contact' %] Contact information | + [% CASE 'alt_address' %] Alternate address | + [% CASE 'alt_contact' %] Alternate contact | + [% CASE 'lib_mgmt' %] Library management | + [% CASE 'lib_setup' %] Library setup | + [% CASE 'login' %] OPAC/Staff login | + [% CASE 'flags' %] Patron account flags | + [% CASE 'debarments' %] Patron restrictions | + [% CASE 'housebound' %] Housebound roles | + [% CASE 'additional' %] Additional attributes and identifiers | + [% CASE 'messaging' %] Patron messaging preferences | + [% END %] + [% END %] +

+ [% END %][% END %] +
[% UNLESS ( check_member ) %] [% IF quickadd && opadd %] @@ -497,7 +527,6 @@ [% END # /IF show_guarantor || guarantor %] - [% UNLESS noaddress && noaddress2 && nocity && nostate && nozipcode && nocountry %] [% IF Koha.Preference( 'AddressFormat' ) %] [% INCLUDE "member-main-address-style-${ Koha.Preference( 'AddressFormat' ) }.inc" %] @@ -1377,7 +1406,91 @@ } } var Sticky; + function showHideFields(){ + [% UNLESS step == 1 %] + [% IF fieldstohide.match('identity') %] + $("#memberentry_identity").find('legend').nextAll().toggle(); + [% END %] + [% IF show_guarantor || guarantor %] + [% IF fieldstohide.match('guarantor') %] + $("#memberentry_guarantor").find('legend').nextAll().toggle(); + [% END %] + [% END %] + [% IF fieldstohide.match('primary_address') %] + $("#memberentry_mainaddress").find('legend').nextAll().toggle(); + [% END %] + [% IF fieldstohide.match('primary_contact') %] + $("#memberentry_contact").find('legend').nextAll().toggle(); + [% END %] + [% END %] + [% UNLESS step == 6 %] + [% IF fieldstohide.match('alt_address') %] + $("#memberentry_address").find('legend').nextAll().toggle(); + [% END %] + [% END %] + [% UNLESS step == 2 %] + [% IF fieldstohide.match('alt_contact') %] + $("#memberentry_altaddress").find('legend').nextAll().toggle(); + [% END %] + [% END %] + [% UNLESS step == 3 %] + [% IF fieldstohide.match('lib_mgmt') %] + $("#memberentry_library_management").find('legend').nextAll().toggle(); + [% END %] + [% UNLESS nodateenrolled && noopacnote && noborrowernotes %] + [% IF fieldstohide.match('lib_setup') %] + $("#memberentry_subscription").find('legend').nextAll().toggle(); + [% END %] + [% END %] + [% UNLESS nouserid && nopassword %] + [% IF fieldstohide.match('login') %] + $("#memberentry_userid").find('legend').nextAll().toggle(); + [% END %] + [% END %] + [% UNLESS ( opadd || opduplicate ) %] + [% IF fieldstohide.match('flags') %] + $("#memberentry_account_flags").find('legend').nextAll().toggle(); + [% END %] + [% END %] + [% IF fieldstohide.match('debarments') %] + $("#memberentry_restrictions").find('legend').nextAll().toggle(); + [% END %] + [% END %] + [% UNLESS step == 7 %] + [% IF Koha.Preference('HouseboundModule') %] + [% IF fieldstohide.match('housebound') %] + $("#memberentry_housebound_roles").find('legend').nextAll().toggle(); + [% END %] + [% END %] + [% END %] + [% UNLESS step == 4 %] + [% IF Koha.Preference('ExtendedPatronAttributes') %] + [% IF fieldstohide.match('additional') %] + $("#memberentry_patron_attributes").find('legend').nextAll().toggle(); + [% END %] + [% END %] + [% END %] + [% UNLESS step == 5 %] + [% IF Koha.Preference('EnhancedMessagingPreferences') %] + [% IF fieldstohide.match('messaging') %] + $("#memberentry_messaging_prefs").find('legend').nextAll().toggle(); + $("#messaging_prefs_loading").toggle(); + [% END %] + [% END %] + [% END %] + } + $(document).ready(function() { + showHideFields(); + $("#toggle_hidden_fields").change(function(){ + showHideFields(); + }); + + $("legend").click(function(){ + $(this).nextAll().toggle(); + $("#messaging_prefs_loading").hide(); + }); + $("#saverecord").css({ 'margin-left': 0 }); Sticky = $("#toolbar"); -- 2.11.0