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 { ActivatedRoute, NavigationExtras, Router } from '@angular/router';
import { ToastService } from 'src/app/services/toast.service'; import { ToastService } from 'src/app/services/toast.service';
import { EliminateEventPage } from 'src/app/modals/eliminate-event/eliminate-event.page'; import { EliminateEventPage } from 'src/app/modals/eliminate-event/eliminate-event.page';
import { Location } from '@angular/common'
@Component({ @Component({
selector: 'app-view-event', selector: 'app-view-event',
@@ -58,6 +59,7 @@ export class ViewEventPage implements OnInit {
private activatedRoute: ActivatedRoute, private activatedRoute: ActivatedRoute,
private router: Router, private router: Router,
private toastService: ToastService, private toastService: ToastService,
private location: Location
) )
{ {
this.isEventEdited = false; this.isEventEdited = false;
@@ -128,13 +130,17 @@ export class ViewEventPage implements OnInit {
/* this.today = new Date(res.StartDate); /* this.today = new Date(res.StartDate);
this.customDate = this.days[this.today.getDay()]+ ", " + this.today.getDate() +" de " + ( this.months[this.today.getMonth()]); */ this.customDate = this.days[this.today.getDay()]+ ", " + this.today.getDate() +" de " + ( this.months[this.today.getMonth()]); */
loader.remove() loader.remove()
}, ()=>{ }, (error)=>{
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() loader.remove()
this.toastService.badRequest('Este evento já não existe na sua agenda')
this.modalController.dismiss('Eevent not Foud'); this.modalController.dismiss('Eevent not Foud');
this.router.navigate(['/home/agenda']); 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 { DespachosOptionsPage } from 'src/app/shared/popover/despachos-options/despachos-options.page';
import { ToastService } from 'src/app/services/toast.service'; import { ToastService } from 'src/app/services/toast.service';
import { DespachoMdService } from 'src/app/Rules/despacho-md.service' import { DespachoMdService } from 'src/app/Rules/despacho-md.service'
import { NavigationService } from 'src/app/services/navigation.service';
import { Location } from '@angular/common'
@Component({ @Component({
selector: 'app-despacho', selector: 'app-despacho',
templateUrl: './despacho.page.html', templateUrl: './despacho.page.html',
@@ -50,7 +53,10 @@ export class DespachoPage implements OnInit {
private router: Router, private router: Router,
private animationController: AnimationController, private animationController: AnimationController,
private toastService: ToastService, private toastService: ToastService,
private despachoMdService: DespachoMdService private despachoMdService: DespachoMdService,
private navigationService: NavigationService,
private location: Location
) { ) {
this.activatedRoute.paramMap.subscribe(params => { this.activatedRoute.paramMap.subscribe(params => {
if(params["params"].SerialNumber) { if(params["params"].SerialNumber) {
@@ -81,31 +87,35 @@ export class DespachoPage implements OnInit {
} }
goBack() { goBack() {
if(this.task.Status == "Pending" && this.caller == 'gabinete-digital'){
if (window.innerWidth < 801) { //this.navigationService.back()
this.router.navigate(['/home/gabinete-digital/pendentes']); this.location.back();
}
else { // if(this.task.Status == "Pending" && this.caller == 'gabinete-digital'){
let navigationExtras: NavigationExtras = { // if (window.innerWidth < 801) {
queryParams: { // this.router.navigate(['/home/gabinete-digital/pendentes']);
"pendentes": true, // }
} // else {
} // let navigationExtras: NavigationExtras = {
this.router.navigate(['/home/gabinete-digital'], navigationExtras); // queryParams: {
} // "pendentes": true,
} // }
else{ // }
if (window.innerWidth < 801) { // this.router.navigate(['/home/gabinete-digital'], navigationExtras);
this.router.navigate(['/home/gabinete-digital/despachos']); // }
} else { // }
let navigationExtras: NavigationExtras = { // else{
queryParams: { // if (window.innerWidth < 801) {
'despachos': true // this.router.navigate(['/home/gabinete-digital/despachos']);
} // } else {
} // let navigationExtras: NavigationExtras = {
this.router.navigate(['/home/gabinete-digital'], navigationExtras); // queryParams: {
} // 'despachos': true
} // }
// }
// this.router.navigate(['/home/gabinete-digital'], navigationExtras);
// }
// }
} }
async LoadTaskDetail(serial: string) { 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(()=>{ setTimeout(()=>{
this.getTask(); this.getTask();
this.getAttachments(); this.getAttachments();
}, 4000) }, 6000)
setTimeout(()=>{ setTimeout(()=>{
this.getTask(); this.getTask();
this.getAttachments(); this.getAttachments();
}, 6000) }, 10000)
} }