mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
fix agenda
This commit is contained in:
@@ -166,6 +166,7 @@ export class AgendaPage implements OnInit {
|
||||
|
||||
SessionStore = SessionStore;
|
||||
environment = environment
|
||||
CalendarName = ''
|
||||
|
||||
constructor(
|
||||
@Inject(LOCALE_ID) private locale: string,
|
||||
@@ -254,6 +255,8 @@ export class AgendaPage implements OnInit {
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
this.setCalendarByDefault()
|
||||
|
||||
setTimeout(() => {
|
||||
const pathname = window.location.pathname
|
||||
let realoadCounter = 0
|
||||
@@ -283,6 +286,17 @@ export class AgendaPage implements OnInit {
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
|
||||
setCalendarByDefault() {
|
||||
if(!this.CalendarName) {
|
||||
if(this.eventService.calendarNamesAry.includes('Meu calendario')) {
|
||||
this.CalendarName = 'Meu calendario';
|
||||
} else {
|
||||
this.CalendarName = this.eventService.calendarNamesAry[0]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Go to the next view of the calendar month/week/day
|
||||
next() {
|
||||
this.myCal.slideNext();
|
||||
@@ -821,105 +835,61 @@ export class AgendaPage implements OnInit {
|
||||
|
||||
} else {
|
||||
|
||||
if(this.loggeduser.OwnerCalendars.length != 0 ) {
|
||||
const selectedCalendarUserId = this.selectedCalendarUserId();
|
||||
this.eventService.getEventsByRoleId(momentG(new Date(startTime), 'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime), 'yyyy-MM-dd 23:59:59'), selectedCalendarUserId).then((response: any) => {
|
||||
|
||||
this.eventService.getAllOwnEvents(momentG(new Date(startTime), 'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime), 'yyyy-MM-dd 23:59:59')).then((response: any) => {
|
||||
let label;
|
||||
|
||||
this.addEventToDB(response, "md");
|
||||
let eventsList = response;
|
||||
|
||||
this.CalendarStore.removeRange(startTime, endTime, 'md')
|
||||
|
||||
// loop
|
||||
this.CalendarStore.pushEvent(eventsList, 'md');
|
||||
|
||||
|
||||
this.TimelineMDList = this.listBoxService.list(this.CalendarStore.eventSource, 'md', this.rangeStartDate, this.rangeEndDate, { segment: this.segment, selectedDate: this.eventSelectedDate })
|
||||
|
||||
this.myCal.update();
|
||||
this.myCal.loadEvents();
|
||||
|
||||
this.showTimelineMD = true;
|
||||
|
||||
counter++;
|
||||
if (counter == 2) {
|
||||
this.showLoader = false;
|
||||
}
|
||||
|
||||
|
||||
}).catch((error) => {
|
||||
console.error(error)
|
||||
this.getFromDB()
|
||||
}).finally(() => {
|
||||
this.deleteLoadRangeEvent(startTime, endTime)
|
||||
counter++;
|
||||
if (counter == 2) {
|
||||
this.showLoader = false;
|
||||
}
|
||||
this.updateEventListBox()
|
||||
})
|
||||
} else {
|
||||
counter++;
|
||||
if (counter == 2) {
|
||||
this.showLoader = false;
|
||||
if(selectedCalendarUserId == SessionStore.user.UserId) {
|
||||
label = 'md'
|
||||
} else {
|
||||
label = "pr"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.addEventToDB(response, label);
|
||||
let eventsList = response;
|
||||
this.CalendarStore.removeRange(startTime, endTime, label)
|
||||
this.CalendarStore.pushEvent(eventsList, label);
|
||||
this.listToPresent = this.CalendarStore.eventSource
|
||||
|
||||
if(this.loggeduser.SharedCalendars.length != 0 ) {
|
||||
this.TimelinePRList = this.listBoxService.list(this.CalendarStore.eventSource, label, this.rangeStartDate, this.rangeEndDate, { segment: this.segment, selectedDate: this.eventSelectedDate })
|
||||
|
||||
this.eventService.genericGetAllSharedEvents(momentG(new Date(startTime), 'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime), 'yyyy-MM-dd 23:59:59')).then((response: any) => {
|
||||
this.myCal.update();
|
||||
this.myCal.loadEvents();
|
||||
|
||||
this.addEventToDB(response, "pr");
|
||||
let eventsList = response;
|
||||
|
||||
// clear the current month only
|
||||
this.CalendarStore.removeRange(startTime, endTime, 'pr')
|
||||
|
||||
|
||||
this.CalendarStore.pushEvent(eventsList, 'pr');
|
||||
this.listToPresent = this.CalendarStore.eventSource
|
||||
|
||||
this.TimelinePRList = this.listBoxService.list(this.CalendarStore.eventSource, 'pr', this.rangeStartDate, this.rangeEndDate, { segment: this.segment, selectedDate: this.eventSelectedDate })
|
||||
// console.log('this.TimelinePRList', this.TimelinePRList)
|
||||
//
|
||||
|
||||
this.myCal.update();
|
||||
this.myCal.loadEvents();
|
||||
|
||||
this.showTimelinePR = true;
|
||||
|
||||
counter++;
|
||||
|
||||
if (counter == 2 || this.loggeduser.Profile == 'PR') {
|
||||
this.showLoader = false;
|
||||
}
|
||||
|
||||
}).catch((error) => {
|
||||
console.error(error)
|
||||
this.getFromDB()
|
||||
})
|
||||
.finally(() => {
|
||||
this.deleteLoadRangeEvent(startTime, endTime)
|
||||
counter++;
|
||||
if (counter == 2) {
|
||||
this.showLoader = false;
|
||||
}
|
||||
this.updateEventListBox()
|
||||
})
|
||||
} else {
|
||||
counter++;
|
||||
if (counter == 2) {
|
||||
this.showLoader = false;
|
||||
}
|
||||
}
|
||||
this.showTimelinePR = true;
|
||||
this.showLoader = false;
|
||||
|
||||
}).finally(() => {
|
||||
this.deleteLoadRangeEvent(startTime, endTime)
|
||||
this.showLoader = false;
|
||||
this.updateEventListBox()
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
getSelectedAgendaCalendars () {
|
||||
let Oficial = this.eventService.calendarNamesType[this.CalendarName]?.['Oficial']
|
||||
let Pessoal = this.eventService.calendarNamesType[this.CalendarName]?.['Pessoal']
|
||||
|
||||
if(Oficial && Pessoal) {
|
||||
|
||||
return [Oficial, Pessoal]
|
||||
|
||||
} else if (Oficial) {
|
||||
return [Oficial]
|
||||
|
||||
} else if (Pessoal) {
|
||||
return [Pessoal]
|
||||
|
||||
} else {
|
||||
return [Oficial, Pessoal]
|
||||
}
|
||||
}
|
||||
|
||||
trasnformData(response, profile) {
|
||||
|
||||
response.forEach(element => {
|
||||
|
||||
Reference in New Issue
Block a user