From 414a1fbb7ddeec3af27ebdd76b765838b301e958 Mon Sep 17 00:00:00 2001 From: Jonathan Druart 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` Signed-off-by: Martin Renvoize Signed-off-by: Katrin Fischer Signed-off-by: Martin Renvoize Signed-off-by: Joy Nelson --- 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 1507bfa4f9..da83b58907 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 = `${oObj.return_claim_created_on_formatted}`; + content = '' + oObj.return_claim_created_on_formatted + ''; } else { - content = ` ${RETURN_CLAIMED_MAKE}`; + content = '' + RETURN_CLAIMED_MAKE + ''; } return content; } @@ -854,7 +854,7 @@ $(document).ready(function() { $('#claims-returned-modal').modal('hide') - $(`.claim-returned-btn[data-itemnumber='${itemnumber}']`).replaceWith(``); + $('.claim-returned-btn[data-itemnumber="' + itemnumber + '"]').replaceWith('${created_on.toLocaleDateString()}`; + content = '' + created_on.toLocaleDateString() + ''; $(id).parent().parent().addClass('ok'); } else { content = RETURN_CLAIMED_FAILURE; @@ -909,14 +909,14 @@ $(document).ready(function() { }, { "mDataProp": function ( oObj ) { - let title = ` - ${oObj.title} - ${oObj.enumchron || ""} - `; + let title = '' + + oObj.title + + ( oObj.enumchron || "" ) + + ''; if ( oObj.author ) { - title += `by ${oObj.author}`; + title += 'by ' + oObj.author; } - title += `${oObj.barcode}`; + title += '' + oObj.barcode + ''; return title; } @@ -924,10 +924,8 @@ $(document).ready(function() { { "sClass": "return-claim-notes-td", "mDataProp": function ( oObj ) { - return ` - ${oObj.notes} - - `; + return '' + oObj.notes + '' + + ''; } }, { @@ -946,32 +944,30 @@ $(document).ready(function() { "mDataProp": function ( oObj ) { if ( ! oObj.resolution ) return ""; - let desc = `${oObj.resolution_data.lib} on ${oObj.resolved_on}`; - if (oObj.resolved_by_data) desc += ` by ${oObj.resolved_by_data.firstname || ""} ${oObj.resolved_by_data.surname || ""}`; + let desc = '' + oObj.resolution_data.lib + ' on ' + oObj.resolved_on + ''; + if (oObj.resolved_by_data) desc += ' by ' + ( oObj.resolved_by_data.firstname || "" ) + ( oObj.resolved_by_data.surname || "" ) + ''; return desc; } }, { "mDataProp": function ( oObj ) { let delete_html = oObj.resolved_on - ? `
  • Delete
  • ` + ? '
  • Delete
  • ' : ""; let resolve_html = ! oObj.resolution - ? `
  • Resolve
  • ` + ? '
  • Resolve
  • ' : ""; - return ` -
    - - -
    - `; + return '
    ' + + ' ' + + ' ' + + '
    '; } }, ], @@ -998,21 +994,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 = ` - - -
    - Update - Cancel -
    - `; + let editor = + ' ' + + ' ' + + '
    ' + + ' Update' + + ' Cancel' + + '
    '; elt.hide(); $(editor).insertAfter( elt ); } @@ -1020,7 +1015,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, @@ -1030,11 +1025,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(); }, @@ -1045,7 +1040,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 @@ -1055,7 +1050,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(); @@ -1085,7 +1080,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.39.5