Skip to content
Snippets Groups Projects
Commit 73e28756 authored by Konrad Mohrfeldt's avatar Konrad Mohrfeldt :koala:
Browse files

fix: ensure calendar selections are reflected in URL

refs #177
parent 61c45a5b
No related branches found
No related tags found
No related merge requests found
Pipeline #7207 passed
......@@ -114,7 +114,7 @@
</template>
<script>
import { parseISO } from 'date-fns'
import { addDays, parseISO } from 'date-fns'
import { h } from 'vue'
import { mapGetters } from 'vuex'
......@@ -156,12 +156,11 @@ export default {
mixins: [prettyDate, playlist],
data() {
const startDay = this.$route.query.start ?? new Date()
return {
view: 'week',
view: this.$route.query.view ?? 'week',
adminUrl: `${import.meta.env.VUE_APP_BASEURI_STEERING}/admin`,
calendarSlots: [],
selectedDay: new Date(startDay),
selectedDay: this.$route.query.day ? parseISO(this.$route.query.day) : new Date(),
// flag for when submitting resolve data
submitting: false,
......@@ -175,7 +174,7 @@ export default {
conflictCount: 0,
conflictSolutions: [],
serverErrors: [],
currentStart: new Date(startDay),
currentStart: this.$route.query.week ? parseISO(this.$route.query.week) : new Date(),
currentEnd: undefined,
stopRenderWatcher: () => {
/* noop */
......@@ -283,8 +282,13 @@ export default {
) {
this.$router.replace({
name: this.$route.name,
params: this.$route.params,
query: { ...this.$route.query, start: getISODateString(view.start) },
params: { ...this.$route.params },
query: {
...this.$route.query,
view: this.view,
day: getISODateString(this.selectedDay),
week: getISODateString(view.start),
},
})
this.currentStart = view.start
this.currentEnd = view.end
......@@ -321,6 +325,20 @@ export default {
}),
},
watch: {
view(newView) {
void this.$router.replace({
name: this.$route.name,
params: { ...this.$route.params },
query: { ...this.$route.query, view: newView },
})
},
selectedDay(newDate) {
void this.$router.replace({
name: this.$route.name,
params: { ...this.$route.params },
query: { ...this.$route.query, day: getISODateString(newDate) },
})
},
selectedShow: {
immediate: true,
handler(newShow) {
......@@ -376,7 +394,7 @@ export default {
},
methods: {
changeDay(delta) {
this.selectedDay = new Date(this.selectedDay.setDate(this.selectedDay.getDate() + delta))
this.selectedDay = addDays(this.selectedDay, delta)
},
selectDay(date) {
......
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