Fix appointment slot interval and selection
This commit is contained in:
parent
0595267a8c
commit
7ac21f361b
@ -40,9 +40,9 @@ class McsAppointmentType(models.Model):
|
||||
)
|
||||
slot_step = fields.Float(
|
||||
string="Slot Step",
|
||||
default=0.5,
|
||||
default=1.0,
|
||||
required=True,
|
||||
help="Distance between proposed slots in hours.",
|
||||
help="Distance between proposed slots in hours. Public slots never overlap the appointment duration.",
|
||||
)
|
||||
min_schedule_hours = fields.Float(
|
||||
string="Minimum Notice",
|
||||
@ -145,8 +145,8 @@ class McsAppointmentType(models.Model):
|
||||
day_end = self._localize(day, 23.99)
|
||||
busy_intervals = self._busy_intervals(day_start, day_end)
|
||||
slots = []
|
||||
step = timedelta(hours=self.slot_step)
|
||||
duration = timedelta(hours=self.duration)
|
||||
step = max(timedelta(hours=self.slot_step), duration)
|
||||
for attendance in attendances.sorted("hour_from"):
|
||||
cursor = self._localize(day, attendance.hour_from)
|
||||
end_limit = self._localize(day, attendance.hour_to)
|
||||
|
||||
@ -2,6 +2,10 @@
|
||||
"use strict";
|
||||
|
||||
function initAppointmentBooking(root) {
|
||||
if (root.dataset.mcsAppointmentReady === "1") {
|
||||
return;
|
||||
}
|
||||
|
||||
const startInput = root.querySelector(".js-mcs-start");
|
||||
const stopInput = root.querySelector(".js-mcs-stop");
|
||||
const selectedLabel = root.querySelector(".js-mcs-selected-slot");
|
||||
@ -11,8 +15,10 @@
|
||||
return;
|
||||
}
|
||||
|
||||
root.dataset.mcsAppointmentReady = "1";
|
||||
buttons.forEach((button) => {
|
||||
button.addEventListener("click", () => {
|
||||
button.addEventListener("click", (ev) => {
|
||||
ev.preventDefault();
|
||||
buttons.forEach((item) => item.classList.remove("active"));
|
||||
button.classList.add("active");
|
||||
startInput.value = button.dataset.start || "";
|
||||
@ -22,7 +28,13 @@
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
function initAllAppointmentBookings() {
|
||||
document.querySelectorAll(".mcs-appointment").forEach(initAppointmentBooking);
|
||||
});
|
||||
}
|
||||
|
||||
if (document.readyState === "loading") {
|
||||
document.addEventListener("DOMContentLoaded", initAllAppointmentBookings);
|
||||
} else {
|
||||
initAllAppointmentBookings();
|
||||
}
|
||||
})();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user