|
Lines 170-175
$("#placeBookingModal").on("show.bs.modal", function (e) {
Link Here
|
| 170 |
if (changed) { |
170 |
if (changed) { |
| 171 |
periodPicker.clear(); |
171 |
periodPicker.clear(); |
| 172 |
} |
172 |
} |
|
|
173 |
periodPicker.set("disable", periodPicker.config.disable); |
| 173 |
periodPicker.redraw(); |
174 |
periodPicker.redraw(); |
| 174 |
|
175 |
|
| 175 |
// Enable flatpickr now we have data we need |
176 |
// Enable flatpickr now we have data we need |
|
Lines 458-464
$("#placeBookingModal").on("show.bs.modal", function (e) {
Link Here
|
| 458 |
} |
459 |
} |
| 459 |
|
460 |
|
| 460 |
// iterate existing bookings |
461 |
// iterate existing bookings |
| 461 |
for (booking of bookings) { |
462 |
for (let booking of bookings) { |
| 462 |
// Skip if we're editing this booking |
463 |
// Skip if we're editing this booking |
| 463 |
if ( |
464 |
if ( |
| 464 |
booking_id && |
465 |
booking_id && |
|
Lines 1112-1117
function setFormValues(
Link Here
|
| 1112 |
}); |
1113 |
}); |
| 1113 |
} |
1114 |
} |
| 1114 |
|
1115 |
|
|
|
1116 |
// If passed an itemnumber, pre-select |
| 1117 |
if (booking_item_id) { |
| 1118 |
// Wait a bit for the item options to be fully created with data attributes |
| 1119 |
setTimeout(function () { |
| 1120 |
$("#booking_item_id").val(booking_item_id).trigger("change"); |
| 1121 |
// Also trigger the select2:select event with proper data |
| 1122 |
let selectedOption = $("#booking_item_id option:selected")[0]; |
| 1123 |
if (selectedOption) { |
| 1124 |
$("#booking_item_id").trigger({ |
| 1125 |
type: "select2:select", |
| 1126 |
params: { |
| 1127 |
data: { |
| 1128 |
id: booking_item_id, |
| 1129 |
element: selectedOption, |
| 1130 |
}, |
| 1131 |
}, |
| 1132 |
}); |
| 1133 |
} |
| 1134 |
}, 100); |
| 1135 |
} |
| 1136 |
|
| 1115 |
// Set booking start & end if this is an edit |
1137 |
// Set booking start & end if this is an edit |
| 1116 |
if (start_date) { |
1138 |
if (start_date) { |
| 1117 |
// Allow invalid pre-load so setDate can set date range |
1139 |
// Allow invalid pre-load so setDate can set date range |
|
Lines 1127-1137
function setFormValues(
Link Here
|
| 1127 |
else { |
1149 |
else { |
| 1128 |
periodPicker.redraw(); |
1150 |
periodPicker.redraw(); |
| 1129 |
} |
1151 |
} |
| 1130 |
|
|
|
| 1131 |
// If passed an itemnumber, pre-select |
| 1132 |
if (booking_item_id) { |
| 1133 |
$("#booking_item_id").val(booking_item_id).trigger("change"); |
| 1134 |
} |
| 1135 |
} |
1152 |
} |
| 1136 |
|
1153 |
|
| 1137 |
$("#placeBookingForm").on("submit", function (e) { |
1154 |
$("#placeBookingForm").on("submit", function (e) { |
| 1138 |
- |
|
|