This commit is contained in:
Peter Maquiran
2024-06-13 16:01:33 +01:00
parent 35b1f3ae08
commit ec1fd5ad91
8 changed files with 146 additions and 47 deletions
@@ -15,6 +15,41 @@ export class EventMapper {
constructor() {}
static toDomain(dto: EventOutputDTO) {
let category;
if(dto.category == 1) {
category = 'Oficial'
} else {
category = 'Pessoal'
}
let ownerType;
if(dto.ownerType == 1) {
ownerType = 'PR'
} else if(dto.ownerType == 2) {
ownerType = 'MD'
} else if(dto.ownerType == 3) {
ownerType = 'Other'
}
let type;
let status;
if(dto.status == 1) {
status = 'Pending'
} else if(dto.status == 2) {
status = 'Revision'
}
function EAttendeeType(num) {
if(num == 1) {
return 'Required'
} else if (num == 2) {
return 'Acknowledgment'
} else if (num == 3) {
return 'Optional'
}
}
return {
"HasAttachments": dto.hasAttachments,
"EventComunicationId": 1682,
@@ -26,7 +61,7 @@ export class EventMapper {
},
"Location": dto.location,
"CalendarId": "",
"CalendarName": dto.category,
"CalendarName": category,
"StartDate": dto.startDate,
"EndDate": dto.endDate,
"EventType": "Single",
@@ -35,14 +70,14 @@ export class EventMapper {
wxUserId: e.wxUserId,
EmailAddress: e.emailAddress,
Name: e.name,
IsRequired: e.attendeeType == 'Required',
IsRequired: EAttendeeType(e.attendeeType) == 'Required',
UserType: "GD",
// "IsPR": false,
attendeeType: e.attendeeType
attendeeType: EAttendeeType(e.attendeeType)
// "RoleDescription": null,
// "RoleId": 0
})),
"IsMeeting": dto.category,
"IsMeeting": category,
"IsRecurring": dto.isRecurring,
"IsAllDayEvent": dto.isAllDayEvent,
"AppointmentState": 1,
@@ -53,7 +88,7 @@ export class EventMapper {
"Name": dto.organizer.wxFullName,
"IsRequired": true,
"UserType": 'GD',
"IsPR": dto.ownerType == 'PR',
"IsPR": ownerType == 'PR',
//"Entity": null,
"Acknowledgment": true,
//"RoleDescription": null,
@@ -1,7 +1,6 @@
import { EventList } from "src/app/models/entiry/agenda/eventList"
import { EventListOutputDTO } from "../model/eventListDTOOutput"
function getTextInsideParentheses(inputString): string {
var startIndex = inputString.indexOf('(');
var endIndex = inputString.indexOf(')');
@@ -14,23 +13,57 @@ function getTextInsideParentheses(inputString): string {
export class ListEventMapper {
static toDomain(dto: EventListOutputDTO, calendarOwnerName: string, userId: string): EventList {
return dto.map((e) => ({
"HasAttachments": e.hasAttachments,
"IsAllDayEvent": e.isAllDayEvent,
"EventId": e.id,
"Subject": e.subject,
"Location": e.location,
"CalendarId": userId,
"CalendarName": e.category,
"StartDate": new Date(e.startDate) + '',
"EndDate": new Date(e.endDate)+ '',
"Schedule": calendarOwnerName,
"RequiredAttendees": null as any,
"OptionalAttendees": null as any,
"HumanDate": "2 semanas atrás" as any,
"TimeZone": getTextInsideParentheses(new Date(e.startDate)+ ''),
"IsPrivate": false as any
}))
return dto.map((e) => {
let category;
if(e.category == 1) {
category = 'Oficial'
} else {
category = 'Pessoal'
}
let ownerType;
if(e.ownerType == 1) {
ownerType = 'PR'
} else if(e.ownerType == 2) {
ownerType = 'MD'
} else if(e.ownerType == 3) {
ownerType = 'Other'
}
let type;
if(e.type == 1) {
type = 'Meeting'
} else {
type = 'Travel'
}
let status;
if(e.status == 1) {
status = 'Pending'
} else if(e.status == 2) {
status = 'Revision'
}
return {
"HasAttachments": e.hasAttachments,
"IsAllDayEvent": e.isAllDayEvent,
"EventId": e.id,
"Subject": e.subject,
"Location": e.location,
"CalendarId": userId,
"CalendarName": category,
"StartDate": new Date(e.startDate) + '',
"EndDate": new Date(e.endDate)+ '',
"Schedule": calendarOwnerName,
"RequiredAttendees": null as any,
"OptionalAttendees": null as any,
"HumanDate": "2 semanas atrás" as any,
"TimeZone": getTextInsideParentheses(new Date(e.startDate)+ ''),
"IsPrivate": false as any
}
})
}
static toDTO() {}
@@ -17,33 +17,58 @@ export class EventToApproveDetailsMapper {
constructor() {}
static toDomain(dto: EventOutputDTO): EventToApproveDetails {
const category = dto.category
let category;
if(dto.category == 1) {
category = 'Oficial'
} else {
category = 'Pessoal'
}
let color;
if(dto.ownerType != 'PR') {
// if(dto.ownerType != 'PR') {
if(dto.ownerType == 2) {
color = 'MDGPR'
} else {
color = 'PR'
}
let activityInstanceName;
let taskStatus;
if(dto.status == 'Pending') {
if(dto.status == 1) {
activityInstanceName = 'Aprovar evento'
} else if(dto.status == 'Revision') {
taskStatus = 'Pending' //////
} else if(dto.status == 2) {
activityInstanceName = 'Editar evento'
} else if (dto.status == 'Approved') {
taskStatus = 'Revision' //////
} else if (dto.status == 3) {
activityInstanceName = 'Evento Aprovado'
} else if (dto.status == 'Evento Rejeitado') {
taskStatus = 'Approved' //////
} else if (dto.status == 4) {
activityInstanceName = 'Declined'
} else if (dto.status == 'Evento comunicado') {
taskStatus = 'Declined' //////
} else if (dto.status == 5) {
activityInstanceName = 'Communicated'
} else if (dto.status == 'Comunicar evento') {
taskStatus = 'Communicated' //////
} else if (dto.status == 6) {
activityInstanceName = 'ToCommunicate'
taskStatus = 'ToCommunicate' //////
}
function EAttendeeType(num) {
if(num == 1) {
return 'Required'
} else if (num == 2) {
return 'Acknowledgment'
} else if (num == 3) {
return 'Optional'
}
}
return {
"serialNumber": dto.id,
"taskStatus": dto.status,
"taskStatus": taskStatus,
"originator": {
"email": dto.organizer.wxeMail,
"manager": "",
@@ -90,10 +115,10 @@ export class EventToApproveDetailsMapper {
...dto.attendees.map( e => ({
Name: e.name,
EmailAddress: e.emailAddress,
IsRequired: e.attendeeType == 'Required',
IsRequired: EAttendeeType(e.attendeeType) == 'Required',
UserType: "GD",
wxUserId: e.wxUserId,
attendeeType: e.attendeeType
attendeeType: EAttendeeType(e.attendeeType)
}))
],
//"EventOrganizer": "{\"$type\":\"GabineteDigital.k2RESTidentifier_EventPerson, GabineteDigital, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null\",\"EmailAddress\":\"agenda.mdgpr@gabinetedigital.local\",\"Name\":\"Agenda do Ministro e Director do Gabinete do PR\",\"IsRequired\":true}",