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

@ -61,6 +61,9 @@ class ScheduledOperationListResource(Resource):
@session_aware @session_aware
@marshal_with_field(fields.List(Object(resource_fields))) @marshal_with_field(fields.List(Object(resource_fields)))
def get(self, session): def get(self, session):
"""
Get all scheduled operation for the account.
"""
kwargs = get_parser.parse_args() kwargs = get_parser.parse_args()
return ScheduledOperation.get_scheduled_operations_for_account( return ScheduledOperation.get_scheduled_operations_for_account(
@ -97,6 +100,9 @@ class ScheduledOperationResource(Resource):
@session_aware @session_aware
@marshal_with_field(Object(resource_fields)) @marshal_with_field(Object(resource_fields))
def delete(self, scheduled_operation_id, session): def delete(self, scheduled_operation_id, session):
"""
Delete a scheduled operation.
"""
try: try:
scheduled_operation = ScheduledOperation.get( scheduled_operation = ScheduledOperation.get(
session, scheduled_operation_id) session, scheduled_operation_id)
@ -110,6 +116,9 @@ class ScheduledOperationResource(Resource):
@session_aware @session_aware
@marshal_with_field(Object(resource_fields)) @marshal_with_field(Object(resource_fields))
def post(self, scheduled_operation_id, session): def post(self, scheduled_operation_id, session):
"""
Update a scheduled operation.
"""
kwargs = parser.parse_args() kwargs = parser.parse_args()
assert (id not in kwargs or kwargs.id is None assert (id not in kwargs or kwargs.id is None

View File

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