Simplify loading using parameter instead of injected account object.
This commit is contained in:
parent
f9d26ed888
commit
89c1c4f64c
@ -5,7 +5,7 @@ import * as moment from 'moment';
|
|||||||
import {
|
import {
|
||||||
Component,
|
Component,
|
||||||
Inject, Input, Output, EventEmitter,
|
Inject, Input, Output, EventEmitter,
|
||||||
OnChanges
|
OnInit, OnChanges
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ class DateRange {
|
|||||||
</jqxChart>
|
</jqxChart>
|
||||||
`
|
`
|
||||||
})
|
})
|
||||||
export class BalanceChartComponent implements OnChanges {
|
export class BalanceChartComponent implements OnInit, OnChanges {
|
||||||
@Input() account: Account;
|
@Input() account: Account;
|
||||||
@Output() onUpdate: EventEmitter<DateRange> = new EventEmitter<DateRange>();
|
@Output() onUpdate: EventEmitter<DateRange> = new EventEmitter<DateRange>();
|
||||||
|
|
||||||
@ -133,9 +133,11 @@ export class BalanceChartComponent implements OnChanges {
|
|||||||
this.data = [];
|
this.data = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
loadData(account: Account) {
|
loadData() {
|
||||||
|
let accountId = this.activatedRoute.snapshot.paramMap.get('accountId');
|
||||||
|
|
||||||
this.dailyBalanceService.query(
|
this.dailyBalanceService.query(
|
||||||
account.id
|
+accountId
|
||||||
).subscribe((results) => {
|
).subscribe((results) => {
|
||||||
this.data = results;
|
this.data = results;
|
||||||
|
|
||||||
@ -157,12 +159,13 @@ export class BalanceChartComponent implements OnChanges {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.loadData();
|
||||||
|
}
|
||||||
|
|
||||||
ngOnChanges(changes) {
|
ngOnChanges(changes) {
|
||||||
if('account' in changes && changes.account.currentValue) {
|
if('account' in changes && changes.account.currentValue) {
|
||||||
this.loadData(changes.account.currentValue);
|
|
||||||
this.setLines(changes.account.currentValue);
|
this.setLines(changes.account.currentValue);
|
||||||
} else {
|
|
||||||
this.setLines(this.account);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user