Cleanup, sort accounts after saving.

This commit is contained in:
Alexis Lahouze 2015-08-19 17:13:31 +02:00
parent 25f43228dd
commit 4bd8bb3819
1 changed files with 12 additions and 2 deletions

View File

@ -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);
});
}
}