Remove conflicting blocks
This commit is contained in:
@@ -177,9 +177,16 @@ function selectBlock(event: MouseEvent, scope: DayBodyScope, block: Interval) {
|
||||
const boatBlocks = computed((): Record<string, Interval[]> => {
|
||||
return scheduleStore
|
||||
.getIntervalsForDate(selectedDate.value)
|
||||
.reduce((result, tb) => {
|
||||
if (!result[tb.boatId]) result[tb.boatId] = [];
|
||||
result[tb.boatId].push(tb);
|
||||
.reduce((result, interval) => {
|
||||
if (!result[interval.boatId]) result[interval.boatId] = [];
|
||||
if (
|
||||
!reservationStore.isResourceTimeOverlapped(
|
||||
interval.boatId,
|
||||
new Date(interval.start),
|
||||
new Date(interval.end)
|
||||
)
|
||||
)
|
||||
result[interval.boatId].push(interval);
|
||||
return result;
|
||||
}, <Record<string, Interval[]>>{});
|
||||
});
|
||||
@@ -203,34 +210,6 @@ function getBoatReservations(scope: DayBodyScope): Reservation[] {
|
||||
return boat ? boatReservations.value[boat.$id] : [];
|
||||
}
|
||||
|
||||
// function changeEvent({ start }: { start: string }) {
|
||||
// const newBlocks = scheduleStore.getIntervalsForDate(start);
|
||||
// const reservations = scheduleStore.getReservationsByDate(
|
||||
// parsed(start) as Timestamp
|
||||
// );
|
||||
// boats.value.map((boat) => {
|
||||
// boat.reservations = reservations.filter(
|
||||
// (reservation) => reservation.resource === boat
|
||||
// );
|
||||
// boat.blocks = newBlocks.filter(
|
||||
// (block) =>
|
||||
// block.boatId === boat.$id &&
|
||||
// boat.reservations?.filter(
|
||||
// (r: Reservation) =>
|
||||
// r.start <
|
||||
// date.addToDate(makeDateTime(parsed(block.end) as Timestamp), {
|
||||
// hours: 4,
|
||||
// }) &&
|
||||
// r.end >
|
||||
// date.addToDate(makeDateTime(parsed(block.start) as Timestamp), {
|
||||
// hours: 4,
|
||||
// })
|
||||
// ).length == 0
|
||||
// );
|
||||
// });
|
||||
// setTimeout(() => calendar.value?.scrollToTime('09:00'), 100); // Should figure out why we need this setTimeout...
|
||||
// }
|
||||
|
||||
const disabledBefore = computed(() => {
|
||||
const todayTs = parseTimestamp(today()) as Timestamp;
|
||||
return addToDate(todayTs, { day: -1 }).date;
|
||||
|
||||
@@ -135,21 +135,6 @@ export const useScheduleStore = defineStore('schedule', () => {
|
||||
console.error('Failed to fetch timeblock templates', error);
|
||||
}
|
||||
}
|
||||
// const getConflicts = (timeblock: Interval, boat: Boat) => {
|
||||
// const start = date.buildDate({
|
||||
// hour: timeblock.start.hour,
|
||||
// minute: timeblock.start.minute,
|
||||
// second: 0,
|
||||
// millisecond: 0,
|
||||
// });
|
||||
// const end = date.buildDate({
|
||||
// hour: timeblock.end.hour,
|
||||
// minute: timeblock.end.minute,
|
||||
// second: 0,
|
||||
// millisecond: 0,
|
||||
// });
|
||||
// return scheduleStore.getConflictingReservations(boat, start, end);
|
||||
// };
|
||||
|
||||
const createInterval = async (interval: Interval) => {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user