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) { modalInstance.result.then(function(transaction) {
$scope.selected = selectedItem; $scope.lastSubmission = undefined;
$scope.refreshList();
}, function () { }, function () {
$log.info('Modal dismissed at: ' + new Date()); $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 transaction.creditor.$promise.then(function(data) {
if (transaction.creditor.name != undefined) {
$scope.transaction.creditor = $scope.transaction.creditor._links.user.href; $scope.transaction.creditor = $scope.transaction.creditor._links.user.href;
console.log('creditor: ' + transaction.creditor.name); },
} function(error) { // transactions without a creditor return a HTTP 404 error
else {
$scope.transaction.creditor = ""; $scope.transaction.creditor = "";
} });
}); });
}); });
$scope.ok = function () { $scope.ok = function () {
// set URI for category and save via PUT request
$scope.transaction.category = $scope.transaction.category._links.self.href; $scope.transaction.category = $scope.transaction.category._links.self.href;
$scope.transaction.$update(function() {}); $scope.transaction.$update(function() {});
$uibModalInstance.close($scope.transaction); $uibModalInstance.close($scope.transaction);
}; };
@@ -290,10 +291,10 @@ transactionControllers.controller('DetailsModalCtrl', [ '$scope', '$resource', '
}; };
// TODO still used? // TODO still used?
$scope.deleteTransaction = function(transaction) { $scope.deleteTransaction = function() {
// TODO auf return code reagieren // TODO auf return code reagieren
$resource(transaction._links.self.href).remove().$promise.then(function() { $resource($scope.transaction._links.self.href).remove().$promise.then(function() {
$location.path('/'); $uibModalInstance.close();
}); });
} }
} ]); } ]);
@@ -167,10 +167,15 @@
</form> </form>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button class="btn btn-primary" ng-disabled="detailsForm.amount.$error.pattern" type="button" ng-click="ok()">OK</button> <div style="float:left">
<button class="btn btn-warning" type="button" ng-click="cancel()">Cancel</button> <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> </div>
<pre style="font-size: 75%; color: black;">{{transaction | json}}</pre> <!-- pre style="font-size: 75%; color: black;">{{transaction | json}}</pre -->
</script> </script>
</div> </div>