mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
Improve create process
This commit is contained in:
@@ -220,8 +220,7 @@ export class CreateProcessPage implements OnInit {
|
||||
try {
|
||||
await this.processes.postParecer(this.postData).toPromise();
|
||||
|
||||
this.FinalizarParecer();
|
||||
this.toastService.successMessage('Pedido de Parecer criado');
|
||||
this.FinalizarParecer('Pedido de Parecer criado');
|
||||
}
|
||||
catch (error) {
|
||||
this.toastService.badRequest('Processo não efectuado');
|
||||
@@ -241,8 +240,7 @@ export class CreateProcessPage implements OnInit {
|
||||
|
||||
try {
|
||||
await this.processes.postDeferimento(this.postData).toPromise();
|
||||
this.executado();
|
||||
this.toastService.successMessage('Pedido de Deferimento criado');
|
||||
this.executado('Pedido de Deferimento criado');
|
||||
}
|
||||
catch (error) {
|
||||
this.toastService.badRequest('Processo não efectuado');
|
||||
@@ -270,11 +268,9 @@ export class CreateProcessPage implements OnInit {
|
||||
}
|
||||
console.log('this.postData', this.postData, this.taskType);
|
||||
|
||||
alert('nice !!')
|
||||
try {
|
||||
// await this.processes.postDespatcho(this.postData).toPromise();
|
||||
this.executado();
|
||||
// this.toastService.successMessage('Despacho criado');
|
||||
await this.processes.postDespatcho(this.postData).toPromise();
|
||||
this.executado('Despacho criado');
|
||||
} catch (error) {
|
||||
this.toastService.badRequest('Processo não efectuado');
|
||||
}
|
||||
@@ -329,7 +325,7 @@ export class CreateProcessPage implements OnInit {
|
||||
|
||||
}
|
||||
|
||||
async executado() {
|
||||
async executado(message?) {
|
||||
let body = {
|
||||
"serialNumber": this.task.serialNumber,
|
||||
"action": "Conhecimento",
|
||||
@@ -339,7 +335,13 @@ export class CreateProcessPage implements OnInit {
|
||||
},
|
||||
"AttachmentList" :null,
|
||||
}
|
||||
await this.processes.CompleteTask(body).toPromise();
|
||||
|
||||
try {
|
||||
await this.processes.CompleteTask(body).toPromise();
|
||||
this.toastService.successMessage(message)
|
||||
} catch(e) {
|
||||
this.toastService.badRequest()
|
||||
}
|
||||
}
|
||||
|
||||
async FinalizarDespacho() {
|
||||
@@ -381,7 +383,7 @@ export class CreateProcessPage implements OnInit {
|
||||
|
||||
}
|
||||
|
||||
async FinalizarParecer() {
|
||||
async FinalizarParecer(message?) {
|
||||
let body = {
|
||||
"serialNumber": this.task.serialNumber,
|
||||
"action": "Parecer",
|
||||
@@ -391,7 +393,15 @@ export class CreateProcessPage implements OnInit {
|
||||
},
|
||||
"AttachmentList" :null,
|
||||
}
|
||||
await this.processes.CompleteTask(body).toPromise();
|
||||
|
||||
|
||||
try {
|
||||
await this.processes.CompleteTask(body).toPromise();
|
||||
this.toastService.successMessage(message)
|
||||
} catch (e) {
|
||||
this.toastService.badRequest()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async addParticipants() {
|
||||
@@ -570,73 +580,4 @@ export class CreateProcessPage implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
async successMessage(message?: any, callback?) {
|
||||
var notification = document.createElement('div')
|
||||
notification.id = 'notification'
|
||||
notification.innerHTML = `
|
||||
|
||||
<div class="main-content width-100 pa-20">
|
||||
<p class="message d-flex align-center">
|
||||
<ion-icon slot="end" class="title-icon pr-10" src="/assets/images/nofitication-success.svg"></ion-icon>
|
||||
<p class="text">{{ message }}</p>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
`
|
||||
|
||||
document.body.append(notification)
|
||||
notification.querySelector('.text').innerHTML = message
|
||||
setTimeout(()=>{
|
||||
notification.remove()
|
||||
},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 não efetuado' ,
|
||||
},
|
||||
cssClass: 'notification-modal'
|
||||
});
|
||||
|
||||
modal.present()
|
||||
|
||||
setTimeout(()=>{
|
||||
if (callback) {
|
||||
callback()
|
||||
}
|
||||
modal.dismiss()
|
||||
},7000)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user