diff --git a/accountant/frontend/static/js/accounts.js b/accountant/frontend/static/js/accounts.js index 794d274..acfb51f 100644 --- a/accountant/frontend/static/js/accounts.js +++ b/accountant/frontend/static/js/accounts.js @@ -19,7 +19,7 @@ // The AccountController. accountantApp -.factory("Accounts", ["$resource", function($resource) { +.factory("Account", ["$resource", function($resource) { return $resource( "/api/accounts/:id", { id: "@id" @@ -29,8 +29,8 @@ accountantApp .controller( "AccountController", [ - "$scope", "Accounts", "notificationService", - function($scope, Accounts, notificationService) { + "$scope", "Account", "notificationService", + function($scope, Account, notificationService) { /* * Return the class for an account current value compared to authorized @@ -66,9 +66,11 @@ accountantApp /* * Add an empty account if not already added. */ - $scope.addAccount = function() { - var account = new Accounts(); - account.authorized_overdraft = 0; + $scope.add = function() { + var account = new Account({ + authorized_overdraft: 0 + }); + $scope.accounts.splice(0, 0, account); }; @@ -86,7 +88,7 @@ accountantApp /* * Save account. */ - $scope.saveAccount = function($data, $index) { + $scope.save = function($data, $index) { var account = $scope.accounts[$index]; account = angular.merge(account, $data); @@ -120,9 +122,9 @@ accountantApp }; /* - * Delete an account and emit accountDeletedEvent. + * Delete an account. */ - $scope.deleteAccount = function(account, $index) { + $scope.delete = function(account, $index) { var id = account.id; bootbox.confirm( @@ -141,5 +143,5 @@ accountantApp }; // Load accounts. - $scope.accounts = Accounts.query(); + $scope.accounts = Account.query(); }]); diff --git a/accountant/frontend/static/templates/accounts.html b/accountant/frontend/static/templates/accounts.html index 63839b5..14859db 100644 --- a/accountant/frontend/static/templates/accounts.html +++ b/accountant/frontend/static/templates/accounts.html @@ -31,7 +31,7 @@ + ng-click="add()">Ajouter @@ -70,7 +70,7 @@
+ onbeforesave="save($data, $index)" shown="!account.id">