problems saving - try curl first
This commit is contained in:
@@ -2,21 +2,37 @@ var transactionControllers = angular.module('transactionControllers', ['ngResour
|
||||
|
||||
transactionControllers.controller('TransactionListCtrl', [ '$scope', '$location', '$resource', function($scope, $location, $resource) {
|
||||
|
||||
// TODO pass accountId
|
||||
$scope.accountId = 1;
|
||||
|
||||
$scope.initList = function() {
|
||||
$scope.refreshList = function() {
|
||||
|
||||
console.log('refreshList()');
|
||||
|
||||
var transactions = $resource('/transactions/search/last10', { accountId: $scope.accountId }).get();
|
||||
|
||||
|
||||
transactions.$promise.then(function(data) {
|
||||
$scope.transactions = transactions._embedded.transactions;
|
||||
|
||||
for (var i = 0; i < $scope.transactions.length; i++) {
|
||||
$scope.transactions[i].category = $resource($scope.transactions[i]._links.category.href).get();
|
||||
$scope.transactions[i].creditor = $resource($scope.transactions[i]._links.creditor.href).get();
|
||||
// $scope.transactions[i].account = $resource($scope.transactions[i]._links.account.href).get();
|
||||
}
|
||||
|
||||
// XXX get selected account from frontend
|
||||
$scope.account = $scope.transactions[0]._links.account;
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
$scope.initList = function() {
|
||||
|
||||
// TODO pass accountId
|
||||
$scope.accountId = 1;
|
||||
|
||||
console.log('initList()');
|
||||
|
||||
$scope.date = new Date();
|
||||
|
||||
$scope.refreshList();
|
||||
|
||||
var categories = $resource('/categories/search/listForAccount', { accountId: $scope.accountId }).get();
|
||||
|
||||
@@ -24,14 +40,16 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$location'
|
||||
$scope.categories = categories._embedded.categories;
|
||||
|
||||
// select the first entry as default
|
||||
$scope.categorySelection = categories._embedded.categories[0];
|
||||
$scope.category = categories._embedded.categories[0];
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
$scope.postTransaction = function() {
|
||||
|
||||
// // simple HTTP POST
|
||||
console.log('postTransaction()');
|
||||
|
||||
// simple HTTP POST
|
||||
// $http.post('/transactions', { "amount" : $scope.amount /* date, */ }).success(function() {
|
||||
// console.log('REFRESH');
|
||||
// $scope.initList();
|
||||
@@ -49,7 +67,11 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$location'
|
||||
"creditor" : $scope.creditor
|
||||
});
|
||||
|
||||
console.log(newTransaction);
|
||||
|
||||
newTransaction.$save();
|
||||
|
||||
$scope.refreshList();
|
||||
};
|
||||
|
||||
$scope.showTransaction = function(transaction) {
|
||||
|
||||
Reference in New Issue
Block a user