From de04b539142dd8ce452eb846ed7dd352b30539af Mon Sep 17 00:00:00 2001 From: Patrick Toal Date: Sun, 28 Apr 2024 19:07:00 -0400 Subject: [PATCH] Time Select --- src/components/scheduling/BoatSelection.vue | 95 +------ .../boat/BoatScheduleTableComponent.vue | 118 +++++++++ .../boat/CalendarHeaderComponent.vue | 241 ++++++++++++++++++ src/pages/schedule/BoatReservationPage.vue | 6 +- src/pages/schedule/BoatScheduleView.vue | 133 +++++++--- src/stores/boat.ts | 8 + src/stores/schedule.ts | 47 +++- 7 files changed, 502 insertions(+), 146 deletions(-) create mode 100644 src/components/scheduling/boat/BoatScheduleTableComponent.vue create mode 100644 src/components/scheduling/boat/CalendarHeaderComponent.vue diff --git a/src/components/scheduling/BoatSelection.vue b/src/components/scheduling/BoatSelection.vue index f1f9c1f..3d1d012 100644 --- a/src/components/scheduling/BoatSelection.vue +++ b/src/components/scheduling/BoatSelection.vue @@ -1,86 +1,9 @@ + + diff --git a/src/components/scheduling/boat/CalendarHeaderComponent.vue b/src/components/scheduling/boat/CalendarHeaderComponent.vue new file mode 100644 index 0000000..3cb77aa --- /dev/null +++ b/src/components/scheduling/boat/CalendarHeaderComponent.vue @@ -0,0 +1,241 @@ + + + + diff --git a/src/pages/schedule/BoatReservationPage.vue b/src/pages/schedule/BoatReservationPage.vue index acc6de9..a14f62d 100644 --- a/src/pages/schedule/BoatReservationPage.vue +++ b/src/pages/schedule/BoatReservationPage.vue @@ -1,7 +1,7 @@ + + + diff --git a/src/stores/boat.ts b/src/stores/boat.ts index 30f3dc9..43cf513 100644 --- a/src/stores/boat.ts +++ b/src/stores/boat.ts @@ -68,6 +68,14 @@ and rough engine performance.`, year: 1989, imgsrc: '/tmpimg/capri25.png', }, + { + $id: '3', + name: 'Just My Imagination', + displayName: 'JMI', + class: 'Capri 25', + year: 1989, + imgsrc: '/tmpimg/capri25.png', + }, ]; export const useBoatStore = defineStore('boat', { diff --git a/src/stores/schedule.ts b/src/stores/schedule.ts index fc54798..4a1f7e8 100644 --- a/src/stores/schedule.ts +++ b/src/stores/schedule.ts @@ -3,7 +3,13 @@ import { ref } from 'vue'; import { Boat, useBoatStore } from './boat'; import { date } from 'quasar'; import { DateOptions } from 'quasar'; -import { Timestamp } from '@quasar/quasar-ui-qcalendar'; +import { + Timestamp, + parseDate, + updateRelative, + today, + parsed, +} from '@quasar/quasar-ui-qcalendar'; export type StatusTypes = 'tentative' | 'confirmed' | 'pending' | undefined; export type Reservation = { @@ -22,26 +28,31 @@ export type Reservation = { objects in here? */ export type Timeblock = { + id: number; start: Timestamp; end: Timestamp; }; const sampleBlocks = [ { - start: { time: '09:00', hour: 9, minute: 0, hasDay: false, hasTime: true }, - end: { time: '12:00', hour: 12, minute: 0, hasDay: false, hasTime: true }, + id: 1, + start: { time: '09:00', hour: 9, minute: 0, hasTime: true }, + end: { time: '11:30', hour: 12, minute: 0, hasTime: true }, }, { - start: { time: '12:00', hour: 12, minute: 0, hasDay: false, hasTime: true }, - end: { time: '15:00', hour: 15, minute: 0, hasDay: false, hasTime: true }, + id: 2, + start: { time: '12:00', hour: 12, minute: 0, hasTime: true }, + end: { time: '15:00', hour: 15, minute: 0, hasTime: true }, }, { - start: { time: '15:00', hour: 15, minute: 0, hasDay: false, hasTime: true }, - end: { time: '18:00', hour: 18, minute: 0, hasDay: false, hasTime: true }, + id: 3, + start: { time: '15:00', hour: 15, minute: 0, hasTime: true }, + end: { time: '18:00', hour: 18, minute: 0, hasTime: true }, }, { - start: { time: '18:00', hour: 18, minute: 0, hasDay: false, hasTime: true }, - end: { time: '21:00', hour: 21, minute: 0, hasDay: false, hasTime: true }, + id: 4, + start: { time: '18:00', hour: 18, minute: 0, hasTime: true }, + end: { time: '21:00', hour: 21, minute: 0, hasTime: true }, }, ] as Timeblock[]; @@ -128,16 +139,26 @@ export const useScheduleStore = defineStore('schedule', () => { const reservations = ref(getSampleReservations()); const timeblocks = sampleBlocks; - const getTimeblocksForDate = (date: Date): Timeblock[] => timeblocks; + const getTimeblocksForDate = (date: Timestamp): Timeblock[] => { + return timeblocks.map((t) => { + return { + // Update all the start/end times with the passed in date + ...t, + start: { ...date, ...t.start }, + end: { ...date, ...t.end }, + }; + }); + }; const getBoatReservations = ( - searchDate: Date, + searchDate: Timestamp, boat?: string ): Reservation[] => { return reservations.value.filter((x) => { + console.log(searchDate); return ( - ((x.start.getDate() == searchDate.getDate() || - x.end.getDate() == searchDate.getDate()) && // Part of reservation falls on day + ((parseDate(x.start)?.date == searchDate.date || + parseDate(x.end)?.date == searchDate.date) && // Part of reservation falls on day x.resource != undefined && // A boat is defined !boat) || x.resource.$id == boat // A specific boat has been passed, and matches