transaction details (using code copied from TransactionListCtrl)
This commit is contained in:
@@ -211,14 +211,55 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$location'
|
||||
} ]);
|
||||
|
||||
transactionControllers.controller('TransactionDetailCtrl', [ '$scope', '$routeParams', '$resource', '$location', function($scope, $routeParams, $resource, $location) {
|
||||
var transaction = $resource($routeParams.transactionURI).get();
|
||||
transaction.$promise.then(function(data) {
|
||||
transaction.category = $resource(transaction._links.category.href).get();
|
||||
transaction.creditor = $resource(transaction._links.creditor.href).get();
|
||||
transaction.account = $resource(transaction._links.account.href).get();
|
||||
});
|
||||
|
||||
$scope.transaction = transaction;
|
||||
$scope.initDetails = function() {
|
||||
console.log('initDetails()');
|
||||
|
||||
var transaction = $resource($routeParams.transactionURI).get();
|
||||
transaction.$promise.then(function(data) {
|
||||
transaction.date = new Date(transaction.date);
|
||||
transaction.category = $resource(transaction._links.category.href).get();
|
||||
transaction.creditor = $resource(transaction._links.creditor.href).get();
|
||||
transaction.account = $resource(transaction._links.account.href).get();
|
||||
|
||||
});
|
||||
|
||||
$scope.transaction = transaction;
|
||||
|
||||
// FIXME
|
||||
// TODO The rest of this function is *copied code* from TransactionListCtrl and desperately needs to be moved into a service
|
||||
|
||||
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) {
|
||||
$scope.accounts = accountInfo._embedded.accounts;
|
||||
$scope.account = $scope.accounts[0];
|
||||
|
||||
var categories = $resource('/categories/search/listForAccount', { accountId: $scope.accounts[0].id }).get();
|
||||
categories.$promise.then(function(data) {
|
||||
$scope.categories = categories._embedded.categories;
|
||||
|
||||
//$scope.categories.push({id: -1, name: '────────────────', position: 9999, disabled: true});
|
||||
$scope.categories.push({id: -1, name: 'private Entnahme', position: 10000, _links: { self: {href: 'withdrawal'}}});
|
||||
|
||||
// FIXME Code from TransactionListCtrl.refreshList()
|
||||
var accountUsers = $resource($scope.account._links.users.href).get();
|
||||
accountUsers.$promise.then(function(data) {
|
||||
$scope.accountUsers = accountUsers._embedded.users;
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
$scope.deleteTransaction = function(transaction) {
|
||||
/*console.log(angular.toJson(transaction, false));*/
|
||||
@@ -228,6 +269,8 @@ transactionControllers.controller('TransactionDetailCtrl', [ '$scope', '$routePa
|
||||
$location.path('/');
|
||||
});
|
||||
}
|
||||
|
||||
$scope.initDetails();
|
||||
|
||||
} ]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user