From 4345a7c1c5ccbd6caed49598421e2a7301972df4 Mon Sep 17 00:00:00 2001 From: Aleisha Amohia <aleishaamohia@hotmail.com> Date: Wed, 5 Apr 2017 04:04:52 +0000 Subject: [PATCH] Bug 3137: HideFieldsAddPatronForm 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 refresh page 2) Go to System preferences and confirm HideFieldsAddPatronForm 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. Sponsored-by: Catalyst IT --- ..._3137_-_add_HideFieldsAddPatronForm_syspref.sql | 1 + installer/data/mysql/sysprefs.sql | 1 + .../prog/en/modules/admin/preferences/patrons.pref | 18 ++++ .../prog/en/modules/members/memberentrygen.tt | 109 +++++++++++++++++++-- 4 files changed, 122 insertions(+), 7 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_3137_-_add_HideFieldsAddPatronForm_syspref.sql diff --git a/installer/data/mysql/atomicupdate/bug_3137_-_add_HideFieldsAddPatronForm_syspref.sql b/installer/data/mysql/atomicupdate/bug_3137_-_add_HideFieldsAddPatronForm_syspref.sql new file mode 100644 index 0000000..6ffd585 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_3137_-_add_HideFieldsAddPatronForm_syspref.sql @@ -0,0 +1 @@ +INSERT IGNORE INTO systempreferences (`variable`,`value`,`options`,`explanation`,`type`) VALUES ('HideFieldsAddPatronForm', '', NULL, 'Hide these fields by default when adding new patron. These fields can still be expanded.', 'Multiple'); diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 7e249b7..893dd94 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -174,6 +174,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('GoogleOAuth2ClientID', '', NULL, 'Client ID for the web app registered with Google', 'Free'), ('GoogleOAuth2ClientSecret', '', NULL, 'Client Secret for the web app registered with Google', 'Free'), ('GoogleOpenIDConnectDomain', '', NULL, 'Restrict Google OpenID Connect to this domain (or subdomains of this domain). Leave blank for all Google domains', 'Free'), +('HideFieldsAddPatronForm', '', NULL, 'Hide these fields by default when adding 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 4a85957..37557f8 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 form (can still be expanded later) + - pref: HideFieldsAddPatronForm + multiple: + identity: "Organization/Patron identity" + guarantor: Guarantor information + primary_address: Main address + primary_contact: Contact + alt_address: Alternate address + alt_contact: Alternate contact + lib_mgmt: Library management + lib_setup: Library set-up + login: OPAC/Staff login + flags: "Patron account flags (existing patrons)" + debarments: "Patron restrictions (existing patrons)" + housebound: Housebound roles + additional: Additional attributes and identifiers + messaging: 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 ff3ef68..28cef30 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt @@ -10,6 +10,17 @@ //<![CDATA[ $(document).ready(function() { + $(".hidefield").hide(); + $("#toggle_hidden_fields").prop("checked", false); + + $("#toggle_hidden_fields").on("change",function(e){ + if ($("#toggle_hidden_fields").prop("checked") == true){ + $(".hidefield").show(); + } else { + $(".hidefield").hide(); + } + }); + $("#saverecord").css({ 'margin-left': 0 }); var original_offset = $("#toolbar").position().top; var additional_height = $("#filters").height(); @@ -207,6 +218,31 @@ $(document).ready(function() { </div> [% END %] +[% SET fields_to_hide = Koha.Preference('HideFieldsAddPatronForm') %] + +[% IF Koha.Preference('HideFieldsAddPatronForm') %] +<p id="selections"> + <input type="checkbox" id="toggle_hidden_fields" checked="checked" title="These fields are hidden by default by the HideFieldsAddPatronForm system preference"><strong>Show hidden fields:</strong> + [% FOREACH field IN fields_to_hide.split(',') %] + [% SWITCH field %] + [% CASE 'identity' %] Organization/Patron identity | + [% CASE 'guarantor' %] Guarantor information | + [% CASE 'primary_address' %] Main address | + [% CASE 'primary_contact' %] Contact | + [% CASE 'alt_address' %] Alternate address | + [% CASE 'alt_contact' %] Alternate contact | + [% CASE 'lib_mgmt' %] Library management | + [% CASE 'lib_setup' %] Library set-up | + [% 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 %] +</p> +[% END %] <div id="toolbar" class="btn-toolbar"> [% UNLESS ( check_member ) %] @@ -251,9 +287,13 @@ $(document).ready(function() { [% IF ( step_1 ) %] [%UNLESS notitle && nosurname && nofirstname && nodateofbirth && noinitials && noothernames &&nosex %] - <fieldset class="rows" id="memberentry_identity"> +[% IF fields_to_hide.search('identity') %] + <fieldset class="rows hidefield" id="memberentry_identity"> +[% ELSE %] + <fieldset class="rows" id="memberentry_identity"> +[% END %] <legend id="identity_lgd">[% IF ( I ) %]Organization [% ELSE %]Patron [% END %]identity</legend> - <ol> + <ol> [% UNLESS ( I ) %] [% UNLESS notitle %] [% IF Koha.Preference('BorrowersTitles') %] @@ -388,7 +428,11 @@ $(document).ready(function() { [% UNLESS step_6 %] <input type="hidden" name="branchcode" value="[% branchcode %]" /> [% END %] - <fieldset id="memberentry_guarantor" class="rows"> + [% IF fields_to_hide.search('guarantor') %] + <fieldset id="memberentry_guarantor" class="rows hidefield"> + [% ELSE %] + <fieldset id="memberentry_guarantor" class="rows"> + [% END %] <legend id="guarantor_lgd">Guarantor information</legend> <ol> [% IF ( P ) %] @@ -484,15 +528,24 @@ $(document).ready(function() { [% END %] [% UNLESS noaddress && noaddress2 && nocity && nostate && nozipcode && nocountry %] +[% IF fields_to_hide.search('primary_address') %] + <fieldset class="hidefield"> +[% ELSE %] [% IF Koha.Preference( 'AddressFormat' ) %] [% INCLUDE "member-main-address-style-${ Koha.Preference( 'AddressFormat' ) }.inc" %] [% ELSE %] [% INCLUDE 'member-main-address-style-us.inc' %] [% END %] +[% END %] +[% IF fields_to_hide.search('primary_address') %]</fieldset>[% END %] [% END # nostreet && nocity etc group%] [% UNLESS nophone && nophonepro && nomobile && noemail && noemailpro && nofax %] +[% IF fields_to_hide.search('primary_contact') %] + <fieldset class="rows hidefield" id="memberentry_contact"> +[% ELSE %] <fieldset class="rows" id="memberentry_contact"> +[% END %] <legend id="contact_lgd">Contact</legend><ol> [% UNLESS nophone %] <li> @@ -577,27 +630,41 @@ $(document).ready(function() { [% IF ( step_6 ) %] [% UNLESS noB_address && noB_address2 && noB_city && noB_zipcode && noB_state && noB_country &&nocontactnote && noB_phone && noB_email %] + [% IF fields_to_hide.search('alt_address') %] + <fieldset class="hidefield"> + [% ELSE %] [% IF Koha.Preference( 'AddressFormat' ) %] [% INCLUDE "member-alt-address-style-${ Koha.Preference( 'AddressFormat' ) }.inc" %] [% ELSE %] [% INCLUDE 'member-alt-address-style-us.inc' %] [% END %] + [% END %] + [% IF fields_to_hide.search('alt_address') %]</fieldset>[% END %] [% END # UNLESS noB_address && noB_city && noB_state && noB_phone && noB_email %] [% END %] [% IF ( step_2 ) %] [% UNLESS noaltcontactsurname && noaltcontactfirstname && noaltcontactaddress1 && noaltcontactaddress2 && noaltcontactaddress3 && noaltcontactstate && noaltcontactzipcode && noaltcontactcountry && noaltcontactphone %] + [% IF fields_to_hide.search('alt_contact') %] + <fieldset class="hidefield"> + [% ELSE %] [% IF Koha.Preference( 'AddressFormat' ) %] [% INCLUDE "member-alt-contact-style-${ Koha.Preference( 'AddressFormat' ) }.inc" %] [% ELSE %] [% INCLUDE 'member-alt-contact-style-us.inc' %] [% END %] + [% END %] + [% IF fields_to_hide.search('alt_contact') %]</fieldset>[% END %] [% END # UNLESS noaltcontactsurname && noaltcontactfirstname etc %] [% END %] [% IF ( step_3 ) %] [% SET autoMemberNum = Koha.Preference('autoMemberNum') %] - <fieldset class="rows" id="memberentry_library_management"> + [% IF fields_to_hide.search('lib_mgmt') %] + <fieldset class="rows hidefield" id="memberentry_library_management"> + [% ELSE %] + <fieldset class="rows" id="memberentry_library_management"> + [% END %] <legend id="library_management_lgd">Library management</legend><ol> [% UNLESS nocardnumber %] <li> @@ -723,7 +790,11 @@ $(document).ready(function() { </ol> </fieldset> [% UNLESS nodateenrolled && noopacnote && noborrowernotes %] - <fieldset class="rows" id="memberentry_subscription"> + [% IF fields_to_hide.search('lib_setup') %] + <fieldset class="rows hidefield" id="memberentry_subscription"> + [% ELSE %] + <fieldset class="rows" id="memberentry_subscription"> + [% END %] <legend id="library_setup_lgd">Library set-up</legend><ol> [% UNLESS nodateenrolled %] <li> @@ -802,7 +873,11 @@ $(document).ready(function() { [% END # hide fieldset %] [% UNLESS nouserid && nopassword %] - <fieldset class="rows" id="memberentry_userid"> + [% IF fields_to_hide.search('login') %] + <fieldset class="rows hidefield" id="memberentry_userid"> + [% ELSE %] + <fieldset class="rows" id="memberentry_userid"> + [% END %] <legend id="opac_staff_login_lgd">OPAC/Staff login</legend><ol> [% UNLESS nouserid %] <li> @@ -924,7 +999,11 @@ $(document).ready(function() { [% END # hide fieldset %][% END %] <!--this zones are not necessary in modif mode --> [% UNLESS ( opadd || opduplicate ) %] - <fieldset class="rows" id="memberentry_account_flags"> + [% IF fields_to_hide.search('flags') %] + <fieldset class="rows hidefield" id="memberentry_account_flags"> + [% ELSE %] + <fieldset class="rows" id="memberentry_account_flags"> + [% END %] <legend id="account_flags_lgd">Patron account flags</legend> <ol class="radio"> [% FOREACH flagloo IN flagloop %] @@ -957,7 +1036,11 @@ $(document).ready(function() { </ol> </fieldset> + [% IF fields_to_hide.search('restrictions') %] + <fieldset class="rows hidefield" id="memberentry_restrictions"> + [% ELSE %] <fieldset class="rows" id="memberentry_restrictions"> + [% END %] <legend id="restrictions_lgd">Patron restrictions</legend> [% IF ( debarments ) %] @@ -1021,7 +1104,11 @@ $(document).ready(function() { [% IF ( step_4 ) %] [% IF Koha.Preference('HouseboundModule') %] +[% IF fields_to_hide.search('housebound') %] + <fieldset class="rows hidefield" id="memberentry_housebound_roles"> +[% ELSE %] <fieldset class="rows" id="memberentry_housebound_roles"> +[% END %] <legend id="housebound_roles">Housebound roles</legend> <ol class="radio"> <li> @@ -1070,7 +1157,11 @@ $(document).ready(function() { </fieldset> [% END # hide fieldset %] [% IF ( ExtendedPatronAttributes ) %][% UNLESS ( no_patron_attribute_types ) %] +[% IF fields_to_hide.search('additional') %] + <fieldset class="rows hidefield" id="memberentry_patron_attributes"> +[% ELSE %] <fieldset class="rows" id="memberentry_patron_attributes"> +[% END %] <legend id="patron_attributes_lgd">Additional attributes and identifiers</legend> <input type="hidden" name="setting_extended_patron_attributes" value="1" /> [% FOREACH pa_loo IN patron_attributes %] @@ -1114,7 +1205,11 @@ $(document).ready(function() { [% END %][% END %][% END %] [% IF ( step_5 ) %][% IF ( EnhancedMessagingPreferences ) %] +[% IF fields_to_hide.search('messaging') %] + <fieldset class="rows hidefield" id="memberentry_messaging_prefs"> +[% ELSE %] <fieldset class="rows" id="memberentry_messaging_prefs"> +[% END %] <legend id="patron_messaging_prefs_lgd">Patron messaging preferences</legend> [% IF ( opadd ) %] <!-- handle changing prefs if creating new patron and changing -- 2.1.4