From 36454d179a05d3c2c17ce05a22f449327daf2bd8 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 5 Mar 2021 15:17:56 -0300 Subject: [PATCH] Bug 27863: Use the /libraries route when AllowHoldsPolicyOverride is set This patch makes the dropdown for changing the pickup location for existing holds use the GET /libraries route instead of GET /holds/:hold_id/pikcup_locations if the configuration allows the override. Terminology: - Pickup location, means a library that is marked as valid pickup location on its configuration. To test: 1. Have the circ rules set so 'Hold pickup library match' is set to 'Item's home library' or 'Any'. The goal is to be able to differentiate when all libraries are returned, from the case only 'valid pickup locations' are returned. The easiest one is 'Item's home library'. 2. Set AllowHoldsPolicyOverride 3. Pick a patron from a library that is not a valid pickup location and an item that belongs to a library that doesn't match any of the valid ones. => SUCCESS: Notice Koha allows you to choose any library (because of the syspref) 4. Place the hold. 5. Now check on the holds list for the bib, if you can use the dropdown to change the pickup location for the hold => SUCCESS: You can, sort of => FAIL: It doesn't show/search all pickup locations. It only shows the valid ones, even though we should be able to override it. 6. Apply this patch 7. Restart all just in case, and reload the holds page for the bib 8. Repeat 5 => SUCCESS: You are presented all pickup locations! 9. Sign off :-D Signed-off-by: Andrew Fuerste-Henry Signed-off-by: Martin Renvoize --- koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 889f8c3819..5dfff18595 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt @@ -1164,13 +1164,17 @@ this_dropdown.select2({ allowClear: false, ajax: { + [%- IF Koha.Preference('AllowHoldPolicyOverride') -%] + url: '/api/v1/libraries', + [%- ELSE -%] url: '/api/v1/holds/' + encodeURIComponent(hold_id) + '/pickup_locations', + [%- END -%] 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+'%'}}), + "q": JSON.stringify({"name":{"-like":search_term+'%'},"pickup_location":1}), "_order_by": "name" }; return query; -- 2.20.1