2021-05-03 20:02:07 +01:00
|
|
|
import { Component, OnInit } from '@angular/core';
|
2021-06-08 15:59:06 +01:00
|
|
|
import { AnimationController, ModalController } from '@ionic/angular';
|
2021-05-19 12:03:00 +01:00
|
|
|
import { SearchDocument } from 'src/app/models/search-document';
|
|
|
|
|
import { SearchPage } from 'src/app/pages/search/search.page';
|
2021-06-08 15:59:06 +01:00
|
|
|
import { BadRequestPage } from 'src/app/shared/popover/bad-request/bad-request.page';
|
|
|
|
|
import { SuccessMessagePage } from 'src/app/shared/popover/success-message/success-message.page';
|
2021-05-03 20:02:07 +01:00
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'app-add-note',
|
|
|
|
|
templateUrl: './add-note.page.html',
|
|
|
|
|
styleUrls: ['./add-note.page.scss'],
|
|
|
|
|
})
|
|
|
|
|
export class AddNotePage implements OnInit {
|
2021-05-19 12:03:00 +01:00
|
|
|
note: string = '';
|
|
|
|
|
documents:SearchDocument[] = [];
|
|
|
|
|
loadedAttachments:any;
|
2021-05-03 20:02:07 +01:00
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
|
private modalController: ModalController,
|
2021-06-08 15:59:06 +01:00
|
|
|
private animationController: AnimationController,
|
2021-05-03 20:02:07 +01:00
|
|
|
) {
|
2021-05-19 12:03:00 +01:00
|
|
|
this.note = '';
|
2021-05-03 20:02:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
|
}
|
|
|
|
|
close(){
|
|
|
|
|
this.modalController.dismiss('');
|
|
|
|
|
}
|
|
|
|
|
save(){
|
2021-05-19 12:03:00 +01:00
|
|
|
let body = {
|
|
|
|
|
"note":this.note,
|
|
|
|
|
"documents":this.documents,
|
|
|
|
|
}
|
|
|
|
|
this.modalController.dismiss(body);
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-25 13:38:46 +01:00
|
|
|
async getDoc() {
|
|
|
|
|
|
2021-05-19 12:03:00 +01:00
|
|
|
const modal = await this.modalController.create({
|
|
|
|
|
component: SearchPage,
|
|
|
|
|
cssClass: 'modal-width-100-width-background modal',
|
|
|
|
|
componentProps: {
|
|
|
|
|
type: 'AccoesPresidenciais & ArquivoDespachoElect',
|
|
|
|
|
showSearchInput: true,
|
|
|
|
|
select: true
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
await modal.present();
|
|
|
|
|
modal.onDidDismiss().then((res)=>{
|
|
|
|
|
if(res){
|
|
|
|
|
const data = res.data;
|
|
|
|
|
this.documents.push(data.selected);
|
|
|
|
|
}
|
|
|
|
|
});
|
2021-05-25 13:38:46 +01:00
|
|
|
|
2021-05-19 12:03:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
removeAttachment(index: number){
|
|
|
|
|
|
|
|
|
|
this.documents = this.documents.filter( (e, i) => index != i);
|
2021-05-25 13:38:46 +01:00
|
|
|
}
|
|
|
|
|
|
2021-06-09 16:38:41 +01:00
|
|
|
async successMessage(message?: any, callback?) {
|
2021-05-25 13:38:46 +01:00
|
|
|
|
2021-06-15 14:30:32 +01:00
|
|
|
var notification = document.createElement('div')
|
|
|
|
|
notification.id = 'notification'
|
|
|
|
|
notification.innerHTML = `
|
2021-06-08 15:59:06 +01:00
|
|
|
|
2021-06-15 14:30:32 +01:00
|
|
|
<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>
|
|
|
|
|
`
|
2021-06-08 15:59:06 +01:00
|
|
|
|
2021-06-15 14:30:32 +01:00
|
|
|
document.body.append(notification)
|
2021-06-15 14:32:12 +01:00
|
|
|
notification.querySelector('.text').innerHTML = message
|
2021-05-25 13:38:46 +01:00
|
|
|
setTimeout(()=>{
|
2021-06-15 14:30:32 +01:00
|
|
|
notification.remove()
|
2021-06-09 10:49:37 +01:00
|
|
|
},7000)
|
2021-05-25 13:38:46 +01:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-09 16:34:14 +01:00
|
|
|
async badRequest(message?: string, callback?) {
|
2021-06-08 15:59:06 +01:00
|
|
|
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');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2021-05-25 13:38:46 +01:00
|
|
|
const modal = await this.modalController.create({
|
2021-06-08 15:59:06 +01:00
|
|
|
enterAnimation,
|
|
|
|
|
leaveAnimation,
|
|
|
|
|
component: BadRequestPage,
|
2021-05-25 13:38:46 +01:00
|
|
|
componentProps: {
|
2021-06-08 15:59:06 +01:00
|
|
|
message: message || 'Processo efetuado' ,
|
2021-05-25 13:38:46 +01:00
|
|
|
},
|
2021-06-08 15:59:06 +01:00
|
|
|
cssClass: 'notification-modal'
|
2021-05-25 13:38:46 +01:00
|
|
|
});
|
2021-05-19 12:03:00 +01:00
|
|
|
|
2021-05-25 13:38:46 +01:00
|
|
|
modal.present()
|
|
|
|
|
|
|
|
|
|
setTimeout(()=>{
|
2021-06-09 16:34:14 +01:00
|
|
|
if (callback) {
|
|
|
|
|
callback()
|
|
|
|
|
}
|
2021-05-25 13:38:46 +01:00
|
|
|
modal.dismiss()
|
2021-06-09 10:49:37 +01:00
|
|
|
},7000)
|
2021-05-03 20:02:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|