Withdrawals and deleteLastSubmission()
This commit is contained in:
@@ -63,7 +63,6 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$location'
|
||||
}
|
||||
radioButtons[0].checked = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$scope.initList = function() {
|
||||
@@ -104,6 +103,30 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$location'
|
||||
amount = '-' + amount;
|
||||
}
|
||||
|
||||
// handle withdrawals
|
||||
if ($scope.transaction.category._links.self.href === 'withdrawal') {
|
||||
if (amount.charAt(0) === '-') {
|
||||
amount = amount.substr(1);
|
||||
}
|
||||
|
||||
var Withdrawal = $resource('/withdrawals');
|
||||
|
||||
var newWithdrawal = new Withdrawal({
|
||||
"account" : $scope.account._links.self.href,
|
||||
"amount" : amount,
|
||||
"date" : $scope.transaction.date,
|
||||
"user" : $scope.userinfo._links.self.href
|
||||
});
|
||||
|
||||
newWithdrawal.$save(function(withdrawal) {
|
||||
$scope.refreshList();
|
||||
$scope.lastSubmission = newWithdrawal;
|
||||
console.log(newWithdrawal);
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// via Resource (might be moved into a service)
|
||||
var Transaction = $resource('/transactions');
|
||||
|
||||
@@ -118,6 +141,16 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$location'
|
||||
|
||||
newTransaction.$save(function(transaction) {
|
||||
$scope.refreshList();
|
||||
$scope.lastSubmission = newTransaction;
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
$scope.deleteLastSubmission = function() {
|
||||
console.log($scope.lastSubmission._links.self.href);
|
||||
var testTrns = $resource($scope.lastSubmission._links.self.href).delete(function() {
|
||||
$scope.lastSubmission = undefined;
|
||||
$scope.refreshList();
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user