diff --git a/src/main/resources/static/app/controllers.js b/src/main/resources/static/app/controllers.js index 1a8f280..ab2a078 100644 --- a/src/main/resources/static/app/controllers.js +++ b/src/main/resources/static/app/controllers.js @@ -383,6 +383,26 @@ transactionControllers.controller('ImportCtrl', [ '$scope', '$resource', '$locat $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 () { var userinfo = $resource('/user').get(); userinfo.$promise.then(function(data) { @@ -397,24 +417,7 @@ transactionControllers.controller('ImportCtrl', [ '$scope', '$resource', '$locat accountInfo.$promise.then(function(data) { $scope.accounts = accountInfo._embedded.accounts; $scope.account = $scope.accounts[0]; - - 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.reloadCategories(); }); }); } diff --git a/src/main/resources/static/app/import.html b/src/main/resources/static/app/import.html index a11bd68..2450868 100644 --- a/src/main/resources/static/app/import.html +++ b/src/main/resources/static/app/import.html @@ -3,6 +3,7 @@