From dea569912007436ae8ddb77ab3bae999ffdcaa9b Mon Sep 17 00:00:00 2001 From: Maryse Simard Date: Tue, 1 Oct 2019 12:12:53 -0400 Subject: [PATCH] Bug 12446: (follow-up) Remove mandatory transfered values With the new system preference AdditionalGuarantorField, one can add data to be transfered to the guarantee, but cannot remove default ones. This patch renames the syspref to GuarantorFields and set hardcoded default values as the preference's default. To test: 1. After database update, check that the default value for the syspref GuarantorFields contains these columns: streetnumber|address|address2|city|state|zipcode|country| branchcode|phonepro|mobile|email|emailpro|fax 2. Set the value as empty 3. Try adding a guarantor to a patron (from the guarantor's page or the guarantee's): no values should be imported. 4. Check that it still works with different values for the preference. --- C4/Members/Attributes.pm | 7 +++---- .../data/mysql/atomicupdate/bug_12446-EnableAdultGarantee.sql | 2 +- installer/data/mysql/sysprefs.sql | 2 +- .../prog/en/modules/admin/preferences/patrons.pref | 4 ++-- .../intranet-tmpl/prog/en/modules/common/patron_search.tt | 2 ++ koha-tmpl/intranet-tmpl/prog/js/members.js | 10 ++++++---- 6 files changed, 15 insertions(+), 12 deletions(-) diff --git a/C4/Members/Attributes.pm b/C4/Members/Attributes.pm index 41490a1..3a64114 100644 --- a/C4/Members/Attributes.pm +++ b/C4/Members/Attributes.pm @@ -374,10 +374,9 @@ sub _sort_by_code { =cut sub get_guarantor_shared_attributes{ - my @attributes = qw( streetnumber address address2 city state zipcode country branchcode phone phonepro mobile email emailpro fax ); - if( my @additional = split(/\|/, C4::Context->preference("AdditionalGuarantorField")) ){ - $_ =~ s/(?:^\s+)|(?:\s+$)//g for (@additional); # Trim whitespaces - @attributes = ( @attributes, @additional); + my @attributes; + if( @attributes = split(/\|/, C4::Context->preference("GuarantorFields")) ){ + $_ =~ s/(?:^\s+)|(?:\s+$)//g for (@attributes); # Trim whitespaces } return \@attributes; } diff --git a/installer/data/mysql/atomicupdate/bug_12446-EnableAdultGarantee.sql b/installer/data/mysql/atomicupdate/bug_12446-EnableAdultGarantee.sql index 233d765..ded53de 100644 --- a/installer/data/mysql/atomicupdate/bug_12446-EnableAdultGarantee.sql +++ b/installer/data/mysql/atomicupdate/bug_12446-EnableAdultGarantee.sql @@ -2,7 +2,7 @@ -- SYSPREFS -- -- ******** -- INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) -VALUES ('AdditionalGuarantorField','',NULL,'Additional fields name to be transfer from guarantor to guarantee.','free'); +VALUES ('GuarantorFields', 'streetnumber|address|address2|city|state|zipcode|country|branchcode|phonepro|mobile|email|emailpro|fax', NULL, 'Fields to be transfered from guarantor to guarantee.', 'free') -- ********* -- -- STRUCTURE -- diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index de2500d..d4d79c8 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -8,7 +8,6 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('AcqViewBaskets','user','user|branch|all','Define which baskets a user is allowed to view: his own only, any within his branch or all','Choice'), ('AcqWarnOnDuplicateInvoice','0','','Warn librarians when they try to create a duplicate invoice','YesNo'), ('AdditionalFieldsInZ3950ResultSearch', '', NULL, 'Determines which MARC field/subfields are displayed in -Additional field- column in the result of a search Z3950', 'Free'), -('AdditionalGuarantorField','',NULL,'Additional fields name to be transfer from guarantor to guarantee.','free'), ('AddressFormat','us','us|de|fr','Choose format to display postal addresses', 'Choice'), ('AdlibrisCoversEnabled','0',NULL,'Display cover images in OPAC results and detail listing from Swedish retailer Adlibris.','YesNo'), ('AdlibrisCoversURL','http://www.adlibris.com/se/organisationer/showimagesafe.aspx',NULL,'Base URL for Adlibris cover image web service.','Free'), @@ -208,6 +207,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'), +('GuarantorFields', 'streetnumber|address|address2|city|state|zipcode|country|branchcode|phonepro|mobile|email|emailpro|fax', NULL, 'Fields to be transfered from guarantor to guarantee.', 'free'), ('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 42ab3d6..b0e5b35 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 @@ -234,8 +234,8 @@ Patrons: - "to access/change superlibrarian privileges." - "
NOTE: A permitted user needs to have the 'permissions' flag (if no superlibrarian)." - - - "These additional following database columns will be transferred from guarantor to guarantee:" - - pref: AdditionalGuarantorField + - "These following database columns will be transferred from guarantor to guarantee:" + - pref: GuarantorFields class: multi - (separate columns with |) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/common/patron_search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/common/patron_search.tt index 22a9c7b..0d1938a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/common/patron_search.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/common/patron_search.tt @@ -221,6 +221,8 @@ var borrowernumber = $(this).data("borrowernumber"); var borrower_data = $("#borrower_data"+borrowernumber).val(); var guarantor_attributes = $("#guarantor_attributes").val(); + if ( !guarantor_attributes ) + guarantor_attributes = "{}"; select_user( borrowernumber, JSON.parse(borrower_data), JSON.parse(guarantor_attributes) ); }); diff --git a/koha-tmpl/intranet-tmpl/prog/js/members.js b/koha-tmpl/intranet-tmpl/prog/js/members.js index 1860783..761037e 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/members.js +++ b/koha-tmpl/intranet-tmpl/prog/js/members.js @@ -210,10 +210,12 @@ function select_user(borrowernumber, borrower, relationship, attributes) { fieldset.find('.new_guarantor_relationship').val(relationship); } - for (var i = 0; i < parseInt(attributes.length, 10); i++) { - var attribute = attributes[i]; - if (borrower[attribute] != null){ - document.forms.entryform[attribute].value = borrower[attribute]; + if ( attributes ) { + for (var i = 0; i < parseInt(attributes.length, 10); i++) { + var attribute = attributes[i]; + if (borrower[attribute] != null){ + document.forms.entryform[attribute].value = borrower[attribute]; + } } } } -- 2.7.4