bugfix for creditor resolving, delete button

This commit is contained in:
2016-07-08 23:53:43 +02:00
parent d612db1b33
commit d58faaf325
2 changed files with 20 additions and 14 deletions
+12 -11
View File
@@ -234,8 +234,9 @@ transactionControllers.controller('TransactionListCtrl', [ '$http', '$scope', '$
}
});
modalInstance.result.then(function(selectedItem) {
$scope.selected = selectedItem;
modalInstance.result.then(function(transaction) {
$scope.lastSubmission = undefined;
$scope.refreshList();
}, function () {
$log.info('Modal dismissed at: ' + new Date());
});
@@ -267,21 +268,21 @@ transactionControllers.controller('DetailsModalCtrl', [ '$scope', '$resource', '
}
}
// FIXME can't wait for the promise since most transactions return HTTP 404 for the creditor
if (transaction.creditor.name != undefined) {
transaction.creditor.$promise.then(function(data) {
$scope.transaction.creditor = $scope.transaction.creditor._links.user.href;
console.log('creditor: ' + transaction.creditor.name);
}
else {
},
function(error) { // transactions without a creditor return a HTTP 404 error
$scope.transaction.creditor = "";
}
});
});
});
$scope.ok = function () {
// set URI for category and save via PUT request
$scope.transaction.category = $scope.transaction.category._links.self.href;
$scope.transaction.$update(function() {});
$uibModalInstance.close($scope.transaction);
};
@@ -290,10 +291,10 @@ transactionControllers.controller('DetailsModalCtrl', [ '$scope', '$resource', '
};
// TODO still used?
$scope.deleteTransaction = function(transaction) {
$scope.deleteTransaction = function() {
// TODO auf return code reagieren
$resource(transaction._links.self.href).remove().$promise.then(function() {
$location.path('/');
$resource($scope.transaction._links.self.href).remove().$promise.then(function() {
$uibModalInstance.close();
});
}
} ]);
@@ -167,10 +167,15 @@
</form>
</div>
<div class="modal-footer">
<button class="btn btn-primary" ng-disabled="detailsForm.amount.$error.pattern" type="button" ng-click="ok()">OK</button>
<button class="btn btn-warning" type="button" ng-click="cancel()">Cancel</button>
<div style="float:left">
<button class="btn btn-danger" ng-click="deleteTransaction()">Löschen</button>
</div>
<div style="float:right">
<button class="btn btn-primary" ng-disabled="detailsForm.amount.$error.pattern" type="button" ng-click="ok()">OK</button>
<button class="btn btn-warning" type="button" ng-click="cancel()">Abbrechen</button>
</div>
</div>
<pre style="font-size: 75%; color: black;">{{transaction | json}}</pre>
<!-- pre style="font-size: 75%; color: black;">{{transaction | json}}</pre -->
</script>
</div>