Fridolin Somers
cc83d8e19a
In new patrons search via API, the road type code is displayed in patron address instead of authorized value description. Also road type is missing a space separator in DE and FR format. Test plan : 1) Create two entries in authorized value category "ROADTYPE" : R1 "Road" R2 "Street" 2) Edit a patron (ie Delgado, Floyd) to set road type to "Road" 3) Perform a search on patrons (click on letter D) 4) Check you see in address "Road" and not "R1" 5) Edit authorized value category "ROADTYPE" to delete entry "R1" 6) Perform a search on patrons (click on letter D) 7) Check you see in address "R1" Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de> (cherry picked from commit3c0ac4cb9a
) Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com> (cherry picked from commit72e78f72a3
) Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
126 lines
5.7 KiB
PHP
126 lines
5.7 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.authorised_value] = r.lib;
|
|
return map;
|
|
}, {});
|
|
|
|
function member_display_address_style_us(data, line_break, include_li) {
|
|
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] : data.street_type;
|
|
}
|
|
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 += 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 += include_li ? '<li class="patroncity">' : ' ';
|
|
address += escape_str(data.city);
|
|
if ( data.state ) {
|
|
if ( data.city ) {
|
|
address += ', ';
|
|
}
|
|
address += escape_str(data.state);
|
|
}
|
|
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 += include_li ? '</li>' : '';
|
|
}
|
|
|
|
return address;
|
|
}
|
|
|
|
function member_display_address_style_de(data, line_break, include_li) {
|
|
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] : data.street_type;
|
|
}
|
|
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 += 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 += 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 += include_li ? '</li>' : '';
|
|
}
|
|
|
|
return address;
|
|
}
|
|
|
|
function member_display_address_style_fr(data, line_break, include_li) {
|
|
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] : data.street_type;
|
|
}
|
|
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 += 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 += 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 += include_li ? '</li>' : '';
|
|
}
|
|
|
|
return address;
|
|
}
|
|
|
|
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, include_li);
|
|
[%~ ELSE ~%]
|
|
return member_display_address_style_us(data, line_break, include_li);
|
|
[%~ END ~%]
|
|
}
|
|
|
|
})();
|
|
</script>
|
|
<!-- / js-patron-format-address.inc -->
|