Bug 39584: Fix end date disable to check selected item, not all items

When a specific item is selected in the booking modal, the end date
disable logic was incorrectly checking if ALL bookable items were
unavailable before disabling a date. This meant dates with existing
bookings for the selected item remained selectable if other items
were available.

Now when a specific item is selected (booking_item_id != 0), the
logic checks if that specific item is in the unavailable_items list.
The "all items unavailable" check is only used when "Any item" is
selected.

This aligns the end date selection behavior with the start date
selection behavior, which already correctly checks only the selected
item.

Signed-off-by: Kristi Krueger <kkrueger@cuyahogalibrary.org>
Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Martin Renvoize 2026-01-21 09:28:21 +00:00 committed by Lucas Gass
parent 22c8829738
commit e58d39671f
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
1 changed files with 22 additions and 8 deletions

View File

@ -566,14 +566,28 @@ $("#placeBookingModal").on("show.bs.modal", function (e) {
continue;
}
// check that there are available items
// available = all bookable items - booked items - booked biblios
let total_available =
bookable_items.length -
unavailable_items.length -
biblio_bookings.length;
if (total_available === 0) {
return true;
// check availability based on selection type
if (
booking_item_id &&
booking_item_id != 0
) {
// Specific item selected - check if that item is unavailable
if (
unavailable_items.indexOf(
parseInt(booking_item_id)
) !== -1
) {
return true;
}
} else {
// "Any item" selected - check if all items are unavailable
let total_available =
bookable_items.length -
unavailable_items.length -
biblio_bookings.length;
if (total_available === 0) {
return true;
}
}
}