mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
175 lines
4.2 KiB
TypeScript
175 lines
4.2 KiB
TypeScript
import { Component, OnInit } from '@angular/core';
|
|
import { ModalController, NavParams, PopoverController } from '@ionic/angular';
|
|
import { ProcessesService } from 'src/app/services/processes.service';
|
|
import { ToastService } from 'src/app/services/toast.service';
|
|
import { EditEventToApproveComponent } from 'src/app/shared/gabinete-digital/edit-event-to-approve/edit-event.page';
|
|
import { EmendMessageModalPage } from '../emend-message-modal/emend-message-modal.page';
|
|
import { ThemeService } from 'src/app/services/theme.service'
|
|
import { RouteService } from 'src/app/services/route.service';
|
|
|
|
|
|
@Component({
|
|
selector: 'app-event-actions-popover',
|
|
templateUrl: './event-actions-popover.page.html',
|
|
styleUrls: ['./event-actions-popover.page.scss'],
|
|
})
|
|
export class EventActionsPopoverPage implements OnInit {
|
|
serialNumber:string;
|
|
instanceId: string;
|
|
activityInstanceName: string
|
|
|
|
constructor(
|
|
private navParams: NavParams,
|
|
private processes:ProcessesService,
|
|
private modalController: ModalController,
|
|
private popoverController: PopoverController,
|
|
private toastService: ToastService,
|
|
private RouteService: RouteService,
|
|
public ThemeService: ThemeService) {
|
|
this.serialNumber = this.navParams.get('serialNumber');
|
|
this.instanceId = this.navParams.get('InstanceId');
|
|
this.activityInstanceName = this.navParams.get('InstanceId');
|
|
}
|
|
|
|
ngOnInit() {
|
|
window.onresize = (event) => {
|
|
if( window.innerWidth >= 800){
|
|
this.popoverController.dismiss();
|
|
}
|
|
};
|
|
}
|
|
|
|
goBack() {
|
|
this.closePopover();
|
|
|
|
this.RouteService.goBack()
|
|
}
|
|
|
|
closePopover() {
|
|
this.popoverController.dismiss();
|
|
}
|
|
|
|
async approveTask() {
|
|
let body = { "serialNumber": this.serialNumber, "action": "Aprovar" }
|
|
|
|
|
|
const loader = this.toastService.loading()
|
|
try {
|
|
await this.processes.PostTaskAction(body).toPromise()
|
|
|
|
this.toastService.successMessage();
|
|
this.goBack();
|
|
} catch (error) {
|
|
|
|
this.toastService.badRequest()
|
|
}
|
|
finally {
|
|
loader.remove()
|
|
}
|
|
|
|
}
|
|
|
|
async ReenviarTask() {
|
|
let body = { "serialNumber": this.serialNumber, "action": "Reenviar" }
|
|
|
|
|
|
const loader = this.toastService.loading()
|
|
try {
|
|
await this.processes.PostTaskAction(body).toPromise()
|
|
|
|
this.toastService.successMessage();
|
|
this.goBack();
|
|
} catch (error) {
|
|
|
|
this.toastService.badRequest()
|
|
}
|
|
finally {
|
|
loader.remove()
|
|
}
|
|
|
|
}
|
|
|
|
async emendarTask() {
|
|
this.closePopover();
|
|
|
|
const modal = await this.modalController.create({
|
|
component: EmendMessageModalPage,
|
|
componentProps:{
|
|
},
|
|
cssClass: 'emend-message-modal',
|
|
backdropDismiss: false
|
|
});
|
|
|
|
await modal.present();
|
|
|
|
modal.onDidDismiss()
|
|
.then( async (res) => {
|
|
|
|
|
|
if(res.data.note !== ''){
|
|
let body = { "serialNumber": this.serialNumber,
|
|
"action": "Emendar",
|
|
"dataFields": {
|
|
"ReviewUserComment": res.data,
|
|
}
|
|
}
|
|
|
|
|
|
const loader = this.toastService.loading()
|
|
|
|
try {
|
|
await this.processes.PostTaskAction(body).toPromise();
|
|
this.toastService.successMessage('Pedido enviado');
|
|
this.goBack();
|
|
} catch (error) {
|
|
this.toastService.badRequest();
|
|
}
|
|
finally {
|
|
loader.remove()
|
|
}
|
|
}
|
|
else{
|
|
|
|
}
|
|
});
|
|
}
|
|
|
|
async rejeitar() {
|
|
let body = { "serialNumber": this.serialNumber, "action": "Rejeitar" }
|
|
|
|
const loader = this.toastService.loading();
|
|
try {
|
|
await this.processes.PostTaskAction(body).toPromise();
|
|
await this.toastService.successMessage('Processo rejeitado');
|
|
this.goBack();
|
|
} catch (error) {
|
|
this.toastService.badRequest();
|
|
}
|
|
finally {
|
|
loader.remove();
|
|
}
|
|
|
|
|
|
}
|
|
|
|
async editTask() {
|
|
this.closePopover();
|
|
const modal = await this.modalController.create({
|
|
component: EditEventToApproveComponent,
|
|
componentProps: {
|
|
serialNumber: this.serialNumber,
|
|
InstanceId: this.instanceId
|
|
},
|
|
cssClass: 'modal modal-desktop',
|
|
// backdropDismiss: false
|
|
});
|
|
|
|
await modal.present();
|
|
|
|
modal.onDidDismiss().then(res => {
|
|
});
|
|
|
|
}
|
|
|
|
}
|