From 562f832b4a0a966b826f3000166cf44ef18fa22c Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Mon, 24 Aug 2020 10:52:28 -0400 Subject: [PATCH] Bug 25534: (QA follow-up) Use modal for cancel links, hide reason unless priority is set to 'del' --- .../prog/en/includes/holds_table.inc | 2 +- .../prog/en/modules/reserve/request.tt | 97 +++++++++++++------ 2 files changed, 69 insertions(+), 30 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 3dc61ee242..26791f819d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc @@ -191,7 +191,7 @@ [% END %] - + Cancel 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 92c195b732..f0832ffc37 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt @@ -801,6 +801,18 @@

Existing holds

+
+ [% SET hold_cancellation = AuthorisedValues.GetAuthValueDropbox('HOLD_CANCELLATION') %] + [% IF hold_cancellation %] + + + [% END %] +
[% FOREACH biblioloo IN biblioloop %] @@ -909,22 +921,6 @@ [% END # /IF biblioloo.reserveloop %] [% END # FOREACH biblioloo %] -
- [% SET hold_cancellation = AuthorisedValues.GetAuthValueDropbox('HOLD_CANCELLATION') %] - [% IF hold_cancellation %] - - - [% END %] -
- -
- -
[% END # IF reserveloop %] @@ -944,6 +940,38 @@ [% END %] + [% MACRO jsinclude BLOCK %] [% INCLUDE 'datatables.inc' %] @@ -955,8 +983,6 @@ var Sticky; var biblionumber = "[% biblionumber | $raw %]"; var borrowernumber = "[% patron.borrowernumber | $raw %]"; - var MSG_CONFIRM_DELETE_HOLD = _("Are you sure you want to cancel this hold?"); - var REASON_LABEL = _("Reason: "); var patron_homebranch = "[% To.json( Branches.GetName( patron.branchcode ) ) | $raw %]"; var override_items = {[% FOREACH bibitemloo IN bibitemloop %][% FOREACH itemloo IN bibitemloo.itemloop %][% IF ( itemloo.override ) %] [% itemloo.itemnumber | html %]: { @@ -980,6 +1006,15 @@ columns_settings_borrowers_table = [% TablesSettings.GetColumns( 'circ', 'circulation', 'table_borrowers', 'json' ) | $raw %] $(document).ready(function() { + $('#cancellation-reason-fieldset').hide(); + $('.rank-request').on('change', function() { + if ( $(".rank-request option:selected[value='del']").length ) { + $('#cancellation-reason-fieldset').show(); + } else { + $('#cancellation-reason-fieldset').hide(); + } + }); + [% SET active = clubs ? 1 : 0 %] $('#circ_holds_select').tabs({ active: [% active | $raw %], @@ -1244,20 +1279,24 @@ $("#" + fieldID).val(""); }); - // Confirm cancelation of hold + // Confirm cancellation of hold + let cancel_link; $(".cancel-hold").on("click",function(e) { e.preventDefault; - let msg = MSG_CONFIRM_DELETE_HOLD ; - if ( $("#cancellation-reason").val() ) { - const reason = $("#cancellation-reason option:selected").text(); - msg += "\n\n" + REASON_LABEL + reason; - } - const confirm = confirmDelete(msg); - if ( confirm ) { - let href = $(this).attr('href'); - href += "&cancellation-reason=" + $("#cancellation-reason").val(); - window.location = href; + cancel_link = $(this); + $('#cancelModal').modal(); + return false; + }); + $("#cancelModalConfirmBtn").on("click",function(e) { + let borrowernumber = cancel_link.data('borrowernumber'); + let biblionumber = cancel_link.data('biblionumber'); + let reserve_id = cancel_link.data('id'); + let reason = $("#modal-cancellation-reason").val(); + let link = `request.pl?action=cancel&borrowernumber=${ borrowernumber }&biblionumber=${ biblionumber }&reserve_id=${ reserve_id }`; + if ( reason ) { + link += "&cancellation-reason=" + reason } + window.location.href = link; return false; }); -- 2.24.1 (Apple Git-126)