mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
502 lines
15 KiB
TypeScript
502 lines
15 KiB
TypeScript
import { Component, OnInit } from '@angular/core';
|
|
import { AlertController, AnimationController, ModalController, NavParams } from '@ionic/angular';
|
|
import { Attachment } from 'src/app/models/attachment.model';
|
|
import { EventPerson } from 'src/app/models/eventperson.model';
|
|
import { SearchDocument } from 'src/app/models/search-document';
|
|
import { AttendeesPage } from 'src/app/pages/events/attendees/attendees.page';
|
|
import { SearchPage } from 'src/app/pages/search/search.page';
|
|
import { AttachmentsService } from 'src/app/services/attachments.service';
|
|
import { EventsService } from 'src/app/services/events.service';
|
|
import { ProcessesService } from 'src/app/services/processes.service';
|
|
import { Event, EventToApproveEdit } from '../../../models/event.model';
|
|
import { BadRequestPage } from '../../popover/bad-request/bad-request.page';
|
|
import { SuccessMessagePage} from '../../popover/success-message/success-message.page';
|
|
|
|
@Component({
|
|
selector: 'app-edit-event',
|
|
templateUrl: './edit-event.page.html',
|
|
styleUrls: ['./edit-event.page.scss'],
|
|
})
|
|
export class EditEventToApproveComponent implements OnInit {
|
|
|
|
serialNumber: string
|
|
loadedAttachments: Attachment[]= []
|
|
|
|
eventProcess = {
|
|
serialNumber: "",
|
|
taskStartDate: "",
|
|
workflowInstanceDataFields:{
|
|
Body: "",
|
|
IsRecurring: false,
|
|
ParticipantsList: [],
|
|
Agenda: '',
|
|
EndDate: '',
|
|
Location: '',
|
|
Subject: '',
|
|
InstanceId: '',
|
|
EventType: '',
|
|
StartDate: '',
|
|
MDEmail: '',
|
|
MDName: '',
|
|
IsAllDayEvent: '',
|
|
Message: ''
|
|
}
|
|
}
|
|
|
|
// event ={
|
|
// "serialNumber":"9073_118",
|
|
// "originator":{
|
|
// "email":"gilson.manuel@gabinetedigital.local",
|
|
// "manager":"",
|
|
// "displayName":"",
|
|
// "fqn":"K2:GABINETEDIGITAL\\gilson.manuel",
|
|
// "username":"GABINETEDIGITAL\\gilson.manuel"
|
|
// },
|
|
// "actions":null,
|
|
// "workflowInstanceFolio":"Final do sprint",
|
|
// "taskStartDate":"4/30/2021 9:06:48 AM",
|
|
// "workflowID":4365,
|
|
// "workflowInstanceID":9073,
|
|
// "workflowName":"MDGPR\\Agenda Oficial MDGPR",
|
|
// "workflowDisplayName":"Agenda Oficial MDGPR",
|
|
// "formURL":"http://bpmdev.gabinetedigital.local/Runtime/Runtime/Form/Exchange+Calendar+Meeting+Approval/?SerialNo=9073_118",
|
|
// "workflowInstanceDataFields": {
|
|
// "Body":"Será fechado o sprint 1 - 26 Abr - 30 Abr",
|
|
// "Location":"Equilibrium - Sala de reuniões",
|
|
// "Subject":"Final do sprint",
|
|
// "StartDate":"2021-04-30T15:00:00",
|
|
// "EndDate":"2021-04-30T15:30:00",
|
|
// "Participants":"gilson.manuel@gabinetedigital.local;tiago.kayaya@gabinetedigital.local;solange.vandunem@gabinetedigital.local",
|
|
// "CC":"",
|
|
// "ReviewerComments":"teste",
|
|
// "Role":0,
|
|
// "MDName":"Paulo Pinto",
|
|
// "MDEmail":"paulo.pinto@gabinetedigital.local",
|
|
// "PREmail":"",
|
|
// "OriginatorComments":"",
|
|
// "Status":"Active",
|
|
// "TimeZone":"W. Central Africa Standard Time",
|
|
// "Agenda":"Oficial",
|
|
// "EventType":"Reunião",
|
|
// "EventID":"",
|
|
// "IsRecurring":false,
|
|
// "ParticipantsList":[
|
|
// {
|
|
// "$type":null,
|
|
// "EmailAddress":"gilson.manuel@gabinetedigital.local",
|
|
// "Name":"Gilson Manuel",
|
|
// "IsRequired":true
|
|
// },
|
|
// {
|
|
// "$type":null,
|
|
// "EmailAddress":"tiago.kayaya@gabinetedigital.local",
|
|
// "Name":"Tiago Kayaya",
|
|
// "IsRequired":true
|
|
// },
|
|
// {
|
|
// "$type":null,
|
|
// "EmailAddress":"solange.vandunem@gabinetedigital.local",
|
|
// "Name":"Solange Van-Dúnem",
|
|
// "IsRequired":true
|
|
// }
|
|
// ],
|
|
// "EventOrganizer":"{\"$type\":\"Gabinete.k2RESTidentifier_EventPerson, Gabinete, 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":"{\"$type\":\"GabineteDigitalV4.k2RESTidentifier_NotificationData[], GabineteDigitalV4, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null\",\"$values\":[{\"$type\":\"GabineteDigitalV4.k2RESTidentifier_NotificationData, GabineteDigitalV4, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null\",\"Service\":\"gabinete-digital\",\"Object\":\"event-list\",\"idObject\":\"9073_118\"}]}",
|
|
// "MDwxUserID":261,
|
|
// "DeserializedItem":"{\"$type\":\"GabineteDigitalV4.k2RESTidentifier_NotificationData, GabineteDigitalV4, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null\",\"Service\":\"gabinete-digital\",\"Object\":\"event-list\",\"idObject\":\"9073_118\"}",
|
|
// "Message":"Foi actualizado o",
|
|
// "InstanceId":"R0RfR0FCSU5FVEVESUdJVEFMXGdpbHNvbi5tYW51ZWxfMjAyMS0wNC0zMCAwODowNDoyN1o=",
|
|
// "For Each Result":"",
|
|
// "For Each Index":0
|
|
// }
|
|
// }
|
|
|
|
show = false
|
|
|
|
postEvent: Event;
|
|
isRecurring:string;
|
|
isEventEdited: boolean;
|
|
segment:string = "true";
|
|
profile:string;
|
|
eventAttendees: EventPerson[];
|
|
|
|
loadedEventAttachments: Attachment[];
|
|
taskParticipants: any = [];
|
|
taskParticipantsCc: any = [];
|
|
adding: "intervenient" | "CC" = "intervenient";
|
|
|
|
Location = ''
|
|
|
|
showAttendees = false;
|
|
|
|
InstanceId: string
|
|
|
|
constructor(
|
|
private modalController: ModalController,
|
|
private navParams: NavParams,
|
|
private eventsService: EventsService,
|
|
public alertController: AlertController,
|
|
private attachmentsService: AttachmentsService,
|
|
private processes:ProcessesService,
|
|
private animationController: AnimationController
|
|
) {
|
|
|
|
this.serialNumber = this.navParams.get('serialNumber');
|
|
// this.profile = this.navParams.get('profile');
|
|
|
|
this.isEventEdited = false;
|
|
|
|
|
|
this.getTask()
|
|
|
|
}
|
|
|
|
async getTask() {
|
|
console.log('this.eventProcess', this.eventProcess);
|
|
|
|
const result = await this.processes.GetTask(this.serialNumber).subscribe( result =>{
|
|
this.eventProcess = result
|
|
|
|
console.log(this.eventProcess.workflowInstanceDataFields.Subject)
|
|
|
|
// description
|
|
let body : any =this.eventProcess.workflowInstanceDataFields.Body.replace(/<[^>]+>/g, '')
|
|
this.eventProcess.workflowInstanceDataFields.Body = body
|
|
this.Location = this.eventProcess.workflowInstanceDataFields.Location
|
|
|
|
this.InstanceId = this.eventProcess.workflowInstanceDataFields.InstanceId
|
|
this.getAttachments()
|
|
|
|
|
|
// attendees
|
|
//this.eventProcess.workflowInstanceDataFields.ParticipantsList
|
|
// subject
|
|
//this.eventProcess.workflowInstanceDataFields.Subject | this.eventProcess.workflowInstanceFolio
|
|
// location
|
|
//this.eventProcess.workflowInstanceDataFields.Location
|
|
// startDate
|
|
//this.eventProcess.taskStartDate
|
|
// endDate
|
|
//this.eventProcess.workflowInstanceDataFields.EndDate
|
|
|
|
// this.eventProcess.workflowInstanceDataFields.Agenda
|
|
|
|
// eventProcess.workflowInstanceDataFields.IsRecurring
|
|
|
|
if(this.eventProcess.workflowInstanceDataFields.IsRecurring == false) {
|
|
this.isRecurring = "Não se repete";
|
|
}
|
|
else {
|
|
this.isRecurring = "Repete";
|
|
}
|
|
|
|
this.eventProcess.workflowInstanceDataFields.ParticipantsList.forEach(e => {
|
|
if(e.IsRequired) {
|
|
this.taskParticipants.push(e);
|
|
} else {
|
|
this.taskParticipantsCc.push(e);
|
|
}
|
|
})
|
|
})
|
|
}
|
|
|
|
ngOnInit() {
|
|
|
|
|
|
window.onresize = (event) => {
|
|
// if not mobile remove all component
|
|
if( window.innerWidth >= 800){
|
|
this.modalController.dismiss();
|
|
}
|
|
};
|
|
|
|
}
|
|
|
|
close() {
|
|
this.modalController.dismiss();
|
|
}
|
|
|
|
save() {
|
|
|
|
this.taskParticipantsCc.forEach(e=>{
|
|
e.IsRequired = false
|
|
})
|
|
|
|
this.eventProcess.workflowInstanceDataFields.ParticipantsList = this.taskParticipants.concat(this.taskParticipantsCc)
|
|
|
|
this.eventProcess.workflowInstanceDataFields.ParticipantsList.forEach(e=>{
|
|
|
|
if(e.hasOwnProperty('$type')) {
|
|
delete e.$type
|
|
}
|
|
})
|
|
|
|
const event: any = {
|
|
Agenda: this.eventProcess.workflowInstanceDataFields.Agenda,
|
|
Body: this.eventProcess.workflowInstanceDataFields.Body,
|
|
EndDate: this.eventProcess.workflowInstanceDataFields.EndDate,
|
|
EventType: this.eventProcess.workflowInstanceDataFields.EventType,
|
|
IsAllDayEvent: this.eventProcess.workflowInstanceDataFields.IsAllDayEvent,
|
|
IsRecurring: this.eventProcess.workflowInstanceDataFields.IsRecurring,
|
|
Location: this.eventProcess.workflowInstanceDataFields.Location,
|
|
Subject: this.eventProcess.workflowInstanceDataFields.Subject,
|
|
serialNumber: this.eventProcess.serialNumber,
|
|
StartDate: this.eventProcess.workflowInstanceDataFields.StartDate,
|
|
MDEmail: this.eventProcess.workflowInstanceDataFields.MDEmail,
|
|
MDName: this.eventProcess.workflowInstanceDataFields.MDName,
|
|
Message: this.eventProcess.workflowInstanceDataFields.Message,
|
|
ParticipantsList: this.eventProcess.workflowInstanceDataFields.ParticipantsList,
|
|
Private: false,
|
|
ReviewerComments: ''
|
|
}
|
|
|
|
this.eventsService.postEventToApproveEdit(event).subscribe(()=>{
|
|
this.successMessage('Evento editado')
|
|
}, error =>{
|
|
this.badRequest('Evento não editado')
|
|
})
|
|
|
|
|
|
this.loadedAttachments.forEach((document:any)=>{
|
|
if(document['action'] == 'add') {
|
|
delete document.action
|
|
this.attachmentsService.setEventAttachmentById(document).subscribe(()=>{
|
|
//this.successMessage()
|
|
}, error =>{
|
|
this.badRequest()
|
|
});
|
|
} else if(document['action'] == 'delete') {
|
|
delete document.action
|
|
this.attachmentsService.deleteEventAttachmentById(document.Id).subscribe( res=>{
|
|
//this.successMessage()
|
|
}, error =>{
|
|
this.badRequest()
|
|
})
|
|
}
|
|
|
|
})
|
|
|
|
|
|
this.modalController.dismiss();
|
|
|
|
}
|
|
|
|
async openAttendees() {
|
|
|
|
if(window.innerWidth <= 1024) {
|
|
const modal = await this.modalController.create({
|
|
component: AttendeesPage,
|
|
componentProps: {
|
|
adding: this.adding,
|
|
taskParticipants: this.taskParticipants,
|
|
taskParticipantsCc: this.taskParticipantsCc
|
|
},
|
|
cssClass: 'attendee modal modal-desktop',
|
|
backdropDismiss: false
|
|
});
|
|
|
|
await modal.present();
|
|
|
|
modal.onDidDismiss().then((data) => {
|
|
|
|
if(data){
|
|
data = data['data'];
|
|
|
|
const newAttendees: EventPerson[] = data['taskParticipants'];
|
|
const newAttendeesCC: EventPerson[] = data['taskParticipantsCc'];
|
|
|
|
this.setIntervenient(newAttendees);
|
|
this.setIntervenientCC(newAttendeesCC);
|
|
}
|
|
});
|
|
} else {
|
|
this.showAttendees = true
|
|
}
|
|
}
|
|
|
|
setIntervenient(data){
|
|
this.taskParticipants = data;
|
|
this.postEvent.Attendees = data;
|
|
}
|
|
|
|
setIntervenientCC(data){
|
|
this.taskParticipantsCc = data;
|
|
}
|
|
|
|
addParticipants(){
|
|
this.adding = 'intervenient'
|
|
|
|
this.openAttendees();
|
|
}
|
|
|
|
addParticipantsCC(){
|
|
|
|
this.adding = 'CC'
|
|
this.openAttendees();
|
|
}
|
|
|
|
dynamicSetIntervenient({taskParticipants, taskParticipantsCc}){
|
|
this.taskParticipants = taskParticipants;
|
|
this.taskParticipantsCc = taskParticipantsCc;
|
|
}
|
|
|
|
|
|
async getAttachments() {
|
|
|
|
let result: any = await this.attachmentsService.getAttachmentsById(this.InstanceId).toPromise();
|
|
|
|
result.forEach((e)=>{
|
|
e.action = false
|
|
})
|
|
|
|
this.loadedAttachments = result
|
|
|
|
console.log('this.loadedAttachments', this.loadedAttachments, result)
|
|
}
|
|
|
|
deleteAttachment(attachment: Attachment, index) {
|
|
|
|
console.log('index', index)
|
|
this.loadedAttachments[index]['action'] = 'delete'
|
|
|
|
}
|
|
|
|
async getDoc() {
|
|
const modal = await this.modalController.create({
|
|
component: SearchPage,
|
|
cssClass: 'modal-width-100-width-background modal',
|
|
componentProps: {
|
|
type: 'AccoesPresidenciais & ArquivoDespachoElect',
|
|
showSearchInput: true,
|
|
select: true,
|
|
}
|
|
});
|
|
await modal.present();
|
|
modal.onDidDismiss().then( async (res)=>{
|
|
if(res){
|
|
|
|
const data: SearchDocument = res.data.selected;
|
|
|
|
const DocumentToSave: any = {
|
|
SourceTitle: data.Assunto,
|
|
ParentId: this.InstanceId,
|
|
Source: '1',
|
|
SourceId: data.Id,
|
|
ApplicationId: data.ApplicationType.toString(),
|
|
Id: '',
|
|
Link: '',
|
|
SerialNumber: '',
|
|
action: 'add',
|
|
CreateDate: data.Data,
|
|
Data: data.Data,
|
|
Description: data.DocTypeDesc,
|
|
SourceName: data.Assunto,
|
|
Stakeholders: data.EntidadeOrganicaNome,
|
|
};
|
|
|
|
|
|
this.loadedAttachments.push(DocumentToSave)
|
|
console.log('push', DocumentToSave)
|
|
|
|
// await this.attachmentsService.setEventAttachmentById(DocumentToSave).subscribe(()=>{
|
|
// this.getAttachments();
|
|
// });
|
|
}
|
|
});
|
|
}
|
|
|
|
async successMessage(message?: string, callback?) {
|
|
|
|
const enterAnimation = (baseEl: any) => {
|
|
const backdropAnimation = this.animationController.create()
|
|
.addElement(baseEl.querySelector('ion-backdrop')!)
|
|
.fromTo('opacity', '0.01', 'var(--backdrop-opacity)');
|
|
|
|
const wrapperAnimation = this.animationController.create()
|
|
.addElement(baseEl.querySelector('.modal-wrapper')!)
|
|
.keyframes([
|
|
{ offset: 0, opacity: '1', right: '-100%' },
|
|
{ offset: 1, opacity: '1', right: '0px' }
|
|
]);
|
|
|
|
return this.animationController.create()
|
|
.addElement(baseEl)
|
|
.easing('ease-out')
|
|
.duration(500)
|
|
.addAnimation([backdropAnimation, wrapperAnimation]);
|
|
}
|
|
|
|
const leaveAnimation = (baseEl: any) => {
|
|
return enterAnimation(baseEl).direction('reverse');
|
|
}
|
|
|
|
|
|
const modal = await this.modalController.create({
|
|
enterAnimation,
|
|
leaveAnimation,
|
|
component: SuccessMessagePage,
|
|
componentProps: {
|
|
message: message || 'Processo efetuado' ,
|
|
},
|
|
cssClass: 'notification-modal'
|
|
});
|
|
|
|
modal.present()
|
|
|
|
setTimeout(()=>{
|
|
if (callback) {
|
|
callback()
|
|
}
|
|
modal.dismiss()
|
|
},7000)
|
|
|
|
}
|
|
|
|
async badRequest(message?: string, callback?) {
|
|
const enterAnimation = (baseEl: any) => {
|
|
const backdropAnimation = this.animationController.create()
|
|
.addElement(baseEl.querySelector('ion-backdrop')!)
|
|
.fromTo('opacity', '0.01', 'var(--backdrop-opacity)');
|
|
|
|
const wrapperAnimation = this.animationController.create()
|
|
.addElement(baseEl.querySelector('.modal-wrapper')!)
|
|
.keyframes([
|
|
{ offset: 0, opacity: '1', right: '-100%' },
|
|
{ offset: 1, opacity: '1', right: '0px' }
|
|
]);
|
|
|
|
return this.animationController.create()
|
|
.addElement(baseEl)
|
|
.easing('ease-out')
|
|
.duration(500)
|
|
.addAnimation([backdropAnimation, wrapperAnimation]);
|
|
}
|
|
|
|
const leaveAnimation = (baseEl: any) => {
|
|
return enterAnimation(baseEl).direction('reverse');
|
|
}
|
|
|
|
|
|
const modal = await this.modalController.create({
|
|
enterAnimation,
|
|
leaveAnimation,
|
|
component: BadRequestPage,
|
|
componentProps: {
|
|
message: message || 'Processo efetuado' ,
|
|
},
|
|
cssClass: 'notification-modal'
|
|
});
|
|
|
|
modal.present()
|
|
|
|
setTimeout(()=>{
|
|
if (callback) {
|
|
callback()
|
|
}
|
|
modal.dismiss()
|
|
},7000)
|
|
}
|
|
|
|
} |