Updates to booking
All checks were successful
Build BAB Application Deployment Artifact / build (push) Successful in 2m30s
All checks were successful
Build BAB Application Deployment Artifact / build (push) Successful in 2m30s
This commit is contained in:
@@ -172,8 +172,8 @@ function monthFormatter() {
|
|||||||
|
|
||||||
function getEvents(scope: ResourceIntervalScope) {
|
function getEvents(scope: ResourceIntervalScope) {
|
||||||
const resourceEvents = scheduleStore.getBoatReservations(
|
const resourceEvents = scheduleStore.getBoatReservations(
|
||||||
scope.resource.id,
|
date.extractDate(selectedDate.value, 'YYYY-MM-DD'),
|
||||||
date.extractDate(selectedDate.value, 'YYYY-MM-DD')
|
scope.resource.$id
|
||||||
);
|
);
|
||||||
|
|
||||||
return resourceEvents.map((event) => {
|
return resourceEvents.map((event) => {
|
||||||
|
|||||||
@@ -1,12 +1,94 @@
|
|||||||
<template>
|
<template>
|
||||||
<q-page padding>
|
<q-page padding>
|
||||||
<!-- content -->
|
<div class="subcontent">
|
||||||
|
<!-- <navigation-bar @today="onToday" @prev="onPrev" @next="onNext" /> -->
|
||||||
|
|
||||||
|
<div class="row justify-center">
|
||||||
|
<div
|
||||||
|
style="display: flex; max-width: 800px; width: 100%; height: 400px"
|
||||||
|
>
|
||||||
|
<q-calendar-day
|
||||||
|
ref="calendar"
|
||||||
|
v-model="selectedDate"
|
||||||
|
view="day"
|
||||||
|
:max-days="3"
|
||||||
|
bordered
|
||||||
|
animated
|
||||||
|
transition-next="slide-left"
|
||||||
|
transition-prev="slide-right"
|
||||||
|
@change="onChange"
|
||||||
|
@moved="onMoved"
|
||||||
|
@click-date="onClickDate"
|
||||||
|
@click-time="onClickTime"
|
||||||
|
@click-interval="onClickInterval"
|
||||||
|
@click-head-intervals="onClickHeadIntervals"
|
||||||
|
@click-head-day="onClickHeadDay"
|
||||||
|
>
|
||||||
|
<template #day-body="{ scope: { timestamp } }">
|
||||||
|
<template
|
||||||
|
v-for="event in scheduleStore.getBoatReservations(
|
||||||
|
makeDateTime(timestamp)
|
||||||
|
)"
|
||||||
|
:key="event.id"
|
||||||
|
>
|
||||||
|
{{ timestamp }}
|
||||||
|
<div v-if="event.start !== undefined" class="my-event">
|
||||||
|
<div class="title q-calendar__ellipsis">
|
||||||
|
{{ event.user }}
|
||||||
|
<q-tooltip>{{
|
||||||
|
event.start + ' - ' + event.resource.name
|
||||||
|
}}</q-tooltip>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</template>
|
||||||
|
</q-calendar-day>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</q-page>
|
</q-page>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useScheduleStore } from 'src/stores/schedule';
|
import { useScheduleStore } from 'src/stores/schedule';
|
||||||
|
import { ref } from 'vue';
|
||||||
const scheduleStore = useScheduleStore();
|
const scheduleStore = useScheduleStore();
|
||||||
scheduleStore.loadSampleData();
|
import { QCalendarDay, today, makeDateTime } from '@quasar/quasar-ui-qcalendar';
|
||||||
|
|
||||||
|
const selectedDate = ref(today());
|
||||||
|
|
||||||
|
// Use ref to get a reference to the QCalendarDay component
|
||||||
|
const calendarRef = ref(QCalendarDay);
|
||||||
|
|
||||||
|
// Method declarations
|
||||||
|
function onToday() {
|
||||||
|
calendarRef.value.moveToToday();
|
||||||
|
}
|
||||||
|
function onPrev() {
|
||||||
|
calendarRef.value.prev();
|
||||||
|
}
|
||||||
|
function onNext() {
|
||||||
|
calendarRef.value.next();
|
||||||
|
}
|
||||||
|
function onMoved(data) {
|
||||||
|
console.log('onMoved', data);
|
||||||
|
}
|
||||||
|
function onChange(data) {
|
||||||
|
console.log('onChange', data);
|
||||||
|
}
|
||||||
|
function onClickDate(data) {
|
||||||
|
console.log('onClickDate', data);
|
||||||
|
}
|
||||||
|
function onClickTime(data) {
|
||||||
|
console.log('onClickTime', data);
|
||||||
|
}
|
||||||
|
function onClickInterval(data) {
|
||||||
|
console.log('onClickInterval', data);
|
||||||
|
}
|
||||||
|
function onClickHeadIntervals(data) {
|
||||||
|
console.log('onClickHeadIntervals', data);
|
||||||
|
}
|
||||||
|
function onClickHeadDay(data) {
|
||||||
|
console.log('onClickHeadDay', data);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -3,11 +3,7 @@ import { ref } from 'vue';
|
|||||||
import { Boat, useBoatStore } from './boat';
|
import { Boat, useBoatStore } from './boat';
|
||||||
import { date } from 'quasar';
|
import { date } from 'quasar';
|
||||||
import { DateOptions } from 'quasar';
|
import { DateOptions } from 'quasar';
|
||||||
import {
|
import { Timestamp } from '@quasar/quasar-ui-qcalendar';
|
||||||
Timestamp,
|
|
||||||
parseTimestamp,
|
|
||||||
TimestampArray,
|
|
||||||
} from '@quasar/quasar-ui-qcalendar';
|
|
||||||
import { timeStamp } from 'console';
|
import { timeStamp } from 'console';
|
||||||
|
|
||||||
export type StatusTypes = 'tentative' | 'confirmed' | 'pending' | undefined;
|
export type StatusTypes = 'tentative' | 'confirmed' | 'pending' | undefined;
|
||||||
@@ -21,6 +17,10 @@ export type Reservation = {
|
|||||||
status?: StatusTypes;
|
status?: StatusTypes;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* TODO: Figure out how best to separate out where qcalendar bits should be.
|
||||||
|
e.g.: Should there be any qcalendar stuff in this store? Or should we have just JS Date
|
||||||
|
objects in here? */
|
||||||
|
|
||||||
export type Timeblock = {
|
export type Timeblock = {
|
||||||
start: Timestamp;
|
start: Timestamp;
|
||||||
end: Timestamp;
|
end: Timestamp;
|
||||||
@@ -52,7 +52,7 @@ function getSampleReservations(): Reservation[] {
|
|||||||
user: 'John Smith',
|
user: 'John Smith',
|
||||||
start: '12:00',
|
start: '12:00',
|
||||||
end: '15:00',
|
end: '15:00',
|
||||||
boat: 1,
|
boat: '1',
|
||||||
status: 'confirmed',
|
status: 'confirmed',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -60,7 +60,7 @@ function getSampleReservations(): Reservation[] {
|
|||||||
user: 'Bob Barker',
|
user: 'Bob Barker',
|
||||||
start: '18:00',
|
start: '18:00',
|
||||||
end: '21:00',
|
end: '21:00',
|
||||||
boat: 1,
|
boat: '1',
|
||||||
status: 'confirmed',
|
status: 'confirmed',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -68,7 +68,7 @@ function getSampleReservations(): Reservation[] {
|
|||||||
user: 'Peter Parker',
|
user: 'Peter Parker',
|
||||||
start: '9:00',
|
start: '9:00',
|
||||||
end: '12:00',
|
end: '12:00',
|
||||||
boat: 2,
|
boat: '2',
|
||||||
status: 'tentative',
|
status: 'tentative',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -76,7 +76,7 @@ function getSampleReservations(): Reservation[] {
|
|||||||
user: 'Vince McMahon',
|
user: 'Vince McMahon',
|
||||||
start: '15:00',
|
start: '15:00',
|
||||||
end: '18:00',
|
end: '18:00',
|
||||||
boat: 2,
|
boat: '2',
|
||||||
status: 'pending',
|
status: 'pending',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -84,7 +84,7 @@ function getSampleReservations(): Reservation[] {
|
|||||||
user: 'Heather Graham',
|
user: 'Heather Graham',
|
||||||
start: '09:00',
|
start: '09:00',
|
||||||
end: '12:00',
|
end: '12:00',
|
||||||
boat: 3,
|
boat: '3',
|
||||||
status: 'confirmed',
|
status: 'confirmed',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -92,7 +92,7 @@ function getSampleReservations(): Reservation[] {
|
|||||||
user: 'Lawrence Fishburne',
|
user: 'Lawrence Fishburne',
|
||||||
start: '18:00',
|
start: '18:00',
|
||||||
end: '21:00',
|
end: '21:00',
|
||||||
boat: 3,
|
boat: '3',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
const boatStore = useBoatStore();
|
const boatStore = useBoatStore();
|
||||||
@@ -110,7 +110,7 @@ function getSampleReservations(): Reservation[] {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return sampleData.map((entry): Reservation => {
|
return sampleData.map((entry): Reservation => {
|
||||||
const boat = <Boat>boatStore.boats.find((b) => b.id == entry.boat);
|
const boat = <Boat>boatStore.boats.find((b) => b.$id == entry.boat);
|
||||||
return {
|
return {
|
||||||
id: entry.id,
|
id: entry.id,
|
||||||
user: entry.user,
|
user: entry.user,
|
||||||
@@ -131,17 +131,16 @@ export const useScheduleStore = defineStore('schedule', () => {
|
|||||||
const getTimeblocksForDate = (date: Date): Timeblock[] => timeblocks;
|
const getTimeblocksForDate = (date: Date): Timeblock[] => timeblocks;
|
||||||
|
|
||||||
const getBoatReservations = (
|
const getBoatReservations = (
|
||||||
boat: number | string,
|
searchDate: Date,
|
||||||
curDate: Date
|
boat?: string
|
||||||
): Reservation[] => {
|
): Reservation[] => {
|
||||||
return reservations.value.filter((x) => {
|
return reservations.value.filter((x) => {
|
||||||
return (
|
return (
|
||||||
(x.start.getDate() == curDate.getDate() ||
|
((x.start.getDate() == searchDate.getDate() ||
|
||||||
x.end.getDate() == curDate.getDate()) &&
|
x.end.getDate() == searchDate.getDate()) && // Part of reservation falls on day
|
||||||
x.resource != undefined &&
|
x.resource != undefined && // A boat is defined
|
||||||
(typeof boat == 'number'
|
!boat) ||
|
||||||
? x.resource.id == boat
|
x.resource.$id == boat // A specific boat has been passed, and matches
|
||||||
: x.resource.name == boat)
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -153,7 +152,7 @@ export const useScheduleStore = defineStore('schedule', () => {
|
|||||||
): Reservation[] => {
|
): Reservation[] => {
|
||||||
const overlapped = reservations.value.filter(
|
const overlapped = reservations.value.filter(
|
||||||
(entry: Reservation) =>
|
(entry: Reservation) =>
|
||||||
entry.resource.id == resource.id &&
|
entry.resource.$id == resource.$id &&
|
||||||
entry.start < end &&
|
entry.start < end &&
|
||||||
entry.end > start
|
entry.end > start
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user