-import {Component, Input, ViewChild, OnInit} from '@angular/core';
+import {Component, Input, ViewChild, OnInit, AfterViewInit} from '@angular/core';
import {Location} from '@angular/common';
import {FormatService} from '@eg/core/format.service';
import {GridDataSource, GridCellTextGenerator} from '@eg/share/grid/grid';
templateUrl: './funding-sources.component.html'
})
-export class FundingSourcesComponent extends AdminPageComponent implements OnInit {
+export class FundingSourcesComponent extends AdminPageComponent implements OnInit, AfterViewInit {
idlClass = 'acqfs';
classLabel: string;
+ @Input() startId: number;
+
@ViewChild('grid', { static: true }) grid: GridComponent;
@ViewChild('fundingSourceTransactionsDialog', { static: false }) fundingSourceTransactionsDialog: FundingSourceTransactionsDialogComponent;
@ViewChild('applyCreditDialog', { static: true }) applyCreditDialog: FmRecordEditorComponent;
this.includeOrgDescendants = true;
}
+ ngAfterViewInit() {
+ if (this.startId) {
+ this.pcrud.retrieve('acqfs', this.startId).subscribe(
+ acqfs => this.openTransactionsDialog([acqfs], 'allocations'),
+ err => {},
+ () => this.startId = null
+ );
+ }
+ }
+
calculateSummary(row: IdlObject): Observable<IdlObject> {
row['balance'] = 0;
row['total_credits'] = 0;
-import {Component, Input, ViewChild, OnInit} from '@angular/core';
+import {Component, Input, ViewChild, OnInit, AfterViewInit} from '@angular/core';
import {Location} from '@angular/common';
import {FormatService} from '@eg/core/format.service';
import {GridDataSource, GridCellTextGenerator} from '@eg/share/grid/grid';
templateUrl: './funds-manager.component.html'
})
-export class FundsManagerComponent extends AdminPageComponent implements OnInit {
+export class FundsManagerComponent extends AdminPageComponent implements OnInit, AfterViewInit {
idlClass = 'acqf';
classLabel: string;
+ @Input() startId: number;
+
@ViewChild('fundDetailsDialog', { static: false }) fundDetailsDialog: FundDetailsDialogComponent;
@ViewChild('fundRolloverDialog', { static: false }) fundRolloverDialog: FundRolloverDialogComponent;
@ViewChild('grid', { static: true }) grid: GridComponent;
this.includeOrgDescendants = true;
}
+ ngAfterViewInit() {
+ if (this.startId) {
+ this.pcrud.retrieve('acqf', this.startId).subscribe(
+ acqf => this.openFundDetailsDialog([acqf]),
+ err => {},
+ () => this.startId = null
+ );
+ }
+ }
+
checkRolloverPerms() {
this.canRollover = false;
<eg-title i18n-prefix prefix="Funds"></eg-title>
-<ul ngbNav #claimingAdminNav="ngbNav" class="nav-tabs">
- <li ngbNavItem>
+<ul ngbNav #claimingAdminNav="ngbNav" class="nav-tabs" [(activeId)]="activeTab"
+ (navChange)="onNavChange($event)">
+ <li [ngbNavItem]="'fund'">
<a ngbNavLink i18n>Funds</a>
<ng-template ngbNavContent>
<div class="mt-2">
- <eg-funds-manager></eg-funds-manager>
+ <eg-funds-manager [startId]="fundId"></eg-funds-manager>
</div>
</ng-template>
</li>
- <li ngbNavItem>
+ <li [ngbNavItem]="'funding_source'">
<a ngbNavLink i18n>Funding Sources</a>
<ng-template ngbNavContent>
<div class="mt-2">
- <eg-funding-sources></eg-funding-sources>
+ <eg-funding-sources [startId]="fundingSourceId"></eg-funding-sources>
</div>
</ng-template>
</li>
- <li ngbNavItem>
+ <li [ngbNavItem]="'fund_tag'">
<a ngbNavLink i18n>Fund Tags</a>
<ng-template ngbNavContent>
<div class="mt-2">
import {Component, OnInit, Input, ViewChild} from '@angular/core';
+import {Router, ActivatedRoute, ParamMap} from '@angular/router';
+import {Location} from '@angular/common';
+import {NgbNav, NgbNavChangeEvent} from '@ng-bootstrap/ng-bootstrap';
@Component({
templateUrl: './funds.component.html'
})
export class FundsComponent implements OnInit {
+ activeTab: string;
+ fundId: number;
+ fundingSourceId: number;
+
+ constructor(
+ private location: Location,
+ private router: Router,
+ private route: ActivatedRoute
+ ) {}
+
ngOnInit() {
+ this.route.paramMap.subscribe((params: ParamMap) => {
+ const tab = params.get('tab');
+ const id = +params.get('id');
+ if (!id || !tab) { return; }
+ if (tab === 'fund' || tab === 'funding_source') {
+ this.activeTab = tab;
+ if (tab === 'fund') {
+ this.fundId = id;
+ } else {
+ this.fundingSourceId = id;
+ }
+ } else {
+ return;
+ }
+ });
+ }
+
+ // Changing a tab in the UI means clearing the route (e.g.,
+ // if we originally navigated vi funds/fund/:id or
+ // funds/funding_source/:id
+ // This is pretty much only cosmetic
+ onNavChange(evt: NgbNavChangeEvent) {
+ const url = this.router.createUrlTree(['/staff/admin/acq/funds']).toString();
+ this.location.go(url); // go without reloading
}
}
const routes: Routes = [{
path: '',
component: FundsComponent
+ }, {
+ path: ':tab/:id',
+ component: FundsComponent
}];
@NgModule({