colors in tables as well

This commit is contained in:
Gwenhael Le Moine 2014-08-19 17:28:41 +02:00
parent d8b8d89d23
commit f50ce728b5
2 changed files with 7 additions and 5 deletions

View file

@ -39,7 +39,7 @@ app.controller( 'BalanceCtrl',
};
// compute an account's score: from 1 (good) to 10 (bad), 0 is neutral/undecided
var score_account = function( account ) {
$scope.score_account = function( account ) {
if ( account.match( /^Income:salaire$/ ) ) {
return 1;
} else if ( account.match( /^Income:Gift$/ ) ) {
@ -63,7 +63,7 @@ app.controller( 'BalanceCtrl',
}
};
var coloring_score = function( score ) {
$scope.coloring_score = function( score ) {
var color_scale = [ '#99f',
'#0f0',
'#3f0',
@ -80,7 +80,7 @@ app.controller( 'BalanceCtrl',
$scope.color = function() {
return function( d, i ) {
return coloring_score( score_account( d.data.account ) );
return $scope.coloring_score( $scope.score_account( d.data.account ) );
};
};

View file

@ -40,7 +40,8 @@
</div>
<div class="panel-footer">
<table data-ng-table="tableParams" class="table">
<tr data-ng-repeat="account in balance.expenses">
<tr data-ng-repeat="account in balance.expenses"
style="border-left:10px solid {{coloring_score( score_account( account.account ) )}}">
<td data-title="'Account'">{{account.account}}</td>
<td data-title="'Amount'">{{account.amount | number:2}} €</td>
</tr>
@ -72,7 +73,8 @@
</div>
<div class="panel-footer">
<table data-ng-table="tableParams" class="table">
<tr data-ng-repeat="account in balance.income">
<tr data-ng-repeat="account in balance.income"
style="border-left:10px solid {{coloring_score( score_account( account.account ) )}}">
<td data-title="'Account'">{{account.account}}</td>
<td data-title="'Amount'">{{account.amount | number:2}} €</td>
</tr>