mirror of
https://github.com/gwenhael-le-moine/ledgerrb.git
synced 2024-12-26 09:59:18 +01:00
sort by date
This commit is contained in:
parent
1190718023
commit
728b4d0710
2 changed files with 24 additions and 1 deletions
|
@ -199,6 +199,29 @@ app.controller( 'DashboardCtrl',
|
|||
var retrieve_graph_values = function( params ) {
|
||||
API.graph_values( params ).then( function( response ) {
|
||||
$scope.periods = [];
|
||||
|
||||
var largest_cat = _(response.data).reduce( function( memo, cat ) {
|
||||
return cat.length > memo.length ? cat : memo;
|
||||
}, [] );
|
||||
_.chain(largest_cat)
|
||||
.pluck( 'date' )
|
||||
.each( function( date ) {
|
||||
_(response.data).each( function( cat ) {
|
||||
var value = _(cat).find( { date: date } );
|
||||
if ( _(value).isUndefined() ) {
|
||||
cat.push( { date: date,
|
||||
amount: 0,
|
||||
currency: _(cat).first().currency } );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
_(response.data).each( function( cat ) {
|
||||
cat = _(cat).sortBy( function( month ) {
|
||||
return month.date;
|
||||
} );
|
||||
} );
|
||||
console.log( response.data )
|
||||
|
||||
$scope.monthly_values = _.chain( response.data )
|
||||
.keys()
|
||||
.reverse()
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
<md-toolbar flex="100" layout="column" layout-gt-md="row" layout-align="center center">
|
||||
<h2>
|
||||
<md-input-container>
|
||||
<md-select data-ng-model="period">
|
||||
<md-select data-ng-model="period" aria-label="what">
|
||||
<md-option data-ng-repeat="period in periods">{{period}}</md-option>
|
||||
</md-select>
|
||||
</md-input-container>
|
||||
|
|
Loading…
Reference in a new issue