Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qalendar fixes #587

Merged
merged 3 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions frontend/src/components/CalendarQalendar.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup>
import {
ref, computed, inject, toRefs, watch,
ref, computed, inject, toRefs, watch, onMounted
} from 'vue';
import { Qalendar } from 'qalendar';
import 'qalendar/dist/style.css';
Expand Down Expand Up @@ -274,7 +274,7 @@ const calendarEvents = computed(() => {
});

/**
* Calculate the start and end times, and then space them our by 2 hours for style!
* Calculate the start and end times, and then space them out by 2 hours for style!
* @type {ComputedRef<TimeNumeric>}
*/
const dayBoundary = computed(() => {
Expand All @@ -300,6 +300,9 @@ const dayBoundary = computed(() => {
};
});

// For now we only support English and German
const locale = getLocale();

/**
* Calendar Config Object
*/
Expand All @@ -308,7 +311,7 @@ const config = ref({
showEventsOnMobileView: false,
},
week: {
startsOn: 'sunday',
startsOn: locale === 'de' ? 'monday' : 'sunday',
},
style: {
// Just the pre-calculated list from tailwind, could use some fine-tuning.
Expand All @@ -329,19 +332,17 @@ const config = ref({
length: timeSlotDuration.value, // Accepts [15, 30, 60]
height: timeSlotHeight.value, // pixel height of each length
},
dayBoundaries: dayBoundary,
dayBoundaries: {
start: dayBoundary.value.start,
end: dayBoundary.value.end
},
Comment on lines -332 to +338
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the point of initializing this config object, dayBoundary.value holds the default values 0, 24 making Qalendar span the container element over that range. Updating the boundary later in the watcher causes Qalendar to recalculate the displayed time rows, but it doesn't update the row height.

eventDialog: {
// We roll our own
isDisabled: true,
},
locale: locale === 'de' ? 'de-DE' : 'en-US'
});

// We only support two locales right now so just stick this in.
const locale = getLocale();
if (locale) {
config.value.locale = locale === 'de' ? 'de-DE' : 'en-US';
}

/**
* Qalendar's selectedDate is only set on init and never updated. So we have to poke at their internals...
*/
Expand All @@ -360,6 +361,7 @@ watch(dayBoundary, () => {
return;
}

// TODO: This does update the boundary values, but does NOT update the container height!
qalendarRef.value.time.DAY_START = dayBoundary.value.start * 100;
qalendarRef.value.time.DAY_END = dayBoundary.value.end * 100;
Comment on lines +364 to 366
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any ideas how to trigger a UI rerender of Qalendar at this point?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might need to adjust our fork, and then pull in our fork. But I'm not sure 🤔

});
Expand All @@ -378,7 +380,6 @@ watch(route, () => {
</script>
<template>
<div
class="w-full"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was also set on the parent. Removing the duplicated class here.

:style="{'color-scheme': preferredTheme === ColorSchemes.Dark ? 'dark' : null}"
:class="{'is-light-mode': preferredTheme === ColorSchemes.Light}"
>
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/stores/appointment-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ export const useAppointmentStore = defineStore('appointments', () => {
const pendingAppointments = computed(
(): Appointment[] => appointments.value.filter((a) => a?.slots[0]?.booking_status === BookingStatus.Requested),
);
const pendingFutureAppointments = computed(
(): Appointment[] => pendingAppointments.value.filter((a) => a?.slots[0]?.start > dj()),
);

/**
* Append additional data to retrieved appointments
Expand Down Expand Up @@ -61,6 +64,6 @@ export const useAppointmentStore = defineStore('appointments', () => {
};

return {
isLoaded, appointments, pendingAppointments, postFetchProcess, fetch, $reset,
isLoaded, appointments, pendingAppointments, pendingFutureAppointments, postFetchProcess, fetch, $reset,
};
});