Wainui Witika-Park
432f058a72
Adds back street number to the address when searching for patrons To test: 1) Edit a patron's contact information 2) Under Main Address put an address, make sure to put something in the Street number field 3) Do a simple patron search that will yield results (i.e. "a") 4) Confirm the street number does not show, but the rest of the address does 5) Apply this patch 6) Do another patron search 5) Confirm the street number now shows Sponsored-by: Catalyst IT Testing note: AddressFormat system preference must be set to "US style" Signed-off-by: Owen Leonard <oleonard@myacpl.org> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
112 lines
4.9 KiB
PHP
112 lines
4.9 KiB
PHP
<!-- js-patron-format-address.inc -->
|
|
[% USE raw %]
|
|
[% USE To %]
|
|
[% USE AuthorisedValues %]
|
|
<script>
|
|
(function() {
|
|
|
|
const roadtypes = [% To.json(AuthorisedValues.Get('ROADTYPE')) | $raw %];
|
|
let roadtypes_map = roadtypes.reduce((map, r) => {
|
|
map[r.street_type] = r;
|
|
return map;
|
|
}, {});
|
|
|
|
function member_display_address_style_us(data, line_break) {
|
|
let address = "";
|
|
if ( data.address || data.address2 ) {
|
|
if ( data.address ) {
|
|
let roadtype_desc = '';
|
|
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>';
|
|
}
|
|
}
|
|
if ( data.address2 ) {
|
|
address += '<li class="patronaddress2">' + escape_str(data.address2) + '</li>'
|
|
}
|
|
if ( data.city || data.postal_code || data.state || data.country ) {
|
|
address += '<li class="patroncity">' + escape_str(data.city);
|
|
if ( data.state ) {
|
|
if ( data.city ) {
|
|
address += ', ';
|
|
}
|
|
address += escape_str(data.city);
|
|
}
|
|
if ( data.postal_code ) {
|
|
address += " " + escape_str(data.postal_code);
|
|
}
|
|
if ( data.country ) {
|
|
if ( data.postal_code || data.state || data.city ) {
|
|
address += ', ';
|
|
}
|
|
address += escape_str(data.country)
|
|
}
|
|
address += '</li>'
|
|
}
|
|
|
|
return address;
|
|
}
|
|
|
|
function member_display_address_style_de(data, line_break) {
|
|
let address = "";
|
|
if ( data.address || data.address2 ) {
|
|
if ( data.address ) {
|
|
let roadtype_desc = '';
|
|
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>';
|
|
}
|
|
}
|
|
if ( data.address2 ) {
|
|
address += '<li class="patronaddress2">' + escape_str(data.address2) + '</li>'
|
|
}
|
|
if ( data.city || data.postal_code || data.state || data.country ) {
|
|
address += '<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>'
|
|
}
|
|
|
|
return address;
|
|
}
|
|
|
|
function member_display_address_style_fr(data, line_break) {
|
|
let address = "";
|
|
if ( data.address || data.address2 ) {
|
|
if ( data.address ) {
|
|
let roadtype_desc = '';
|
|
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>';
|
|
}
|
|
}
|
|
if ( data.address2 ) {
|
|
address += '<li class="patronaddress2">' + escape_str(data.address2) + '</li>'
|
|
}
|
|
if ( data.city || data.postal_code || data.state || data.country ) {
|
|
address += '<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>'
|
|
}
|
|
|
|
return address;
|
|
}
|
|
|
|
window.$format_address = function(data, options) {
|
|
let line_break = options && options.no_line_break ? ' ' : '<br/>';
|
|
[%~ IF Koha.Preference( 'AddressFormat' ) ~%]
|
|
return member_display_address_style_[% Koha.Preference( 'AddressFormat' ) | html %](data, line_break);
|
|
[%~ ELSE ~%]
|
|
return member_display_address_style_us(data, line_break);
|
|
[%~ END ~%]
|
|
}
|
|
|
|
})();
|
|
</script>
|
|
<!-- / js-patron-format-address.inc -->
|