From 68c37861c0f4ee6b3b985ee69f87e58b454fa6df Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 11 Mar 2021 14:22:54 +0000 Subject: [PATCH] Bug 27930: Move _escape_* from acqui/parcel.tt to js/staff-global.js This patch moves the _escape_str and _escape_price functions into the staff-global.js include Test plan 1/ The acquisitions parcel page should look the same before and after the patch. 2/ Signoff Signed-off-by: Jonathan Druart --- .../prog/en/modules/acqui/parcel.tt | 57 ++++++++----------- .../intranet-tmpl/prog/js/staff-global.js | 6 ++ 2 files changed, 31 insertions(+), 32 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt index 40fa162bdb..44ecee72ea 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt @@ -333,13 +333,6 @@ dt_overwrite_html_sorting_localeCompare(); var columns_filter = {}; - function _escape_str(s){ - return s != null ? s.escapeHtml() : ""; - } - function _escape_price(p){ - return p != null ? p.escapeHtml().format_price() : ""; - } - $(document).ready(function(){ if ( $("#receivedt").length ) { @@ -400,15 +393,15 @@ "searchable": true, "orderable": true, "render": function(data, type, row, meta) { - if (type != 'display') return _escape_str(data); - return "" + _escape_str(data) + " (" + _escape_str(row.basket.basket_id) + ")"; + if (type != 'display') return escape_str(data); + return "" + escape_str(data) + " (" + escape_str(row.basket.basket_id) + ")"; } }, { "data": "basket.basket_group.name", "orderable": true, "render": function(data, type, row, meta) { if ( type != 'display' ) { - return _escape_str(data); + return escape_str(data); } if ( row.basket.basket_group_id == null ) { return _("No basket group"); @@ -417,15 +410,15 @@ return "" - + _escape_str(row.basket.basket_group.name) + " (" + _escape_str(row.basket.basket_group_id) + ")"; + + escape_str(row.basket.basket_group.name) + " (" + escape_str(row.basket.basket_group_id) + ")"; } } }, { "data": "order_id", "render": function(data, type, row, meta) { - if (type != 'display') return _escape_str(data); - return ""+_escape_str(data)+""; + if (type != 'display') return escape_str(data); + return ""+escape_str(data)+""; } }, { @@ -435,22 +428,22 @@ "render": function(data, type, row, meta) { var result = ''; if ( row && row.biblio_id != null ) { - result = "

"+_escape_str(row.biblio.title)+""; + result = "

"+escape_str(row.biblio.title)+""; if ( row.biblio.author != null ) - result += _(" by ") + _escape_str(row.biblio.author); + result += _(" by ") + escape_str(row.biblio.author); if ( row.biblio.isbn != null ) - result += " – " + _escape_str(row.biblio.isbn); + result += " – " + escape_str(row.biblio.isbn); [% IF Koha.Preference('marcflavour')=='UNIMARC' %] if ( row.biblio.ean != null ) - result += " – EAN:" + _escape_str(row.biblio.ean); + result += " – EAN:" + escape_str(row.biblio.ean); [% END %] if ( row.biblio.publisher != null ) { - result += "
" + _("Publisher: ") + _escape_str(row.biblio.publisher); + result += "
" + _("Publisher: ") + escape_str(row.biblio.publisher); if ( row.biblio.publication_year != null ) { - result += ", " + _escape_str(row.biblio.publication_year); + result += ", " + escape_str(row.biblio.publication_year); } else if ( row.biblio.copyright_date != null ) { - result += _escape_str(row.biblio.copyright_date); + result += escape_str(row.biblio.copyright_date); } } var suggestions = row.biblio.suggestions; @@ -460,10 +453,10 @@ var suggester = suggestion.suggester; var suggested_by = []; if ( suggester.surname != null ) { - suggested_by.push(_escape_str(suggester.surname)); + suggested_by.push(escape_str(suggester.surname)); } if ( suggester.firstname != null ) { - suggested_by.push(_escape_str(suggester.firstname)); + suggested_by.push(escape_str(suggester.firstname)); } result += "
" + _("Suggested by: ") + @@ -471,7 +464,7 @@ + encodeURIComponent(suggestion.suggestionid) + '&op=show">' + suggested_by.join(", ") - + " (#" + _escape_str(suggestions[0].suggestionid) + ")"; // FIXME: could be changed if we allow matching multiple suggestions + + " (#" + escape_str(suggestions[0].suggestionid) + ")"; // FIXME: could be changed if we allow matching multiple suggestions } } result += '

'; @@ -481,7 +474,7 @@ if ( internal_note != null && internal_note != '' ) { result += '

' + _("Internal note: ") - + '' + _escape_str(internal_note) + + '' + escape_str(internal_note) + ' [' + _("Change internal note") + ']

'; @@ -496,7 +489,7 @@ if ( vendor_note != null && vendor_note != '' ) { result += '

' + _("Vendor note: ") - + '' + _escape_str(vendor_note) + '

'; + + '' + escape_str(vendor_note) + '

'; } else { result += ' [' + _("Receive") + '
' - + '' + + '' + _("Transfer") + ''; }, "orderable": false, @@ -569,7 +562,7 @@ if ( row.current_holds_count > 0 ) { result += '' + + _("Can't cancel order, (%s) holds are linked with this order. Cancel holds first").format( escape_str(row.holds_count) ) + '">' + _("Can't cancel order") + '
'; } else { diff --git a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js index 4f06af9465..5a7f7fff74 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js +++ b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js @@ -26,6 +26,9 @@ String.prototype.escapeHtml = function() { return HtmlCharsToEscape[c] || c; }); }; +function escape_str(s){ + return s != null ? s.escapeHtml() : ""; +} /* * Void method for numbers, for consistency @@ -33,6 +36,9 @@ String.prototype.escapeHtml = function() { Number.prototype.escapeHtml = function() { return this; }; +function escape_price(p){ + return p != null ? p.escapeHtml().format_price() : ""; +} // http://stackoverflow.com/questions/14859281/select-tab-by-name-in-jquery-ui-1-10-0/16550804#16550804 $.fn.tabIndex = function () { -- 2.20.1