Bug 36120: Account for both pickup_location and date selection in items
This patch ensures we account for both pickup location and date selections having taken place before an item selection is pondered. We now correctly disable item options given both conditions rather than it being a race between the two. Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
parent
eef929f3f1
commit
3d403e48e2
|
|
@ -254,6 +254,11 @@ $("#placeBookingModal").on("show.bs.modal", function (e) {
|
|||
false,
|
||||
false
|
||||
);
|
||||
newOption.setAttribute(
|
||||
"data-available",
|
||||
true
|
||||
);
|
||||
|
||||
// Append it to the select
|
||||
$("#booking_item_id").append(newOption);
|
||||
}
|
||||
|
|
@ -459,9 +464,13 @@ $("#placeBookingModal").on("show.bs.modal", function (e) {
|
|||
let option = $(this);
|
||||
let item_id = option.val();
|
||||
if (valid_items.includes(parseInt(item_id))) {
|
||||
option.prop("disabled", false);
|
||||
option.attr("data-pickup", true);
|
||||
if (option.data("available")) {
|
||||
option.prop("disabled", false);
|
||||
}
|
||||
} else {
|
||||
option.prop("disabled", true);
|
||||
option.attr("data-pickup", false);
|
||||
}
|
||||
});
|
||||
$("#booking_item_id").trigger("change.select2");
|
||||
|
|
@ -526,9 +535,13 @@ $("#placeBookingModal").on("show.bs.modal", function (e) {
|
|||
);
|
||||
})
|
||||
) {
|
||||
option.attr("data-available", false);
|
||||
option.prop("disabled", true);
|
||||
} else {
|
||||
option.prop("disabled", false);
|
||||
option.attr("data-available", true);
|
||||
if (option.data("pickup")) {
|
||||
option.prop("disabled", false);
|
||||
}
|
||||
}
|
||||
});
|
||||
$("#booking_item_id").trigger("change.select2");
|
||||
|
|
@ -536,7 +549,10 @@ $("#placeBookingModal").on("show.bs.modal", function (e) {
|
|||
// Range not set, reset field options
|
||||
else {
|
||||
$("#booking_item_id > option").each(function () {
|
||||
$(this).prop("disabled", false);
|
||||
let option = $(this);
|
||||
if (option.data("pickup")) {
|
||||
option.prop("disabled", false);
|
||||
}
|
||||
});
|
||||
$("#booking_item_id").trigger("change.select2");
|
||||
}
|
||||
|
|
@ -774,9 +790,11 @@ $("#placeBookingForm").on("submit", function (e) {
|
|||
$("#placeBookingModal").on("hidden.bs.modal", function (e) {
|
||||
$("#booking_patron_id").val(null).trigger("change");
|
||||
$("#booking_patron_id").empty();
|
||||
booking_patron = undefined;
|
||||
$("#booking_item_id").val(0).trigger("change");
|
||||
$("#pickup_library_id").val(null).trigger("change");
|
||||
$("#pickup_library_id").empty();
|
||||
$("#pickup_library_id").prop("disabled", true);
|
||||
$("#period").get(0)._flatpickr.clear();
|
||||
$("#booking_start_date").val("");
|
||||
$("#booking_end_date").val("");
|
||||
|
|
|
|||
Loading…
Reference in New Issue