2021-02-26 15:29:05 +01:00
|
|
|
import { Component, OnInit, Input, EventEmitter, Output } from '@angular/core';
|
2021-04-07 14:08:05 +01:00
|
|
|
import { NavigationExtras, Router } from '@angular/router';
|
2021-06-30 10:24:23 +01:00
|
|
|
import { ModalController, PopoverController } from '@ionic/angular';
|
2021-02-26 15:29:05 +01:00
|
|
|
import { Event } from 'src/app/models/event.model';
|
|
|
|
|
import { AttachmentsService } from 'src/app/services/attachments.service';
|
|
|
|
|
import { ProcessesService } from 'src/app/services/processes.service';
|
|
|
|
|
import { EmendMessageModalPage } from 'src/app/pages/agenda/emend-message-modal/emend-message-modal.page';
|
|
|
|
|
import { EventActionsPopoverPage } from 'src/app/pages/agenda/event-actions-popover/event-actions-popover.page';
|
2021-06-15 15:09:20 +01:00
|
|
|
import { ToastService } from 'src/app/services/toast.service';
|
2021-10-18 15:44:22 +01:00
|
|
|
import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page';
|
2023-03-14 09:53:39 +01:00
|
|
|
import { ThemeService } from 'src/app/services/theme.service';
|
|
|
|
|
import { HttpErrorHandle } from 'src/app/services/http-error-handle.service';
|
2023-08-28 17:06:16 +01:00
|
|
|
import { TaskService } from 'src/app/services/task.service'
|
2024-07-31 11:29:26 +01:00
|
|
|
import { AgendaDataRepositoryService } from 'src/app/module/agenda/data/repository/agenda-data-repository.service';
|
2024-05-30 12:03:30 +01:00
|
|
|
import { EventToApproveDetails } from 'src/app/models/entiry/agenda/eventToApproveDetails';
|
2024-06-18 09:14:22 +01:00
|
|
|
import { EventsService } from 'src/app/services/events.service';
|
|
|
|
|
import { isHttpError } from 'src/app/services/http.service';
|
|
|
|
|
import { TracingType, XTracerAsync } from 'src/app/services/monitoring/opentelemetry/tracer';
|
2024-06-21 16:38:19 +01:00
|
|
|
import { PermissionService } from 'src/app/services/permission.service';
|
2021-02-26 15:29:05 +01:00
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'app-approve-event',
|
2021-06-03 14:10:16 +01:00
|
|
|
templateUrl: './approve-event.page.html',
|
|
|
|
|
styleUrls: ['./approve-event.page.scss'],
|
2021-02-26 15:29:05 +01:00
|
|
|
})
|
2021-06-03 14:10:16 +01:00
|
|
|
export class ApproveEventPage implements OnInit {
|
2021-02-26 15:29:05 +01:00
|
|
|
|
|
|
|
|
event: Event;
|
2024-05-30 12:03:30 +01:00
|
|
|
@Input() loadedEvent: EventToApproveDetails;
|
2024-06-02 13:53:46 +01:00
|
|
|
loadedAttachments: any;
|
|
|
|
|
customDate: any;
|
|
|
|
|
today: any;
|
2021-03-25 15:46:43 +01:00
|
|
|
show: boolean = false;
|
2021-10-18 15:44:22 +01:00
|
|
|
|
2021-02-26 15:29:05 +01:00
|
|
|
months = ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"];
|
|
|
|
|
days = ["Domingo", "Segunda-feira", "Terça-feira", "Quarta-feira", "Quinta-feira", "Sexta-feira", "Sábado"];
|
|
|
|
|
|
2024-06-02 13:53:46 +01:00
|
|
|
@Input() serialNumber: string;
|
|
|
|
|
@Input() showComponent: string;
|
2021-07-26 15:19:03 +01:00
|
|
|
@Input() componentTransparent: any
|
2024-06-02 13:53:46 +01:00
|
|
|
@Input() InstanceId: string;
|
|
|
|
|
@Input() showAside: boolean;
|
2021-02-26 15:29:05 +01:00
|
|
|
|
|
|
|
|
@Output() approveEventDismiss = new EventEmitter<any>();
|
|
|
|
|
@Output() closeEventToApprove = new EventEmitter<any>();
|
2021-03-03 10:15:44 +01:00
|
|
|
@Output() AproveEventEditEvent = new EventEmitter<any>();
|
2021-02-26 15:29:05 +01:00
|
|
|
|
2021-06-29 14:15:56 +01:00
|
|
|
@Output() EditApproveEventDismiss = new EventEmitter<any>();
|
|
|
|
|
|
2021-02-26 15:29:05 +01:00
|
|
|
constructor(
|
2022-06-03 16:53:50 +01:00
|
|
|
private router: Router,
|
2021-02-26 15:29:05 +01:00
|
|
|
private modalController: ModalController,
|
|
|
|
|
private popoverController: PopoverController,
|
2021-10-25 13:21:48 +01:00
|
|
|
private toastService: ToastService,
|
2023-03-14 09:53:39 +01:00
|
|
|
public ThemeService: ThemeService,
|
|
|
|
|
private httpErroHandle: HttpErrorHandle,
|
2024-05-30 12:03:30 +01:00
|
|
|
public TaskService: TaskService,
|
2024-06-18 09:14:22 +01:00
|
|
|
private agendaDataRepository: AgendaDataRepositoryService,
|
|
|
|
|
public EventsService: EventsService,
|
|
|
|
|
private httpErrorHandle: HttpErrorHandle,
|
2024-06-21 16:38:19 +01:00
|
|
|
public p: PermissionService,
|
2021-06-30 10:24:23 +01:00
|
|
|
) {
|
|
|
|
|
// Event to approve list
|
2021-06-10 11:20:41 +01:00
|
|
|
|
2023-06-10 14:44:42 +01:00
|
|
|
|
2024-06-02 13:53:46 +01:00
|
|
|
window['edit-approve-event-desktop'] = () => {
|
2023-06-10 14:44:42 +01:00
|
|
|
this.getTask()
|
|
|
|
|
}
|
2021-05-03 13:08:57 +01:00
|
|
|
}
|
2021-02-26 15:29:05 +01:00
|
|
|
|
2021-07-17 22:42:02 +01:00
|
|
|
toDateString(e) {
|
|
|
|
|
return new Date(e).toDateString()
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-26 15:29:05 +01:00
|
|
|
ngOnInit() {
|
|
|
|
|
this.getTask();
|
2021-07-26 15:19:03 +01:00
|
|
|
}
|
|
|
|
|
|
2021-02-26 15:29:05 +01:00
|
|
|
|
2021-05-24 16:49:25 +01:00
|
|
|
close() {
|
2021-02-26 15:29:05 +01:00
|
|
|
this.closeEventToApprove.emit();
|
2021-03-25 15:46:43 +01:00
|
|
|
this.modalController.dismiss();
|
2021-02-26 15:29:05 +01:00
|
|
|
}
|
|
|
|
|
|
2024-06-19 09:03:26 +01:00
|
|
|
@XTracerAsync({name:'ApproveEventPage/getTask', bugPrint: true})
|
2024-06-18 09:14:22 +01:00
|
|
|
async getTask(tracing?: TracingType) {
|
2024-05-30 12:03:30 +01:00
|
|
|
|
2024-06-18 09:14:22 +01:00
|
|
|
const res = await this.agendaDataRepository.getEventToApproveById(this.serialNumber, tracing)
|
2024-05-30 12:03:30 +01:00
|
|
|
|
2024-06-02 13:53:46 +01:00
|
|
|
if (res.isOk()) {
|
2024-05-30 12:03:30 +01:00
|
|
|
this.loadedEvent = res.value;
|
2024-05-31 12:49:49 +01:00
|
|
|
this.loadedAttachments = this.loadedEvent.Attachments
|
2024-05-30 12:03:30 +01:00
|
|
|
this.today = new Date(res.value.workflowInstanceDataFields.StartDate);
|
|
|
|
|
//
|
2024-06-02 13:53:46 +01:00
|
|
|
this.customDate = this.days[this.today.getDay()] + ", " + this.today.getDate() + " de " + (this.months[this.today.getMonth()]);
|
2024-06-18 09:14:22 +01:00
|
|
|
tracing.setAttribute('outcome', 'success')
|
2024-05-30 12:03:30 +01:00
|
|
|
} else {
|
2024-06-18 09:14:22 +01:00
|
|
|
tracing.setAttribute('eventId', this.serialNumber)
|
|
|
|
|
|
|
|
|
|
if(!isHttpError(res.error)) {
|
|
|
|
|
this.toastService._badRequest('Pedimos desculpa mas não foi possível executar a acção. Por favor, contacte o apoio técnico. #133')
|
|
|
|
|
console.log(res.error)
|
|
|
|
|
} else if (isHttpError(res.error)) {
|
|
|
|
|
|
|
|
|
|
if(res.error.status == 404) {
|
|
|
|
|
this.toastService._badRequest('Este evento já não existe')
|
|
|
|
|
} else {
|
|
|
|
|
this.httpErrorHandle.httpStatusHandle(res.error)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2024-05-30 12:03:30 +01:00
|
|
|
}
|
2021-10-18 15:44:22 +01:00
|
|
|
|
2021-02-26 15:29:05 +01:00
|
|
|
}
|
2021-05-24 16:49:25 +01:00
|
|
|
|
2024-06-02 13:53:46 +01:00
|
|
|
async approveTask(serialNumber: string) {
|
2021-04-06 09:26:31 +01:00
|
|
|
let body = { "serialNumber": serialNumber, "action": "Aprovar" }
|
2021-05-24 16:49:25 +01:00
|
|
|
|
2021-07-12 11:13:29 +01:00
|
|
|
const loader = this.toastService.loading()
|
|
|
|
|
|
2024-07-09 12:36:46 +01:00
|
|
|
const result = await this.agendaDataRepository.approveEvent(serialNumber)// .subscribe((value) => {
|
|
|
|
|
if(result.isOk()) {
|
|
|
|
|
|
|
|
|
|
console.log(result.value)
|
|
|
|
|
this.modalController.dismiss(serialNumber);
|
|
|
|
|
this.httpErroHandle.httpsSucessMessagge('Aprovar')
|
|
|
|
|
this.TaskService.loadEventosParaAprovacao();
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
console.log('aprove event error: ', result.error)
|
|
|
|
|
this.httpErroHandle.httpStatusHandle(result.error)
|
2021-05-24 16:49:25 +01:00
|
|
|
}
|
|
|
|
|
|
2024-07-09 12:36:46 +01:00
|
|
|
this.close()
|
|
|
|
|
loader.remove()
|
|
|
|
|
|
|
|
|
|
|
2021-02-26 15:29:05 +01:00
|
|
|
}
|
|
|
|
|
|
2024-06-02 13:53:46 +01:00
|
|
|
async rejectTask(serialNumber: string) {
|
2021-10-18 15:44:22 +01:00
|
|
|
|
2023-09-06 21:23:21 +01:00
|
|
|
let body = { "serialNumber": serialNumber, "action": "Rejeitar" }
|
2024-05-30 12:03:30 +01:00
|
|
|
|
2021-05-24 16:49:25 +01:00
|
|
|
|
2021-07-12 11:13:29 +01:00
|
|
|
const loader = this.toastService.loading()
|
2024-07-12 10:23:02 +01:00
|
|
|
const result = await this.agendaDataRepository.deleteEvent(serialNumber, true)//.subscribe((value) => {
|
2021-07-12 11:13:29 +01:00
|
|
|
|
2024-07-09 12:36:46 +01:00
|
|
|
if(result.isOk()) {
|
2024-07-12 10:23:02 +01:00
|
|
|
this.httpErroHandle.httpsSucessMessagge('delete event');
|
2023-05-19 12:00:51 +01:00
|
|
|
this.TaskService.loadEventosParaAprovacao();
|
2024-07-09 12:36:46 +01:00
|
|
|
|
2021-07-26 15:19:03 +01:00
|
|
|
this.close()
|
2024-07-09 12:36:46 +01:00
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
console.log('reject event error: ', result.error)
|
|
|
|
|
this.httpErroHandle.httpStatusHandle(result.error)
|
2021-05-24 16:49:25 +01:00
|
|
|
}
|
|
|
|
|
|
2024-07-09 12:36:46 +01:00
|
|
|
loader.remove()
|
2021-02-26 15:29:05 +01:00
|
|
|
}
|
2021-10-18 15:44:22 +01:00
|
|
|
|
2021-05-03 13:08:57 +01:00
|
|
|
|
2024-06-02 13:53:46 +01:00
|
|
|
async viewDocument(DocId: string, Document) {
|
2021-10-18 15:44:22 +01:00
|
|
|
|
|
|
|
|
const modal = await this.modalController.create({
|
|
|
|
|
component: ViewDocumentPage,
|
|
|
|
|
componentProps: {
|
|
|
|
|
trustedUrl: '',
|
|
|
|
|
file: {
|
2023-08-24 18:39:31 +01:00
|
|
|
title: Document.Description,
|
2021-10-18 15:44:22 +01:00
|
|
|
url: '',
|
|
|
|
|
title_link: '',
|
|
|
|
|
},
|
|
|
|
|
Document,
|
|
|
|
|
applicationId: Document.ApplicationId,
|
|
|
|
|
docId: Document.DocId || Document.SourceId,
|
2024-05-30 12:03:30 +01:00
|
|
|
// folderId: this.loadedEvent.FolderId,
|
2021-10-18 15:44:22 +01:00
|
|
|
task: this.loadedEvent
|
|
|
|
|
},
|
|
|
|
|
cssClass: 'modal modal-desktop'
|
2021-02-26 15:29:05 +01:00
|
|
|
});
|
2021-10-18 15:44:22 +01:00
|
|
|
await modal.present();
|
|
|
|
|
|
2021-02-26 15:29:05 +01:00
|
|
|
}
|
|
|
|
|
|
2024-06-02 13:53:46 +01:00
|
|
|
async openOptions(ev: any) {
|
2021-02-26 15:29:05 +01:00
|
|
|
const popover = await this.popoverController.create({
|
|
|
|
|
component: EventActionsPopoverPage,
|
2022-06-03 16:53:50 +01:00
|
|
|
componentProps: {
|
|
|
|
|
activityInstanceName: this.loadedEvent.activityInstanceName
|
|
|
|
|
},
|
2021-02-26 15:29:05 +01:00
|
|
|
cssClass: 'event-actions-popover',
|
|
|
|
|
event: ev,
|
|
|
|
|
translucent: true
|
|
|
|
|
});
|
2024-06-02 13:53:46 +01:00
|
|
|
return await popover.present().then(() => {
|
2023-05-18 17:40:52 +01:00
|
|
|
this.TaskService.loadEventosParaAprovacao()
|
2023-06-10 14:44:42 +01:00
|
|
|
this.getTask()
|
2023-07-14 10:46:35 +01:00
|
|
|
}, (error) => {
|
|
|
|
|
console.log(error)
|
2023-05-18 17:40:52 +01:00
|
|
|
})
|
2021-02-26 15:29:05 +01:00
|
|
|
}
|
2021-05-24 16:49:25 +01:00
|
|
|
|
2024-06-02 13:53:46 +01:00
|
|
|
async emendTask(serialNumber: string) {
|
2024-05-30 12:03:30 +01:00
|
|
|
|
2021-02-26 15:29:05 +01:00
|
|
|
const modal = await this.modalController.create({
|
|
|
|
|
component: EmendMessageModalPage,
|
2024-06-02 13:53:46 +01:00
|
|
|
componentProps: {
|
2021-02-26 15:29:05 +01:00
|
|
|
},
|
|
|
|
|
cssClass: 'emend-message-modal',
|
|
|
|
|
backdropDismiss: false
|
2021-06-22 12:59:28 +01:00
|
|
|
});
|
2021-02-26 15:29:05 +01:00
|
|
|
|
2023-07-15 11:01:09 +01:00
|
|
|
|
2021-02-26 15:29:05 +01:00
|
|
|
|
2021-06-22 12:59:28 +01:00
|
|
|
modal.onDidDismiss()
|
2024-06-02 13:53:46 +01:00
|
|
|
.then(async (res) => {
|
2023-02-17 15:23:43 +01:00
|
|
|
|
2024-06-02 13:53:46 +01:00
|
|
|
if (res.data.option == 'save') {
|
2024-05-30 12:03:30 +01:00
|
|
|
|
2023-02-17 15:23:43 +01:00
|
|
|
|
2023-08-28 17:06:16 +01:00
|
|
|
|
2024-06-02 13:53:46 +01:00
|
|
|
let body = {
|
|
|
|
|
"serialNumber": serialNumber,
|
|
|
|
|
"action": "Emendar",
|
2023-08-28 17:06:16 +01:00
|
|
|
"dataFields": {
|
2024-06-02 13:53:46 +01:00
|
|
|
"ReviewUserComment": res.data,
|
|
|
|
|
}
|
2023-02-02 12:01:18 +01:00
|
|
|
}
|
2024-05-30 12:03:30 +01:00
|
|
|
|
2024-06-02 13:53:46 +01:00
|
|
|
const loader = this.toastService.loading();
|
2024-07-09 12:36:46 +01:00
|
|
|
/* await this.processes.PostTaskAction(body).toPromise(); */
|
|
|
|
|
const result = await this.agendaDataRepository.eventToaprovalStatus(serialNumber, 'Revision', res.data.note)// .subscribe((value) => {
|
|
|
|
|
if(result.isOk()) {
|
2024-06-02 13:53:46 +01:00
|
|
|
this.httpErroHandle.httpsSucessMessagge('Rever')
|
|
|
|
|
this.TaskService.loadEventosParaAprovacao();
|
|
|
|
|
this.close();
|
2024-07-09 12:36:46 +01:00
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
console.log('send event to revision error: ', result.error)
|
|
|
|
|
this.httpErroHandle.httpStatusHandle(result.error)
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-02 13:53:46 +01:00
|
|
|
loader.remove()
|
2024-07-09 12:36:46 +01:00
|
|
|
|
2024-05-30 12:03:30 +01:00
|
|
|
|
2024-06-02 13:53:46 +01:00
|
|
|
} else {
|
2024-05-30 12:03:30 +01:00
|
|
|
|
2024-06-02 13:53:46 +01:00
|
|
|
}
|
2024-05-30 12:03:30 +01:00
|
|
|
|
2024-06-02 13:53:46 +01:00
|
|
|
}, (error) => {
|
|
|
|
|
console.log(error)
|
|
|
|
|
});
|
2021-10-18 15:44:22 +01:00
|
|
|
|
2023-07-15 11:01:09 +01:00
|
|
|
await modal.present();
|
|
|
|
|
|
2021-02-26 15:29:05 +01:00
|
|
|
}
|
|
|
|
|
|
2021-06-30 09:45:56 +01:00
|
|
|
goToEventsToApprove() {
|
2024-06-02 13:53:46 +01:00
|
|
|
if (window.location.pathname.startsWith('/home/agenda')) {
|
2021-07-28 14:18:02 +01:00
|
|
|
this.close()
|
|
|
|
|
} else {
|
|
|
|
|
let navigationExtras: NavigationExtras = {
|
|
|
|
|
queryParams: {
|
2021-05-21 10:05:59 +01:00
|
|
|
"eventos": true,
|
2021-07-28 14:18:02 +01:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
this.router.navigate(['/home/gabinete-digital'], navigationExtras);
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-07 14:08:05 +01:00
|
|
|
}
|
|
|
|
|
|
2021-05-04 13:55:28 +01:00
|
|
|
|
2021-06-30 09:45:56 +01:00
|
|
|
/** @description edit event to aprove */
|
2021-05-04 13:55:28 +01:00
|
|
|
async editar(serialNumber: string) {
|
|
|
|
|
|
2021-06-30 09:45:56 +01:00
|
|
|
this.EditApproveEventDismiss.emit();
|
2021-05-24 16:49:25 +01:00
|
|
|
|
2021-06-30 09:45:56 +01:00
|
|
|
}
|
2021-02-26 15:29:05 +01:00
|
|
|
}
|