diff --git a/src/app/pages/agenda/agenda.page.ts b/src/app/pages/agenda/agenda.page.ts index f5b383d40..a4ef74ec4 100644 --- a/src/app/pages/agenda/agenda.page.ts +++ b/src/app/pages/agenda/agenda.page.ts @@ -611,7 +611,7 @@ export class AgendaPage implements OnInit { delete this.loadRequest[index] } - loadRangeEventRun(startTime: Date, endTime: Date) { + async loadRangeEventRun(startTime: Date, endTime: Date) { if (SessionStore.user.OwnerCalendars.length == 0 && SessionStore.user.SharedCalendars.length == 0) { return false @@ -630,60 +630,53 @@ export class AgendaPage implements OnInit { try { this.myCal.update(); this.myCal.loadEvents(); - } catch (error) { - - } + } catch (error) {} let load = 0; for (const selectedCalendar of selectedCalendarIds) { - (async () => { + const response = await this.AgendaDataRepositoryService.EventList({userId: selectedCalendar.OwnerUserId, calendarOwnerName: selectedCalendar['FullName'] }) + if(response.isOk()) { + let label; - const response = await this.AgendaDataRepositoryService.EventList({userId: selectedCalendar.OwnerUserId, calendarOwnerName: selectedCalendar['FullName'] }) - - if(response.isOk()) { - let label; - - if (SessionStore.user.Profile == 'PR') { - label = "pr" - } else if (SessionStore.user.OwnerCalendars.find(e => e.CalendarId == selectedCalendar.CalendarId)) { - label = 'md' - } else { - label = "pr" - } - - let eventsList = response.value; - this.CalendarStore.pushEvent(eventsList, label); - - this.listToPresent = this.CalendarStore.getEventsByCalendarIds(selectedCalendarIds) - - - this.showTimelinePR = true; - - load++ - if (load == selectedCalendarIds.length) { - this.showLoader = false; - } - - this.myCal.update(); - this.myCal.loadEvents(); - this.updateEventListBox() + if (SessionStore.user.Profile == 'PR') { + label = "pr" + } else if (SessionStore.user.OwnerCalendars.find(e => e.CalendarId == selectedCalendar.CalendarId)) { + label = 'md' } else { - load++ - if (load == selectedCalendarIds.length) { - this.showLoader = false; - } - - this.myCal.update(); - this.myCal.loadEvents(); - - console.log('111b') - this.listToPresent = this.CalendarStore.getEventsByCalendarIds(selectedCalendarIds) - this.updateEventListBox() + label = "pr" } - })() + + this.CalendarStore.removeRangeForCalendar(startTime, endTime, null , selectedCalendar.OwnerUserId as any) + + let eventsList = response.value; + this.CalendarStore.pushEvent(eventsList, label, selectedCalendar.OwnerUserId); + + this.listToPresent = this.CalendarStore.getEventsByCalendarIds(selectedCalendarIds) + this.showTimelinePR = true; + + load++ + if (load == selectedCalendarIds.length) { + this.showLoader = false; + } + + this.myCal.update(); + this.myCal.loadEvents(); + this.updateEventListBox() + } else { + load++ + if (load == selectedCalendarIds.length) { + this.showLoader = false; + } + + this.myCal.update(); + this.myCal.loadEvents(); + + this.listToPresent = this.CalendarStore.getEventsByCalendarIds(selectedCalendarIds) + this.updateEventListBox() + } } @@ -695,9 +688,13 @@ export class AgendaPage implements OnInit { if (this.CalendarName == 'PR+MDGPR') { + const pr = this.SessionStore.user.SharedCalendars.filter(e => e.CalendarRoleId == this.RoleIdService.PRES.toString()) + return[{ ...this.eventService.calendarNamesType['Meu calendario'], OwnerUserId: this.SessionStore.user.UserId + }, { + ...pr[0] }] } else { diff --git a/src/app/services/Repositorys/Agenda/mapper/eventToApproveListMapper.ts b/src/app/services/Repositorys/Agenda/mapper/eventToApproveListMapper.ts index 48970d935..cb7c53bc5 100644 --- a/src/app/services/Repositorys/Agenda/mapper/eventToApproveListMapper.ts +++ b/src/app/services/Repositorys/Agenda/mapper/eventToApproveListMapper.ts @@ -26,12 +26,13 @@ export class EventListToApproveMapper { if(dto.ownerType == 'PR') { color = 'PR' workflowDisplayName = `Agenda ${category} ${color}` - } else if(dto.ownerType == 'MD') { + } else { color = 'MDGPR' workflowDisplayName = `Agenda ${category} ${color}` - } else { - workflowDisplayName = `Agenda ${category}` } + // else { + // workflowDisplayName = `Agenda ${category}` + // } return { serialNumber: dto.id, diff --git a/src/app/store/calendar.service.ts b/src/app/store/calendar.service.ts index f60c41e74..61a74a666 100644 --- a/src/app/store/calendar.service.ts +++ b/src/app/store/calendar.service.ts @@ -72,7 +72,7 @@ export class CalendarService { }) } - pushEvent(eventsList: EventList, profile: 'pr' | 'md') { + pushEvent(eventsList: EventList, profile: 'pr' | 'md', CalendarId: string) { let news = [] eventsList.forEach((element, eventIndex) => { @@ -85,7 +85,7 @@ export class CalendarService { calendarName: element.CalendarName, profile: profile, id: element.EventId, - CalendarId: element.CalendarId + CalendarId: CalendarId }); });