Bug 40613: Add 'ungroup holds' button

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 <anneli.osterman@koha-suomi.fi>
Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Pedro Amorim 2025-08-07 15:36:10 +00:00 committed by Lucas Gass
parent 8648c3982c
commit de53593b49
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
2 changed files with 28 additions and 1 deletions

View File

@ -4,7 +4,7 @@
</head>
<body id="hold-group">
<h1>Holds group ([% hold_group.id | html %])</h1>
<div id="main">
<div id="main" data-hold-group-id="[% hold_group.id | uri %]">
[% holds = hold_group.holds %]
[% IF holds.count %]
<table>

View File

@ -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);
}
}
});