Initialize account from parent.
This commit is contained in:
parent
7ace852f43
commit
2a2738ddeb
@ -35,6 +35,7 @@ var balanceChartModule = angular.module('balanceChartModule', [
|
||||
.component('balanceChart', {
|
||||
template: '<div></div>',
|
||||
bindings: {
|
||||
account: '<',
|
||||
onUpdate: '&'
|
||||
},
|
||||
controller: function($routeParams, Balances, Account, $element) {
|
||||
@ -131,10 +132,6 @@ var balanceChartModule = angular.module('balanceChartModule', [
|
||||
},
|
||||
y: {
|
||||
show: true,
|
||||
lines: [
|
||||
{ value: 0, axis: 'y2' },
|
||||
{ value: 0, axis: 'y', class: 'zeroline'}
|
||||
]
|
||||
}
|
||||
},
|
||||
tooltip: {
|
||||
@ -153,12 +150,34 @@ var balanceChartModule = angular.module('balanceChartModule', [
|
||||
});
|
||||
|
||||
vm.loadData();
|
||||
};
|
||||
|
||||
vm.setLines = function(account) {
|
||||
if(vm.chart) {
|
||||
vm.chart.ygrids([
|
||||
{ value: 0, axis: 'y2' },
|
||||
{ value: 0, axis: 'y', class: 'zeroline'},
|
||||
]);
|
||||
|
||||
Account.get({id: $routeParams.accountId}, function(result) {
|
||||
vm.chart.ygrids.add({
|
||||
value: result.authorized_overdraft, class: 'overdraft'
|
||||
value: account.authorized_overdraft,
|
||||
axis: 'y',
|
||||
class: 'overdraft'
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
vm.$onChanges = function(changes) {
|
||||
if('account' in changes) {
|
||||
if('$promise' in vm.account && vm.account.$resolved === false) {
|
||||
vm.account.$promise.then(function(account) {
|
||||
vm.setLines(account);
|
||||
return account;
|
||||
});
|
||||
} else {
|
||||
vm.setLines(vm.account);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}).factory('Balances', function($resource) {
|
||||
|
Loading…
Reference in New Issue
Block a user