edit event to aprove done

This commit is contained in:
Eudes Inácio
2024-05-31 12:50:25 +01:00
19 changed files with 652 additions and 144 deletions
@@ -1,12 +1,17 @@
import { Injectable } from '@angular/core';
import { AgendaDataService } from './agenda-data.service';
import { map } from 'rxjs/operators';
import { catchError, map } from 'rxjs/operators';
import { ListEventMapper } from './mapper/EventListMapper';
import { EventMapper } from './mapper/EventDetailsMapper';
import { Utils } from './utils';
import { EventInputDTO } from './agendaDataModels';
import { Event } from 'src/app/models/event.model';
import { SessionStore } from 'src/app/store/session.service';
import { EventListToApproveMapper } from './mapper/eventToApproveListMapper';
import { err, ok } from 'neverthrow';
import { of } from 'rxjs';
import { HttpErrorResponse } from '@angular/common/http';
import { EventToApproveDetailsMapper } from './mapper/EventToApproveDetailsMapper';
@Injectable({
providedIn: 'root'
@@ -18,26 +23,52 @@ export class AgendaDataRepositoryService {
private utils: Utils
) { }
getEventById(id: string) {
return this.agendaDataService.getEvent(id).pipe(
map((response) => {
return EventMapper.toDomain(response.data)
})
)
async getEventById(id: string) {
try {
const result = await this.agendaDataService.getEvent(id).pipe(
map((response) => {
return EventMapper.toDomain(response.data)
})
).toPromise()
return ok (result)
} catch (e) {
return err(e as HttpErrorResponse)
}
}
EventList({ userId = null, startDate = null, endDate = null, status = 2, category = null, type = null, calendarOwnerName = '' }) {
return this.agendaDataService.getEvents(userId, startDate, endDate, status, category, type).pipe(
map((response) => {
return ListEventMapper.toDomain(response.data, calendarOwnerName, userId)
}
))
async getEventToApproveById(id: string) {
try {
const result = await this.agendaDataService.getEvent(id).pipe(
map((response) => {
return EventToApproveDetailsMapper.toDomain(response.data)
})
).toPromise()
return ok (result)
} catch (e) {
return err(e as HttpErrorResponse)
}
}
eventToApprove({ userId, startDate = null, endDate = null, status = 0, category = null, type = null, calendarOwnerName = '' }) {
return this.agendaDataService.getEvents(userId, startDate = null, endDate = null, status, category = null, type = null).pipe(
async EventList({userId = null, startDate = null, endDate = null, status= 2, category= null, type= null, calendarOwnerName = ''}) {
try {
const result = await this.agendaDataService.getEvents(userId, startDate, endDate, status, category, type).pipe(
map((response) => {
return ListEventMapper.toDomain(response.data, calendarOwnerName, userId)
}
)).toPromise()
return ok (result)
} catch (e) {
return err(e as HttpErrorResponse)
}
}
eventToApproveList({userId, startDate = null, endDate = null, status = 0, category= null, type= null, calendarOwnerName = ''}) {
return this.agendaDataService.getEvents(userId, startDate = null, endDate = null, status, category= null, type= null).pipe(
map((response) => {
return ListEventMapper.toDomain(response.data, calendarOwnerName, userId)
return EventListToApproveMapper.toDomain(response.data, calendarOwnerName, userId)
}
))
}
@@ -68,13 +99,13 @@ export class AgendaDataRepositoryService {
return this.agendaDataService.createEvent(eventInput)
}
updateEvent(eventId, eventData: Event, CalendarName, documents) {
updateEvent(eventId, eventData) {
console.log(eventData.StartDate)
console.log(eventData.EndDate)
let eventInput = {
subject: eventData.Subject,
body: eventData.Body.Text,
body: eventData.Body.Text || eventData.Body,
location: eventData.Location,
startDate: eventData.StartDate,
endDate: eventData.EndDate,
@@ -103,4 +134,19 @@ export class AgendaDataRepositoryService {
removeEventAttachment(eventId,attachmentData) {
return this.agendaDataService.removeEventAttachment(eventId,attachmentData);
}
async deleteEvent1(eventId) {
try {
const result = await this.agendaDataService.deleteEvent(eventId,false).toPromise()
return ok (result)
} catch (e) {
return err(e as HttpErrorResponse)
}
}
eventToaprovalStatus(eventId, status) {
return this.agendaDataService.updateEventStatus(eventId,this.utils.statusEventAproval(status))
}
}
@@ -2,6 +2,7 @@ import { HttpClient, HttpParams } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { EventOutputDTO } from './model/eventDTOOutput';
import { EventInputDTO } from './model/eventInputDTO';
@Injectable({
providedIn: 'root'
@@ -34,14 +35,23 @@ export class AgendaDataService {
}
// Events Endpoints
createEvent(eventData: any): Observable<any> {
createEvent(eventData: EventInputDTO): Observable<any> {
return this.http.post<any>(`${this.baseUrl}/Events`, eventData);
}
getEvents(userId: number, startDate: string, endDate: string, status: number, category: string, type: string): Observable<any> {
const params = new HttpParams()
let params = new HttpParams()
.set('UserId', userId)
.set('Status', status)
if (startDate !== null && startDate !== undefined) {
params = params.set('startDate', startDate);
}
if (endDate !== null && endDate !== undefined) {
params = params.set('endDate', endDate);
}
return this.http.get<any>(`${this.baseUrl}/Events`, { params });
}
@@ -0,0 +1,102 @@
import { EventToApproveDetails } from "src/app/models/entiry/agenda/eventToApproveDetails"
import { EventOutputDTO } from "../model/eventDTOOutput"
export class EventToApproveDetailsMapper {
constructor() {}
static toDomain(dto: EventOutputDTO): EventToApproveDetails {
return {
"serialNumber": dto.id,
"taskStatus": dto.status,
"originator": {
"email": dto.organizer.wxeMail,
"manager": "",
"displayName": "",
// "fqn": "K2:gabinetedigital\\dlima",
// "username": "gabinetedigital\\dlima"
},
// "isDelegated": false,
// "isExtended": false,
// "hasTakenAcknowledge": false,
// "actions": [
// "Reenviar",
// "Descartar"
// ],
"activityInstanceName": "Editar Evento",
// "workflowInstanceFolio": "MTk4",
// "taskStartDate": "2024-04-10T14:30:39.58",
// "deadline": null,
// "workflowID": 24744,
// "workflowInstanceID": 47026,
//"workflowName": "Agenda\\Agenda Oficial MDGPR",
"workflowDisplayName": "Agenda Oficial MDGPR",
//"formURL": "http://bpmdev.gabinetedigital.local/Runtime/Runtime/Form/Exchange+Calendar+Meeting+Edition/?SerialNo=47026_169&ProcessInstanceID=&InstanceId=",
"workflowInstanceDataFields": {
"Body": "safsafas",
"Location": "Luanda",
"Subject": "Event to approve MD",
"StartDate": "2024-04-10 00:00:00",
"EndDate": "2024-04-11 05:00: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",
//"TimeZone": "",
"Agenda": "Oficial",
"EventType": "Reunião",
//"EventID": "",
//"HasAttachments": true,
"ParticipantsList": [
...dto.attendees.map( e => ({
Name: e.name,
EmailAddress: e.emailAddress,
IsRequired: e.attendeeType == '0' ? true : false,
UserType: "GD",
}))
],
//"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 => ({
DocId: '',
Description: '',
Stakeholders: '',
CreateDate: '',
ApplicationId: 0,
}))
}
}
static toDTO(data: any): any {
return {}
}
}
@@ -0,0 +1,85 @@
import { EventList } from "src/app/models/entiry/agenda/eventList"
import { EventListOutputDTO } from "../model/eventListDTOOutput"
import { EventToApproveListOutputDTO } from "../model/eventToApproveListOutputDTO";
import { EventToApproveList } from "src/app/models/entiry/agenda/eventToApproveList";
function getTextInsideParentheses(inputString): string {
var startIndex = inputString.indexOf('(');
var endIndex = inputString.indexOf(')');
if (startIndex !== -1 && endIndex !== -1) {
return inputString.substring(startIndex + 1, endIndex);
} else {
return null;
}
}
export class EventListToApproveMapper {
static toDomain(dto: EventToApproveListOutputDTO, calendarOwnerName: string, userId: string): EventToApproveList {
return dto.map((e) => ({
serialNumber: e.id,
taskStatus: e.status,
taskStartDate: e.startDate,
taskReceiveDate: e.startDate,
deadline: null,
workflowDisplayName: "",
activityInstanceName: "",
totalDocuments: 0,
workflowInstanceDataFields: {
Agenda: e.category,
EndDate: e.endDate,
StartDate: e.startDate,
Subject: e.body,
Location: e.location,
Status: e.status,
IsAllDayEvent: e.isAllDayEvent,
InstanceId: "",
originator: ""
}
}))
}
static toDTO() {}
}
// "serialNumber": "47315_184",
// "taskStatus": "Open",
// "taskStartDate": "2024-04-24T11:27:12.527",
// "taskReceiveDate": "2024-04-24T11:29:17.76",
// "deadline": null,
// "workflowDisplayName": "Agenda Oficial PR",
// "activityInstanceName": "Comunicar Evento",
// "totalDocuments": 0,
// "workflowInstanceDataFields": {
// "Agenda": "Oficial",
// "EndDate": "2024-04-25 11:30:00",
// "StartDate": "2024-04-24 11:30:00",
// "Subject": "Event 2 After MERGE",
// "Location": "lUANDA",
// "Status": "Active",
// "IsAllDayEvent": false,
// "InstanceId": "AAMkADVhOGY3ZDQzLTg4ZGEtNDYxMC1iMzc5LTJkMDgwNjMxOWFlZQBGAAAAAABEDW9nKs69TKQcVqQURj8YBwBR2HR2eO7pSpNdD9cc70l+AAAAAAFKAABR2HR2eO7pSpNdD9cc70l+AACK2Od9AAA=",
// "originator": "dlima@gabinetedigital.local"
// }
// {
// "id": "5b170417-df57-4b5c-9a5e-3c73726a116d",
// "owner": null,
// "ownerType": "PR",
// "subject": "string",
// "body": "string",
// "location": "string",
// "startDate": "2024-05-29T00:00:00+00:00",
// "endDate": "2024-05-29T23:59:00+00:00",
// "type": "Meeting",
// "category": "Oficial",
// "isRecurring": false,
// "eventRecurrence": null,
// "hasAttachments": false,
// "isPrivate": false,
// "isAllDayEvent": true,
// "status": "Pending"
// }
@@ -0,0 +1,42 @@
import { z } from 'zod';
const attendeeSchema = z.object({
name: z.string(),
emailAddress: z.string(),
attendeeType: z.number(),
wxUserId: z.number()
});
const attachmentSchema = z.object({
docId: z.number(),
sourceName: z.string(),
description: z.string(),
applicationId: z.number()
});
const recurrenceSchema = z.object({
frequency: z.number(),
occurrences: z.number()
});
const EventInputDTOSchema = z.object({
userId: z.number(),
ownerType: z.number(),
subject: z.string(),
body: z.string(),
location: z.string(),
startDate: z.string().datetime(),
endDate: z.string().datetime(),
type: z.number(),
category: z.number(),
attendees: z.array(attendeeSchema),
attachments: z.array(attachmentSchema),
recurrence: recurrenceSchema,
organizerId: z.number(),
isAllDayEvent: z.boolean()
});
export type EventInputDTO = z.infer<typeof EventInputDTOSchema>
@@ -1,6 +1,6 @@
import { z } from "zod";
const EventToApproveList = z.object({
const EventToApproveList = z.array(z.object({
id: z.string().uuid(),
owner: z.string().nullable(),
ownerType: z.enum(["PR", "MD", "Other"]),
@@ -17,4 +17,6 @@ const EventToApproveList = z.object({
isPrivate: z.boolean(),
isAllDayEvent: z.boolean(),
status: z.enum(["Pending"])
});
}))
export type EventToApproveListOutputDTO = z.infer<typeof EventToApproveList>;
@@ -94,4 +94,15 @@ export class Utils {
}
});
}
statusEventAproval(type) {
var selectedType = {
'Pending': 0,
'Revision':1,
'Approved':2,
"Declined":3,
"Communicated":4
}
return selectedType[type];
}
}
+1 -1
View File
@@ -44,7 +44,7 @@ export class DateService {
}
fixDate(res: EventList) {
fixDate(res: EventList): any {
if(res.IsAllDayEvent && this.deferenceBetweenDays(new Date(res.StartDate), new Date(res.EndDate)) >= 1) {
const date = new Date(res.EndDate);