From b54396295f76b962dcb1a7c47368ecc5042b29ad Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Wed, 18 Aug 2021 12:48:08 +0000 Subject: [PATCH] Bug 28720: (follow-up) Improve string translation This patch fixes the following issues raised by QA: - It modifies the markup so that "Add note" and "Edit note" can be translated more easily. - It adds display of existing notes back to the table of checkouts. - It adds to the table configuration so that a "plain" view of the notes (without buttons) is shown in print view and in CSV export. - It improves handling of notes containing quotation marks which would previously have broken some edit interactions. Signed-off-by: David Nind --- .../bootstrap/en/modules/opac-user.tt | 73 +++++++++++++------ 1 file changed, 51 insertions(+), 22 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt index 3416c41203..3978d3050f 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt @@ -273,7 +273,8 @@ Links [% END %] [% IF ( Koha.Preference('AllowCheckoutNotes') ) %] - Report a problem + Checkout note + Report a problem [% END %] @@ -452,16 +453,21 @@ [% ISSUE.MySummaryHTML | $raw %] [% END %] [% IF ( Koha.Preference('AllowCheckoutNotes') ) %] + + [% ISSUE.note | html %] + - [% IF ( ISSUE.note ) -%] - [% SET note_action = "Edit note" %] - [% ELSE -%] - [% SET note_action = "Add note" %] - [% END %] - - [% note_action | html %] - - +
+ [% ISSUE.note | html %] +
+
+ [% IF ( ISSUE.note ) -%] + Edit note + [% ELSE -%] + Add note + [% END %] + + [% END %] @@ -960,13 +966,32 @@ "dom": '<"top"<"table_entries"><"table_controls"fB>>t', "columnDefs": [ { "targets": [ "nosort" ],"sortable": false,"searchable": false }, - { "type": "anti-the", "targets" : [ "anti-the" ] } + { "type": "anti-the", "targets" : [ "anti-the" ] }, + { "visible": false, "targets" : [ "hidden" ] } ], "language": { "search": "_INPUT_", "searchPlaceholder": _("Search") }, - "autoWidth": false + "autoWidth": false, + buttons: [ + /* Override default button set so that we can extend the options of print and csv */ + 'clearFilter', 'copy', + { + extend: "print", + exportOptions: { + /* Print view should show all columns (even invisible ones) unless they are .noExport */ + columns: ":not(.noExport)" + } + }, + { + extend: "csv", + exportOptions: { + /* CSV export should include all columns (even invisible ones) unless they are .noExport */ + columns: ":not(.noExport)" + } + } + ] })); }); @@ -1055,8 +1080,8 @@ e.preventDefault(); var title = $(this).data("title"); var issue_id = $(this).data("issueid"); - var note = $(this).data("note"); - var origvalue = $(this).data("origvalue"); + var note = $("#note_" + issue_id ).val(); + var origvalue = $("#note_" + issue_id ).data("origvalue"); $("#addNote").val( note ); $("#addNoteIssueId").val( issue_id ); $("#addNoteTitle").text( title ); @@ -1079,7 +1104,8 @@ function submitNote( title, issue_id, note ){ var self = $("#addNoteModal"); - var noteinput = $("#save_" + issue_id ); + var notebutton = $("#save_" + issue_id ); + var noteinput = $("#note_" + issue_id ); var ajaxData = { 'action': 'issuenote', @@ -1099,27 +1125,29 @@ $("#notesaved").removeClass("alert-error"); $("#notesaved").addClass("alert-info"); noteinput.data('origvalue', data.note) - .data('note', data.note) - .text( _("Edit note" ) ); + .val(data.note); + notebutton.text( _("Edit note" ) ); + $("#viewnote_" + issue_id ).text( data.note ); message = "

" + _("Your note about %s has been saved and sent to the library.").format( em(title) ) + "

"; message += "

" + data.note; - message += " " + _("Edit note") + ""; + message += " " + _("Edit note") + ""; message += "

"; } else if(data.status == 'removed') { $("#notesaved").removeClass("alert-error"); $("#notesaved").addClass("alert-info"); noteinput.data('origvalue', "") - .data("note", "") - .text( _("Add note") ); + .val("") + notebutton.text( _("Add note") ); + $("#viewnote_" + issue_id ).text( data.note ); message = "

" + _("Your note about %s was removed.").format( em(title) ) + "

"; } else { $("#notesaved").removeClass("alert-info"); $("#notesaved").addClass("alert-error"); message = "

" + _("Your note about %s could not be saved.").format( em(title) ) + "

"; - noteinput.text( _("Add note") ); + notebutton.text( _("Add note") ); + $("#viewnote_" + issue_id ).text( data.note ); message += "

" + _("Something went wrong. The note has not been saved") + "

"; } - self.modal("hide"); $("#notesaved").html(message); }) .fail(function(data) { @@ -1129,6 +1157,7 @@ $("#notesaved").html(message); }) .always(function() { + self.modal("hide"); $("#notesaved").show(); }); } -- 2.20.1