From 7827c461fdb495156d4ae3f1e9027a6a255196dc Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Thu, 13 Nov 2025 14:12:13 +0000 Subject: [PATCH] Bug 41247: Improve ILL batches modal resetability Test plan, preparation: A) Enable ILLModule B) Install a metadata enrichment plugin, e.g: https://github.com/openfifth/koha-plugin-api-pubmed/releases/tag/1.1.1 C) Restart plack to pick up the newly installed plugin if needed. D) Create a new batch, visit: /cgi-bin/koha/ill/ill-requests.pl? Issue #1: 1.1) Click 'New ILL requests batch' 1.2) Enter a name, '42' on the cardnumber and any library. Click 'Continue'. 1.3) Click the 'Close' button (or click anywhere outside the modal) to close the modal. 1.4) Repeat 1.1). Notice the 'Continue' button is no longer there. Issue #2: 2.1) Click 'New ILL requests batch' 2.2) Enter a name, '42' on the cardnumber and any library. Click 'Continue'. 2.3) Enter '123' on the textarea, click 'Process identifiers'. 2.4) Notice a 'Add items to batch' buttons appears. Don't click that, as before, close the modal. 2.5) Repeat 2.1) Notice the progress bar shows right off the bat (it shouldn't) with NaN as its value as well as table elements (export button, 'No entries to show' message, etc, with no table. Apply patch, hard-refresh the browser and repeat Issues 1 and 2. Confirm the patch fixes them. --- .../intranet-tmpl/prog/js/ill-batch-modal.js | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/ill-batch-modal.js b/koha-tmpl/intranet-tmpl/prog/js/ill-batch-modal.js index 1051c5a3ca8..552541d5708 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/ill-batch-modal.js +++ b/koha-tmpl/intranet-tmpl/prog/js/ill-batch-modal.js @@ -159,11 +159,10 @@ }); $("#ill-batch-modal").on("hidden.bs.modal", function () { // Reset our state when we close the modal - // TODO: need to also reset progress bar and already processed identifiers delete elId.dataset.batchId; delete elId.dataset.backend; batchId = null; - tableEl.style.display = "none"; + $("#identifier-table_wrapper").hide(); tableContent.data = []; progressTotals.data = { total: 0, @@ -173,6 +172,8 @@ textarea.value = ""; batch.data = {}; cancelButton.innerHTML = cancelButtonOriginalText; + hideProgress(); + hideErrors(); // Remove event listeners we created removeEventListeners(); }); @@ -192,11 +193,13 @@ isUpdate = true; setModalHeading(); finishButton.removeAttribute("disabled"); - createButton.style.display = "none"; + hideCreateButton(); } else { batch.data = emptyBatch; setModalHeading(); finishButton.style.display = "none"; + createButton.style.display = "inline-block"; + createButton.setAttribute("disabled", 1); } fetchStatuses(); finishButtonEventListener(); @@ -399,7 +402,7 @@ createButton.removeEventListener("click", createBatch); identifierTable.removeEventListener("click", toggleMetadata); identifierTable.removeEventListener("click", removeRow); - createRequestsButton.remove("click", requestRequestable); + createRequestsButton.removeEventListener("click", requestRequestable); } function finishButtonEventListener() { @@ -637,6 +640,11 @@ el.style.display = "block"; } + function hideProgress() { + var el = document.getElementById("create-progress"); + el.style.display = "none"; + } + function showCreateRequestsButton() { var data = progressTotals.data; var el = document.getElementById("create-requests"); @@ -729,6 +737,8 @@ // Now build and display the table if (!table) { buildTable(); + } else { + tableEl.parentElement.style.display = "block"; } // We may be appending new values to an existing table, @@ -783,7 +793,7 @@ } function hideCreateButton() { - createButton.remove(); + createButton.style.display = "none"; } async function populateMetadata(identifier) { -- 2.39.5