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
+2 -3
View File
@@ -247,8 +247,8 @@
</div> </div>
<div *ngFor="let event of day.events " class="EventListBox mb-10" > <div *ngFor="let event of day.events " class="EventListBox mb-10" >
<div class="d-flex content-{{event.profile}}-{{event.event.CalendarName}} mt-10 cursor-pointer width-100 " (click)="eventClicked(event)"
> <div class="d-flex content-{{event.profile}}-{{event.event.CalendarName}} mt-10 cursor-pointer width-100 " (click)="eventClicked(event)">
<div class="schedule-time" *ngIf="!event.event.IsAllDayEvent"> <div class="schedule-time" *ngIf="!event.event.IsAllDayEvent">
<div *ngIf="event.startMany && !event.middle" class="time-start labelb">Início</div> <div *ngIf="event.startMany && !event.middle" class="time-start labelb">Início</div>
@@ -266,7 +266,6 @@
<div *ngIf="event.middle" class="time-start">Todo </div> <div *ngIf="event.middle" class="time-start">Todo </div>
<div *ngIf="event.middle" class="time-end text-center">o dia</div> <div *ngIf="event.middle" class="time-end text-center">o dia</div>
<div *ngIf="!event.middle && !(event.endMany && !event.middle)" class="time-start">Todo </div> <div *ngIf="!event.middle && !(event.endMany && !event.middle)" class="time-start">Todo </div>
<div *ngIf="!event.middle && !(event.endMany && !event.middle)" class="time-end text-center">o dia </div> <div *ngIf="!event.middle && !(event.endMany && !event.middle)" class="time-end text-center">o dia </div>
+2 -1
View File
@@ -704,7 +704,8 @@ export class AgendaPage implements OnInit {
userId: selectedCalendar.wxUserId, userId: selectedCalendar.wxUserId,
calendarOwnerName: selectedCalendar.wxFullName, calendarOwnerName: selectedCalendar.wxFullName,
endDate: endTime.toISOString(), endDate: endTime.toISOString(),
startDate: startTime.toISOString() startDate: startTime.toISOString(),
status: -1
}) })
if(response.isOk()) { if(response.isOk()) {
@@ -48,12 +48,16 @@ export class AgendaDataService {
getEvents(userId: number, startDate: string, endDate: string, status: number, category: string, type: string): Observable<any> { getEvents(userId: number, startDate: string, endDate: string, status: number, category: string, type: string): Observable<any> {
let params = new HttpParams() let params = new HttpParams()
.set('UserId', userId) .set('UserId', userId)
.set('Status', status)
if(userId == null || userId == undefined) { if(userId == null || userId == undefined) {
throw('userId '+ userId) throw('userId '+ userId)
} }
if(status == -1 || status == undefined) {
params = params.set('status', status);
}
if (startDate !== null && startDate !== undefined) { if (startDate !== null && startDate !== undefined) {
params = params.set('startDate', startDate); params = params.set('startDate', startDate);
} }
@@ -15,6 +15,41 @@ export class EventMapper {
constructor() {} constructor() {}
static toDomain(dto: EventOutputDTO) { 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 { return {
"HasAttachments": dto.hasAttachments, "HasAttachments": dto.hasAttachments,
"EventComunicationId": 1682, "EventComunicationId": 1682,
@@ -26,7 +61,7 @@ export class EventMapper {
}, },
"Location": dto.location, "Location": dto.location,
"CalendarId": "", "CalendarId": "",
"CalendarName": dto.category, "CalendarName": category,
"StartDate": dto.startDate, "StartDate": dto.startDate,
"EndDate": dto.endDate, "EndDate": dto.endDate,
"EventType": "Single", "EventType": "Single",
@@ -35,14 +70,14 @@ export class EventMapper {
wxUserId: e.wxUserId, wxUserId: e.wxUserId,
EmailAddress: e.emailAddress, EmailAddress: e.emailAddress,
Name: e.name, Name: e.name,
IsRequired: e.attendeeType == 'Required', IsRequired: EAttendeeType(e.attendeeType) == 'Required',
UserType: "GD", UserType: "GD",
// "IsPR": false, // "IsPR": false,
attendeeType: e.attendeeType attendeeType: EAttendeeType(e.attendeeType)
// "RoleDescription": null, // "RoleDescription": null,
// "RoleId": 0 // "RoleId": 0
})), })),
"IsMeeting": dto.category, "IsMeeting": category,
"IsRecurring": dto.isRecurring, "IsRecurring": dto.isRecurring,
"IsAllDayEvent": dto.isAllDayEvent, "IsAllDayEvent": dto.isAllDayEvent,
"AppointmentState": 1, "AppointmentState": 1,
@@ -53,7 +88,7 @@ export class EventMapper {
"Name": dto.organizer.wxFullName, "Name": dto.organizer.wxFullName,
"IsRequired": true, "IsRequired": true,
"UserType": 'GD', "UserType": 'GD',
"IsPR": dto.ownerType == 'PR', "IsPR": ownerType == 'PR',
//"Entity": null, //"Entity": null,
"Acknowledgment": true, "Acknowledgment": true,
//"RoleDescription": null, //"RoleDescription": null,
@@ -1,7 +1,6 @@
import { EventList } from "src/app/models/entiry/agenda/eventList" import { EventList } from "src/app/models/entiry/agenda/eventList"
import { EventListOutputDTO } from "../model/eventListDTOOutput" import { EventListOutputDTO } from "../model/eventListDTOOutput"
function getTextInsideParentheses(inputString): string { function getTextInsideParentheses(inputString): string {
var startIndex = inputString.indexOf('('); var startIndex = inputString.indexOf('(');
var endIndex = inputString.indexOf(')'); var endIndex = inputString.indexOf(')');
@@ -14,23 +13,57 @@ function getTextInsideParentheses(inputString): string {
export class ListEventMapper { export class ListEventMapper {
static toDomain(dto: EventListOutputDTO, calendarOwnerName: string, userId: string): EventList { static toDomain(dto: EventListOutputDTO, calendarOwnerName: string, userId: string): EventList {
return dto.map((e) => ({
"HasAttachments": e.hasAttachments, return dto.map((e) => {
"IsAllDayEvent": e.isAllDayEvent,
"EventId": e.id, let category;
"Subject": e.subject, if(e.category == 1) {
"Location": e.location, category = 'Oficial'
"CalendarId": userId, } else {
"CalendarName": e.category, category = 'Pessoal'
"StartDate": new Date(e.startDate) + '', }
"EndDate": new Date(e.endDate)+ '',
"Schedule": calendarOwnerName, let ownerType;
"RequiredAttendees": null as any, if(e.ownerType == 1) {
"OptionalAttendees": null as any, ownerType = 'PR'
"HumanDate": "2 semanas atrás" as any, } else if(e.ownerType == 2) {
"TimeZone": getTextInsideParentheses(new Date(e.startDate)+ ''), ownerType = 'MD'
"IsPrivate": false as any } 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() {} static toDTO() {}
@@ -17,33 +17,58 @@ export class EventToApproveDetailsMapper {
constructor() {} constructor() {}
static toDomain(dto: EventOutputDTO): EventToApproveDetails { static toDomain(dto: EventOutputDTO): EventToApproveDetails {
const category = dto.category let category;
if(dto.category == 1) {
category = 'Oficial'
} else {
category = 'Pessoal'
}
let color; let color;
if(dto.ownerType != 'PR') { // if(dto.ownerType != 'PR') {
if(dto.ownerType == 2) {
color = 'MDGPR' color = 'MDGPR'
} else { } else {
color = 'PR' color = 'PR'
} }
let activityInstanceName; let activityInstanceName;
let taskStatus;
if(dto.status == 'Pending') { if(dto.status == 1) {
activityInstanceName = 'Aprovar evento' activityInstanceName = 'Aprovar evento'
} else if(dto.status == 'Revision') { taskStatus = 'Pending' //////
} else if(dto.status == 2) {
activityInstanceName = 'Editar evento' activityInstanceName = 'Editar evento'
} else if (dto.status == 'Approved') { taskStatus = 'Revision' //////
} else if (dto.status == 3) {
activityInstanceName = 'Evento Aprovado' activityInstanceName = 'Evento Aprovado'
} else if (dto.status == 'Evento Rejeitado') { taskStatus = 'Approved' //////
} else if (dto.status == 4) {
activityInstanceName = 'Declined' activityInstanceName = 'Declined'
} else if (dto.status == 'Evento comunicado') { taskStatus = 'Declined' //////
} else if (dto.status == 5) {
activityInstanceName = 'Communicated' activityInstanceName = 'Communicated'
} else if (dto.status == 'Comunicar evento') { taskStatus = 'Communicated' //////
} else if (dto.status == 6) {
activityInstanceName = 'ToCommunicate' 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 { return {
"serialNumber": dto.id, "serialNumber": dto.id,
"taskStatus": dto.status, "taskStatus": taskStatus,
"originator": { "originator": {
"email": dto.organizer.wxeMail, "email": dto.organizer.wxeMail,
"manager": "", "manager": "",
@@ -90,10 +115,10 @@ export class EventToApproveDetailsMapper {
...dto.attendees.map( e => ({ ...dto.attendees.map( e => ({
Name: e.name, Name: e.name,
EmailAddress: e.emailAddress, EmailAddress: e.emailAddress,
IsRequired: e.attendeeType == 'Required', IsRequired: EAttendeeType(e.attendeeType) == 'Required',
UserType: "GD", UserType: "GD",
wxUserId: e.wxUserId, 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}", //"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}",
@@ -18,7 +18,7 @@ const CommentSchema = z.object({
const AttendeeSchema = z.object({ const AttendeeSchema = z.object({
id: z.string(), id: z.string(),
name: z.string(), name: z.string(),
attendeeType: z.enum(["Required", "Acknowledgment", "Optional"]), attendeeType: z.enum(["Required", "Acknowledgment", "Optional"]), // ["Required", "Acknowledgment", "Optional"] = [1,2,3]
emailAddress: z.string(), emailAddress: z.string(),
wxUserId: z.number(), wxUserId: z.number(),
}); });
@@ -50,14 +50,14 @@ const EventRecurrenceSchema = z.object({
export const EventOutputDTOSchema = z.object({ export const EventOutputDTOSchema = z.object({
id: z.string(), id: z.string(),
owner: OwnerSchema, owner: OwnerSchema,
ownerType: z.enum(["PR", "MD", "Other"]), ownerType: z.number(), // ["PR", "MD", "Other"] = [1,2,3],
subject: z.string(), subject: z.string(),
body: z.string(), body: z.string(),
location: z.string(), location: z.string(),
startDate: z.string(), startDate: z.string(),
endDate: z.string(), endDate: z.string(),
type: z.string(), type: z.string(),
category: z.enum(['Oficial', 'Pessoal']), category: z.number(), // ['Oficial', 'Pessoal'] = [1, 2]
attendees: z.array(AttendeeSchema), attendees: z.array(AttendeeSchema),
isRecurring: z.boolean(), isRecurring: z.boolean(),
eventRecurrence: EventRecurrenceSchema, eventRecurrence: EventRecurrenceSchema,
@@ -67,7 +67,7 @@ export const EventOutputDTOSchema = z.object({
isPrivate: z.boolean(), isPrivate: z.boolean(),
isAllDayEvent: z.boolean(), isAllDayEvent: z.boolean(),
organizer: OrganizerSchema, organizer: OrganizerSchema,
status: z.enum(['Pending', 'Revision']), status: z.number(), // ['Pending', 'Revision', 'Approved', 'Declined', 'Communicated', 'ToCommunicate'] = [1, 2, 3, 4, 5, 6]
}); });
export type EventOutputDTO = z.infer<typeof EventOutputDTOSchema> export type EventOutputDTO = z.infer<typeof EventOutputDTOSchema>
@@ -3,20 +3,22 @@ import { z } from 'zod';
const EventSchema = z.array(z.object({ const EventSchema = z.array(z.object({
id: z.string(), id: z.string(),
owner: z.string().nullable(), owner: z.string().nullable(),
ownerType: z.enum(['MD','PR', 'Other']), // Assuming "MD" is the only valid option based on provided data ownerType: z.number(),// ['MD','PR', 'Other'] // Assuming "MD" is the only valid option based on provided data
subject: z.string(), subject: z.string(),
body: z.string(), body: z.string(),
location: z.string(), location: z.string(),
startDate: z.string().datetime({ offset: true }), startDate: z.string().datetime({ offset: true }),
endDate: z.string().datetime({ offset: true }), endDate: z.string().datetime({ offset: true }),
type: z.enum(['Meeting', 'Travel']), type: z.number(), // ['Meeting', 'Travel'] = [1,2 ]
category: z.enum(['Oficial', 'Pessoal']), // Assuming "Oficial" is the only valid option based on provided data // category: z.enum(['Oficial', 'Pessoal']), // Assuming "Oficial" is the only valid option based on provided data
category: z.number(),
isRecurring: z.boolean(), isRecurring: z.boolean(),
eventRecurrence: z.null(), eventRecurrence: z.null(),
hasAttachments: z.boolean(), hasAttachments: z.boolean(),
isPrivate: z.boolean(), isPrivate: z.boolean(),
isAllDayEvent: z.boolean(), isAllDayEvent: z.boolean(),
status: z.enum(['Approved']), // Assuming "Approved" is the only valid option based on provided data // status: z.enum(['Approved']), // Assuming "Approved" is the only valid option based on provided data
status: z.number(), // Assuming "Approved" is the only valid option based on provided data
})) }))
export type EventListOutputDTO = z.infer<typeof EventSchema>; export type EventListOutputDTO = z.infer<typeof EventSchema>;