update(LvPlan router) manages the route changes in the Calendar component instead of the LvPlan

This commit is contained in:
SimonGschnell
2025-06-23 11:37:33 +02:00
parent 6e9650ddfa
commit 1d9936757c
2 changed files with 23 additions and 21 deletions
+23 -1
View File
@@ -202,6 +202,28 @@ export default {
},
},
methods: {
handleChangeOffset(offset){
let date = new Date(
this.focusDate.y,
this.focusDate.m,
this.focusDate.d
);
date = date.getFullYear() + "-" +
String(date.getMonth() + 1).padStart(2, "0") + "-" +
String(date.getDate()).padStart(2, "0");
this.$router.push({
name: "LvPlan",
params: {
mode: this.mode[0].toUpperCase() + this.mode.slice(1),
focus_date: date,
lv_id: this.$route.params.lv_id || null
}
})
},
setMode(mode) {
this.mode = mode
},
@@ -253,7 +275,7 @@ export default {
template: /*html*/`
<div ref="container" class="fhc-calendar card h-100" :class="sizeClass">
<component :is="'calendar-' + mode" @updateMode="mode = $event" @change:range="$emit('change:range',$event)"
@input="handleInput" @change:offset="$emit('change:offset', $event)">
@input="handleInput" @change:offset="handleChangeOffset">
<template #calendarDownloads>
<slot name="calendarDownloads" ></slot>
</template>
-20
View File
@@ -178,26 +178,6 @@ const LvPlan = {
this.currentDay = day;
},
handleOffset: function(offset) {
this.currentDay = new Date(
this.currentDay.getFullYear() + offset.y,
this.currentDay.getMonth() + offset.m,
this.currentDay.getDate() + offset.d
)
const date = this.currentDay.getFullYear() + "-" +
String(this.currentDay.getMonth() + 1).padStart(2, "0") + "-" +
String(this.currentDay.getDate()).padStart(2, "0");
this.$router.push({
name: "LvPlan",
params: {
mode: this.calendarMode[0].toUpperCase() + this.calendarMode.slice(1),
focus_date: date,
lv_id: this.propsViewData?.lv_id || null
}
})
},
handleChangeMode(mode) {
let m = mode[0].toUpperCase() + mode.slice(1)
if(m === this.calendarMode) return; // TODO(chris): check for date and lv_id too!