From 4605d76a73f9b13ba3b0259e3f480fb396051309 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Wed, 6 Mar 2019 19:59:53 +0000 Subject: [PATCH] Bug 3766: Cities/Towns only on one address This patch ties the alternate address and alternate contact address fields in the patron entry form to the cities and towns data. This provides a dropdown of predefined city data to these address fields. To test, apply the patch and edit a patron record. Test city selection for all three address fields: Main address, alternate address, and alternate contact. Confirm that city selection works correctly and that your changes are saved correctly. Perform these tests with all AddressFormat options: French, German, and US. Signed-off-by: Liz Rea Signed-off-by: Katrin Fischer Signed-off-by: Nick Clemens --- .../includes/member-alt-address-style-de.inc | 39 +++++++++++++------ .../includes/member-alt-address-style-fr.inc | 14 +++++++ .../includes/member-alt-address-style-us.inc | 18 ++++++++- .../includes/member-alt-contact-style-de.inc | 16 +++++++- .../includes/member-alt-contact-style-fr.inc | 20 ++++++++-- .../includes/member-alt-contact-style-us.inc | 20 ++++++++-- .../includes/member-main-address-style-de.inc | 2 +- .../includes/member-main-address-style-fr.inc | 20 +++++----- .../includes/member-main-address-style-us.inc | 2 +- .../prog/en/modules/members/memberentrygen.tt | 9 ++--- koha-tmpl/intranet-tmpl/prog/js/members.js | 15 +++---- 11 files changed, 130 insertions(+), 45 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/member-alt-address-style-de.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/member-alt-address-style-de.inc index 3171105ccc..82532998ab 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/member-alt-address-style-de.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/member-alt-address-style-de.inc @@ -1,17 +1,5 @@
Alternate address
    - [% UNLESS noB_address %] -
  1. - [% IF ( mandatoryB_address ) %] -
  2. - [% END %] [% IF roadtypes %]
  3. @@ -35,6 +23,19 @@
  4. [% END %] + [% UNLESS noB_address %] +
  5. + [% IF ( mandatoryB_address ) %] +
  6. + [% END %] + [% UNLESS noB_streetnumber %]
  7. [% IF ( mandatoryB_streetnumber ) %] @@ -81,6 +82,20 @@ [% END %] City: + [% IF cities.count %]or choose + + [% END %] [% IF ( mandatoryB_city ) %]Required[% END %]
  8. [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/member-alt-address-style-fr.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/member-alt-address-style-fr.inc index 9d0cda01ac..6f376e4771 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/member-alt-address-style-fr.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/member-alt-address-style-fr.inc @@ -82,6 +82,20 @@ [% END %] City: + [% IF cities.count %]or choose + + [% END %] [% IF ( mandatoryB_city ) %]Required[% END %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/member-alt-address-style-us.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/member-alt-address-style-us.inc index 6afd3e1898..ec3d6e274c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/member-alt-address-style-us.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/member-alt-address-style-us.inc @@ -68,7 +68,21 @@ [% END %] City: - [% IF ( mandatoryB_city ) %]Required[% END %] + [% IF cities.count %]or choose + + [% END %] + [% IF ( mandatoryB_city ) %]Required[% END %] [% END %] [% UNLESS noB_state %] @@ -138,7 +152,7 @@ - + [% IF ( mandatorycontactnote ) %]Required[% END %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/member-alt-contact-style-de.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/member-alt-contact-style-de.inc index cbc2f7eab7..b760addb5a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/member-alt-contact-style-de.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/member-alt-contact-style-de.inc @@ -68,7 +68,21 @@ - + + [% IF cities.count %]or choose + + [% END %] [% IF ( mandatoryaltcontactaddress3 ) %]Required[% END %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/member-alt-contact-style-fr.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/member-alt-contact-style-fr.inc index 60c0fec2d2..333f5a718e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/member-alt-contact-style-fr.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/member-alt-contact-style-fr.inc @@ -63,12 +63,26 @@ [% UNLESS noaltcontactaddress3 %]
  9. [% IF ( mandatoryaltcontactaddress3 ) %] -
  10. [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/member-alt-contact-style-us.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/member-alt-contact-style-us.inc index bd8c0493ce..5191897f1f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/member-alt-contact-style-us.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/member-alt-contact-style-us.inc @@ -51,12 +51,26 @@ [% UNLESS noaltcontactaddress3 %]
  11. [% IF ( mandatoryaltcontactaddress3 ) %] -
  12. [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/member-main-address-style-de.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/member-main-address-style-de.inc index a5c7c0fe27..818d7c6317 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/member-main-address-style-de.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/member-main-address-style-de.inc @@ -81,7 +81,7 @@ City: [% IF cities.count %]or choose - [% FOREACH c IN cities %] [% IF c.city_name == patron.city && c.city_state == patron.state && c.city_zipcode == patron.zipcode %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/member-main-address-style-fr.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/member-main-address-style-fr.inc index 245c773bc0..a79df88123 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/member-main-address-style-fr.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/member-main-address-style-fr.inc @@ -2,14 +2,16 @@ Main address
      [% UNLESS nostreettype %] [% UNLESS nostreetnumber %] - [% IF ( mandatorystreetnumber ) %] - [% IF cities.count %]or choose - [% FOREACH c IN cities %] [% IF c.city_name == patron.city && c.city_state == patron.state && c.city_zipcode == patron.zipcode %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/member-main-address-style-us.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/member-main-address-style-us.inc index 4c95b59aef..0db6e834dd 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/member-main-address-style-us.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/member-main-address-style-us.inc @@ -69,7 +69,7 @@ City: [% IF cities.count %]or choose - [% FOREACH c IN cities %] [% IF c.city_name == patron.city && c.city_state == patron.state && c.city_zipcode == patron.zipcode %] 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 1ca6d6318e..62fc2db2de 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt @@ -425,12 +425,9 @@ [% END %] [% UNLESS noaddress && noaddress2 && nocity && nostate && nozipcode && nocountry %] - [% SWITCH Koha.Preference( 'AddressFormat' ) %] - [% CASE 'de' %] - [% INCLUDE 'member-main-address-style-de.inc' %] - [% CASE # us %] - [% INCLUDE 'member-main-address-style-us.inc' %] - [% END %] + [% IF Koha.Preference( 'AddressFormat' ) %] + [% INCLUDE "member-main-address-style-${ Koha.Preference( 'AddressFormat' ) }.inc" %] + [% END %] [% END # nostreet && nocity etc group%] [% UNLESS nophone && nophonepro && nomobile && noemail && noemailpro && nofax %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/members.js b/koha-tmpl/intranet-tmpl/prog/js/members.js index cfd3a830d4..bcca8ef83c 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/members.js +++ b/koha-tmpl/intranet-tmpl/prog/js/members.js @@ -293,14 +293,15 @@ $(document).ready(function(){ $("#quick_add_form #guarantorsearch, #guarantorsearch").val(LABEL_SET_TO_PATRON); }); - $(document.body).on('change','select[name="select_city"]',function(){ - $('select[name="select_city"]').val( $(this).val() ); + $(document.body).on('change','.select_city',function(){ + var selected_city = $(this).val(); + var addressfield = $(this).data("addressfield"); var myRegEx=new RegExp(/(.*)\|(.*)\|(.*)\|(.*)/); - $(this).val().match(myRegEx); - $('input[name="zipcode"]').val( RegExp.$1 ); - $('input[name="city"]').val( RegExp.$2 ); - $('input[name="state"]').val( RegExp.$3 ); - $('input[name="country"]').val( RegExp.$4 ); + var matches = selected_city.match( myRegEx ); + $("#" + addressfield + "zipcode").val( matches[1] ); + $("#" + addressfield + "city").val( matches[2] ); + $("#" + addressfield + "state").val( matches[3] ); + $("#" + addressfield + "country").val( matches[4] ); }); dateformat = $("#dateofbirth").siblings(".hint").first().html(); -- 2.39.5