.boat-schedule-table-component
display: flex
- height: 60vh
+ max-height: 60vh
.timeblock
display: flex
position: absolute
justify-content: center
align-items: center
- width: 100%
- opacity: 0.25
- margin: 0 1px
+ width: 99%
+ opacity: 0.5
+ margin: 0px
text-overflow: ellipsis
- overflow: hidden
font-size: 0.8em
cursor: pointer
background: $primary
color: white
- border: 2px solid black
+ border: 1px solid black
.selected
opacity: 1 !important
.q-calendar-day__interval--text
font-size: 0.8em
+.q-calendar-day__day.q-current-day
+ padding: 1px
diff --git a/src/stores/boat.ts b/src/stores/boat.ts
index 43cf513..b20a91a 100644
--- a/src/stores/boat.ts
+++ b/src/stores/boat.ts
@@ -69,7 +69,7 @@ and rough engine performance.`,
imgsrc: '/tmpimg/capri25.png',
},
{
- $id: '3',
+ $id: '4',
name: 'Just My Imagination',
displayName: 'JMI',
class: 'Capri 25',
diff --git a/src/stores/sampledata/schedule.ts b/src/stores/sampledata/schedule.ts
index 236f995..806bb6d 100644
--- a/src/stores/sampledata/schedule.ts
+++ b/src/stores/sampledata/schedule.ts
@@ -1,40 +1,66 @@
import { DateOptions, date } from 'quasar';
import { Boat, useBoatStore } from '../boat';
-import type { StatusTypes, Timeblock, Reservation } from '../schedule.types';
+import { ID } from 'src/boot/appwrite';
+import {
+ parseTimestamp,
+ today,
+ Timestamp,
+ addToDate,
+} from '@quasar/quasar-ui-qcalendar';
-export const weekdayBlocks = [
- {
- start: { time: '08:00', hour: 8, minute: 0 },
- end: { time: '12:00', hour: 12, minute: 0 },
- },
- {
- start: { time: '12:00', hour: 12, minute: 0 },
- end: { time: '16:00', hour: 16, minute: 0 },
- },
- {
- start: { time: '17:00', hour: 17, minute: 0 },
- end: { time: '21:00', hour: 21, minute: 0 },
- },
-] as Timeblock[];
+import type {
+ StatusTypes,
+ Reservation,
+ TimeBlockTemplate,
+ Timeblock,
+} from '../schedule.types';
-export const weekendBlocks = [
- {
- start: { time: '07:00', hour: 7, minute: 0 },
- end: { time: '10:00', hour: 10, minute: 0 },
- },
- {
- start: { time: '10:00', hour: 10, minute: 0 },
- end: { time: '13:00', hour: 13, minute: 0 },
- },
- {
- start: { time: '13:00', hour: 13, minute: 0 },
- end: { time: '16:00', hour: 16, minute: 0 },
- },
- {
- start: { time: '16:00', hour: 16, minute: 0 },
- end: { time: '19:00', hour: 19, minute: 0 },
- },
-];
+export const templateA: TimeBlockTemplate = {
+ id: '1',
+ name: 'WeekdayBlocks',
+ blocks: [
+ ['08:00', '12:00'],
+ ['12:00', '16:00'],
+ ['17:00', '21:00'],
+ ],
+};
+
+export const templateB: TimeBlockTemplate = {
+ id: '2',
+ name: 'WeekendBlocks',
+ blocks: [
+ ['07:00', '10:00'],
+ ['10:00', '13:00'],
+ ['13:00', '16:00'],
+ ['16:00', '19:00'],
+ ],
+};
+
+export function getSampleTimeBlocks(): Timeblock[] {
+ // Hard-code 30 days worth of blocks, for now. Make them random templates
+ const boats = useBoatStore().boats;
+ const result: Timeblock[] = [];
+ const tsToday: Timestamp = parseTimestamp(today()) as Timestamp;
+
+ for (let i = 0; i <= 30; i++) {
+ const template = Math.random() < 0.5 ? templateA : templateB;
+ result.push(
+ ...boats
+ .map((b): Timeblock[] => {
+ return template.blocks.map((t): Timeblock => {
+ return {
+ id: 'id' + Math.random().toString(32).slice(2),
+ boatId: b.$id,
+ start: addToDate(tsToday, { day: i }).date + ' ' + t[0],
+ end: addToDate(tsToday, { day: i }).date + ' ' + t[1],
+ };
+ });
+ })
+ .flat(2)
+ );
+ }
+ return result;
+}
export function getSampleReservations(): Reservation[] {
const sampleData = [
diff --git a/src/stores/schedule.ts b/src/stores/schedule.ts
index 360abba..e585ccb 100644
--- a/src/stores/schedule.ts
+++ b/src/stores/schedule.ts
@@ -1,25 +1,27 @@
import { defineStore } from 'pinia';
import { ref } from 'vue';
import { Boat } from './boat';
-import { Timestamp, parseDate } from '@quasar/quasar-ui-qcalendar';
+import {
+ Timestamp,
+ parseDate,
+ parsed,
+ compareDate,
+} from '@quasar/quasar-ui-qcalendar';
import { Reservation, Timeblock } from './schedule.types';
-import { weekdayBlocks, getSampleReservations } from './sampledata/schedule';
+import {
+ getSampleReservations,
+ getSampleTimeBlocks,
+} from './sampledata/schedule';
export const useScheduleStore = defineStore('schedule', () => {
// TODO: Implement functions to dynamically pull this data.
const reservations = ref(getSampleReservations());
- const timeblocks = weekdayBlocks;
- 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 getTimeblocksForDate = (date: string): Timeblock[] => {
+ return getSampleTimeBlocks().filter((b) =>
+ compareDate(parsed(b.start) as Timestamp, parsed(date) as Timestamp)
+ );
};
const getBoatReservations = (
@@ -27,7 +29,6 @@ export const useScheduleStore = defineStore('schedule', () => {
boat?: string
): Reservation[] => {
return reservations.value.filter((x) => {
- console.log(searchDate);
return (
((parseDate(x.start)?.date == searchDate.date ||
parseDate(x.end)?.date == searchDate.date) && // Part of reservation falls on day
@@ -38,6 +39,21 @@ export const useScheduleStore = defineStore('schedule', () => {
});
};
+ // const getConflicts = (timeblock: Timeblock, 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 getConflictingReservations = (
resource: Boat,
start: Date,
diff --git a/src/stores/schedule.types.ts b/src/stores/schedule.types.ts
index 835be6b..3724e25 100644
--- a/src/stores/schedule.types.ts
+++ b/src/stores/schedule.types.ts
@@ -1,4 +1,3 @@
-import type { Timestamp } from '@quasar/quasar-ui-qcalendar';
import type { Boat } from './boat';
export type StatusTypes = 'tentative' | 'confirmed' | 'pending' | undefined;
@@ -17,8 +16,17 @@ export interface Reservation {
e.g.: Should there be any qcalendar stuff in this store? Or should we have just JS Date
objects in here? */
+export type timeTuple = [start: string, end: string];
export interface Timeblock {
- start: Timestamp;
- end: Timestamp;
+ id: string;
+ boatId: string;
+ start: string;
+ end: string;
selected?: false;
}
+
+export interface TimeBlockTemplate {
+ id: string;
+ name: string;
+ blocks: timeTuple[];
+}