From 4dafa03ded53db649f5608feedc273b58556a721 Mon Sep 17 00:00:00 2001 From: Paul Derscheid Date: Wed, 22 Jan 2025 17:21:45 +0000 Subject: [PATCH] Bug 37618: (follow-up) Prevent setting of incorrect default if no filtered pickup locations available Signed-off-by: Marion Durand --- .../intranet-tmpl/prog/js/modals/place_booking.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/modals/place_booking.js b/koha-tmpl/intranet-tmpl/prog/js/modals/place_booking.js index 0d9a7c9706..2a0e80d75e 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/modals/place_booking.js +++ b/koha-tmpl/intranet-tmpl/prog/js/modals/place_booking.js @@ -211,7 +211,15 @@ $("#placeBookingModal").on("show.bs.modal", function (e) { $pickupSelect.prop("disabled", false); - // If filtered_pickup_locations contain the booking_patron's home library, use it as the default for pickup_library_id + /* If there are no filtered_pickup_locations, clear the picker + * and return early without trying to set a default. */ + if (!filtered_pickup_locations.length && !pickup_library_id) { + $pickupSelect.val(null).trigger("change"); + return; + } + + /* If filtered_pickup_locations contain the booking_patron's home library, + * use it as the default for pickup_library_id. */ pickup_library_id ??= filtered_pickup_locations.find( pickup_location => pickup_location.library_id === -- 2.39.5