Skip to content
Snippets Groups Projects
Commit 730ff304 authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Merge branch '253-add-date-to-timetable-overview-page-route-like-on-calendar-page' into 'master'

Resolve "Add date to timetable overview page route (like on calendar page)"

Closes #253

See merge request !368
parents e9d8fa7f 585e6cac
No related branches found
Tags 4.0.0.dev6
1 merge request!368Resolve "Add date to timetable overview page route (like on calendar page)"
Pipeline #192971 passed
<script setup>
import TimetableWrapper from "./TimetableWrapper.vue";
</script>
<script>
import { DateTime } from "luxon";
export default {
name: "Timetable",
data() {
return {
calendarFocus: "",
calendarType: "week",
initialRouteFocusSet: false,
};
},
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.initialRouteFocusSet = true;
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;
// Do not redirect when calendar focus was just set with route param values
if (this.initialRouteFocusSet) {
this.initialRouteFocusSet = false;
return;
}
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 +92,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