Improve create process

This commit is contained in:
Peter Maquiran
2021-06-18 16:03:34 +01:00
parent a6c67bf455
commit 699898fe96
3 changed files with 26 additions and 86 deletions
@@ -220,8 +220,7 @@ export class CreateProcessPage implements OnInit {
try { try {
await this.processes.postParecer(this.postData).toPromise(); await this.processes.postParecer(this.postData).toPromise();
this.FinalizarParecer(); this.FinalizarParecer('Pedido de Parecer criado');
this.toastService.successMessage('Pedido de Parecer criado');
} }
catch (error) { catch (error) {
this.toastService.badRequest('Processo não efectuado'); this.toastService.badRequest('Processo não efectuado');
@@ -241,8 +240,7 @@ export class CreateProcessPage implements OnInit {
try { try {
await this.processes.postDeferimento(this.postData).toPromise(); await this.processes.postDeferimento(this.postData).toPromise();
this.executado(); this.executado('Pedido de Deferimento criado');
this.toastService.successMessage('Pedido de Deferimento criado');
} }
catch (error) { catch (error) {
this.toastService.badRequest('Processo não efectuado'); this.toastService.badRequest('Processo não efectuado');
@@ -270,11 +268,9 @@ export class CreateProcessPage implements OnInit {
} }
console.log('this.postData', this.postData, this.taskType); console.log('this.postData', this.postData, this.taskType);
alert('nice !!')
try { try {
// await this.processes.postDespatcho(this.postData).toPromise(); await this.processes.postDespatcho(this.postData).toPromise();
this.executado(); this.executado('Despacho criado');
// this.toastService.successMessage('Despacho criado');
} catch (error) { } catch (error) {
this.toastService.badRequest('Processo não efectuado'); this.toastService.badRequest('Processo não efectuado');
} }
@@ -329,7 +325,7 @@ export class CreateProcessPage implements OnInit {
} }
async executado() { async executado(message?) {
let body = { let body = {
"serialNumber": this.task.serialNumber, "serialNumber": this.task.serialNumber,
"action": "Conhecimento", "action": "Conhecimento",
@@ -339,7 +335,13 @@ export class CreateProcessPage implements OnInit {
}, },
"AttachmentList" :null, "AttachmentList" :null,
} }
try {
await this.processes.CompleteTask(body).toPromise(); await this.processes.CompleteTask(body).toPromise();
this.toastService.successMessage(message)
} catch(e) {
this.toastService.badRequest()
}
} }
async FinalizarDespacho() { async FinalizarDespacho() {
@@ -381,7 +383,7 @@ export class CreateProcessPage implements OnInit {
} }
async FinalizarParecer() { async FinalizarParecer(message?) {
let body = { let body = {
"serialNumber": this.task.serialNumber, "serialNumber": this.task.serialNumber,
"action": "Parecer", "action": "Parecer",
@@ -391,7 +393,15 @@ export class CreateProcessPage implements OnInit {
}, },
"AttachmentList" :null, "AttachmentList" :null,
} }
try {
await this.processes.CompleteTask(body).toPromise(); await this.processes.CompleteTask(body).toPromise();
this.toastService.successMessage(message)
} catch (e) {
this.toastService.badRequest()
}
} }
async addParticipants() { 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)
}
} }
+2
View File
@@ -69,6 +69,8 @@ export class ToastService {
</div> </div>
` `
notification.style.animationName = 'notification-top'
document.body.append(notification) document.body.append(notification)
notification.querySelector('.text').innerHTML = message || 'Processo não efetuado' notification.querySelector('.text').innerHTML = message || 'Processo não efetuado'
setTimeout(()=>{ setTimeout(()=>{
+2 -5
View File
@@ -817,7 +817,6 @@ background: rgb(92, 92, 92);
top: 23px; top: 23px;
right: 0px; right: 0px;
height: 87px; height: 87px;
max-width: 400px;
border-radius: 9px; border-radius: 9px;
-webkit-border-radius: 9px; -webkit-border-radius: 9px;
-moz-border-radius: 9px; -moz-border-radius: 9px;
@@ -835,9 +834,7 @@ background: rgb(92, 92, 92);
background-repeat: no-repeat; background-repeat: no-repeat;
min-width: 340px; min-width: 340px;
box-shadow: 0px 2px 10px #0000003d; box-shadow: 0px 2px 10px #0000003d;
display: flex; animation-name: notification;
align-items: center;
animation-name: example;
animation-duration: 1s; animation-duration: 1s;
animation-timing-function: ease-in; animation-timing-function: ease-in;
transition: 1s; transition: 1s;
@@ -852,7 +849,7 @@ background: rgb(92, 92, 92);
} }
@keyframes example { @keyframes notification {
from {right: -100%;} from {right: -100%;}
to {right: 0px;} to {right: 0px;}
} }