diff --git a/src/app/pages/publications/publications.page.ts b/src/app/pages/publications/publications.page.ts index fa75f9dd2..985272835 100644 --- a/src/app/pages/publications/publications.page.ts +++ b/src/app/pages/publications/publications.page.ts @@ -2,7 +2,6 @@ import { Component, OnInit } from '@angular/core'; import { Router, NavigationEnd } from '@angular/router'; import { ModalController, PopoverController } from '@ionic/angular'; import { PublicationFolder } from 'src/app/models/publicationfolder'; -import { ProcessesService } from 'src/app/services/processes.service'; import { PublicationsService } from 'src/app/services/publications.service'; import { NewActionPage } from './new-action/new-action.page'; import { ViewPublicationsPage } from './view-publications/view-publications.page'; @@ -13,7 +12,7 @@ import { LoadingService } from 'src/app/services/loading.service'; import { Publication } from 'src/app/models/publication'; import { ActionsOptionsPage } from 'src/app/shared/popover/actions-options/actions-options.page'; import { EditActionPage } from './edit-action/edit-action.page'; - +import { ToastService } from 'src/app/services/toast.service'; @Component({ selector: 'app-publications', @@ -61,6 +60,7 @@ export class PublicationsPage implements OnInit { private loading: LoadingService, private publications: PublicationsService, private popoverController:PopoverController, + private toastService: ToastService ) { this.months = ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"]; this.days = ["Domingo", "Segunda-feira", "Terça-feira", "Quarta-feira", "Quinta-feira", "Sexta-feira", "Sábado"]; @@ -164,14 +164,26 @@ export class PublicationsPage implements OnInit { } deleteAction(id?: string){ - this.publications.DeletePresidentialAction(id).toPromise(); + + const loader = this.toastService.loading(); + + try { + this.publications.DeletePresidentialAction(id).toPromise(); + this.toastService.successMessage() + } catch(e) { + this.toastService.badRequest() + } + finally { + loader.remove() + } + this.refreshing() } async AddPublicationFolder(item?:any) { this.closeDesktopComponent(); - if(window.innerWidth <= 1024){ + if(window.innerWidth <= 1024) { const modal = await this.modalController.create({ component: NewActionPage, @@ -188,7 +200,6 @@ export class PublicationsPage implements OnInit { } else { this.desktopComponent.showAddActions = true; } - } @@ -361,7 +372,9 @@ export class PublicationsPage implements OnInit { this.closeDesktopComponent(); this.desktopComponent.showEditActions = true; } else if (res['data']=='delete') { - this.getActions(); + setTimeout(()=>{ + this.getActions(); + },1000) } }); }