From cf9d15b932c4ceced4c8b40b8d2a8d786f22a2f1 Mon Sep 17 00:00:00 2001 From: Alexis Lahouze Date: Mon, 20 Jul 2015 12:59:07 +0200 Subject: [PATCH] Code cleanup. --- accountant/frontend/static/js/accounts.js | 64 ----------------------- 1 file changed, 64 deletions(-) diff --git a/accountant/frontend/static/js/accounts.js b/accountant/frontend/static/js/accounts.js index 06e2829..cb38a8e 100644 --- a/accountant/frontend/static/js/accounts.js +++ b/accountant/frontend/static/js/accounts.js @@ -32,12 +32,6 @@ accountantApp "$scope", "$rootScope", "$routeParams", "Accounts", function($scope, $rootScope, $routeParams, Accounts) { - $scope.accountClass = function(account) { - if(account == $scope.selectedAccount) { - return "active"; - } - }; - $scope.valueClass = function(account, value) { if(!account) { return; @@ -144,11 +138,6 @@ accountantApp * Reload acounts when an account is deleted. */ $rootScope.$on("accountDeletedEvent", function(e, account) { - // Reset the selected account if this is the one whe have deleted. - if($scope.selectedAccount.id == account.id) { - $scope.selectedAccount = null; - } - $scope.loadAccounts(); }); @@ -165,58 +154,5 @@ accountantApp }); }; - /* - * Update the selected account with loaded one or select the first of the - * list. - */ - $rootScope.$on("accountsLoadedEvent", function(e, accounts) { - var accountToSelect = null; - - // Reset selected account to the new instance corresponding to the old - // one. - if($routeParams.accountId) { - // Find the new instance of the previously selected account. - angular.forEach($scope.accounts, function(account) { - if(account.id == $routeParams.accountId) { - // No need to emit accountSelectedEvent. - $scope.selectedAccount = account; - } - }); - } else if($scope.selectedAccount) { - // Find the new instance of the previously selected account. - angular.forEach($scope.accounts, function(account) { - if(account.id == $scope.selectedAccount.id) { - // No need to emit accountSelectedEvent. - $scope.selectedAccount = account; - } - }); - } else { - // Set selected account to first one if not yet selected - $scope.selectAccount($scope.accounts[0]); - } - }); - - /* - * Select the account to display and emit accountSelectedEvent. - */ - $scope.selectAccount = function(account) { - $scope.selectedAccount = account; - - $scope.$emit("accountSelectedEvent", {account: account}); - }; - - /* - * Refresh account information. - */ - $scope.refreshAccount = function() { - $scope.selectedAccount.$get(); - }; - - $rootScope.$on("entrySavedEvent", $scope.refreshAccount); - $rootScope.$on("entryCreatedEvent", $scope.refreshAccount); - $rootScope.$on("entryRemovedEvent", $scope.refreshAccount); - //$rootScope.$on("operationSavedEvent", $scope.refreshAccount); - //$rootScope.$on("operationRemovedEvent", $scope.refreshAccount); - $scope.loadAccounts(); }]);