From e7ea2f892294f2b5aff38f1316956288084e7115 Mon Sep 17 00:00:00 2001 From: Daniel Egger Date: Fri, 19 Apr 2024 11:38:28 +0200 Subject: [PATCH] Selecte courseSession from route query for dueDates --- .../src/components/dueDates/DueDateSingle.vue | 1 - .../pages/dashboard/DashboardDueDatesPage.vue | 36 +++++++++++++------ 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/client/src/components/dueDates/DueDateSingle.vue b/client/src/components/dueDates/DueDateSingle.vue index 8da00e6c..47f659d7 100644 --- a/client/src/components/dueDates/DueDateSingle.vue +++ b/client/src/components/dueDates/DueDateSingle.vue @@ -7,7 +7,6 @@ import dayjs from "dayjs"; const props = defineProps<{ dueDate: DashboardDueDate; singleLine?: boolean; - showCourseSession?: boolean; }>(); const { t } = useTranslation(); diff --git a/client/src/pages/dashboard/DashboardDueDatesPage.vue b/client/src/pages/dashboard/DashboardDueDatesPage.vue index dcfa1135..f427ee25 100644 --- a/client/src/pages/dashboard/DashboardDueDatesPage.vue +++ b/client/src/pages/dashboard/DashboardDueDatesPage.vue @@ -6,11 +6,12 @@ import ItDropdownSelect from "@/components/ui/ItDropdownSelect.vue"; import { computed, ref, watch } from "vue"; import { useTranslation } from "i18next-vue"; import _ from "lodash"; -import DueDatesList from "@/components/dueDates/DueDatesList.vue"; +import { useRouteQuery } from "@vueuse/router"; +import DueDateSingle from "@/components/dueDates/DueDateSingle.vue"; log.debug("DashboardPersonsPage created"); -const UNFILTERED = Number.MAX_SAFE_INTEGER.toString(); +const UNFILTERED = "0"; type DropboxItem = { id: string; @@ -74,8 +75,27 @@ const courseSessions = computed(() => { ]; }); +const selectedSessionRouteQuery = useRouteQuery("session"); const selectedSession = ref(courseSessions.value[0]); +watch(selectedSession, () => { + selectedSessionRouteQuery.value = selectedSession.value.id; +}); + +watch(courseSessions, () => { + if (courseSessions.value.length > 0 && selectedSessionRouteQuery.value) { + // preselect session from route query + const selectedSessionFromRoute = courseSessions.value.find( + (cs) => cs.id === selectedSessionRouteQuery.value + ); + if (selectedSessionFromRoute) { + selectedSession.value = selectedSessionFromRoute; + return; + } + } + selectedSession.value = courseSessions.value[0]; +}); + const filteredDueDates = computed(() => { return _.orderBy( dashboardDueDates.value @@ -247,15 +267,9 @@ watch(selectedCourse, async () => {
- +
+ +