From 4861f5ce49b148ca9a1d01a50d31df9d56a9cf39 Mon Sep 17 00:00:00 2001 From: Alexis Lahouze Date: Fri, 14 Jul 2017 10:33:20 +0200 Subject: [PATCH] Fix account change handling in balance chart component. --- src/operations/balance-chart.component.ts | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/operations/balance-chart.component.ts b/src/operations/balance-chart.component.ts index 6ab3fb0..10cea1c 100644 --- a/src/operations/balance-chart.component.ts +++ b/src/operations/balance-chart.component.ts @@ -156,24 +156,21 @@ module.exports = angular.module('balanceChartModule', [ { value: 0, axis: 'y', class: 'zeroline'}, ]); - vm.chart.ygrids.add({ - value: account.authorized_overdraft, - axis: 'y', - class: 'overdraft' - }); + if(account) { + vm.chart.ygrids.add({ + 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); - } + vm.setLines(changes.account.currentValue); + } else { + vm.setLines(vm.account); } }; }