api-client: Use accounts.asub instead of children, needs fixing of the api
This commit is contained in:
		
							parent
							
								
									6733599a5f
								
							
						
					
					
						commit
						ee2c06c320
					
				@ -14,8 +14,8 @@
 | 
				
			|||||||
        <span class="commodity commodity-side-{{balance.astyle.ascommodityside}}">{{balance.acommodity}}</span>
 | 
					        <span class="commodity commodity-side-{{balance.astyle.ascommodityside}}">{{balance.acommodity}}</span>
 | 
				
			||||||
      </div>
 | 
					      </div>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
    <ul ng-if="account.children">
 | 
					    <ul ng-if="account.asubs">
 | 
				
			||||||
      <li ng-repeat="account in account.children | filter: account_name" ng-include="'account.html'"></li>
 | 
					      <li ng-repeat="account in account.asubs | filter: account_name" ng-include="'account.html'"></li>
 | 
				
			||||||
    </ul>
 | 
					    </ul>
 | 
				
			||||||
  </script
 | 
					  </script
 | 
				
			||||||
</div>
 | 
					</div>
 | 
				
			||||||
 | 
				
			|||||||
@ -3,19 +3,6 @@ var hledger = angular.module('hledger', [
 | 
				
			|||||||
  'ngResource'
 | 
					  'ngResource'
 | 
				
			||||||
])
 | 
					])
 | 
				
			||||||
hledger.api_root = '/api/v1';
 | 
					hledger.api_root = '/api/v1';
 | 
				
			||||||
function listToTree(list, id_field, parent_field) {
 | 
					 | 
				
			||||||
  children = function(list, parent_id) {
 | 
					 | 
				
			||||||
    return $.grep(list,
 | 
					 | 
				
			||||||
      function(element) {
 | 
					 | 
				
			||||||
        return element[parent_field] === parent_id
 | 
					 | 
				
			||||||
      });
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  $.map(list, function(element) {
 | 
					 | 
				
			||||||
    element.children = children(list, element[id_field])
 | 
					 | 
				
			||||||
  });
 | 
					 | 
				
			||||||
  root = children(list, '');
 | 
					 | 
				
			||||||
  return root;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
hledger.config(function($stateProvider, $urlRouterProvider) {
 | 
					hledger.config(function($stateProvider, $urlRouterProvider) {
 | 
				
			||||||
  //$urlRouterProvider.otherwise("/");
 | 
					  //$urlRouterProvider.otherwise("/");
 | 
				
			||||||
@ -60,7 +47,7 @@ hledger.factory('Account', function($resource) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
hledger.controller("AccountsController", function($scope, Account) {
 | 
					hledger.controller("AccountsController", function($scope, Account) {
 | 
				
			||||||
  Account.query(function(data) {
 | 
					  Account.query(function(data) {
 | 
				
			||||||
    $scope.accounts = listToTree(data, 'aname', 'aparentname')[0].children;
 | 
					    $scope.accounts = data;
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user