diff --git a/aleksis/apps/alsijil/frontend/components/Coursebook.vue b/aleksis/apps/alsijil/frontend/components/Coursebook.vue new file mode 100644 index 0000000000000000000000000000000000000000..25bf02ca58a0ae11364ac496c3ada608bfa4a13b --- /dev/null +++ b/aleksis/apps/alsijil/frontend/components/Coursebook.vue @@ -0,0 +1,58 @@ +<template> + <c-r-u-d-iterator + i18n-key="coursebook" + :gql-query="gqlQuery" + :gql-additional-query-args="gqlQueryArgs" + > + <template #default="{ items, groupedItems }"> + {{ items }} + </template> + </c-r-u-d-iterator> +</template> + +<script> +import CRUDIterator from "aleksis.core/components/generic/CRUDIterator.vue" +import gqlDocumentationsForCoursebook from "./coursebook.graphql" + +export default { + name: "Coursebook", + components: { + CRUDIterator, + }, + props: { + // Either as props OR route params + // TODO: Remove default? + courseId: { + type: [Number, String], + required: false, + default: 0, + }, + // Next two in ISODate + dateStart: { + type: String, + required: false, + default: "", + }, + dateEnd: { + type: String, + required: false, + default: "", + }, + }, + data() { + return { + gqlQuery: gqlDocumentationsForCoursebook, + }; + }, + computed: { + gqlQueryArgs() { + return { + // Assure courseId is a number + courseId: Number(this.courseId), + dateStart: this.dateStart, + dateEnd: this.dateEnd, + }; + }, + }, +}; +</script> diff --git a/aleksis/apps/alsijil/frontend/index.js b/aleksis/apps/alsijil/frontend/index.js index 521c4b5629d6800abebaec1e4ce27f4f57cc3ab4..fe62f3a331a29295380d5e33fd235364a978585c 100644 --- a/aleksis/apps/alsijil/frontend/index.js +++ b/aleksis/apps/alsijil/frontend/index.js @@ -2,6 +2,7 @@ import { notLoggedInValidator, hasPersonValidator, } from "aleksis.core/routeValidators"; +import { DateTime } from "luxon"; export default { meta: { @@ -392,5 +393,41 @@ export default { byTheGreatnessOfTheAlmightyAleksolotlISwearIAmWorthyOfUsingTheLegacyBaseTemplate: true, }, }, + { + path: "coursebook/:courseId(\\d+)/", + component: () => import("./components/Coursebook.vue"), + redirect: to => { + console.log('redirect to', to); + return { name: "alsijil.coursebook_by_course_id_and_date", + params: { + courseId: to.params.courseId, + dateStart: DateTime.now().toISODate(), + dateEnd: DateTime.now().plus({ weeks: 1 }).toISODate(), + }, + }; + }, + name: "alsijil.coursebook_by_course_id", + props: true, + meta: { + inMenu: true, + icon: "mdi-calendar-outline", + iconActive: "mdi-calendar", + titleKey: "calendar.menu_title", + toolbarTitle: "calendar.menu_title", + permission: "core.view_calendar_feed_rule", + }, + children: [ + { + path: ":dateStart(\\d\\d\\d\\d-\\d\\d-\\d\\d)/:dateEnd(\\d\\d\\d\\d-\\d\\d-\\d\\d)/", + component: () => import("./components/Coursebook.vue"), + name: "alsijil.coursebook_by_course_id_and_date", + meta: { + titleKey: "calendar.menu_title", + toolbarTitle: "calendar.menu_title", + permission: "core.view_calendar_feed_rule", + }, + }, + ], + }, ], };