Bugzilla – Attachment 184402 Details for
Bug 40395
Allow selecting multiple holds in patron detail page to perform actions on
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40395: Reimplement suspend
Bug-40395-Reimplement-suspend.patch (text/plain), 8.94 KB, created by
Andrew Fuerste-Henry
on 2025-07-18 16:38:29 UTC
(
hide
)
Description:
Bug 40395: Reimplement suspend
Filename:
MIME Type:
Creator:
Andrew Fuerste-Henry
Created:
2025-07-18 16:38:29 UTC
Size:
8.94 KB
patch
obsolete
>From bdbe85ef0b1f1939fc0580f492c44ec05e95da48 Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@openfifth.co.uk> >Date: Tue, 15 Jul 2025 12:46:39 +0000 >Subject: [PATCH] Bug 40395: Reimplement suspend > >Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com> >--- > .../prog/en/includes/patron-detail-tabs.inc | 18 +--- > koha-tmpl/intranet-tmpl/prog/js/holds.js | 98 +++++++++++++------ > 2 files changed, 71 insertions(+), 45 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-detail-tabs.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-detail-tabs.inc >index 24e01ea9b38..8389312a123 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-detail-tabs.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-detail-tabs.inc >@@ -182,21 +182,9 @@ > </form> > > [% IF Koha.Preference('SuspendHoldsIntranet') %] >- <form action="/cgi-bin/koha/reserve/modrequest_suspendall.pl" method="post"> >- [% INCLUDE 'csrf-token.inc' %] >- <fieldset class="action"> >- <input type="hidden" name="op" value="cud-suspendall" /> >- <input type="hidden" name="from" value="[% patronpage | html %]" /> >- <input type="hidden" name="borrowernumber" value="[% patron.borrowernumber | html %]" /> >- <input type="submit" class="btn btn-primary" value="Suspend all holds" /> >- >- [% IF Koha.Preference('AutoResumeSuspendedHolds') %] >- <label for="suspend_until">until</label> >- <input type="text" size="10" id="suspend_until" name="suspend_until" class="flatpickr" data-flatpickr-futuredate="true" /> >- <span class="hint">Specify date on which to resume [% INCLUDE 'date-format.inc' %]: </span> >- [% END %] >- </fieldset> >- </form> >+ <fieldset class="action"> >+ <button class="btn btn-primary suspend_selected_holds" data-bulk="true"></button> >+ </fieldset> > > <form action="/cgi-bin/koha/reserve/modrequest_suspendall.pl" method="post"> > [% INCLUDE 'csrf-token.inc' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/js/holds.js b/koha-tmpl/intranet-tmpl/prog/js/holds.js >index 8e3acf7b1ac..8b18e7756d7 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/holds.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/holds.js >@@ -107,16 +107,22 @@ function display_pickup_location(state) { > > /* global __ borrowernumber SuspendHoldsIntranet */ > $(document).ready(function () { >- function suspend_hold(hold_id, end_date) { >- var params; >- if (end_date !== null && end_date !== "") >- params = JSON.stringify({ end_date: end_date }); >+ var url = window.location.href; >+ let patron_page; >+ if (url.indexOf("/circ/circulation.pl?borrowernumber=") !== -1) >+ patron_page = "circ"; >+ else if (url.indexOf("/members/moremember.pl?borrowernumber=") !== -1) >+ patron_page = "borrower"; >+ >+ function suspend_hold(hold_ids, end_date) { >+ var params = { hold_ids: hold_ids }; >+ if (end_date !== null && end_date !== "") params.end_date = end_date; > > return $.ajax({ > method: "POST", >- url: "/api/v1/holds/" + encodeURIComponent(hold_id) + "/suspension", >+ url: "/api/v1/holds/suspension_bulk", > contentType: "application/json", >- data: params, >+ data: JSON.stringify(params), > }); > } > >@@ -124,6 +130,10 @@ $(document).ready(function () { > return $.ajax({ > method: "DELETE", > url: "/api/v1/holds/" + encodeURIComponent(hold_id) + "/suspension", >+ }).done(function () { >+ if ($(".select_hold_all").prop("checked")) { >+ $(".select_hold_all").click(); >+ } > }); > } > >@@ -491,7 +501,7 @@ $(document).ready(function () { > $(".hold-suspend").on("click", function () { > var hold_id = $(this).data("hold-id"); > var hold_title = $(this).data("hold-title"); >- $("#suspend-modal-title").html(hold_title); >+ $("#suspend-modal-title").html("<i>" + hold_title + "</i>"); > $("#suspend-modal-submit").data("hold-id", hold_id); > $("#suspend-modal").modal("show"); > }); >@@ -585,7 +595,6 @@ $(document).ready(function () { > </div>\ > \ > <div class='modal-body'>\ >- <input type='hidden' id='suspend-modal-reserve_id' name='reserve_id' />\ > \ > <label for='suspend-modal-until'>" + > __("Suspend until:") + >@@ -606,6 +615,7 @@ $(document).ready(function () { > __("Cancel") + > "</button>\ > </div>\ >+ <div id='suspend-selected-container'></div>\ > </form>\ > </div>\ > </div>\ >@@ -619,31 +629,59 @@ $(document).ready(function () { > > $("#suspend-modal-submit").on("click", function (e) { > e.preventDefault(); >+ let selected_holds; >+ if (!$(this).data("hold-id")) { >+ selected_holds = >+ "[" + >+ $(".holds_table .select_hold:checked") >+ .toArray() >+ .map(el => >+ JSON.stringify({ >+ hold: $(el).data("id"), >+ borrowernumber: $(el).data("borrowernumber"), >+ biblionumber: $(el).data("biblionumber"), >+ }) >+ ) >+ .join(",") + >+ "]"; >+ } else { >+ selected_holds = >+ "[" + JSON.stringify({ hold: $(this).data("hold-id") }) + "]"; >+ $(this).removeData("hold-id"); >+ } >+ > var suspend_until_date = $("#suspend-modal-until").val(); > if (suspend_until_date !== null) > suspend_until_date = $date(suspend_until_date, { > dateformat: "rfc3339", > }); >- suspend_hold($(this).data("hold-id"), suspend_until_date) >- .success(function () { >- holdsTable.api().ajax.reload(); >- }) >- .error(function (jqXHR, textStatus, errorThrown) { >- if (jqXHR.status === 404) { >- alert(__("Unable to suspend, hold not found.")); >- } else { >- alert( >- __( >- "Your request could not be processed. Check the logs for details." >- ) >- ); >- } >- holdsTable.api().ajax.reload(); >- }) >- .done(function () { >- $("#suspend-modal-until").flatpickr().clear(); // clean the input >- $("#suspend-modal").modal("hide"); >- }); >+ >+ const hold_ids = JSON.parse(selected_holds).map(hold => hold.hold); >+ try { >+ suspend_hold(hold_ids, suspend_until_date) >+ .success(function () { >+ holdsTable.api().ajax.reload(); >+ }) >+ .done(function () { >+ if ($("#suspend-modal-until").length) { >+ $("#suspend-modal-until").flatpickr().clear(); // clean the input >+ } >+ $("#suspend-modal").modal("hide"); >+ if ($(".select_hold_all").prop("checked")) { >+ $(".select_hold_all").click(); >+ } >+ }); >+ } catch (error) { >+ if (error.status === 404) { >+ alert(__("Unable to suspend, hold not found.")); >+ } else { >+ alert( >+ __( >+ "Your request could not be processed. Check the logs for details." >+ ) >+ ); >+ } >+ } > }); > > function toggle_suspend(node, inputs) { >@@ -688,7 +726,7 @@ $(document).ready(function () { > }); > > var MSG_SUSPEND_SELECTED = _("Suspend selected (%s)"); >- var MSG_SUSPEND_SELECTED_HOLDS = _("Suspend selected holds"); >+ var MSG_SUSPEND_SELECTED_HOLDS = _("selected holds"); > $(".suspend_selected_holds").html( > MSG_SUSPEND_SELECTED.format( > $(".holds_table .select_hold:checked").length >@@ -700,7 +738,7 @@ $(document).ready(function () { > if (!$(".holds_table .select_hold:checked").length) { > return false; > } >- $(".modal-title").html(MSG_SUSPEND_SELECTED_HOLDS); >+ $("#suspend-modal-title").html(MSG_SUSPEND_SELECTED_HOLDS); > $("#suspend-modal").modal("show"); > return false; > }); >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 40395
:
184109
|
184110
|
184111
|
184112
|
184113
|
184114
|
184115
|
184116
|
184134
|
184135
|
184136
|
184137
|
184138
|
184139
|
184140
|
184141
|
184398
|
184399
|
184400
|
184401
|
184402
|
184403
|
184404
|
184405
|
184434
|
184435
|
184437
|
184470
|
184471
|
184472
|
184473
|
184474
|
184475
|
184476
|
184477
|
184478
|
184479