diff --git a/src/app/pages/agenda/view-event/view-event.page.ts b/src/app/pages/agenda/view-event/view-event.page.ts index f25b969b1..276144c67 100644 --- a/src/app/pages/agenda/view-event/view-event.page.ts +++ b/src/app/pages/agenda/view-event/view-event.page.ts @@ -15,6 +15,7 @@ import { OptsExpedientePage } from 'src/app/shared/popover/opts-expediente/opts- import { ActivatedRoute, NavigationExtras, Router } from '@angular/router'; import { ToastService } from 'src/app/services/toast.service'; import { EliminateEventPage } from 'src/app/modals/eliminate-event/eliminate-event.page'; +import { Location } from '@angular/common' @Component({ selector: 'app-view-event', @@ -58,6 +59,7 @@ export class ViewEventPage implements OnInit { private activatedRoute: ActivatedRoute, private router: Router, private toastService: ToastService, + private location: Location ) { this.isEventEdited = false; @@ -128,13 +130,17 @@ export class ViewEventPage implements OnInit { /* this.today = new Date(res.StartDate); this.customDate = this.days[this.today.getDay()]+ ", " + this.today.getDate() +" de " + ( this.months[this.today.getMonth()]); */ loader.remove() - }, ()=>{ + }, (error)=>{ - loader.remove() - this.toastService.badRequest('Este evento já não existe na sua agenda') - this.modalController.dismiss('Eevent not Foud'); - this.router.navigate(['/home/agenda']); + if(error.status == 0) { + this.toastService.badRequest('não é possível vizualizar este event no modo offline') + } else { + this.toastService.badRequest('Este evento já não existe na sua agenda') + } + loader.remove() + this.modalController.dismiss('Eevent not Foud'); + this.location.back(); }); } diff --git a/src/app/pages/gabinete-digital/despachos/despacho/despacho.page.ts b/src/app/pages/gabinete-digital/despachos/despacho/despacho.page.ts index 8275ce40f..3284e82b2 100644 --- a/src/app/pages/gabinete-digital/despachos/despacho/despacho.page.ts +++ b/src/app/pages/gabinete-digital/despachos/despacho/despacho.page.ts @@ -16,6 +16,9 @@ import { AddNotePage } from 'src/app/modals/add-note/add-note.page'; import { DespachosOptionsPage } from 'src/app/shared/popover/despachos-options/despachos-options.page'; import { ToastService } from 'src/app/services/toast.service'; import { DespachoMdService } from 'src/app/Rules/despacho-md.service' +import { NavigationService } from 'src/app/services/navigation.service'; +import { Location } from '@angular/common' + @Component({ selector: 'app-despacho', templateUrl: './despacho.page.html', @@ -50,7 +53,10 @@ export class DespachoPage implements OnInit { private router: Router, private animationController: AnimationController, private toastService: ToastService, - private despachoMdService: DespachoMdService + private despachoMdService: DespachoMdService, + private navigationService: NavigationService, + private location: Location + ) { this.activatedRoute.paramMap.subscribe(params => { if(params["params"].SerialNumber) { @@ -81,31 +87,35 @@ export class DespachoPage implements OnInit { } goBack() { - if(this.task.Status == "Pending" && this.caller == 'gabinete-digital'){ - if (window.innerWidth < 801) { - this.router.navigate(['/home/gabinete-digital/pendentes']); - } - else { - let navigationExtras: NavigationExtras = { - queryParams: { - "pendentes": true, - } - } - this.router.navigate(['/home/gabinete-digital'], navigationExtras); - } - } - else{ - if (window.innerWidth < 801) { - this.router.navigate(['/home/gabinete-digital/despachos']); - } else { - let navigationExtras: NavigationExtras = { - queryParams: { - 'despachos': true - } - } - this.router.navigate(['/home/gabinete-digital'], navigationExtras); - } - } + + //this.navigationService.back() + this.location.back(); + + // if(this.task.Status == "Pending" && this.caller == 'gabinete-digital'){ + // if (window.innerWidth < 801) { + // this.router.navigate(['/home/gabinete-digital/pendentes']); + // } + // else { + // let navigationExtras: NavigationExtras = { + // queryParams: { + // "pendentes": true, + // } + // } + // this.router.navigate(['/home/gabinete-digital'], navigationExtras); + // } + // } + // else{ + // if (window.innerWidth < 801) { + // this.router.navigate(['/home/gabinete-digital/despachos']); + // } else { + // let navigationExtras: NavigationExtras = { + // queryParams: { + // 'despachos': true + // } + // } + // this.router.navigate(['/home/gabinete-digital'], navigationExtras); + // } + // } } async LoadTaskDetail(serial: string) { diff --git a/src/app/services/navigation.service.spec.ts b/src/app/services/navigation.service.spec.ts new file mode 100644 index 000000000..3faeea3de --- /dev/null +++ b/src/app/services/navigation.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { NavigationService } from './navigation.service'; + +describe('NavigationService', () => { + let service: NavigationService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(NavigationService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/src/app/services/navigation.service.ts b/src/app/services/navigation.service.ts new file mode 100644 index 000000000..05c24f6b4 --- /dev/null +++ b/src/app/services/navigation.service.ts @@ -0,0 +1,26 @@ +import { Injectable } from '@angular/core' +import { Location } from '@angular/common' +import { Router, NavigationEnd } from '@angular/router' + +@Injectable({ providedIn: 'root' }) +export class NavigationService { + private history: string[] = [] + + constructor(private router: Router, private location: Location) { + this.router.events.subscribe((event) => { + if (event instanceof NavigationEnd) { + this.history.push(event.urlAfterRedirects) + } + }) + } + + back(): void { + this.history.pop() + if (this.history.length > 0) { + this.location.back() + } else { + this.router.navigateByUrl('/') + } + } +} + diff --git a/src/app/shared/agenda/approve-event/approve-event.page.ts b/src/app/shared/agenda/approve-event/approve-event.page.ts index 7bd01d909..1c65d4533 100644 --- a/src/app/shared/agenda/approve-event/approve-event.page.ts +++ b/src/app/shared/agenda/approve-event/approve-event.page.ts @@ -69,12 +69,12 @@ export class ApproveEventPage implements OnInit { setTimeout(()=>{ this.getTask(); this.getAttachments(); - }, 4000) + }, 6000) setTimeout(()=>{ this.getTask(); this.getAttachments(); - }, 6000) + }, 10000) }