From 63d710e3b3580b319e49b34bb7abcf713c40deab Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 10 Oct 2023 12:07:49 +0100 Subject: [PATCH] Bug 29002: Fix item select options SQUASH INTO RESET BUG? This patch ensures that when a period is not selected we remove all item selection limitations from the item select. Prior to this patch, if you clicked to edit a booking, cancelled, then clicked to place a new booking.. the modal would prevent selection of the item which you just edited. Signed-off-by: Martin Renvoize Signed-off-by: Janet McGowan Signed-off-by: Caroline Cyr La Rose Signed-off-by: Laurence Rault Signed-off-by: Kyle M Hall Signed-off-by: Tomas Cohen Arazi --- koha-tmpl/intranet-tmpl/prog/js/place_booking_modal.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/koha-tmpl/intranet-tmpl/prog/js/place_booking_modal.js b/koha-tmpl/intranet-tmpl/prog/js/place_booking_modal.js index 2f3803e3de..467872fdb2 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/place_booking_modal.js +++ b/koha-tmpl/intranet-tmpl/prog/js/place_booking_modal.js @@ -207,6 +207,7 @@ $('#placeBookingModal').on('show.bs.modal', function(e) { let changeExists = periodPicker.config.onChange.filter(f => f.name ==='periodChange'); if(changeExists.length === 0) { periodPicker.config.onChange.push(function periodChange(selectedDates, dateStr, instance) { + // Range set, update hidden fields and set available items if ( selectedDates[0] && selectedDates[1] ) { // set form fields from picker let picker_start = dayjs(selectedDates[0]); @@ -241,6 +242,14 @@ $('#placeBookingModal').on('show.bs.modal', function(e) { option.prop('disabled',false); } }); + $('#booking_item_id').trigger('change.select2'); + } + // Range not set, reset field options + else { + $('#booking_item_id > option').each(function() { + $(this).prop('disabled', false); + }); + $('#booking_item_id').trigger('change.select2'); } }); }; -- 2.39.5