Selecte courseSession from route query for dueDates
This commit is contained in:
parent
4925c1a178
commit
e7ea2f8922
|
|
@ -7,7 +7,6 @@ import dayjs from "dayjs";
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
dueDate: DashboardDueDate;
|
dueDate: DashboardDueDate;
|
||||||
singleLine?: boolean;
|
singleLine?: boolean;
|
||||||
showCourseSession?: boolean;
|
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,12 @@ import ItDropdownSelect from "@/components/ui/ItDropdownSelect.vue";
|
||||||
import { computed, ref, watch } from "vue";
|
import { computed, ref, watch } from "vue";
|
||||||
import { useTranslation } from "i18next-vue";
|
import { useTranslation } from "i18next-vue";
|
||||||
import _ from "lodash";
|
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");
|
log.debug("DashboardPersonsPage created");
|
||||||
|
|
||||||
const UNFILTERED = Number.MAX_SAFE_INTEGER.toString();
|
const UNFILTERED = "0";
|
||||||
|
|
||||||
type DropboxItem = {
|
type DropboxItem = {
|
||||||
id: string;
|
id: string;
|
||||||
|
|
@ -74,8 +75,27 @@ const courseSessions = computed(() => {
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const selectedSessionRouteQuery = useRouteQuery("session");
|
||||||
const selectedSession = ref<DropboxItem>(courseSessions.value[0]);
|
const selectedSession = ref<DropboxItem>(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(() => {
|
const filteredDueDates = computed(() => {
|
||||||
return _.orderBy(
|
return _.orderBy(
|
||||||
dashboardDueDates.value
|
dashboardDueDates.value
|
||||||
|
|
@ -247,15 +267,9 @@ watch(selectedCourse, async () => {
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
<DueDatesList
|
<div v-for="dueDate in filteredDueDates" :key="dueDate.id" class="border-b">
|
||||||
:show-top-border="false"
|
<DueDateSingle :single-line="true" :due-date="dueDate"></DueDateSingle>
|
||||||
:show-bottom-border="false"
|
</div>
|
||||||
:due-dates="filteredDueDates"
|
|
||||||
:show-all-due-dates-link="false"
|
|
||||||
:max-count="100"
|
|
||||||
data-cy="due-date-list"
|
|
||||||
:show-course-session="true"
|
|
||||||
/>
|
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue