import { Component, OnInit } from '@angular/core'; import { AnimationController, ModalController } from '@ionic/angular'; import { SearchDocument } from 'src/app/models/search-document'; import { SearchPage } from 'src/app/pages/search/search.page'; import { BadRequestPage } from 'src/app/shared/popover/bad-request/bad-request.page'; import { SuccessMessagePage } from 'src/app/shared/popover/success-message/success-message.page'; @Component({ selector: 'app-add-note', templateUrl: './add-note.page.html', styleUrls: ['./add-note.page.scss'], }) export class AddNotePage implements OnInit { note: string = ''; documents:SearchDocument[] = []; loadedAttachments:any; constructor( private modalController: ModalController, private animationController: AnimationController, ) { this.note = ''; } ngOnInit() { } close(){ this.modalController.dismiss(''); } save(){ let body = { "note":this.note, "documents":this.documents, } this.modalController.dismiss(body); } async getDoc() { 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); } }); } removeAttachment(index: number){ this.documents = this.documents.filter( (e, i) => index != i); } async successMessage(message?: string) { 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: SuccessMessagePage, componentProps: { message: message || 'Processo efetuado' , }, cssClass: 'notification-modal' }); modal.present() setTimeout(()=>{ modal.dismiss() },3000) } async badRequest(message?: string) { 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 efetuado' , }, cssClass: 'notification-modal' }); modal.present() setTimeout(()=>{ modal.dismiss() },3000) } }