From cfe1c5cb79432b602bde9d4feb3d1a3bbc15bb2c Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Thu, 20 Feb 2025 16:07:32 +0000 Subject: [PATCH] Bug 39179: Allow edit batch without having to add new items Test plan: BEFORE APPLYING PATCHES: 1) Enabled ILLModule 2) Install a metadata enrichment plugin .e.g: https://github.com/PTFS-Europe/koha-plugin-api-pubmed/releases/tag/1.1.1 3) Visit ILL requests: http://localhost:8081/cgi-bin/koha/ill/ill-requests.pl 4) Click 'New ILL requests batch' and pick 'Standard' 5) Enter a name 'test', a cardnumber '42' and any library 6) Click "Continue", enter '123' on the identifiers textarea on the right. 7) Click "Process identifiers" 8) Click "Add items to batch" 9) Click "Finish and view batch" 10) Click 'Batch requests' at the top right of the page. 11) Select the batch you just created and click 'edit' 12) Notice you're unable to 'Continue' or 'Finish and view batch' until you add some pubmedid and click 'Process identifiers' APPLY ALL PATCHES 13) Repeat test plan 14) Notice the layout and cosmetic changes. 15) Notice you can now edit a batch without having to add new requests. Edit the batch name or library or status and click 'Finish and view batch'. Notice it saves the batch. Sponsored-by: UKHSA - UK Health Security Agency Signed-off-by: Jeremy Evans --- .../intranet-tmpl/prog/js/ill-batch-modal.js | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) 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 eaf1ce922dc..1e4c2788380 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/ill-batch-modal.js +++ b/koha-tmpl/intranet-tmpl/prog/js/ill-batch-modal.js @@ -28,7 +28,7 @@ "create-requests-button" ); var statusesSelect = document.getElementById("status_code"); - var cancelButton = document.getElementById("lhs").querySelector("button"); + var cancelButton = document.getElementById("button_cancel_batch"); var cancelButtonOriginalText = cancelButton.innerHTML; // We need a data structure keyed on identifier type, which tells us how to parse that @@ -134,6 +134,9 @@ // Are we updating an existing batch var isUpdate = false; + // Have requests been created? + var requestsCreated = false; + // The datatable var table; var tableEl = document.getElementById("identifier-table"); @@ -188,6 +191,7 @@ fetchBatch(); isUpdate = true; setModalHeading(); + finishButton.removeAttribute("disabled"); createButton.style.display = "none"; } else { batch.data = emptyBatch; @@ -317,6 +321,9 @@ return row; }); }) + .then(function (data) { + requestsCreated = true; + }) .catch(function () { window.handleApiError(ill_batch_api_request_fail); }); @@ -470,6 +477,18 @@ } function doFinish() { + if (!requestsCreated && textarea.value.trim().length !== 0) { + if ( + !confirm( + __( + "Staged identifiers have not yet been added as requests. Proceed?" + ) + ) + ) { + return; + } + } + updateBatch().then(function () { $("#ill-batch-modal").modal({ show: false }); location.href = -- 2.39.5