Add options for diploma

This commit is contained in:
Peter Maquiran
2021-05-27 14:33:17 +01:00
parent b17b9e06f7
commit 2a404577c0
23 changed files with 1331 additions and 6 deletions
@@ -0,0 +1,188 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { ModalController, PopoverController } from '@ionic/angular';
import { AddNotePage } from 'src/app/modals/add-note/add-note.page';
import { BookMeetingModalPage } from 'src/app/pages/gabinete-digital/expediente/book-meeting-modal/book-meeting-modal.page';
import { ProcessesService } from 'src/app/services/processes.service';
import { BadRequestComponent } from '../bad-request/bad-request.component';
import { SuccessMessageComponent } from '../success-message/success-message.component';
@Component({
selector: 'app-deploma-options',
templateUrl: './deploma-options.page.html',
styleUrls: ['./deploma-options.page.scss'],
})
export class DeplomaOptionsPage implements OnInit {
serialnumber: string;
profile: string;
task: any
fulltask: any
constructor(public popoverController: PopoverController,
private modalController: ModalController,
private activatedRoute: ActivatedRoute,
private processes: ProcessesService,) {
this.activatedRoute.queryParams.subscribe(params => {
if(params["serialNumber"]) {
this.serialnumber = params["serialNumber"];
console.log(params["serialNumber"]);
}
});
}
ngOnInit() {
}
async openAddNoteModal(actionName:string) {
let classs;
if( window.innerWidth <= 800){
classs = 'modal modal-desktop'
} else {
classs = 'modal modal-desktop'
}
const modal = await this.modalController.create({
component: AddNotePage,
componentProps:{
},
cssClass: classs,
backdropDismiss: true
});
await modal.present();
modal.onDidDismiss().then(res => {
if(res.data){
const DocumentToSave = res.data.documents.map((e) => {
return {
ApplicationId: e.ApplicationType,
SourceId: e.Id,
}
});
let docs = {
ProcessInstanceID: "",
Attachments: DocumentToSave,
}
if(actionName == 'Solicitar assinatura'){
this.askSignature(res.data.note, docs);
this.goBack();
}
else if(actionName == 'Solicitar alteração'){
this.askToChange(res.data.note, docs);
this.goBack();
}
}
});
}
async askToChange(note:string, documents:any){
let body = {
"serialNumber": this.serialnumber,
"action": "Retificar",
"ActionTypeId": 99999841,
"dataFields": {
"ReviewUserComment": note,
},
"AttachmentList" :documents,
}
try {
await this.processes.CompleteTask(body);
this.close();
this.successMessage()
} catch (error) {
this.badRequest()
}
}
async openBookMeetingModal(task: any) {
let classs;
if( window.innerWidth <= 800){
classs = 'book-meeting-modal modal modal-desktop'
} else {
classs = 'modal modal-desktop showAsideOptions'
}
const modal = await this.modalController.create({
component: BookMeetingModalPage,
componentProps: {
task: this.task,
},
cssClass: classs,
backdropDismiss: false
});
await modal.present();
modal.onDidDismiss();
}
async askSignature(note:string, documents:any){
let body = {
"serialNumber": this.serialnumber,
"action": "Aprovar",
"ActionTypeId": 99999840,
"dataFields": {
"ReviewUserComment": note,
},
"AttachmentList" :documents,
}
try {
await this.processes.CompleteTask(body);
this.close();
this.successMessage()
} catch (error) {
this.badRequest()
}
}
async successMessage(message?: string) {
const modal = await this.modalController.create({
component: SuccessMessageComponent,
componentProps: {
message: message || 'Processo efetuado' ,
},
cssClass: 'modal modal-desktop'
});
modal.present()
setTimeout(()=>{
modal.dismiss()
},3000)
}
async badRequest(message?: string) {
const modal = await this.modalController.create({
component: BadRequestComponent,
componentProps: {
message: message || 'Processo não efetuado' ,
},
cssClass: 'modal modal-desktop'
});
modal.present()
setTimeout(()=>{
modal.dismiss()
},3000)
}
goBack() {
this.close()
}
close(){}
}