diff --git a/accountant-ui/js/accounts.js b/accountant-ui/js/accounts.js index 11719cc..85d0f92 100644 --- a/accountant-ui/js/accounts.js +++ b/accountant-ui/js/accounts.js @@ -110,11 +110,11 @@ angular.module('accountant.accounts', [ * Cancel account edition. Remove it from array if a new one. */ $scope.cancelEdit = function(rowform, account, $index) { - if (!account.id) { + if (account.id) { + rowform.$cancel(); + } else { // Account not saved, just remove it from array. $scope.accounts.splice($index, 1); - } else { - rowform.$cancel(); } }; diff --git a/accountant-ui/js/operations.js b/accountant-ui/js/operations.js index a29d9bf..7a1f55a 100644 --- a/accountant-ui/js/operations.js +++ b/accountant-ui/js/operations.js @@ -391,10 +391,10 @@ angular.module('accountant.operations', [ * Cancel edition. */ $scope.cancelEdit = function(operation, rowform, $index) { - if (!operation.id) { - $scope.operations.splice($index, 1); - } else { + if (operation.id) { rowform.$cancel(); + } else { + $scope.operations.splice($index, 1); } }; diff --git a/accountant-ui/js/scheduler.js b/accountant-ui/js/scheduler.js index 8c2731c..bc2d3ee 100644 --- a/accountant-ui/js/scheduler.js +++ b/accountant-ui/js/scheduler.js @@ -89,10 +89,10 @@ angular.module('accountant.scheduler', [ * Cancel operation edition. Delete if new. */ $scope.cancelEdit = function(operation, rowform, $index) { - if (!operation.id) { - $scope.operations.splice($index, 1); - } else { + if (operation.id) { rowform.$cancel(); + } else { + $scope.operations.splice($index, 1); } };