Bugzilla – Attachment 147818 Details for
Bug 26967
Patron autocomplete does not correctly format addresses
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26967: Correctly format patron address in autocomplete
Bug-26967-Correctly-format-patron-address-in-autoc.patch (text/plain), 11.88 KB, created by
Jonathan Druart
on 2023-03-07 10:10:33 UTC
(
hide
)
Description:
Bug 26967: Correctly format patron address in autocomplete
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2023-03-07 10:10:33 UTC
Size:
11.88 KB
patch
obsolete
>From ac4c3a1e6f584c3cf37e956f49f113f3e45e40ce Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 28 Feb 2023 09:51:20 +0100 >Subject: [PATCH] Bug 26967: Correctly format patron address in autocomplete > >We should use the JS function to format patron's address in the >autocomplete result > >Test plan: >Search for patron using the autocomplete feature, using the different values >of addressformat. >The address should be formatted correctly, like other places in Koha. >You should also notice that the street number is now displayed. >--- > .../en/includes/js-patron-format-address.inc | 48 ++++++++++++------- > .../prog/en/includes/js_includes.inc | 1 + > .../prog/en/includes/patron-search.inc | 8 ++-- > .../prog/js/patron-autocomplete.js | 5 +- > 4 files changed, 37 insertions(+), 25 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/js-patron-format-address.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/js-patron-format-address.inc >index f72d28371b4..b561431c0ad 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/js-patron-format-address.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/js-patron-format-address.inc >@@ -11,7 +11,7 @@ > return map; > }, {}); > >- function member_display_address_style_us(data, line_break) { >+ function member_display_address_style_us(data, line_break, include_li) { > let address = ""; > if ( data.address || data.address2 ) { > if ( data.address ) { >@@ -19,14 +19,19 @@ > if ( data.street_type ) { > roadtype_desc = roadtypes_map[data.street_type] ? roadtypes_map[data.street_type].street_type : data.street_type; > } >- address += '<li class="patronaddress1">' + escape_str(data.street_number) + ' ' + escape_str(data.address) + ' ' + escape_str(roadtype_desc) + '</li>'; >+ address += include_li ? '<li class="patronaddress1">' : ''; >+ address += escape_str(data.street_number) + ' ' + escape_str(data.address) + ' ' + escape_str(roadtype_desc); >+ address += include_li ? '</li>' : ''; > } > } > if ( data.address2 ) { >- address += '<li class="patronaddress2">' + escape_str(data.address2) + '</li>' >+ address += include_li ? '<li class="patronaddress2">' : ' '; >+ address += escape_str(data.address2); >+ address += include_li ? '</li>' : ''; > } > if ( data.city || data.postal_code || data.state || data.country ) { >- address += '<li class="patroncity">' + escape_str(data.city); >+ address += include_li ? '<li class="patroncity">' : ' '; >+ address += escape_str(data.city); > if ( data.state ) { > if ( data.city ) { > address += ', '; >@@ -42,13 +47,13 @@ > } > address += escape_str(data.country) > } >- address += '</li>' >+ address += include_li ? '</li>' : ''; > } > > return address; > } > >- function member_display_address_style_de(data, line_break) { >+ function member_display_address_style_de(data, line_break, include_li) { > let address = ""; > if ( data.address || data.address2 ) { > if ( data.address ) { >@@ -56,24 +61,28 @@ > if ( data.street_type ) { > roadtype_desc = roadtypes_map[data.street_type] ? roadtypes_map[data.street_type].street_type : data.street_type; > } >- address += '<li class="patronaddress1">' + escape_str(data.address) + ' ' + escape_str(roadtype_desc) + escape_str(data.street_number) + '</li>'; >+ address += include_li ? '<li class="patronaddress1">' : ' '; >+ address += escape_str(data.address) + ' ' + escape_str(roadtype_desc) + escape_str(data.street_number); >+ address += include_li ? '</li>' : ''; > } > } > if ( data.address2 ) { >- address += '<li class="patronaddress2">' + escape_str(data.address2) + '</li>' >+ address += include_li ? '<li class="patronaddress2">' : ' '; >+ address += escape_str(data.address2); >+ address += include_li ? '</li>' : ''; > } > if ( data.city || data.postal_code || data.state || data.country ) { >- address += '<li class="patroncity">'; >+ address += include_li ? '<li class="patroncity">' : ' '; > address += escape_str(data.postal_code) + ' ' + escape_str(data.city); > address += data.state ? line_break + escape_str(data.state) : ''; > address += data.country ? line_break + escape_str(data.country) : ''; >- address += '</li>' >+ address += include_li ? '</li>' : ''; > } > > return address; > } > >- function member_display_address_style_fr(data, line_break) { >+ function member_display_address_style_fr(data, line_break, include_li) { > let address = ""; > if ( data.address || data.address2 ) { > if ( data.address ) { >@@ -81,18 +90,22 @@ > if ( data.street_type ) { > roadtype_desc = roadtypes_map[data.street_type] ? roadtypes_map[data.street_type].street_type : data.street_type; > } >- address += '<li class="patronaddress1">' + escape_str(data.street_number) + ' ' + escape_str(roadtype_desc) + escape_str(data.address) + '</li>'; >+ address += include_li ? '<li class="patronaddress1">' : ''; >+ address += escape_str(data.street_number) + ' ' + escape_str(roadtype_desc) + escape_str(data.address); >+ address += include_li ? '</li>' : ''; > } > } > if ( data.address2 ) { >- address += '<li class="patronaddress2">' + escape_str(data.address2) + '</li>' >+ address += include_li ? '<li class="patronaddress2">' : ' '; >+ address += escape_str(data.address2); >+ address += include_li ? '</li>' : ''; > } > if ( data.city || data.postal_code || data.state || data.country ) { >- address += '<li class="patroncity">'; >+ address += include_li ? '<li class="patroncity">' : ' '; > address += escape_str(data.postal_code) + ' ' + escape_str(data.city); > address += data.state ? line_break + escape_str(data.state) : ''; > address += data.country ? line_break + escape_str(data.country) : ''; >- address += '</li>' >+ address += include_li ? '</li>' : ''; > } > > return address; >@@ -100,10 +113,11 @@ > > window.$format_address = function(data, options) { > let line_break = options && options.no_line_break ? ' ' : '<br/>'; >+ let include_li = options && options.include_li; > [%~ IF Koha.Preference( 'AddressFormat' ) ~%] >- return member_display_address_style_[% Koha.Preference( 'AddressFormat' ) | html %](data, line_break); >+ return member_display_address_style_[% Koha.Preference( 'AddressFormat' ) | html %](data, line_break, include_li); > [%~ ELSE ~%] >- return member_display_address_style_us(data, line_break); >+ return member_display_address_style_us(data, line_break, include_li); > [%~ END ~%] > } > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc >index 2d1af01c4f8..a2ba59bf31e 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc >@@ -28,6 +28,7 @@ > [% Asset.js("js/staff-global.js") | $raw %] > [% INCLUDE 'js-date-format.inc' %] > [% INCLUDE 'js-patron-get-age.inc' %] >+[% INCLUDE 'js-patron-format-address.inc' %] > [% Asset.js("js/patron-autocomplete.js") | $raw %] > > [% INCLUDE 'validator-strings.inc' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >index 4078ebf65ac..ec35d923356 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >@@ -438,7 +438,7 @@ > "orderable": true, > "render": function( data, type, row, meta ) { > let r = '<div class="address"><ul>'; >- r += $format_address(row, { no_line_break: 1 }); >+ r += $format_address(row, { no_line_break: true, include_li: true }); > r += '</div></ul>'; > return r; > } >@@ -450,7 +450,7 @@ > "orderable": true, > "render": function( data, type, row, meta ) { > let r = '<div class="address"><ul>'; >- r += $format_address(row, { no_line_break: 1 }); >+ r += $format_address(row, { no_line_break: true, include_li: true }); > r += '</div></ul>'; > r += " " + escape_str(libraries_map[row.library_id].branchname); > return r; >@@ -471,7 +471,7 @@ > [% END %] > r += '<br/>'; > r += '<div class="address"><ul>'; >- r += $format_address(row, { no_line_break: 1 }); >+ r += $format_address(row, { no_line_break: true, include_li: true }); > > if ( row.email ) { > r += "<li>" + _("Email: ") + "<a href='mailto:" + encodeURIComponent(row.email) + "'>" + escape_str(row.email) + "</a></li>"; >@@ -496,7 +496,7 @@ > [% END %] > r += '<br/>'; > r += '<div class="address"><ul>'; >- r += $format_address(row, { no_line_break: 1 }); >+ r += $format_address(row, { no_line_break: true, include_li: true }); > > if ( row.email ) { > r += "<li>" + _("Email: ") + "<a href='mailto:" + encodeURIComponent(row.email) + "'>" + escape_str(row.email) + "</a></li>"; >diff --git a/koha-tmpl/intranet-tmpl/prog/js/patron-autocomplete.js b/koha-tmpl/intranet-tmpl/prog/js/patron-autocomplete.js >index 49ff14f84b8..cc8ec068ae1 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/patron-autocomplete.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/patron-autocomplete.js >@@ -106,10 +106,7 @@ function patron_autocomplete(node, options) { > + ")</span>," > : "" > ) + " " >- + ( item.address ? item.address.escapeHtml() : "" ) + " " >- + ( item.city ? item.city.escapeHtml() : "" ) + " " >- + ( item.zipcode ? item.zipcode.escapeHtml() : "" ) + " " >- + ( item.country ? item.country.escapeHtml() : "" ) + " " >+ + $format_address(item, { no_line_break: true, include_li: false }) + " " > + ( !singleBranchMode > ? > "<span class=\"ac-library\">" >-- >2.25.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 26967
:
147480
|
147512
|
147818
|
148498
|
149376