Cleanup, sort accounts after saving.

This commit is contained in:
Alexis Lahouze 2015-08-19 17:13:31 +02:00
parent 25f43228dd
commit 4bd8bb3819

View File

@ -92,6 +92,17 @@ accountantApp
} }
return promise.then(function(data) { 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."); notificationService.success("Account #" + data.id + " saved.");
return data; return data;
@ -103,7 +114,6 @@ accountantApp
*/ */
$scope.deleteAccount = function(account, $index) { $scope.deleteAccount = function(account, $index) {
var id = account.id; var id = account.id;
var index = $index;
bootbox.confirm( bootbox.confirm(
"Voulez-vous supprimer le compte \"" + account.name + "\" ?", "Voulez-vous supprimer le compte \"" + account.name + "\" ?",
@ -113,7 +123,7 @@ accountantApp
notificationService.success("Account #" + id + " deleted."); notificationService.success("Account #" + id + " deleted.");
// Remove account from array. // Remove account from array.
$scope.accounts.splice(index, 1); $scope.accounts.splice($index, 1);
}); });
} }
} }