new api implementation

This commit is contained in:
Eudes Inácio
2024-05-29 15:43:37 +01:00
parent 08303ef8cf
commit 3769a7b8fe
12 changed files with 325 additions and 34 deletions
@@ -0,0 +1,114 @@
import { Injectable } from '@angular/core';
import { AgendaDataService } from './agenda-data.service';
import { EventsService } from '../../events.service';
@Injectable({
providedIn: 'root'
})
export class Utils {
constructor(
private agendaDataService: AgendaDataService,
public eventService: EventsService,
) { }
selectedCalendarUserId(CalendarName,postEvent) {
if (this.eventService.calendarNamesType[CalendarName]?.['Oficial'] && postEvent.CalendarName == 'Oficial') {
return this.eventService.calendarNamesType[CalendarName]['OwnerId']
} else if (this.eventService.calendarNamesType[CalendarName]?.['Pessoal'] && postEvent.CalendarName == 'Pessoal') {
return this.eventService.calendarNamesType[CalendarName]['OwnerId']
} else {
return '11:11'
}
}
editeEventCalendarUserId(CalendarName,postEvent) {
let CalendarNameOwnerName = this.eventService.detectCalendarNameByCalendarId(postEvent.CalendarId)
if(this.eventService.calendarNamesType[CalendarNameOwnerName]?.['Oficial'] && this.eventService.calendarNamesType[CalendarNameOwnerName]?.['Pessoal']) {
return this.eventService.calendarNamesType[CalendarName]['OwnerId']
} else if (this.eventService.calendarNamesType[CalendarNameOwnerName]?.['Oficial']) {
return this.eventService.calendarNamesType[CalendarName]['OwnerId']
} else if (this.eventService.calendarNamesType[CalendarNameOwnerName]?.['Pessoal']) {
return this.eventService.calendarNamesType[CalendarName]['OwnerId']
} else {
return this.eventService.calendarNamesType[CalendarName]['OwnerId']
}
}
selectedCalendarOwner(CalendarName) {
let selectedCalendar = this.eventService.calendarNamesType[CalendarName]?.['RoleId'];
if (selectedCalendar) {
if (selectedCalendar.Role == 100000014) {
return 1;
} else if (selectedCalendar.Role == 100000011) {
return 2
} else {
return 3
}
}
}
calendarCategorySeleted(calendarName) {
var selectedCalendar = {
'Oficial': 1,
'Pessoal': 2
}
return selectedCalendar[calendarName];
}
calendarTypeSeleted(calendarName) {
var selectedType = {
'Reunião': 1,
'Viagem': 2,
'Conferência': 3,
'Encontro': 1
}
return selectedType[calendarName];
}
documentAdded(documents:any[]) {
return documents.map((e) => {
return {
sourceId: e.Id,
sourceName: e.Assunto,
description: "",
applicationId: parseInt(e.ApplicationType.toString())
};
});
}
atendeesSeletedType(type) {
var selectedType = {
'true': 1,
'false':2,
'other':3,
}
return selectedType[type];
}
attendeesAdded(taskParticipants: any[]) {
return taskParticipants.map((e) => {
return {
name: e.Name,
emailAddress: e.EmailAddress,
attendeeType: this.atendeesSeletedType(JSON.stringify(e.IsRequired)),
wxUserId: e.Id,
}
});
}
}