Bugzilla – Attachment 118128 Details for
Bug 27930
Move _escape_* functions from acq/parcel.tt to be re-usable
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27930: Move _escape_* from acqui/parcel.tt to js/staff-global.js
Bug-27930-Move-escape-from-acquiparceltt-to-jsstaf.patch (text/plain), 13.16 KB, created by
Martin Renvoize (ashimema)
on 2021-03-11 14:27:31 UTC
(
hide
)
Description:
Bug 27930: Move _escape_* from acqui/parcel.tt to js/staff-global.js
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2021-03-11 14:27:31 UTC
Size:
13.16 KB
patch
obsolete
>From a47e40f2dbbe6889376bf2cbe11d6fd3d52a8c1d Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >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 >--- > .../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 "<a href=\"/cgi-bin/koha/acqui/basket.pl?basketno=" + encodeURIComponent(row.basket.basket_id) + "\">" + _escape_str(data) + " (" + _escape_str(row.basket.basket_id) + ")</a>"; >+ if (type != 'display') return escape_str(data); >+ return "<a href=\"/cgi-bin/koha/acqui/basket.pl?basketno=" + encodeURIComponent(row.basket.basket_id) + "\">" + escape_str(data) + " (" + escape_str(row.basket.basket_id) + ")</a>"; > } > }, > { "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 "<a href=\"/cgi-bin/koha/acqui/basketgroup.pl?op=add&booksellerid=" > + encodeURIComponent(row.basket.vendor_id) + "&basketgroupid=" > + encodeURIComponent(row.basket.basket_group_id) + "\">" >- + _escape_str(row.basket.basket_group.name) + " (" + _escape_str(row.basket.basket_group_id) + ")</a>"; >+ + escape_str(row.basket.basket_group.name) + " (" + escape_str(row.basket.basket_group_id) + ")</a>"; > } > } > }, > { > "data": "order_id", > "render": function(data, type, row, meta) { >- if (type != 'display') return _escape_str(data); >- return "<a href=\"neworderempty.pl?ordernumber="+encodeURIComponent(data)+"&booksellerid="+encodeURIComponent(row.basket.vendor_id)+"\">"+_escape_str(data)+"</a>"; >+ if (type != 'display') return escape_str(data); >+ return "<a href=\"neworderempty.pl?ordernumber="+encodeURIComponent(data)+"&booksellerid="+encodeURIComponent(row.basket.vendor_id)+"\">"+escape_str(data)+"</a>"; > } > }, > { >@@ -435,22 +428,22 @@ > "render": function(data, type, row, meta) { > var result = ''; > if ( row && row.biblio_id != null ) { >- result = "<p><a href=\"/cgi-bin/koha/catalogue/detail.pl?biblionumber="+encodeURIComponent(row.biblio_id)+"\">"+_escape_str(row.biblio.title)+"</a>"; >+ result = "<p><a href=\"/cgi-bin/koha/catalogue/detail.pl?biblionumber="+encodeURIComponent(row.biblio_id)+"\">"+escape_str(row.biblio.title)+"</a>"; > 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 += "<br/>" + _("Publisher: ") + _escape_str(row.biblio.publisher); >+ result += "<br/>" + _("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 += "<br/>" + _("Suggested by: ") + >@@ -471,7 +464,7 @@ > + encodeURIComponent(suggestion.suggestionid) > + '&op=show">' > + suggested_by.join(", ") >- + " (#" + _escape_str(suggestions[0].suggestionid) + ")</a>"; // FIXME: could be changed if we allow matching multiple suggestions >+ + " (#" + escape_str(suggestions[0].suggestionid) + ")</a>"; // FIXME: could be changed if we allow matching multiple suggestions > } > } > result += '</p>'; >@@ -481,7 +474,7 @@ > if ( internal_note != null && internal_note != '' ) { > result += '<p class="ordernote"><strong>' > + _("Internal note: ") >- + '</strong>' + _escape_str(internal_note) >+ + '</strong>' + escape_str(internal_note) > + ' [<a href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=' > + encodeURIComponent(row.order_id) + '&referrer=/cgi-bin/koha/acqui/parcel.pl%3Finvoiceid=[% invoiceid | uri %]' > + '&type=internal">' + _("Change internal note") + '</a>]</p>'; >@@ -496,7 +489,7 @@ > if ( vendor_note != null && vendor_note != '' ) { > result += '<p class="ordernote"><strong>' > + _("Vendor note: ") >- + '</strong>' + _escape_str(vendor_note) + '</p>'; >+ + '</strong>' + escape_str(vendor_note) + '</p>'; > } > else { > result += ' [<a href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=' >@@ -522,7 +515,7 @@ > { > "data": "replacement_price", > "render": function(data, type, row, meta) { >- return _escape_price(row.replacement_price); >+ return escape_price(row.replacement_price); > }, > }, > { >@@ -532,13 +525,13 @@ > { > "data": "ecost", > "render": function(data, type, row, meta) { >- return _escape_price(row.ecost); >+ return escape_price(row.ecost); > }, > }, > { > "data": "", > "render": function(data, type, row, meta) { >- return _escape_price(row.quantity * row.ecost); >+ return escape_price(row.quantity * row.ecost); > }, > "orderable": false, // FIXME: How can we do it in DBIC? > "searchable": false >@@ -546,8 +539,8 @@ > { > "data": "fund.name", > "render": function(data, type, row, meta) { >- if (type != 'display') return _escape_str(data); >- return _escape_str(row.fund.name); >+ if (type != 'display') return escape_str(data); >+ return escape_str(row.fund.name); > } > }, > { >@@ -556,7 +549,7 @@ > return '<a href="orderreceive.pl?ordernumber=' > + encodeURIComponent(row.order_id) + '&invoiceid=[% invoiceid | uri %]' + '">' > + _("Receive") + '</a><br/>' >- + '<a href="#" onclick="transfer_order_popup(' + _escape_str(row.order_id) + '); return false;">' >+ + '<a href="#" onclick="transfer_order_popup(' + escape_str(row.order_id) + '); return false;">' > + _("Transfer") + '</a>'; > }, > "orderable": false, >@@ -569,7 +562,7 @@ > > if ( row.current_holds_count > 0 ) { > result += '<span class="button" title="' >- + _("Can't cancel order, (%s) holds are linked with this order. Cancel holds first").format( _escape_str(row.holds_count) ) + '">' >+ + _("Can't cancel order, (%s) holds are linked with this order. Cancel holds first").format( escape_str(row.holds_count) ) + '">' > + _("Can't cancel order") + '</span><br/>'; > } > 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
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 27930
:
118128
|
118153
|
118154