From fd5e603c3d80975867d95bdd7de714a16b58c0fd Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 12 Mar 2021 18:01:28 -0300 Subject: [PATCH] Bug 27864: Visual feedback on overridden pickup locations when placing hold This patch makes the form for placing a hold, use the API to retrieve the valid pickup locations for a biblio. To test: 1 - In Circulation and fines rules > Default checkout, hold and return policy, change 'Hold pickup library match' to 'item's home library' 2 - Set AllowHoldPolicyOverride system preference to Allow 3 - Try placing a hold on a biblio with several items. Ensure that there is one item with homebranch of the patrons branch and one at another branch 4 - Note the pickup location dropdown lists all branches, even those not matching the policy (Item's home library) 5 - FAIL: There's no sign they are overrides to rules 6 - Apply the patch 7 - Repeat 3 8 - SUCCESS: Same behavior as before all libraires listed, but there's a sign + tooltip for overridden ones. 9 - Sign off :-D Note: styling follow-up coming Signed-off-by: Martin Renvoize Signed-off-by: Nick Clemens Signed-off-by: Jonathan Druart --- .../prog/en/modules/reserve/request.tt | 50 ++++++++++++++++--- 1 file changed, 44 insertions(+), 6 deletions(-) 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 0c7968617a..9f63efdec4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt @@ -441,12 +441,13 @@
  • - + + [% ELSE %] +
  • @@ -1237,6 +1238,43 @@ templateResult: display_pickup_location }); }); + $("#pickup").each( function () { + var this_dropdown = $(this); + var patron_id = $(this).data('patron-id'); + var biblio_id = $(this).data('biblio-id'); + + this_dropdown.select2({ + allowClear: false, + ajax: { + url: '/api/v1/biblios/' + encodeURIComponent(biblio_id) + '/pickup_locations', + delay: 300, // wait 300 milliseconds before triggering the request + dataType: 'json', + data: function (params) { + var search_term = (params.term === undefined) ? '' : params.term; + var query = { + "q": JSON.stringify({"name":{"-like":search_term+'%'}}), + "_order_by": "name", + "patron_id": patron_id + }; + return query; + }, + processResults: function (data) { + var results = []; + data.forEach( function ( pickup_location ) { + results.push( + { + "id": pickup_location.library_id.escapeHtml(), + "text": pickup_location.name.escapeHtml(), + "needs_override": pickup_location.needs_override + } + ); + }); + return { "results": results }; + } + }, + templateResult: display_pickup_location + }); + }); }); function check() { -- 2.39.5