From f50ce728b5c434eec3ff385482ec660e76a7531a Mon Sep 17 00:00:00 2001 From: Gwenhael Le Moine <glemoine@erasme.org> Date: Tue, 19 Aug 2014 17:28:41 +0200 Subject: [PATCH] colors in tables as well --- public/app/js/main/controllers/BalanceCtrl.js | 6 +++--- public/app/js/main/templates/balance.tpl.html | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/public/app/js/main/controllers/BalanceCtrl.js b/public/app/js/main/controllers/BalanceCtrl.js index 086dd545..6d6bb5c1 100644 --- a/public/app/js/main/controllers/BalanceCtrl.js +++ b/public/app/js/main/controllers/BalanceCtrl.js @@ -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 ) ); }; }; diff --git a/public/app/js/main/templates/balance.tpl.html b/public/app/js/main/templates/balance.tpl.html index 7132a3aa..d68a934c 100644 --- a/public/app/js/main/templates/balance.tpl.html +++ b/public/app/js/main/templates/balance.tpl.html @@ -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>