fix(Calendar Day SelectedEvent): fixes the watcher on the property active to additionally look at the events property and set the selectedEvent accordingly to the situation

This commit is contained in:
SimonGschnell
2025-03-03 13:29:31 +01:00
parent 98fa76ca1d
commit a408c85fd4
+19 -15
View File
@@ -52,29 +52,27 @@ export default {
watch: {
//TODO: on first render non of the day-page components are active and the watcher on selectedEvent does not fetch the lvMenu
//TODO: workaround is to watch the active state and refetch in case the lvMenu is empty
active: {
handler(value) {
activeAndEventsReady: {
handler({active,events}) {
// handles fetching the lvMenu
if (value) {
if (active) {
if (!this.lvMenu) {
this.fetchLvMenu(this.selectedEvent);
}
if(events){
// if no event is selected, select the first event of the day
if (this.selectedEvent == null && this.events[this.day.toDateString()]?.length > 0) {
let events = this.events[this.day.toDateString()];
if (Array.isArray(events) && events.length > 0) {
this.setSelectedEvent(events[0]);
}
}
}
}
},
immediate: true,
},
events: {
handler(newEvents) {
// if no event is selected, select the first event of the day
if (this.selectedEvent == null && newEvents[this.day.toDateString()]?.length > 0) {
let events = newEvents[this.day.toDateString()];
if (Array.isArray(events) && events.length > 0) {
this.setSelectedEvent(events[0]);
}
}
},
immediate: true
},
selectedEvent: {
handler(event) {
// return early if the day-page component is not the active carousel item
@@ -95,6 +93,12 @@ export default {
}
},
computed: {
activeAndEventsReady(){
return {
active: this.active,
events: this.events,
}
},
allDayEvents() {
let allDayEvents = {};
for (let day in this.events) {