(untested) bugfix for import category loading
This commit is contained in:
@@ -383,6 +383,26 @@ transactionControllers.controller('ImportCtrl', [ '$scope', '$resource', '$locat
|
|||||||
$location.path('importList');
|
$location.path('importList');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$scope.reloadCategories = function () {
|
||||||
|
var categories = $resource('/api/categories/search/listForAccount', { accountId: $scope.account.id }).get();
|
||||||
|
categories.$promise.then(function(data) {
|
||||||
|
$scope.categories = categories._embedded.categories;
|
||||||
|
|
||||||
|
// remove retired categories
|
||||||
|
for (i = 0; i < $scope.categories.length; i++) {
|
||||||
|
if ($scope.categories[i].retired) {
|
||||||
|
$scope.categories.splice(i, 1);
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($scope.importForm) {
|
||||||
|
$scope.importForm.$setPristine();
|
||||||
|
$scope.importForm.$setUntouched();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
$scope.initPage = function () {
|
$scope.initPage = function () {
|
||||||
var userinfo = $resource('/user').get();
|
var userinfo = $resource('/user').get();
|
||||||
userinfo.$promise.then(function(data) {
|
userinfo.$promise.then(function(data) {
|
||||||
@@ -397,24 +417,7 @@ transactionControllers.controller('ImportCtrl', [ '$scope', '$resource', '$locat
|
|||||||
accountInfo.$promise.then(function(data) {
|
accountInfo.$promise.then(function(data) {
|
||||||
$scope.accounts = accountInfo._embedded.accounts;
|
$scope.accounts = accountInfo._embedded.accounts;
|
||||||
$scope.account = $scope.accounts[0];
|
$scope.account = $scope.accounts[0];
|
||||||
|
$scope.reloadCategories();
|
||||||
var categories = $resource('/api/categories/search/listForAccount', { accountId: $scope.account.id }).get();
|
|
||||||
categories.$promise.then(function(data) {
|
|
||||||
$scope.categories = categories._embedded.categories;
|
|
||||||
|
|
||||||
// remove retired categories
|
|
||||||
for (i = 0; i < $scope.categories.length; i++) {
|
|
||||||
if ($scope.categories[i].retired) {
|
|
||||||
$scope.categories.splice(i, 1);
|
|
||||||
i--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($scope.importForm) {
|
|
||||||
$scope.importForm.$setPristine();
|
|
||||||
$scope.importForm.$setUntouched();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
<div ng-show="accounts.length > 1" style="margin: 2ex; text-align: center; font-size: 120%;">
|
<div ng-show="accounts.length > 1" style="margin: 2ex; text-align: center; font-size: 120%;">
|
||||||
<select
|
<select
|
||||||
ng-model='account'
|
ng-model='account'
|
||||||
|
ng-change='reloadCategories()'
|
||||||
ng-options="account.name for account in accounts track by account.id"></select>
|
ng-options="account.name for account in accounts track by account.id"></select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user