From 88b56184b3bad26aef9b30dba01d5ceaf1f11349 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 19 Dec 2024 17:37:31 +0000 Subject: [PATCH] Bug 38689: Display errors in a modal This patch adds a `(with errors)` link next to the status of any edifact messages that produced errors on processing. The link will popup a modal containing the error details recorded for that message. --- api/v1/swagger/definitions/edifact_file.yaml | 2 + .../prog/en/modules/acqui/edifactmsgs.tt | 79 ++++++++++++++++--- 2 files changed, 69 insertions(+), 12 deletions(-) diff --git a/api/v1/swagger/definitions/edifact_file.yaml b/api/v1/swagger/definitions/edifact_file.yaml index 4602ba28b68..de74f020934 100644 --- a/api/v1/swagger/definitions/edifact_file.yaml +++ b/api/v1/swagger/definitions/edifact_file.yaml @@ -55,4 +55,6 @@ properties: - string - "null" description: EDIFACT file name + errors: + type: array additionalProperties: false diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/edifactmsgs.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/edifactmsgs.tt index 227ca241fc2..94a9ca180ca 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/edifactmsgs.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/edifactmsgs.tt @@ -41,6 +41,17 @@
+ + + + +
+ +
+ + - - - - -
- + + +
[% MACRO jsinclude BLOCK %] [% Asset.js("js/acquisitions-menu.js") | $raw %] @@ -83,7 +100,8 @@ }, "embed": [ "vendor", - "basket" + "basket", + "errors" ], "columns": [ { @@ -105,7 +123,23 @@ "data": "status", "title": _("Status"), "searchable": true, - "orderable": true + "orderable": true, + "render": function(daya, type, row, meta) { + let rendered = ''; + if ( row.errors.length > 0 ) { + let errorsList = ''; + rendered = row.status + ' (' + _("with errors") + ')'; + } else { + rendered = row.status; + } + return rendered; + } }, { "data": "vendor.name", @@ -180,6 +214,27 @@ EDIModal.on("hidden.bs.modal", function(){ EDIModalBody.html("
\"\" "+_("Loading")+"
"); }); + + const errorsModal = document.getElementById('EDI_errors_modal') + if (errorsModal) { + errorsModal.addEventListener('show.bs.modal', event => { + // Link that triggered the modal + const link = event.relatedTarget + + // Extract info from data-bs-* attributes + const filename = link.getAttribute('data-bs-filename') + const errors = link.getAttribute('data-bs-errors') + + // Update the modal's title. + const modalTitleSpan = errorsModal.querySelector('.modal-title #EDI_errors_filename') + modalTitleSpan.textContent = filename; + + // Update the modal's content. + const modalBody = errorsModal.querySelector('.modal-body') + modalBody.innerHTML = errors; + }) + } + $("body").on("click", ".delete_msg" ,function(){ return confirm(_("Are you sure you want to delete this message?")); }); -- 2.47.1