From 966c5af9effb996152a9e2dcac9b2267c7e5b744 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Wed, 30 Jul 2025 11:32:58 +0000 Subject: [PATCH] Bug 40552: Allow selecting all holds from a group 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 'select group holds' buttons exist. 10) Click that button, ensure it selects the group holds. Test with more holds, more groups, unselecting all beforehand, selecting all beforehand, etc. Signed-off-by: Anneli Österman --- .../prog/en/modules/reserve/hold-group.tt | 2 +- koha-tmpl/intranet-tmpl/prog/js/hold-group.js | 32 +++++++++++++++++++ 2 files changed, 33 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 09d7b4a32d3..d0739a9b7ae 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 @@ -20,7 +20,7 @@ [% biblio = hold.biblio %] - [% biblio.title | html %] + [% biblio.title | html %] [% IF (hold.is_hold_group_target) %]
(target of hold group) [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/hold-group.js b/koha-tmpl/intranet-tmpl/prog/js/hold-group.js index cae322324ad..60320ae22ab 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/hold-group.js +++ b/koha-tmpl/intranet-tmpl/prog/js/hold-group.js @@ -3,6 +3,38 @@ $(document).ready(function () { var href = $(this).attr("href"); $("#hold-group-modal .modal-body").load(href + " #main"); $("#hold-group-modal").modal("show"); + if (holds_table_patron_page()) { + append_select_group_holds_button(); + } return false; }); + $("body").on("click", "button#select-group-holds", function () { + let group_hold_ids = $(".hold-group-entry") + .map(function () { + return $(this).data("hold-id"); + }) + .get(); + + $(".select_hold").each(function () { + var $this = $(this); + if ( + group_hold_ids.includes($this.data("id")) !== + $this.prop("checked") + ) { + $this.click(); + } + }); + }); + + function append_select_group_holds_button() { + var button = document.createElement("button"); + button.type = "button"; + button.className = "btn btn-primary"; + button.id = "select-group-holds"; + button.dataset.bsDismiss = "modal"; + button.innerHTML = _("Select group holds"); + if (!$("#select-group-holds").length) { + $("#hold-group-modal .modal-footer").prepend(button); + } + } }); -- 2.39.5