Bugzilla – Attachment 99585 Details for
Bug 24725
xgettext does not support (yet) ES template literals
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24725: Remove ES template literals in checkouts.js
Bug-24725-Remove-ES-template-literals-in-checkouts.patch (text/plain), 13.37 KB, created by
Jonathan Druart
on 2020-02-25 14:02:04 UTC
(
hide
)
Description:
Bug 24725: Remove ES template literals in checkouts.js
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2020-02-25 14:02:04 UTC
Size:
13.37 KB
patch
obsolete
>From 6782a521242e48cde636173aa914e3d3de70f3c2 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 25 Feb 2020 14:40:06 +0100 >Subject: [PATCH] Bug 24725: Remove ES template literals in checkouts.js > >From Julian on bug 24661 comment 6: >""" >It looks like xgettext does not like ES6 template literals. > >https://savannah.gnu.org/bugs/?50920 > >From what I understand, support for template literals was added in gettext 0.20 (still not packaged in debian) but is still buggy in latest released version 0.20.1 and a fix is present in master. >""" > >We should not use backticks ` in .js file, it breaks xgettext. > >To replicate: >kohadev-koha@e1f3025cca60:/kohadevbox/koha/misc/translator$ perl translate update es-ES >koha-tmpl/intranet-tmpl/prog/js/checkouts.js:569: warning: unterminated string >koha-tmpl/intranet-tmpl/prog/js/checkouts.js:858: warning: unterminated string >koha-tmpl/intranet-tmpl/prog/js/checkouts.js:904: warning: unterminated string >koha-tmpl/intranet-tmpl/prog/js/checkouts.js:911: warning: unterminated string >koha-tmpl/intranet-tmpl/prog/js/checkouts.js:1095: warning: RegExp literal terminated too early >/usr/bin/msgmerge: error while opening "/kohadevbox/koha/misc/translator/po/es-ES-messages-js.po" for reading: No such file or directory > >(last error 'No such file or directory' is not related to this). > >Test plan: >Make sure nothing is broken on the claims table >Confirm that the errors do not longer appear on `perl translate update LANG` >--- > koha-tmpl/intranet-tmpl/prog/js/checkouts.js | 87 +++++++++++++--------------- > 1 file changed, 41 insertions(+), 46 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js >index 1bbb884afe..cb8535dcdd 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js >@@ -554,9 +554,9 @@ $(document).ready(function() { > let content = ""; > > if ( oObj.return_claim_id ) { >- content = `<span class="badge">${oObj.return_claim_created_on_formatted}</span>`; >+ content = '<span class="badge">' + oObj.return_claim_created_on_formatted + '</span>'; > } else { >- content = `<a class="btn btn-default btn-xs claim-returned-btn" data-itemnumber="${oObj.itemnumber}"><i class="fa fa-exclamation-circle"></i> ${RETURN_CLAIMED_MAKE}</a>`; >+ content = '<a class="btn btn-default btn-xs claim-returned-btn" data-itemnumber="' + oObj.itemnumber + '"><i class="fa fa-exclamation-circle"></i>' + RETURN_CLAIMED_MAKE + '</a>'; > } > return content; > } >@@ -845,7 +845,7 @@ $(document).ready(function() { > > $('#claims-returned-modal').modal('hide') > >- $(`.claim-returned-btn[data-itemnumber='${itemnumber}']`).replaceWith(`<img id='return_claim_spinner_${itemnumber}' src='${interface}/${theme}/img/spinner-small.gif' />`); >+ $('.claim-returned-btn[data-itemnumber="' + itemnumber + '"]').replaceWith('<img id="return_claim_spinner_' + itemnumber + ' src=' + interface + '/' + theme + '/img/spinner-small.gif />'); > > params = { > item_id: itemnumber, >@@ -862,7 +862,7 @@ $(document).ready(function() { > > let content = ""; > if ( data.claim_id ) { >- content = `<span class="badge">${created_on.toLocaleDateString()}</span>`; >+ content = '<span class="badge">' + created_on.toLocaleDateString() + '</span>'; > $(id).parent().parent().addClass('ok'); > } else { > content = RETURN_CLAIMED_FAILURE; >@@ -900,14 +900,14 @@ $(document).ready(function() { > }, > { > "mDataProp": function ( oObj ) { >- let title = `<a class="return-claim-title strong" href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=${oObj.biblionumber}"> >- ${oObj.title} >- ${oObj.enumchron || ""} >- </a>`; >+ let title = '<a class="return-claim-title strong" href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=' + oObj.biblionumber + '">' >+ + oObj.title >+ + ( oObj.enumchron || "" ) >+ + '</a>'; > if ( oObj.author ) { >- title += `by ${oObj.author}`; >+ title += 'by ' + oObj.author; > } >- title += `<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=${oObj.biblionumber}&itemnumber=${oObj.itemnumber}">${oObj.barcode}</a>`; >+ title += '<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=' + oObj.biblionumber + '&itemnumber=' + oObj.itemnumber + '">' + oObj.barcode + '</a>'; > > return title; > } >@@ -915,10 +915,8 @@ $(document).ready(function() { > { > "sClass": "return-claim-notes-td", > "mDataProp": function ( oObj ) { >- return ` >- <span id="return-claim-notes-static-${oObj.id}" class="return-claim-notes" data-return-claim-id="${oObj.id}">${oObj.notes}</span> >- <i style="float:right" class="fa fa-pencil-square-o" title="Double click to edit"></i> >- `; >+ return '<span id="return-claim-notes-static-' + oObj.id + '" class="return-claim-notes" data-return-claim-id="' + oObj.id + '">' + oObj.notes + '</span>' >+ + '<i style="float:right" class="fa fa-pencil-square-o" title="Double click to edit"></i>'; > } > }, > { >@@ -937,32 +935,30 @@ $(document).ready(function() { > "mDataProp": function ( oObj ) { > if ( ! oObj.resolution ) return ""; > >- let desc = `<strong>${oObj.resolution_data.lib}</strong> on <i>${oObj.resolved_on}</i>`; >- if (oObj.resolved_by_data) desc += ` by <a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=${oObj.resolved_by_data.borrowernumber}">${oObj.resolved_by_data.firstname || ""} ${oObj.resolved_by_data.surname || ""}</a>`; >+ let desc = '<strong>' + oObj.resolution_data.lib + '</strong> on <i>' + oObj.resolved_on + '</i>'; >+ if (oObj.resolved_by_data) desc += ' by <a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=' + oObj.resolved_by_data.borrowernumber + '">' + ( oObj.resolved_by_data.firstname || "" ) + ( oObj.resolved_by_data.surname || "" ) + '</a>'; > return desc; > } > }, > { > "mDataProp": function ( oObj ) { > let delete_html = oObj.resolved_on >- ? `<li><a href="#" class="return-claim-tools-delete" data-return-claim-id="${oObj.id}"><i class="fa fa-trash"></i> Delete</a></li>` >+ ? '<li><a href="#" class="return-claim-tools-delete" data-return-claim-id="' + oObj.id + '"><i class="fa fa-trash"></i> Delete</a></li>' > : ""; > let resolve_html = ! oObj.resolution >- ? `<li><a href="#" class="return-claim-tools-resolve" data-return-claim-id="${oObj.id}"><i class="fa fa-check-square"></i> Resolve</a></li>` >+ ? '<li><a href="#" class="return-claim-tools-resolve" data-return-claim-id="' + oObj.id + '"><i class="fa fa-check-square"></i> Resolve</a></li>' > : ""; > >- return ` >- <div class="btn-group"> >- <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> >- Actions <span class="caret"></span> >- </button> >- <ul class="dropdown-menu"> >- <li><a href="#" class="return-claim-tools-editnotes" data-return-claim-id="${oObj.id}"><i class="fa fa-edit"></i> Edit notes</a></li> >- ${resolve_html} >- ${delete_html} >- </ul> >- </div> >- `; >+ return '<div class="btn-group">' >+ + ' <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">' >+ + ' Actions <span class="caret"></span>' >+ + ' </button>' >+ + ' <ul class="dropdown-menu">' >+ + ' <li><a href="#" class="return-claim-tools-editnotes" data-return-claim-id="' + oObj.id + '"><i class="fa fa-edit"></i> Edit notes</a></li>' >+ + resolve_html >+ + delete_html >+ + ' </ul>' >+ + ' </div>'; > } > }, > ], >@@ -989,21 +985,20 @@ $(document).ready(function() { > > $('body').on('click', '.return-claim-tools-editnotes', function() { > let id = $(this).data('return-claim-id'); >- $(`#return-claim-notes-static-${id}`).parent().dblclick(); >+ $('#return-claim-notes-static-' + id).parent().dblclick(); > }); > $('body').on('dblclick', '.return-claim-notes-td', function() { > let elt = $(this).children('.return-claim-notes'); > let id = elt.data('return-claim-id'); >- if ( $(`#return-claim-notes-editor-textarea-${id}`).length == 0 ) { >+ if ( $('#return-claim-notes-editor-textarea-' + id).length == 0 ) { > let note = elt.text(); >- let editor = ` >- <span id="return-claim-notes-editor-${id}"> >- <textarea id="return-claim-notes-editor-textarea-${id}">${note}</textarea> >- <br/> >- <a class="btn btn-default btn-xs claim-returned-notes-editor-submit" data-return-claim-id="${id}"><i class="fa fa-save"></i> Update</a> >- <a class="claim-returned-notes-editor-cancel" data-return-claim-id="${id}" href="#">Cancel</a> >- </span> >- `; >+ let editor = >+ ' <span id="return-claim-notes-editor-' + id + '">' >+ + ' <textarea id="return-claim-notes-editor-textarea-' + id + '">' + note + '</textarea>' >+ + ' <br/>' >+ + ' <a class="btn btn-default btn-xs claim-returned-notes-editor-submit" data-return-claim-id="' + id + '"><i class="fa fa-save"></i> Update</a>' >+ + ' <a class="claim-returned-notes-editor-cancel" data-return-claim-id="' + id + '" href="#">Cancel</a>' >+ + '</span>'; > elt.hide(); > $(editor).insertAfter( elt ); > } >@@ -1011,7 +1006,7 @@ $(document).ready(function() { > > $('body').on('click', '.claim-returned-notes-editor-submit', function(){ > let id = $(this).data('return-claim-id'); >- let notes = $(`#return-claim-notes-editor-textarea-${id}`).val(); >+ let notes = $('#return-claim-notes-editor-textarea-' + id).val(); > > let params = { > notes: notes, >@@ -1021,11 +1016,11 @@ $(document).ready(function() { > $(this).parent().remove(); > > $.ajax({ >- url: `/api/v1/return_claims/${id}/notes`, >+ url: '/api/v1/return_claims/' + id + '/notes', > type: 'PUT', > data: JSON.stringify(params), > success: function( data ) { >- let notes = $(`#return-claim-notes-static-${id}`); >+ let notes = $('#return-claim-notes-static-' + id); > notes.text(data.notes); > notes.show(); > }, >@@ -1036,7 +1031,7 @@ $(document).ready(function() { > $('body').on('click', '.claim-returned-notes-editor-cancel', function(){ > let id = $(this).data('return-claim-id'); > $(this).parent().remove(); >- $(`#return-claim-notes-static-${id}`).show(); >+ $('#return-claim-notes-static-' + id).show(); > }); > > // Hanld return claim deletion >@@ -1046,7 +1041,7 @@ $(document).ready(function() { > let id = $(this).data('return-claim-id'); > > $.ajax({ >- url: `/api/v1/return_claims/${id}`, >+ url: '/api/v1/return_claims/' + id, > type: 'DELETE', > success: function( data ) { > refreshReturnClaimsTable(); >@@ -1076,7 +1071,7 @@ $(document).ready(function() { > }; > > $.ajax({ >- url: `/api/v1/return_claims/${id}/resolve`, >+ url: '/api/v1/return_claims/' + id + '/resolve', > type: 'PUT', > data: JSON.stringify(params), > success: function( data ) { >-- >2.11.0
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 24725
:
99584
|
99585
|
99646
|
99814
|
99815