add defualt calendar

This commit is contained in:
Peter Maquiran
2024-01-29 15:50:32 +01:00
parent 78c6ac2f36
commit 07939149ee
3 changed files with 99 additions and 67 deletions
+18 -4
View File
@@ -239,6 +239,14 @@ export class AgendaPage implements OnInit {
} }
this.weekToShow() this.weekToShow()
this.eventService.registerOnLoadCalendars(()=> {
this.setCalendarByDefault(true)
const selectedCalendarIds = this.getSelectedAgendaCalendars();
this.listToPresent = this.CalendarStore.getEventsByCalendarIds(selectedCalendarIds)
this.tigerUpdate()
})
} }
tigerUpdate() { tigerUpdate() {
@@ -257,7 +265,7 @@ export class AgendaPage implements OnInit {
ngOnInit() { ngOnInit() {
this.setCalendarByDefault() this.setCalendarByDefault(false)
const selectedCalendarIds = this.getSelectedAgendaCalendars(); const selectedCalendarIds = this.getSelectedAgendaCalendars();
this.listToPresent = this.CalendarStore.getEventsByCalendarIds(selectedCalendarIds) this.listToPresent = this.CalendarStore.getEventsByCalendarIds(selectedCalendarIds)
@@ -338,14 +346,20 @@ export class AgendaPage implements OnInit {
}, 250) }, 250)
} }
setCalendarByDefault() { setCalendarByDefault(force) {
if (!this.CalendarName) { if (!this.CalendarName || force) {
if (this.eventService.calendarNamesAry.includes('Meu calendario')) { const prObject = this.eventService.calendarNamesAry.find(e => e?.RoleId == 100000014)
if(prObject) {
console.log({prObject})
this.CalendarName = prObject.Fullname
} else if (this.eventService.calendarNamesAry.includes('Meu calendario')) {
this.CalendarName = 'Meu calendario'; this.CalendarName = 'Meu calendario';
} else { } else {
this.CalendarName = this.eventService.calendarNamesAry[0] this.CalendarName = this.eventService.calendarNamesAry[0]
} }
} }
} }
//Go to the next view of the calendar month/week/day //Go to the next view of the calendar month/week/day
+18
View File
@@ -65,6 +65,10 @@ export class EventsService {
HasMdGPR = false HasMdGPR = false
onLoadCalendars: Function[] =[]
loadCalendars = false
onCalendarFinishLoad = new Subscribe({execute : false, deleteOnExecute: true}) onCalendarFinishLoad = new Subscribe({execute : false, deleteOnExecute: true})
constructor( constructor(
@@ -368,6 +372,20 @@ export class EventsService {
} }
this.onLoadCalendars.forEach(e=> e());
this.loadCalendars = true
}
registerOnLoadCalendars(e: Function) {
if( this.loadCalendars) {
e()
} else {
this.onLoadCalendars.push(e)
}
} }