Compare commits

3 Commits

Author SHA1 Message Date
29f9aeaba4 Minor cosmetic cleanup
All checks were successful
Build BAB Application Deployment Artifact / build (push) Successful in 2m9s
2024-04-30 17:11:11 -04:00
28600578f1 Fix update of timblock 2024-04-30 17:04:55 -04:00
b66afb5692 Change colour of date header to white 2024-04-30 16:04:30 -04:00
6 changed files with 66 additions and 53 deletions

View File

@@ -90,17 +90,13 @@ interface BoatData extends Boat {
const scheduleStore = useScheduleStore(); const scheduleStore = useScheduleStore();
const boatStore = useBoatStore(); const boatStore = useBoatStore();
const selectedBlock = ref<Timeblock | null>(null); const selectedBlock = defineModel<Timeblock | null>();
const selectedDate = ref(today()); const selectedDate = ref(today());
const boatData = ref<BoatData[]>(boatStore.boats); const boatData = ref<BoatData[]>(boatStore.boats);
const calendar = ref<QCalendarDay | null>(null); const calendar = ref<QCalendarDay | null>(null);
const emit = defineEmits<{
updateBoatTime: [block: Timeblock];
}>();
function handleSwipe({ ...event }) { function handleSwipe({ ...event }) {
event.direction === 'right' ? calendar.value?.prev() : calendar.value?.next(); event.direction === 'right' ? calendar.value?.prev() : calendar.value?.next();
} }
@@ -165,8 +161,9 @@ interface DayBodyScope {
function selectBlock(event: MouseEvent, scope: DayBodyScope, block: Timeblock) { function selectBlock(event: MouseEvent, scope: DayBodyScope, block: Timeblock) {
// TODO: Disable blocks before today with updateDisabled and/or comparison // TODO: Disable blocks before today with updateDisabled and/or comparison
selectedBlock.value = block; selectedBlock.value === block
emit('updateBoatTime', block); ? (selectedBlock.value = null)
: (selectedBlock.value = block);
} }
function changeEvent({ start }: { start: string }) { function changeEvent({ start }: { start: string }) {
@@ -194,11 +191,13 @@ const disabledBefore = computed(() => {
.boat-schedule-table-component .boat-schedule-table-component
display: flex display: flex
max-height: 60vh max-height: 60vh
max-width: 98vw
.reservation .reservation
display: flex display: flex
position: absolute position: absolute
justify-content: center justify-content: center
align-items: center align-items: center
text-align: center
width: 100% width: 100%
opacity: 1 opacity: 1
margin: 0px margin: 0px
@@ -212,6 +211,7 @@ const disabledBefore = computed(() => {
display: flex display: flex
position: absolute position: absolute
justify-content: center justify-content: center
text-align: center
align-items: center align-items: center
width: 100% width: 100%
opacity: 0.5 opacity: 0.5

View File

@@ -155,7 +155,7 @@ function dayFormatterFunc() {
position: relative position: relative
width: 100% width: 100%
height: 70px height: 70px
background: $primary background: white
display: flex display: flex
flex-direction: row flex-direction: row
flex: 1 0 100% flex: 1 0 100%
@@ -164,6 +164,7 @@ function dayFormatterFunc() {
overflow: hidden overflow: hidden
border-radius: 3px border-radius: 3px
user-select: none user-select: none
margin: 2px 0px 2px
.dates-holder .dates-holder
position: relative position: relative
@@ -186,8 +187,8 @@ function dayFormatterFunc() {
user-select: none user-select: none
.direction-button .direction-button
background: $primary background: white
color: white color: $primary
width: 40px width: 40px
max-width: 50px !important max-width: 50px !important
@@ -212,8 +213,8 @@ function dayFormatterFunc() {
font-size: 3em font-size: 3em
.date-button .date-button
color: white color: $primary
background: $primary background: white
z-index: 2 z-index: 2
height: 100% height: 100%
outline: 0 outline: 0
@@ -236,6 +237,6 @@ function dayFormatterFunc() {
user-select: none user-select: none
.selected-date-button .selected-date-button
color: #3f51b5 !important color: white !important
background: white !important background: $primary !important
</style> </style>

View File

@@ -24,11 +24,12 @@
Use the calendar to pick a date. Select an available boat and Use the calendar to pick a date. Select an available boat and
timeslot below. timeslot below.
</q-banner> </q-banner>
<BoatScheduleTableComponent @updateBoatTime="updateBoat" /> <BoatScheduleTableComponent v-model="timeblock" />
<q-banner <q-banner
rounded rounded
class="bg-warning text-grey-10" class="bg-warning text-grey-10"
style="max-width: 95vw; margin: auto"
v-if="bookingForm.boat?.defects" v-if="bookingForm.boat?.defects"
> >
<template v-slot:avatar> <template v-slot:avatar>
@@ -79,11 +80,20 @@ import { useScheduleStore } from 'src/stores/schedule';
import { Reservation, Timeblock } from 'src/stores/schedule.types'; import { Reservation, Timeblock } from 'src/stores/schedule.types';
import BoatScheduleTableComponent from 'src/components/scheduling/boat/BoatScheduleTableComponent.vue'; import BoatScheduleTableComponent from 'src/components/scheduling/boat/BoatScheduleTableComponent.vue';
interface BookingForm {
bookingId: string;
name?: string;
boat?: Boat;
startDate?: string;
endDate?: string;
}
const auth = useAuthStore(); const auth = useAuthStore();
const dateFormat = 'MMM D, YYYY h:mm A'; const dateFormat = 'MMM D, YYYY h:mm A';
const resourceView = ref(true); const resourceView = ref(true);
const scheduleStore = useScheduleStore(); const scheduleStore = useScheduleStore();
const bookingForm = reactive({ const timeblock = ref<Timeblock>();
const bookingForm = ref<BookingForm>({
bookingId: scheduleStore.getNewId(), bookingId: scheduleStore.getNewId(),
name: auth.currentUser?.name, name: auth.currentUser?.name,
boat: <Boat | undefined>undefined, boat: <Boat | undefined>undefined,
@@ -91,22 +101,21 @@ const bookingForm = reactive({
endDate: date.formatDate(new Date(), dateFormat), endDate: date.formatDate(new Date(), dateFormat),
}); });
watch(bookingForm, (b, a) => { watch(timeblock, (tb_new) => {
const newRes = <Reservation>{ console.log('Hi');
id: b.bookingId, bookingForm.value.boat = useBoatStore().boats.find(
user: b.name, (b) => b.$id === tb_new?.boatId
resource: b.boat, );
start: date.extractDate(b.startDate, dateFormat), bookingForm.value.startDate = date.formatDate(tb_new?.start, dateFormat);
end: date.extractDate(b.endDate, dateFormat), bookingForm.value.endDate = date.formatDate(tb_new?.end, dateFormat);
reservationDate: new Date(), console.log(tb_new);
status: 'tentative',
};
//TODO: Turn this into a validator.
scheduleStore.isReservationOverlapped(newRes)
? Dialog.create({ message: 'This booking overlaps another!' })
: scheduleStore.addOrCreateReservation(newRes);
}); });
// //TODO: Turn this into a validator.
// scheduleStore.isReservationOverlapped(newRes)
// ? Dialog.create({ message: 'This booking overlaps another!' })
// : scheduleStore.addOrCreateReservation(newRes);
const onReset = () => { const onReset = () => {
// TODO // TODO
}; };
@@ -115,27 +124,27 @@ const onSubmit = () => {
// TODO // TODO
}; };
const updateBoat = (block: Timeblock) => {
bookingForm.boat = useBoatStore().boats.find((b) => b.$id === block.boatId);
bookingForm.startDate = date.formatDate(block.start, dateFormat);
bookingForm.endDate = date.formatDate(block.end, dateFormat);
console.log(bookingForm.startDate);
};
const bookingDuration = computed(() => { const bookingDuration = computed(() => {
const diff = date.getDateDiff( if (bookingForm.value.endDate && bookingForm.value.startDate) {
bookingForm.endDate, const diff = date.getDateDiff(
bookingForm.startDate, bookingForm.value.endDate,
'minutes' bookingForm.value.startDate,
); 'minutes'
return diff <= 0 );
? 'Invalid' return diff <= 0
: (diff > 60 ? Math.trunc(diff / 60) + ' hours' : '') + ? 'Invalid'
(diff % 60 > 0 ? ' ' + (diff % 60) + ' minutes' : ''); : (diff > 60 ? Math.trunc(diff / 60) + ' hours' : '') +
(diff % 60 > 0 ? ' ' + (diff % 60) + ' minutes' : '');
} else {
return 0;
}
}); });
const bookingSummary = computed(() => { const bookingSummary = computed(() => {
return bookingForm.boat && bookingForm.startDate && bookingForm.endDate return bookingForm.value.boat &&
? `${bookingForm.boat.name} @ ${bookingForm.startDate} for ${bookingDuration.value}` bookingForm.value.startDate &&
bookingForm.value.endDate
? `${bookingForm.value.boat.name} @ ${bookingForm.value.startDate} for ${bookingDuration.value}`
: ''; : '';
}); });
</script> </script>

View File

@@ -82,9 +82,9 @@ export function getSampleReservations(): Reservation[] {
{ {
id: 3, id: 3,
user: 'Peter Parker', user: 'Peter Parker',
start: '9:00', start: '7:00',
end: '12:00', end: '13:00',
boat: '2', boat: '4',
status: 'tentative', status: 'tentative',
}, },
{ {

View File

@@ -81,9 +81,12 @@ export const useScheduleStore = defineStore('schedule', () => {
return isResourceTimeOverlapped(res.resource, res.start, res.end); return isResourceTimeOverlapped(res.resource, res.start, res.end);
}; };
const getNewId = () => { const getNewId = (): string => {
return [...Array(20)]
.map(() => Math.floor(Math.random() * 16).toString(16))
.join('');
// Trivial placeholder // Trivial placeholder
return Math.max(...reservations.value.map((item) => item.id)) + 1; //return Math.max(...reservations.value.map((item) => item.id)) + 1;
}; };
const addOrCreateReservation = (reservation: Reservation) => { const addOrCreateReservation = (reservation: Reservation) => {

View File

@@ -2,7 +2,7 @@ import type { Boat } from './boat';
export type StatusTypes = 'tentative' | 'confirmed' | 'pending' | undefined; export type StatusTypes = 'tentative' | 'confirmed' | 'pending' | undefined;
export interface Reservation { export interface Reservation {
id: number; id: string;
user: string; user: string;
start: Date; start: Date;
end: Date; end: Date;