mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-21 13:55:51 +00:00
list event to approve
This commit is contained in:
@@ -0,0 +1,30 @@
|
|||||||
|
import { z } from 'zod';
|
||||||
|
|
||||||
|
const WorkflowInstanceDataFieldsSchema = z.object({
|
||||||
|
Agenda: z.string(),
|
||||||
|
EndDate: z.string(),
|
||||||
|
StartDate: z.string(),
|
||||||
|
Subject: z.string(),
|
||||||
|
Location: z.string(),
|
||||||
|
Status: z.string(),
|
||||||
|
IsAllDayEvent: z.boolean(),
|
||||||
|
InstanceId: z.string(),
|
||||||
|
originator: z.string().email(),
|
||||||
|
});
|
||||||
|
|
||||||
|
const EventToApproveListSchema = z.array(
|
||||||
|
z.object({
|
||||||
|
serialNumber: z.string(),
|
||||||
|
taskStatus: z.string(),
|
||||||
|
taskStartDate: z.string(),
|
||||||
|
taskReceiveDate: z.string(),
|
||||||
|
deadline: z.null(),
|
||||||
|
workflowDisplayName: z.string(),
|
||||||
|
activityInstanceName: z.string(),
|
||||||
|
totalDocuments: z.number(),
|
||||||
|
workflowInstanceDataFields: WorkflowInstanceDataFieldsSchema,
|
||||||
|
})
|
||||||
|
) ;
|
||||||
|
|
||||||
|
|
||||||
|
export type EventToApproveList = z.infer<typeof EventToApproveListSchema>
|
||||||
@@ -1,12 +1,16 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { AgendaDataService } from './agenda-data.service';
|
import { AgendaDataService } from './agenda-data.service';
|
||||||
import { map } from 'rxjs/operators';
|
import { catchError, map } from 'rxjs/operators';
|
||||||
import { ListEventMapper } from './mapper/EventListMapper';
|
import { ListEventMapper } from './mapper/EventListMapper';
|
||||||
import { EventMapper } from './mapper/EventDetailsMapper';
|
import { EventMapper } from './mapper/EventDetailsMapper';
|
||||||
import { Utils } from './utils';
|
import { Utils } from './utils';
|
||||||
import { EventInputDTO } from './agendaDataModels';
|
import { EventInputDTO } from './agendaDataModels';
|
||||||
import { Event } from 'src/app/models/event.model';
|
import { Event } from 'src/app/models/event.model';
|
||||||
import { SessionStore } from 'src/app/store/session.service';
|
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';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
@@ -34,10 +38,11 @@ export class AgendaDataRepositoryService {
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
eventToApprove({userId, startDate = null, endDate = null, status = 0, category= null, type= null, calendarOwnerName = ''}) {
|
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(
|
return this.agendaDataService.getEvents(userId, startDate = null, endDate = null, status, category= null, type= null).pipe(
|
||||||
map((response) => {
|
map((response) => {
|
||||||
return ListEventMapper.toDomain(response.data, calendarOwnerName, userId)
|
return EventListToApproveMapper.toDomain(response.data, calendarOwnerName, userId)
|
||||||
}
|
}
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
@@ -109,4 +114,15 @@ export class AgendaDataRepositoryService {
|
|||||||
console.log(error)
|
console.log(error)
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async deleteEvent1(eventId) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
const result = await this.agendaDataService.deleteEvent(eventId,false).toPromise()
|
||||||
|
return ok (result)
|
||||||
|
} catch (e) {
|
||||||
|
return err(e as HttpErrorResponse)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { HttpClient, HttpParams } from '@angular/common/http';
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { EventOutputDTO } from './model/eventDTOOutput';
|
import { EventOutputDTO } from './model/eventDTOOutput';
|
||||||
|
import { EventInputDTO } from './model/eventInputDTO';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
@@ -34,7 +35,7 @@ export class AgendaDataService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Events Endpoints
|
// Events Endpoints
|
||||||
createEvent(eventData: any): Observable<any> {
|
createEvent(eventData: EventInputDTO): Observable<any> {
|
||||||
return this.http.post<any>(`${this.baseUrl}/Events`, eventData);
|
return this.http.post<any>(`${this.baseUrl}/Events`, eventData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|
||||||
+4
-2
@@ -1,6 +1,6 @@
|
|||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
const EventToApproveList = z.object({
|
const EventToApproveList = z.array(z.object({
|
||||||
id: z.string().uuid(),
|
id: z.string().uuid(),
|
||||||
owner: z.string().nullable(),
|
owner: z.string().nullable(),
|
||||||
ownerType: z.enum(["PR", "MD", "Other"]),
|
ownerType: z.enum(["PR", "MD", "Other"]),
|
||||||
@@ -17,4 +17,6 @@ const EventToApproveList = z.object({
|
|||||||
isPrivate: z.boolean(),
|
isPrivate: z.boolean(),
|
||||||
isAllDayEvent: z.boolean(),
|
isAllDayEvent: z.boolean(),
|
||||||
status: z.enum(["Pending"])
|
status: z.enum(["Pending"])
|
||||||
});
|
}))
|
||||||
|
|
||||||
|
export type EventToApproveListOutputDTO = z.infer<typeof EventToApproveList>;
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
<ion-segment [(ngModel)]="segment" (ionChange)="segmentChanged($event)">
|
<ion-segment [(ngModel)]="segment" (ionChange)="segmentChanged($event)">
|
||||||
|
|
||||||
<ion-segment-button *ngFor="let calendars of eventService.calendarNamesAryPR; let i index" [value]="i === 'Meu calendario' ? 'Meu calendario' : i.OwnerUserId ">
|
<ion-segment-button *ngFor="let calendars of eventService.calendarNamesAryPR; let i index" [value]="i === 'Meu calendario' ? 'Meu calendario' : i.OwnerUserId ">
|
||||||
<div *ngIf="calendars == 'Meu calendario'">
|
<div *ngIf="calendars == 'Meu calendario'">
|
||||||
<!-- <span *ngIf="SessionStore.user.Profile == 'PR' ">PR</span>
|
<!-- <span *ngIf="SessionStore.user.Profile == 'PR' ">PR</span>
|
||||||
<span *ngIf="SessionStore.user.Profile == 'MDGPR' ">MDGPR</span>
|
<span *ngIf="SessionStore.user.Profile == 'MDGPR' ">MDGPR</span>
|
||||||
<span *ngIf="SessionStore.user.Profile != 'MDGPR' && SessionStore.user.Profile != 'PR' ">Minha agenda</span> -->
|
<span *ngIf="SessionStore.user.Profile != 'MDGPR' && SessionStore.user.Profile != 'PR' ">Minha agenda</span> -->
|
||||||
@@ -66,17 +66,17 @@
|
|||||||
<h3>{{event.workflowInstanceDataFields.Subject}}</h3>
|
<h3>{{event.workflowInstanceDataFields.Subject}}</h3>
|
||||||
<p *ngIf="toDateString(event.workflowInstanceDataFields.StartDate) != toDateString(event.workflowInstanceDataFields.EndDate)">{{event.workflowInstanceDataFields.StartDate | date: 'd/M/yy' }} - {{ event.workflowInstanceDataFields.EndDate | date: 'dd/M/yy'}} | {{event.workflowInstanceDataFields.Location}}</p>
|
<p *ngIf="toDateString(event.workflowInstanceDataFields.StartDate) != toDateString(event.workflowInstanceDataFields.EndDate)">{{event.workflowInstanceDataFields.StartDate | date: 'd/M/yy' }} - {{ event.workflowInstanceDataFields.EndDate | date: 'dd/M/yy'}} | {{event.workflowInstanceDataFields.Location}}</p>
|
||||||
<p *ngIf="toDateString(event.workflowInstanceDataFields.StartDate) == toDateString(event.workflowInstanceDataFields.EndDate)">{{event.workflowInstanceDataFields.StartDate | date: 'd/M/yy' }} | {{event.workflowInstanceDataFields.Location}}</p>
|
<p *ngIf="toDateString(event.workflowInstanceDataFields.StartDate) == toDateString(event.workflowInstanceDataFields.EndDate)">{{event.workflowInstanceDataFields.StartDate | date: 'd/M/yy' }} | {{event.workflowInstanceDataFields.Location}}</p>
|
||||||
|
|
||||||
<div *ngIf="event.activityInstanceName">
|
<div *ngIf="event.activityInstanceName">
|
||||||
<div class="label-event-type font-13-rem"> {{ event.activityInstanceName }} </div>
|
<div class="label-event-type font-13-rem"> {{ event.activityInstanceName }} </div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</ion-list>
|
</ion-list>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</ion-content>
|
</ion-content>
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import { EventsService } from 'src/app/services/events.service';
|
|||||||
import { EventoAprovacaoStore } from 'src/app/store/eventoaprovacao-store.service';
|
import { EventoAprovacaoStore } from 'src/app/store/eventoaprovacao-store.service';
|
||||||
import { environment } from 'src/environments/environment';
|
import { environment } from 'src/environments/environment';
|
||||||
import { AgendaDataRepositoryService } from 'src/app/services/Repositorys/Agenda/agenda-data-repository.service';
|
import { AgendaDataRepositoryService } from 'src/app/services/Repositorys/Agenda/agenda-data-repository.service';
|
||||||
|
import { EventToApproveList } from 'src/app/models/entiry/agenda/eventToApproveList';
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-event-list',
|
selector: 'app-event-list',
|
||||||
templateUrl: './event-list.page.html',
|
templateUrl: './event-list.page.html',
|
||||||
@@ -19,7 +20,7 @@ export class EventListPage implements OnInit {
|
|||||||
// [desktop] event list to approve
|
// [desktop] event list to approve
|
||||||
|
|
||||||
showLoader: boolean;
|
showLoader: boolean;
|
||||||
eventsList: any = []
|
eventsList: EventToApproveList = []
|
||||||
|
|
||||||
eventPerson: EventPerson;
|
eventPerson: EventPerson;
|
||||||
eventBody: EventBody;
|
eventBody: EventBody;
|
||||||
@@ -92,61 +93,34 @@ export class EventListPage implements OnInit {
|
|||||||
return new Date(e).toDateString()
|
return new Date(e).toDateString()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async LoadToApproveEvents() {
|
async LoadToApproveEvents() {
|
||||||
|
|
||||||
|
|
||||||
/* if(SessionStore.user.Profile == 'PR') {
|
|
||||||
return false
|
|
||||||
} */
|
|
||||||
|
|
||||||
this.showLoader = true;
|
this.showLoader = true;
|
||||||
|
|
||||||
const segment: any = this.segment
|
const segment: any = this.segment
|
||||||
|
let userId;
|
||||||
|
|
||||||
if(this.segment == 'Meu calendario') {
|
if(this.segment == 'Meu calendario') {
|
||||||
// color
|
|
||||||
|
|
||||||
if(SessionStore.user.Profile == 'PR') {
|
if(SessionStore.user.Profile == 'PR') {
|
||||||
this.color = 'pr'
|
this.color = 'pr'
|
||||||
} else {
|
} else {
|
||||||
this.color = 'mdgpr'
|
this.color = 'mdgpr'
|
||||||
}
|
}
|
||||||
|
userId = SessionStore.user.UserId
|
||||||
let genericEvents = await this.processes.eventsToApprove(SessionStore.user.UserId,'mobile agenda').toPromise()
|
|
||||||
try {
|
|
||||||
this.eventsList = this.sortService.sortArrayByDate(genericEvents).reverse();
|
|
||||||
} catch (error) {
|
|
||||||
this.eventsList = [];
|
|
||||||
this.showLoader = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
alert('my agenda')
|
|
||||||
this.eventoaprovacaostore.save(segment, this.eventsList)
|
|
||||||
|
|
||||||
let a = await this.AgendaDataRepositoryService.eventToApprove({userId: this.SessionStore.user.UserId}).toPromise()
|
|
||||||
|
|
||||||
|
|
||||||
} else if(segment) {
|
} else if(segment) {
|
||||||
// console.log('segment', segment)
|
|
||||||
|
|
||||||
this.color = 'pr'
|
this.color = 'pr'
|
||||||
let allEvents = await this.processes.eventsToApprove(segment,'agenda desktop').toPromise()
|
userId = segment
|
||||||
try {
|
|
||||||
this.eventsList = this.sortService.sortArrayByDate(allEvents).reverse();
|
|
||||||
} catch(error) {
|
|
||||||
this.eventsList = []
|
|
||||||
this.showLoader = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.eventsList = this.eventsList
|
|
||||||
this.eventsList = this.eventsList
|
|
||||||
this.eventoaprovacaostore.save(segment, this.eventsList)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.showLoader = false;
|
try {
|
||||||
|
let allEvents = await this.AgendaDataRepositoryService.eventToApproveList({userId}).toPromise()
|
||||||
|
this.eventsList = this.sortService.sortArrayByDate(allEvents).reverse();
|
||||||
|
this.eventoaprovacaostore.save(segment, this.eventsList)
|
||||||
|
} catch (e) {
|
||||||
|
this.eventsList = [];
|
||||||
|
this.showLoader = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async LoadToApproveEventsNoLoader() {
|
async LoadToApproveEventsNoLoader() {
|
||||||
|
|||||||
Reference in New Issue
Block a user