From a444eeac016139a125c7a39de6dc738c4024424e Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Wed, 3 Nov 2021 14:48:44 -0300 Subject: [PATCH] Bug 29397: Use kohaSelect for pickup locations This patch makes the pickup location dropdowns that rely on Select2 and the API use the new wrapper. The original transport function is removed as it is now embedded in the wrapper. To test: 1. Follow bug 29404 test plan => SUCCESS: All works 2. Apply this patches 3. Repeat 1 => SUCCESS: All works! 4. sign off :-D Signed-off-by: Tomas Cohen Arazi Signed-off-by: Martin Renvoize Signed-off-by: Kyle M Hall Signed-off-by: Fridolin Somers --- koha-tmpl/intranet-tmpl/prog/js/holds.js | 5 ++--- koha-tmpl/intranet-tmpl/prog/js/select2.js | 20 -------------------- 2 files changed, 2 insertions(+), 23 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/holds.js b/koha-tmpl/intranet-tmpl/prog/js/holds.js index 20ada49226..9f17863f1b 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/holds.js +++ b/koha-tmpl/intranet-tmpl/prog/js/holds.js @@ -48,7 +48,7 @@ function display_pickup_location (state) { url = '/api/v1/holds/' + encodeURIComponent(hold_id) + '/pickup_locations'; } - select.select2({ + select.kohaSelect({ width: 'style', allowClear: false, ajax: { @@ -82,8 +82,7 @@ function display_pickup_location (state) { ); }); return { "results": results, "pagination": { "more": data.pagination.more } }; - }, - transport: kohaSelect2Transport, + } }, templateResult: display_pickup_location }); diff --git a/koha-tmpl/intranet-tmpl/prog/js/select2.js b/koha-tmpl/intranet-tmpl/prog/js/select2.js index df8b108d84..52d910a2fa 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/select2.js +++ b/koha-tmpl/intranet-tmpl/prog/js/select2.js @@ -38,26 +38,6 @@ $(document).ready(function(){ }); }); -function kohaSelect2Transport(params, success, failure) { - var read_headers = function (data, textStatus, jqXHR) { - var more = false; - var link = jqXHR.getResponseHeader('Link') || ''; - if (link.search(/<([^>]+)>;\s*rel\s*=\s*['"]?next['"]?\s*(,|$)/i) > -1) { - more = true; - } - - return { - results: data, - pagination: { - more: more - } - }; - }; - var $request = $.ajax(params); - $request.then(read_headers).then(success); - $request.fail(failure); -} - (function($) { /** -- 2.39.5