2024-05-30 12:03:30 +01:00
import { EventToApproveDetails } from "src/app/models/entiry/agenda/eventToApproveDetails"
import { EventOutputDTO } from "../model/eventDTOOutput"
2024-06-13 16:47:51 +01:00
import { EAttendeeType , EEventCategory , EEventOwnerType , EEventStatus } from "../model/enums" ;
2024-05-30 12:03:30 +01:00
2024-06-03 13:28:18 +01:00
function getTextInsideParentheses ( inputString ) {
var startIndex = inputString . indexOf ( '(' ) ;
var endIndex = inputString . indexOf ( ')' ) ;
if ( startIndex !== - 1 && endIndex !== - 1 ) {
return inputString . substring ( startIndex + 1 , endIndex ) ;
} else {
return null ;
}
}
2024-05-30 12:03:30 +01:00
export class EventToApproveDetailsMapper {
constructor ( ) { }
static toDomain ( dto : EventOutputDTO ) : EventToApproveDetails {
2024-06-13 16:01:33 +01:00
let category ;
2024-06-13 16:47:51 +01:00
if ( dto . category == EEventCategory . Oficial ) {
2024-06-13 16:01:33 +01:00
category = 'Oficial'
} else {
category = 'Pessoal'
}
2024-05-31 12:49:49 +01:00
let color ;
2024-06-13 16:01:33 +01:00
// if(dto.ownerType != 'PR') {
2024-06-13 16:47:51 +01:00
let ownerType ;
if ( dto . ownerType == EEventOwnerType . PR ) {
ownerType = 'PR'
} else if ( dto . ownerType == EEventOwnerType . MD ) {
ownerType = 'MD'
} else if ( dto . ownerType == EEventOwnerType . Others ) {
ownerType = 'Other'
2024-05-31 12:49:49 +01:00
}
2024-06-13 16:47:51 +01:00
2024-05-31 12:49:49 +01:00
let activityInstanceName ;
2024-06-13 16:01:33 +01:00
let taskStatus ;
2024-05-31 12:49:49 +01:00
2024-06-13 16:47:51 +01:00
if ( dto . status == EEventStatus . Pending ) {
2024-06-11 16:39:56 +01:00
activityInstanceName = 'Aprovar evento'
2024-06-13 16:01:33 +01:00
taskStatus = 'Pending' //////
2024-06-13 16:47:51 +01:00
} else if ( dto . status == EEventStatus . Revision ) {
2024-06-11 16:39:56 +01:00
activityInstanceName = 'Editar evento'
2024-06-13 16:01:33 +01:00
taskStatus = 'Revision' //////
2024-06-13 16:47:51 +01:00
} else if ( dto . status == EEventStatus . Approved ) {
2024-06-11 16:39:56 +01:00
activityInstanceName = 'Evento Aprovado'
2024-06-13 16:01:33 +01:00
taskStatus = 'Approved' //////
2024-06-13 16:47:51 +01:00
} else if ( dto . status == EEventStatus . Declined ) {
2024-06-11 16:39:56 +01:00
activityInstanceName = 'Declined'
2024-06-13 16:01:33 +01:00
taskStatus = 'Declined' //////
2024-06-13 16:47:51 +01:00
} else if ( dto . status == EEventStatus . Communicated ) {
2024-06-11 16:39:56 +01:00
activityInstanceName = 'Communicated'
2024-06-13 16:01:33 +01:00
taskStatus = 'Communicated' //////
2024-06-13 16:47:51 +01:00
} else if ( dto . status == EEventStatus . ToCommunicate ) {
2024-06-11 16:39:56 +01:00
activityInstanceName = 'ToCommunicate'
2024-06-13 16:01:33 +01:00
taskStatus = 'ToCommunicate' //////
2024-05-31 12:49:49 +01:00
}
2024-06-13 16:47:51 +01:00
function FEAttendeeType ( num ) {
if ( num == EAttendeeType . Required ) {
2024-06-13 16:01:33 +01:00
return 'Required'
2024-06-13 16:47:51 +01:00
} else if ( num == EAttendeeType . Acknowledgment ) {
2024-06-13 16:01:33 +01:00
return 'Acknowledgment'
2024-06-13 16:47:51 +01:00
} else if ( num == EAttendeeType . Optional ) {
2024-06-13 16:01:33 +01:00
return 'Optional'
}
}
2024-05-30 12:03:30 +01:00
return {
"serialNumber" : dto . id ,
2024-06-13 16:01:33 +01:00
"taskStatus" : taskStatus ,
2024-05-30 12:03:30 +01:00
"originator" : {
"email" : dto . organizer . wxeMail ,
"manager" : "" ,
"displayName" : "" ,
// "fqn": "K2:gabinetedigital\\dlima",
// "username": "gabinetedigital\\dlima"
} ,
// "isDelegated": false,
// "isExtended": false,
// "hasTakenAcknowledge": false,
// "actions": [
// "Reenviar",
// "Descartar"
// ],
2024-05-31 12:49:49 +01:00
"activityInstanceName" : activityInstanceName ,
2024-05-30 12:03:30 +01:00
// "workflowInstanceFolio": "MTk4",
// "taskStartDate": "2024-04-10T14:30:39.58",
// "deadline": null,
// "workflowID": 24744,
// "workflowInstanceID": 47026,
//"workflowName": "Agenda\\Agenda Oficial MDGPR",
2024-05-31 12:49:49 +01:00
"workflowDisplayName" : ` Agenda ${ category } ${ color } ` ,
2024-05-30 12:03:30 +01:00
//"formURL": "http://bpmdev.gabinetedigital.local/Runtime/Runtime/Form/Exchange+Calendar+Meeting+Edition/?SerialNo=47026_169&ProcessInstanceID=&InstanceId=",
"workflowInstanceDataFields" : {
2024-05-31 13:05:53 +01:00
"Body" : dto . body ,
"Location" : dto . location ,
"Subject" : dto . subject ,
"StartDate" : dto . startDate ,
"EndDate" : dto . endDate ,
2024-05-30 12:03:30 +01:00
// "Participants": "evilarinho@gabinetedigital.local",
// "CC": "",
// "ReviewUserComment": "{\r\n \"option\": \"save\",\r\n \"note\": \"\"\r\n}",
// "Role": 100000011,
// "MDName": "Eduardo Vilarinho",
// "MDEmail": "evilarinho@gabinetedigital.local",
// "OriginatorComments": "",
"Status" : "Active" ,
2024-06-03 13:28:18 +01:00
"TimeZone" : getTextInsideParentheses ( new Date ( dto . startDate ) + '' ) ,
2024-05-31 13:33:10 +01:00
"Agenda" : category ,
2024-05-30 12:03:30 +01:00
"EventType" : "Reunião" ,
//"EventID": "",
//"HasAttachments": true,
"ParticipantsList" : [
. . . dto . attendees . map ( e = > ( {
Name : e.name ,
EmailAddress : e.emailAddress ,
2024-06-13 16:47:51 +01:00
IsRequired : FEAttendeeType ( e . attendeeType ) == 'Required' ,
2024-05-30 12:03:30 +01:00
UserType : "GD" ,
2024-06-04 09:38:11 +01:00
wxUserId : e.wxUserId ,
2024-06-13 16:47:51 +01:00
attendeeType : FEAttendeeType ( e . attendeeType )
2024-05-30 12:03:30 +01:00
} ) )
] ,
//"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}",
"CreateEvent" : "" ,
"IsAllDayEvent" : false ,
//"SerializedItem": "",
//"MDwxUserID": 198,
//"DeserializedItem": "",
//"Message": "Foi adicionado para a sua agenda um evento com o assunto: Event to approve MD, para a vossa aprovação",
//"InstanceId": "AGD_dlima_2024-04-10_14:30:39.453",
//"For Each Result": "",
//"For Each Index": 0,
//"Header": "",
//"RecurringString": "",
//"LastOccurrence": "",
//"OccurrenceType": "-1",
//"SerialNumber": "",
//"For Each Result 1": "false",
//"For Each Index 1": 0,
//"UserEmail": "",
//"LastActivInstanceID": "78",
"IsRecurring" : false ,
//"CalendarId": "AQMkAGVhZWZkOGM0LWNiZjMtNGE4Ny05NTY4LWZjMTEANTE2MWU4YmUALgAAAwkDRuPtBKJItLDcu6efhYABACLK19NpGvtHh8oQYZPTW2sAAAIBSgAAAA==",
//"wxUserID": 312
} ,
"totalDocuments" : null ,
"Documents" : null ,
"PrivateMessage" : null ,
Attachments : dto.attachments.map ( e = > ( {
2024-06-04 09:38:11 +01:00
id : e.id ,
2024-05-31 15:49:36 +01:00
DocId : e.docId ,
Description : e.sourceName ,
2024-05-30 12:03:30 +01:00
Stakeholders : '' ,
CreateDate : '' ,
2024-05-31 15:49:36 +01:00
ApplicationId : e.applicationId ,
2024-05-30 12:03:30 +01:00
} ) )
}
}
static toDTO ( data : any ) : any {
return { }
}
}