Many improvements. Still no reactivity on List
This commit is contained in:
@@ -35,7 +35,10 @@
|
||||
|
||||
<template #day-body="{ scope }">
|
||||
<div
|
||||
v-for="block in getBoatBlocks(scope)"
|
||||
v-for="block in getAvailableIntervals(
|
||||
scope.timestamp,
|
||||
boats[scope.columnIndex]
|
||||
)"
|
||||
:key="block.$id">
|
||||
<div
|
||||
class="timeblock"
|
||||
@@ -95,23 +98,24 @@ import CalendarHeaderComponent from './CalendarHeaderComponent.vue';
|
||||
|
||||
import { ref, computed, onMounted } from 'vue';
|
||||
import { useBoatStore } from 'src/stores/boat';
|
||||
import { useScheduleStore } from 'src/stores/schedule';
|
||||
import { useAuthStore } from 'src/stores/auth';
|
||||
import { Interval, Reservation } from 'src/stores/schedule.types';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useReservationStore } from 'src/stores/reservation';
|
||||
import { useIntervalTemplateStore } from 'src/stores/intervalTemplate';
|
||||
import { useIntervalStore } from 'src/stores/interval';
|
||||
|
||||
const scheduleStore = useScheduleStore();
|
||||
const intervalTemplateStore = useIntervalTemplateStore();
|
||||
const reservationStore = useReservationStore();
|
||||
const { boats } = storeToRefs(useBoatStore());
|
||||
const selectedBlock = defineModel<Interval | null>();
|
||||
const selectedDate = ref(today());
|
||||
|
||||
const { getAvailableIntervals } = useIntervalStore();
|
||||
const calendar = ref<QCalendarDay | null>(null);
|
||||
|
||||
onMounted(async () => {
|
||||
await useBoatStore().fetchBoats();
|
||||
await scheduleStore.fetchIntervalTemplates();
|
||||
await intervalTemplateStore.fetchIntervalTemplates();
|
||||
});
|
||||
|
||||
function handleSwipe({ ...event }) {
|
||||
@@ -194,23 +198,6 @@ function selectBlock(event: MouseEvent, scope: DayBodyScope, block: Interval) {
|
||||
: (selectedBlock.value = block);
|
||||
}
|
||||
|
||||
const boatBlocks = computed((): Record<string, Interval[]> => {
|
||||
return scheduleStore
|
||||
.getIntervals(selectedDate.value)
|
||||
.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[]>>{});
|
||||
});
|
||||
|
||||
const boatReservations = computed((): Record<string, Reservation[]> => {
|
||||
return reservationStore
|
||||
.getReservationsByDate(selectedDate.value)
|
||||
@@ -220,11 +207,6 @@ const boatReservations = computed((): Record<string, Reservation[]> => {
|
||||
return result;
|
||||
}, <Record<string, Reservation[]>>{});
|
||||
});
|
||||
|
||||
function getBoatBlocks(scope: DayBodyScope): Interval[] {
|
||||
const boat = boats.value[scope.columnIndex];
|
||||
return boat ? boatBlocks.value[boat.$id] : [];
|
||||
}
|
||||
function getBoatReservations(scope: DayBodyScope): Reservation[] {
|
||||
const boat = boats.value[scope.columnIndex];
|
||||
return boat ? boatReservations.value[boat.$id] : [];
|
||||
|
||||
Reference in New Issue
Block a user