Add support for multiple new scheduled operations.
This commit is contained in:
parent
8868dd18c2
commit
b5a483e8e5
@ -34,11 +34,9 @@ accountantApp
|
|||||||
$scope.categories = [];
|
$scope.categories = [];
|
||||||
|
|
||||||
$scope.addOperation = function() {
|
$scope.addOperation = function() {
|
||||||
if(! $scope.inserted) {
|
operation = new ScheduledOperations({});
|
||||||
$scope.inserted = new ScheduledOperations({});
|
operation.account_id = $routeParams.accountId;
|
||||||
$scope.inserted.account_id = $routeParams.accountId;
|
$scope.operations.splice(0, 0, operation);
|
||||||
$scope.operations.splice(0, 0, $scope.inserted);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.loadOperations = function(accountId) {
|
$scope.loadOperations = function(accountId) {
|
||||||
@ -62,25 +60,16 @@ accountantApp
|
|||||||
operation = angular.merge(operation, $data);
|
operation = angular.merge(operation, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
var promise = operation.$save();
|
return operation.$save().then(function(data) {
|
||||||
|
|
||||||
if(operation == $scope.inserted) {
|
|
||||||
promise = promise.then(function(data) {
|
|
||||||
$scope.inserted = false;
|
|
||||||
return data;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return promise.then(function(data) {
|
|
||||||
notificationService.success("Operation #" + data.id + " saved.");
|
notificationService.success("Operation #" + data.id + " saved.");
|
||||||
return data;
|
return data;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// Reload operation from server to cancel edition.
|
// Reload operation from server to cancel edition.
|
||||||
$scope.cancelEditOperation = function(operation, rowform) {
|
$scope.cancelEditOperation = function(operation, rowform, $index) {
|
||||||
if(operation == $scope.inserted) {
|
if(!operation.id) {
|
||||||
$scope.entries.splice(0, 1);
|
$scope.operations.splice($index, 1);
|
||||||
} else {
|
} else {
|
||||||
rowform.$cancel();
|
rowform.$cancel();
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@
|
|||||||
<td>
|
<td>
|
||||||
<form editable-form name="rowform"
|
<form editable-form name="rowform"
|
||||||
onbeforesave="saveOperation($data, $index)"
|
onbeforesave="saveOperation($data, $index)"
|
||||||
shown="operation == inserted">
|
shown="!operation.id">
|
||||||
<div class="btn-group btn-group-xs">
|
<div class="btn-group btn-group-xs">
|
||||||
<!-- Save current operation -->
|
<!-- Save current operation -->
|
||||||
<button type="submit" class="btn btn-success"
|
<button type="submit" class="btn btn-success"
|
||||||
@ -124,13 +124,14 @@
|
|||||||
<!-- Cancel edit. -->
|
<!-- Cancel edit. -->
|
||||||
<button type="button" class="btn btn-default"
|
<button type="button" class="btn btn-default"
|
||||||
ng-if="rowform.$visible"
|
ng-if="rowform.$visible"
|
||||||
ng-click="cancelEditOperation(operation, rowform)"
|
ng-click="cancelEditOperation(operation, rowform, $index)"
|
||||||
title="Cancel">
|
title="Cancel">
|
||||||
<span class="fa fa-times"></span>
|
<span class="fa fa-times"></span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<!-- Remove operation. -->
|
<!-- Remove operation. -->
|
||||||
<button type="button" class="btn btn-default"
|
<button type="button" class="btn btn-default"
|
||||||
|
ng-if="!operation.id"
|
||||||
ng-click="delete(operation, $index)"
|
ng-click="delete(operation, $index)"
|
||||||
title="remove">
|
title="remove">
|
||||||
<span class="fa fa-trash"></span>
|
<span class="fa fa-trash"></span>
|
||||||
|
Loading…
Reference in New Issue
Block a user