1 import {Component, OnInit, Input, ViewChild} from '@angular/core';
2 import {Router, ActivatedRoute, ParamMap} from '@angular/router';
3 import {Location} from '@angular/common';
4 import {NgbNav, NgbNavChangeEvent} from '@ng-bootstrap/ng-bootstrap';
7 templateUrl: './funds.component.html'
9 export class FundsComponent implements OnInit {
13 fundingSourceId: number;
16 private location: Location,
17 private router: Router,
18 private route: ActivatedRoute
22 this.route.paramMap.subscribe((params: ParamMap) => {
23 const tab = params.get('tab');
24 const id = +params.get('id');
25 if (!id || !tab) { return; }
26 if (tab === 'fund' || tab === 'funding_source') {
31 this.fundingSourceId = id;
39 // Changing a tab in the UI means clearing the route (e.g.,
40 // if we originally navigated vi funds/fund/:id or
41 // funds/funding_source/:id
42 onNavChange(evt: NgbNavChangeEvent) {
43 // clear any IDs parsed from the original route
44 // to avoid reopening the fund or funding source
45 // dialogs when navigating back to the fund/funding source
48 this.fundingSourceId = null;
49 const url = this.router.createUrlTree(['/staff/admin/acq/funds']).toString();
50 this.location.go(url); // go without reloading