Filtering booked blocks
All checks were successful
Build BAB Application Deployment Artifact / build (push) Successful in 1m53s
All checks were successful
Build BAB Application Deployment Artifact / build (push) Successful in 1m53s
This commit is contained in:
@@ -75,6 +75,7 @@ import {
|
|||||||
parseTimestamp,
|
parseTimestamp,
|
||||||
parseDate,
|
parseDate,
|
||||||
addToDate,
|
addToDate,
|
||||||
|
makeDateTime,
|
||||||
} from '@quasar/quasar-ui-qcalendar';
|
} from '@quasar/quasar-ui-qcalendar';
|
||||||
import CalendarHeaderComponent from './CalendarHeaderComponent.vue';
|
import CalendarHeaderComponent from './CalendarHeaderComponent.vue';
|
||||||
|
|
||||||
@@ -82,6 +83,7 @@ import { ref, computed } from 'vue';
|
|||||||
import { Boat, useBoatStore } from 'src/stores/boat';
|
import { Boat, useBoatStore } from 'src/stores/boat';
|
||||||
import { useScheduleStore } from 'src/stores/schedule';
|
import { useScheduleStore } from 'src/stores/schedule';
|
||||||
import { Reservation, Timeblock } from 'src/stores/schedule.types';
|
import { Reservation, Timeblock } from 'src/stores/schedule.types';
|
||||||
|
import { date } from 'quasar';
|
||||||
|
|
||||||
interface BoatData extends Boat {
|
interface BoatData extends Boat {
|
||||||
blocks?: Timeblock[];
|
blocks?: Timeblock[];
|
||||||
@@ -171,11 +173,25 @@ function changeEvent({ start }: { start: string }) {
|
|||||||
const reservations = scheduleStore.getBoatReservations(
|
const reservations = scheduleStore.getBoatReservations(
|
||||||
parsed(start) as Timestamp
|
parsed(start) as Timestamp
|
||||||
);
|
);
|
||||||
boatData.value.map((b) => {
|
boatData.value.map((boat) => {
|
||||||
b.blocks = newBlocks.filter((block) => block.boatId === b.$id);
|
boat.reservations = reservations.filter(
|
||||||
b.reservations = reservations.filter(
|
(reservation) => reservation.resource === boat
|
||||||
(reservation) => reservation.resource === b
|
);
|
||||||
); // TODO: search by id, not item.
|
boat.blocks = newBlocks.filter(
|
||||||
|
(block) =>
|
||||||
|
block.boatId === boat.$id &&
|
||||||
|
boat.reservations?.filter(
|
||||||
|
(r) =>
|
||||||
|
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...
|
setTimeout(() => calendar.value?.scrollToTime('09:00'), 100); // Should figure out why we need this setTimeout...
|
||||||
|
|||||||
Reference in New Issue
Block a user