From 4cd5d9ab23e654fafc82d5697b414d116ac2aec1 Mon Sep 17 00:00:00 2001 From: John Mitchell Date: Tue, 16 Jun 2015 16:39:20 -0400 Subject: [PATCH] fix logic of active module check --- .../system-tracking.controller.js | 34 ++++++++----------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/awx/ui/static/js/system-tracking/system-tracking.controller.js b/awx/ui/static/js/system-tracking/system-tracking.controller.js index 07a20c2b2a..0ca55b9346 100644 --- a/awx/ui/static/js/system-tracking/system-tracking.controller.js +++ b/awx/ui/static/js/system-tracking/system-tracking.controller.js @@ -136,31 +136,25 @@ function controller($rootScope, } $scope.setActiveModule = function(newModuleName, initialData) { - var isAlreadyActive = false; - for (var i in $scope.modules) { - if ($scope.modules[i].name === newModuleName && - $scope.modules[i].isActive) { - isAlreadyActive = true; - } - } - var newModule = _.find($scope.modules, function(module) { return module.name === newModuleName; }); - if (!isAlreadyActive) { - $scope.modules.forEach(function(module) { - module.isActive = false; - }); - - newModule.isActive = true; - - $location.replace(); - $location.search('module', newModuleName); - - reloadData({ module: newModule - }, initialData).value(); + if (newModule.isActive) { + return; } + + $scope.modules.forEach(function(module) { + module.isActive = false; + }); + + newModule.isActive = true; + + $location.replace(); + $location.search('module', newModuleName); + + reloadData({ module: newModule + }, initialData).value(); }; function dateWatcher(dateProperty) {