Skip to content
Snippets Groups Projects
Commit cb39aec5 authored by Hangzhi Yu's avatar Hangzhi Yu
Browse files

Add date to timetable overview route

parent 50ba0341
No related branches found
No related tags found
No related merge requests found
Pipeline #192655 passed with warnings
<script setup>
import TimetableWrapper from "./TimetableWrapper.vue";
</script>
<script>
import { DateTime } from "luxon";
export default {
name: "Timetable",
data() {
return {
calendarFocus: "",
calendarType: "week",
};
},
methods: {
setCalendarFocus(val) {
this.calendarFocus = val;
},
setCalendarType(val) {
this.calendarType = val;
},
setInnerFocusAndType() {
if (this.$route.name === "chronos.timetableWithId") {
this.$refs.calendarWithControls.setCalendarFocus(
DateTime.now().toISODate(),
);
this.$refs.calendarWithControls.setCalendarType(
this.$vuetify.breakpoint.mdAndDown ? "day" : "week",
);
} else {
this.$refs.calendarWithControls.setCalendarFocus(
[
this.$route.params.year,
this.$route.params.month,
this.$route.params.day,
].join("-"),
);
this.$refs.calendarWithControls.setCalendarType(
this.$route.params.view,
);
}
},
},
watch: {
calendarFocus(newValue, oldValue) {
// Do not redirect on first page load
if (oldValue === "") return;
// FIXME: avoid duplicate navigation on first page load when route params already contain date
const [year, month, day] = newValue.split("-");
this.$router.push({
name: "chronos.timetableWithIdAndParams",
params: {
view: this.calendarType,
year,
month,
day,
},
});
},
calendarType(newValue) {
const [year, month, day] = this.calendarFocus.split("-");
this.$router.push({
name: "chronos.timetableWithIdAndParams",
params: {
view: newValue,
year,
month,
day,
},
});
},
},
};
</script>
......@@ -17,6 +86,10 @@ export default {
{ name: 'holidays' },
]"
:params="{ type: selected.type, id: selected.objId }"
ref="calendarWithControls"
@changeCalendarFocus="setCalendarFocus"
@changeCalendarType="setCalendarType"
@calendarReady="setInnerFocusAndType"
/>
</template>
</timetable-wrapper>
......
......@@ -31,6 +31,17 @@ export default {
permission: "chronos.view_timetable_overview_rule",
fullWidth: true,
},
children: [
{
path: ":view(month|week|day)/:year(\\d\\d\\d\\d)/:month(\\d\\d)/:day(\\d\\d)/",
component: Timetable,
name: "chronos.timetableWithIdAndParams",
meta: {
permission: "chronos.view_timetable_overview_rule",
fullWidth: true,
},
},
],
},
{
path: "substitutions/print/",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment