From de53593b49fed333d9bf67881885d18d2eb3f89f Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Thu, 7 Aug 2025 15:36:10 +0000 Subject: [PATCH] Bug 40613: Add 'ungroup holds' button MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Test plan, k-t-d, patches applied: 1) Search for 'test': http://localhost:8081/cgi-bin/koha/catalogue/search.pl?q=test 2) Click the 'Select all' link on the left of the search toolbar 3) Click the 'Place hold' button on the same toolbar 4) On the patron input, add 'koha' 5) You need to pick the 'Pickup location' specifically for each hold. Click 'Place holds' 6) Now visit the patron details page: http://localhost:8081/cgi-bin/koha/members/moremember.pl?borrowernumber=51 7) Click the 'Holds' tab. 8) Click the top most checkbox to select all holds. Click the 'group selected' button. Notice the holds are grouped and the 'group hold' column shows the hold group number accordingly. 9) Test that selecting the hold group number opens the hold group modal and a new 'ungroup holds' button exist. 10) Click that button, ensure it deletes the holde group. Test with more holds, more groups, etc. Signed-off-by: Anneli Österman Signed-off-by: Andrew Fuerste Henry Signed-off-by: Lucas Gass --- .../prog/en/modules/reserve/hold-group.tt | 2 +- koha-tmpl/intranet-tmpl/prog/js/hold-group.js | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/hold-group.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/hold-group.tt index d0739a9b7a..ecb4f7f5bb 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/hold-group.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/hold-group.tt @@ -4,7 +4,7 @@

Holds group ([% hold_group.id | html %])

-
+
[% holds = hold_group.holds %] [% IF holds.count %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/hold-group.js b/koha-tmpl/intranet-tmpl/prog/js/hold-group.js index 8d68da5840..9b60c79443 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/hold-group.js +++ b/koha-tmpl/intranet-tmpl/prog/js/hold-group.js @@ -5,6 +5,7 @@ $(document).ready(function () { $("#hold-group-modal").modal("show"); if (holds_table_patron_page()) { append_select_group_holds_button(); + append_ungroup_holds_button(); } return false; }); @@ -26,6 +27,20 @@ $(document).ready(function () { }); }); + $("body").on("click", "button#ungroup-hold-group", function () { + let hold_group_id = $("#hold-group-modal #main").data("hold-group-id"); + $.ajax({ + method: "DELETE", + url: + "/api/v1/patrons/" + + borrowernumber + + "/hold_groups/" + + hold_group_id, + }).done(function () { + $("#holds-table").DataTable().ajax.reload(); + }); + }); + function append_select_group_holds_button() { var button = document.createElement("button"); button.type = "button"; @@ -37,4 +52,16 @@ $(document).ready(function () { $("#hold-group-modal .modal-footer").prepend(button); } } + + function append_ungroup_holds_button() { + var button = document.createElement("button"); + button.type = "button"; + button.className = "btn btn-danger"; + button.id = "ungroup-hold-group"; + button.dataset.bsDismiss = "modal"; + button.innerHTML = __("Ungroup holds"); + if (!$("#ungroup-hold-group").length) { + $("#hold-group-modal .modal-footer").prepend(button); + } + } });