Pattern processing, pt. 2
This commit is contained in:
@@ -359,7 +359,7 @@ transactionControllers.controller('OutstandingsModalCtrl', [ '$scope', '$uibModa
|
||||
}
|
||||
} ]);
|
||||
|
||||
transactionControllers.controller('ImportCtrl', [ '$scope', '$location', 'ImportService', function($scope, $location, ImportService) {
|
||||
transactionControllers.controller('ImportCtrl', [ '$scope', '$resource', '$location', 'ImportService', function($scope, $resource, $location, ImportService) {
|
||||
|
||||
$scope.importCSV = function () {
|
||||
ImportService.saveData($scope.csvInput);
|
||||
@@ -373,4 +373,45 @@ transactionControllers.controller('ImportCtrl', [ '$scope', '$location', 'Import
|
||||
console.log($scope.csv);
|
||||
}
|
||||
|
||||
// COPIED CODE from TransactionListCtrl.initList, needs to be moved into a Service
|
||||
$scope.initPage = function () {
|
||||
console.log('aloha');
|
||||
var userinfo = $resource('/user').get();
|
||||
userinfo.$promise.then(function(data) {
|
||||
$scope.userid = userinfo.name;
|
||||
|
||||
userinfo = $resource('/users/search/findByUsername', { username: $scope.userid }).get();
|
||||
userinfo.$promise.then(function(data) {
|
||||
$scope.userinfo = userinfo;
|
||||
});
|
||||
|
||||
var accountInfo = $resource('/accounts/search/findByUserName', { username: $scope.userid }).get();
|
||||
accountInfo.$promise.then(function(data) {
|
||||
console.log(accountInfo._embedded.accounts);
|
||||
$scope.accounts = accountInfo._embedded.accounts;
|
||||
if ($scope.account == undefined) {
|
||||
$scope.account = $scope.accounts[0];
|
||||
if ($routeParams.account != undefined) {
|
||||
for (i = 0; i < $scope.accounts.length; i++) {
|
||||
if ($scope.accounts[i].name == $routeParams.account)
|
||||
$scope.account = $scope.accounts[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var categories = $resource('/categories/search/listForAccount', { accountId: $scope.account.id }).get();
|
||||
categories.$promise.then(function(data) {
|
||||
$scope.categories = categories._embedded.categories;
|
||||
|
||||
if ($scope.importForm) {
|
||||
$scope.importForm.$setPristine();
|
||||
$scope.importForm.$setUntouched();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
$scope.initPage();
|
||||
|
||||
} ]);
|
||||
|
||||
Reference in New Issue
Block a user