Comments.

This commit is contained in:
Alexis Lahouze
2015-07-15 17:00:18 +02:00
parent bbc8e051f0
commit 6821d8d0c6
2 changed files with 21 additions and 14 deletions

View File

@ -74,6 +74,7 @@ accountantApp
});
};
// Notify on success.
$scope.$on("operationCreatedEvent", function(e, operation) {
new PNotify({
type: "success",
@ -82,12 +83,14 @@ accountantApp
});
});
// Save operation.
$scope.saveOperation = function(operation) {
operation.$save(function(data) {
$scope.$emit("operationSavedEvent", operation);
});
};
// Notify on success.
$scope.$on("operationSavedEvent", function(e, operation) {
new PNotify({
type: "success",
@ -101,36 +104,28 @@ accountantApp
operation.state='edit';
};
// Reload operation from server to cancel edition.
$scope.cancelEditOperation = function(operation) {
operation.$get();
};
// Remove an operation.
$scope.removeOperation = function(operation, modalScope) {
// Cancel current editing.
if (!$scope.isNew(operation)) {
$http.delete("/api/scheduled_operations/" + operation.id).success(function (result) {
$.pnotify({
operation.$delete(function(data) {
new PNotify({
type: "success",
title: "Delete",
text: result
text: "Operation #" + operation.id + " deleted."
});
// Send the "entry removed" event.
$scope.$emit("operationRemovedEvent", operation);
$scope.closeModal(modalScope);
}).error(function (data) {
$.pnotify({
type: "error",
title: "Delete",
text: data
});
$scope.closeModal(modalScope);
});
}
};
// Close modal.
$scope.closeModal = function(modalScope) {
// Close the modal dialog
if(modalScope && modalScope.dismiss) {
@ -138,9 +133,12 @@ accountantApp
}
};
// Load operations on account selection.
// FIXME Alexis Lahouze 2015-07-15 Deprecated.
$rootScope.$on("accountSelectedEvent", function(event, args){
$scope.loadOperations(args.account.id);
});
// Load operations on controller initialization.
$scope.loadOperations($routeParams.accountId);
}]);