From 8bfd5349da492d80c10092ee0696c110c35ceb21 Mon Sep 17 00:00:00 2001 From: Gwenhael Le Moine Date: Mon, 27 Oct 2014 15:20:20 +0100 Subject: [PATCH] our own table, sortable --- public/app/js/app.js | 1 - public/app/js/controllers/BalanceCtrl.js | 32 +++++++++++---------- public/app/js/templates/balance.tpl.html | 36 +++++++++++++++--------- 3 files changed, 40 insertions(+), 29 deletions(-) diff --git a/public/app/js/app.js b/public/app/js/app.js index 83c90a5d..5c392e75 100644 --- a/public/app/js/app.js +++ b/public/app/js/app.js @@ -2,7 +2,6 @@ var app = angular.module( 'app', [ 'ui.router', 'nvd3ChartDirectives', 'angularMoment', 'chieffancypants.loadingBar', - 'ngTable', 'angular-underscore', 'ngMaterial' ] ); diff --git a/public/app/js/controllers/BalanceCtrl.js b/public/app/js/controllers/BalanceCtrl.js index 27653347..4191d597 100644 --- a/public/app/js/controllers/BalanceCtrl.js +++ b/public/app/js/controllers/BalanceCtrl.js @@ -56,17 +56,6 @@ app.controller( 'BalanceCtrl', }; }; - $scope.tableParams = new ngTableParams( { - page: 1, // show first page - count: 999 // count per page - }, { - counts: [], // hide page counts control - total: 1 //, // value less than count hide pagination - // getData: function($defer, params) { - // $defer.resolve(data.slice((params.page() - 1) * params.count(), params.page() * params.count())); - // } - } ); - $scope.filter_data = function() { _($scope.balance.buckets).each( function( bucket ) { bucket.data = []; @@ -91,11 +80,24 @@ app.controller( 'BalanceCtrl', } ); }}; + var Bucket = function( categories ) { + var _this = this; + this.categories = categories; + this.score_threshold = 0; + this.orderBy = 'amount'; + this.orderDesc = false; + this.order_by = function( field ) { + if ( _this.orderBy == field ) { + _this.orderDesc = !_this.orderDesc; + } else { + _this.orderBy = field; + } + }; + }; + $scope.balance = { - buckets: [ { categories: 'Expenses', - score_threshold: 0 }, - { categories: 'Income', - score_threshold: 0 } ], + buckets: [ new Bucket( 'Expenses' ), + new Bucket( 'Income' ) ], details: {} }; diff --git a/public/app/js/templates/balance.tpl.html b/public/app/js/templates/balance.tpl.html index 73d23ac0..e3b157ab 100644 --- a/public/app/js/templates/balance.tpl.html +++ b/public/app/js/templates/balance.tpl.html @@ -55,19 +55,29 @@ - - - - - +
- {{account.account}} - - {{account.amount | number:2}} € -
+ + + + + + + + + + + + + +
accountamountscore
+ {{account.account}} + + {{account.amount | number:2}} € + + {{account.score}} +