From 00e573d7da384aca5b736efe41a6494b2a8b5b13 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Wed, 6 May 2020 18:50:29 -0300 Subject: [PATCH] Bug 25288: (QA follow-up) Escape data and restore empty list behaviour After the QA round on bug 25279, some things needed to get fixed: - Data needs to be escaped - When no library is defined, we should keep the original behaviour and message. This patch does that. Signed-off-by: Tomas Cohen Arazi --- admin/branches.pl | 3 + .../prog/en/modules/admin/branches.tt | 74 +++++++++++-------- 2 files changed, 47 insertions(+), 30 deletions(-) diff --git a/admin/branches.pl b/admin/branches.pl index c3eeea7d53..b609c20d83 100755 --- a/admin/branches.pl +++ b/admin/branches.pl @@ -147,6 +147,9 @@ if ( $op eq 'add_form' ) { $op = 'list'; } +$template->param( libraries_count => Koha::Libraries->search->count ) + if $op eq 'list'; + $template->param( messages => \@messages, op => $op, diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt index 3c9ca49923..3a7d5cdadb 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt @@ -183,19 +183,23 @@ [% IF op == 'list' %]

Libraries

- - - - - - - - - - - - -
NameCodeAddressMARC organization codeIPPickup locationActions
+ [% IF libraries_count > 0 %] + + + + + + + + + + + + +
NameCodeAddressMARC organization codeIPPickup locationActions
+ [% ELSE %] +
There are no libraries defined. Start defining libraries.
+ [% END %] [% END %] @@ -218,13 +222,23 @@ var columns_settings = [% ColumnsSettings.GetColumns( 'admin', 'libraries', 'libraries', 'json' ) | $raw %]; $(document).ready(function() { + const to_html = (x) => $('
').text(x).html(); + var libraries_url = '/api/v1/libraries'; var libraries = $("#libraries").api({ "ajax": { "url": libraries_url }, - 'dom': 'C<"top pager"ilpfB><"#filter_c">tr<"bottom pager"ip>', 'emptyTable': '
'+_("There are no libraries defined.")+' '+_("Start defining libraries")+'.
', + "columnDefs": [ { + "targets": [0,1,3,4,7,8,9,10,11,12,13,14,15], + "render": function (data, type, row, meta) { + if ( type == 'display' ) { + return to_html(data); + } + return data; + } + } ], "columns": [ { "data": "name", @@ -239,27 +253,27 @@ { "data": function( row, type, val, meta ) { const library_info = []; - if ( row.address1 != null ) library_info.push(row.address1); - if ( row.address2 != null ) library_info.push(row.address2); - if ( row.address3 != null ) library_info.push(row.address3); + if ( row.address1 != null ) library_info.push(to_html(row.address1)); + if ( row.address2 != null ) library_info.push(to_html(row.address2)); + if ( row.address3 != null ) library_info.push(to_html(row.address3)); // geographical_location = city, state postal_code const locations = []; - if ( row.city != null ) locations.push(row.city); - if ( row.state != null ) locations.push(row.state); + if ( row.city != null ) locations.push(to_html(row.city)); + if ( row.state != null ) locations.push(to_html(row.state)); const geographical_location = locations.join(', '); if ( geographical_location != '' && row.postal_code != null) { - library_info.push(geographical_location+' '+row.postal_code); + library_info.push(geographical_location+' '+to_html(row.postal_code)); } else { library_info.push(geographical_location); } - if ( row.country != null ) library_info.push(row.country); - if ( row.phone != null ) library_info.push(_("Ph: ") + row.phone); - if ( row.fax != null ) library_info.push(_("Fax: ") + row.fax); - if ( row.email != null ) library_info.push(''+row.email+''); - if ( row.url != null ) library_info.push(''+row.url+''); - if ( row.opac_info != null ) library_info.push(_("OPAC Info") + ':
'+row.opac_info+'
'); - if ( row.notes != null ) library_info.push(_("Notes")+': '+row.notes); + if ( row.country != null ) library_info.push(to_html(row.country)); + if ( row.phone != null ) library_info.push(_("Ph: ") + to_html(row.phone)); + if ( row.fax != null ) library_info.push(_("Fax: ") + to_html(row.fax)); + if ( row.email != null ) library_info.push(''+to_html(row.email)+''); + if ( row.url != null ) library_info.push(''+to_html(row.url)+''); + if ( row.opac_info != null ) library_info.push(_("OPAC Info") + ':
'+to_html(row.opac_info)+'
'); + if ( row.notes != null ) library_info.push(_("Notes")+': '+to_html(row.notes)); return library_info.join('
'); }, "searchable": false, @@ -286,11 +300,11 @@ { "data": function( row, type, val, meta ) { - var result = ' '+_("Edit")+''; + var result = ' '+_("Edit")+''; result += '
'; - result += ''; + result += ''+"\n"; result += ''; - result += '
'; + result += ''; return result; -- 2.26.2