From d6c35c7c1a08c8cc079316e2614c82a05ed494b8 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Mon, 18 Oct 2021 16:29:15 +0000 Subject: [PATCH] Bug 29060: Use modal for suspending holds until a date from the holds page This patch modifies the way suspensions are handled when viewing the list of holds on a particular title. In particular, when AutoResumeSuspendedHolds is enabled the "suspend until" form field is hidden until the suspend button is clicked, when a modal window appears. This is consistent with the way it works when working with the list of holds on a patron record. The patch also converts the hold deletion button from an "X" image to a more-standard "Delete" button. To test, apply the patch and make sure AutoResumeSuspendedHolds is enabled. - Locate a title in the catalog with multiple holds. - View the holds on that title. In the list of holds you should see "Delete" and "Suspend" buttons in the last two columns of the tabel of holds. - Test that the "Delete" button works correctly, - Test the "Suspend" button. Clicking it should trigger a modal window where you can set a date for the hold to resume. - Submitting the form with a date should result in the page reloading and showing the hold as suspended until that date. - Submitting hte form without a date should result in the page reloading and showing the hold as suspended. - Test that the "Resume" button works to remove the suspension. - Disable AutoResumeSuspendedHolds. Now when you click the "Suspend" button you should not see the modal. The page should reload and the hold should be suspended without a resume date. --- .../prog/en/includes/holds_table.inc | 22 ++++--- .../prog/en/modules/reserve/request.tt | 57 ++++++++++++++++++- 2 files changed, 68 insertions(+), 11 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc index 516b04f322..b296fc3b6a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc @@ -173,6 +173,13 @@ [%- IF hold.non_priority -%]
Non priority hold [%- END -%] + [% IF ( hold.suspend ) %] + [% IF ( hold.suspend_until ) -%] +

Hold is suspended until [% hold.suspend_until | $KohaDates %]

+ [% ELSE %] +

Hold is suspended

+ [% END %] + [% END %] [%- IF ( CAN_user_reserveforothers_modify_holds_priority ) -%] [%- UNLESS hold.found -%] @@ -190,24 +197,23 @@ [%- END -%] [%- END -%] - - Cancel + + Delete [%- IF Koha.Preference('SuspendHoldsIntranet') -%] [%- UNLESS ( hold.found ) -%] - - [%- IF Koha.Preference('AutoResumeSuspendedHolds') -%] - - + + [% IF ( hold.suspend ) %] + Resume [%- ELSE -%] - + Suspend [%- END -%] [%- END -%] [%- END # IF SuspendHoldsIntranet -%] [%- IF ( hold.found ) -%] - + [%- END -%] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt index 8e9bf1fd4f..a37936e629 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt @@ -1005,12 +1005,12 @@ [% holds_by_itemtype.push( h ) %] [% END %] [% END %] - [% INCLUDE holds_table.inc holds=holds_by_itemtype %] + [% INCLUDE holds_table.inc holds=holds_by_itemtype hold_title = biblioloo.title %] [% END %] [% END # /FOREACH b %] [% ELSE %] - [% INCLUDE holds_table.inc holds=biblioloo.reserveloop %] + [% INCLUDE holds_table.inc holds=biblioloo.reserveloop hold_title = biblioloo.title %] [% END # /IF HoldsSplitQueue %] [% END # /IF biblioloo.reserveloop %] @@ -1067,6 +1067,33 @@ + + [% MACRO jsinclude BLOCK %] [% INCLUDE 'datatables.inc' %] [% INCLUDE 'calendar.inc' %] @@ -1148,7 +1175,7 @@ [% END %] [% IF AutoResumeSuspendedHolds %] - $(".suspend_until_datepicker").flatpickr({ + $(".suspend-until").flatpickr({ minDate: new Date().fp_incr(1) /* Require that "until date" be in the future */ }); [% END %] @@ -1672,6 +1699,30 @@ return false; }); + $(".hold-suspend, .hold-resume").on( "click", function(e) { + e.preventDefault(); + var id = $(this).data("reserve-id") + var title = $(this).data("title"); + var borrowernumber = $(this).data("borrowernumber"); + var biblionumber = $(this).data("biblionumber"); + var date = $(this).data("date"); + + $("#suspend-modal-title").html( title ); + $("#suspend-modal-reserve_id").val( id ); + $("#suspend-modal-borrowernumber").val( borrowernumber ); + $("#suspend-modal-biblionumber").val( biblionumber ); + $("#suspend-modal-date").val( date ); + /* Actions based on which button was pushed */ + if( $(this).hasClass("hold-resume") ){ + document.forms["suspend-modal-form"].submit(); + } else { + [% IF Koha.Preference('AutoResumeSuspendedHolds') %] + $('#suspend-modal').modal('show'); + [% ELSE %] + document.forms["suspend-modal-form"].submit(); + [% END %] + } + }); }); [% END %] -- 2.20.1