This commit is contained in:
Peter Maquiran
2021-07-27 22:34:47 +01:00
parent 2cb96a80ac
commit 999da281e8
5 changed files with 91 additions and 33 deletions
@@ -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();
});
}
@@ -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) {
@@ -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();
});
});
+26
View File
@@ -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('/')
}
}
}
@@ -69,12 +69,12 @@ export class ApproveEventPage implements OnInit {
setTimeout(()=>{
this.getTask();
this.getAttachments();
}, 4000)
}, 6000)
setTimeout(()=>{
this.getTask();
this.getAttachments();
}, 6000)
}, 10000)
}