Skip to content

Commit 1487512

Browse files
authored
Fix overlapping hold events and auto confirm setting (#1338)
* 🔨 Fix the auto-confirm settings to align with db * 🔨 Prevent overlapping events in the week calendar
1 parent 12f58e9 commit 1487512

2 files changed

Lines changed: 39 additions & 32 deletions

File tree

frontend/src/views/AvailabilityView/components/AvailabilitySettings/index.vue

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@ const isBookable = computed({
3030
}
3131
})
3232
33-
const requiresBookingConfirmation = computed({
34-
get: () => currentState.value.booking_confirmation,
33+
// The database stores a boolean, if booking requests should have manual confirmation. However, since we offer
34+
// an "automatic confirmation" toggle in the UI, we need to negate the value from the database here.
35+
const autoConfirmBookings = computed({
36+
get: () => !currentState.value.booking_confirmation,
3537
set: (value) => {
36-
availabilityStore.$patch({ currentState: { booking_confirmation: value } })
38+
availabilityStore.$patch({ currentState: { booking_confirmation: !value } })
3739
}
3840
})
3941
@@ -116,10 +118,10 @@ export default {
116118

117119
<!-- Automatically confirm booking checkbox -->
118120
<checkbox-input
119-
:name="t('label.automaticallyConfirmBookingsIfTimeIsAvailable')"
121+
name="availability-automatically-confirm"
120122
:label="t('label.automaticallyConfirmBookingsIfTimeIsAvailable')"
121123
data-testid="availability-automatically-confirm-checkbox"
122-
v-model="requiresBookingConfirmation"
124+
v-model="autoConfirmBookings"
123125
:disabled="!currentState.active"
124126
/>
125127
</div>
@@ -275,4 +277,4 @@ h3 {
275277
gap: 1.5rem;
276278
}
277279
}
278-
</style>
280+
</style>

frontend/src/views/DashboardView/components/WeekCalendar.vue

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -251,32 +251,6 @@ const timeSlotsForGrid = computed(() => {
251251
return slots;
252252
});
253253
254-
/**
255-
* Generates an array of remote events that fall within the active week with grid positioning info
256-
* Note we are still fetching monthly events to reduce the roundtrips
257-
*/
258-
const filteredRemoteEventsForGrid = computed(() => {
259-
const slots = timeSlotsForGrid.value;
260-
if (!slots.length) return [];
261-
262-
const { start, end } = props.activeDateRange;
263-
const remoteEventsWithinActiveWeek = props.events.filter((remoteEvent) => dj(remoteEvent.start).isBetween(start, end))
264-
265-
return remoteEventsWithinActiveWeek.map(remoteEvent => {
266-
const eventStart = dj(remoteEvent.start);
267-
const eventEnd = dj(remoteEvent.end);
268-
269-
const gridPosition = calculateEventGridPosition(eventStart, eventEnd, slots);
270-
271-
if (gridPosition) {
272-
return {
273-
...remoteEvent,
274-
...gridPosition,
275-
};
276-
}
277-
}).filter(Boolean)
278-
});
279-
280254
/**
281255
* Generates an array of pending appointments that fall within the active week with grid positioning info
282256
*/
@@ -312,6 +286,37 @@ const filteredPendingAppointmentsForGrid = computed(() => {
312286
}).filter(Boolean)
313287
});
314288
289+
/**
290+
* Generates an array of remote events that fall within the active week with grid positioning info
291+
* Note we are still fetching monthly events to reduce the roundtrips
292+
*/
293+
const filteredRemoteEventsForGrid = computed(() => {
294+
const slots = timeSlotsForGrid.value;
295+
if (!slots.length) return [];
296+
297+
const { start, end } = props.activeDateRange;
298+
const remoteEventsWithinActiveWeek = props.events.filter((remoteEvent) => dj(remoteEvent.start).isBetween(start, end))
299+
300+
return remoteEventsWithinActiveWeek.map(remoteEvent => {
301+
const eventStart = dj(remoteEvent.start);
302+
const eventEnd = dj(remoteEvent.end);
303+
304+
const gridPosition = calculateEventGridPosition(eventStart, eventEnd, slots);
305+
const hasPendingPlaceholder = filteredPendingAppointmentsForGrid.value.find(
306+
(a) => a.title === remoteEvent.title && eventStart.isSame(a.start)
307+
);
308+
309+
// Only show remote event, if we have a valid grid position and if we don't already have calculated
310+
// a placeholder for a pending (HOLD) event
311+
if (gridPosition && !hasPendingPlaceholder) {
312+
return {
313+
...remoteEvent,
314+
...gridPosition,
315+
};
316+
}
317+
}).filter(Boolean);
318+
});
319+
315320
/**
316321
* Generates an array of selectable time slots that fall within the active week with grid positioning info
317322
*/

0 commit comments

Comments
 (0)