diff --git a/accountant/frontend/static/js/accounts.js b/accountant/frontend/static/js/accounts.js index b82fc07..28029ba 100644 --- a/accountant/frontend/static/js/accounts.js +++ b/accountant/frontend/static/js/accounts.js @@ -92,6 +92,17 @@ accountantApp } return promise.then(function(data) { + // Sort accounts by name. + $scope.accounts.sort(function(a, b) { + if(a.name < b.name) { + return -1; + } else if(a.name > b.name) { + return 1; + } else { + return a.id - b.id; + } + }); + notificationService.success("Account #" + data.id + " saved."); return data; @@ -103,7 +114,6 @@ accountantApp */ $scope.deleteAccount = function(account, $index) { var id = account.id; - var index = $index; bootbox.confirm( "Voulez-vous supprimer le compte \"" + account.name + "\" ?", @@ -113,7 +123,7 @@ accountantApp notificationService.success("Account #" + id + " deleted."); // Remove account from array. - $scope.accounts.splice(index, 1); + $scope.accounts.splice($index, 1); }); } }