From 999aac007a44f5b74f788fd3cbf56247081ae29e Mon Sep 17 00:00:00 2001 From: Michael Abashian Date: Tue, 14 Jun 2016 15:13:27 -0400 Subject: [PATCH] Highlight active management job when editing notification --- .../management-jobs/card/card.controller.js | 23 +++++++++++++++++++ .../management-jobs/card/card.partial.html | 4 ++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/awx/ui/client/src/management-jobs/card/card.controller.js b/awx/ui/client/src/management-jobs/card/card.controller.js index e497f0c1d3..714e643550 100644 --- a/awx/ui/client/src/management-jobs/card/card.controller.js +++ b/awx/ui/client/src/management-jobs/card/card.controller.js @@ -35,6 +35,11 @@ export default parent_scope = scope; scope.cleanupJob = true; + // This handles the case where the user refreshes the management job notifications page. + if($state.current.name === 'managementJobsList.notifications') { + $scope.activeCard = parseInt($state.params.management_id); + $scope.cardAction = "notifications"; + } // Cancel scope.cancelConfigure = function () { @@ -263,5 +268,23 @@ export default parent_scope.refreshJobs = function(){ scope.search(SchedulesList.iterator); }; + + var cleanUpStateChangeListener = $rootScope.$on('$stateChangeSuccess', function(event, toState, toParams) { + if(toState.name === "managementJobsList") { + // We are on the management job list view - nothing needs to be highlighted + delete $scope.activeCard; + delete $scope.cardAction; + } + else if(toState.name === "managementJobsList.notifications") { + // We are on the notifications view - update the active card and the action + $scope.activeCard = parseInt(toParams.management_id); + $scope.cardAction = "notifications"; + } + }); + + // Remove the listener when the scope is destroyed to avoid a memory leak + $scope.$on('$destroy', function() { + cleanUpStateChangeListener(); + }); } ]; diff --git a/awx/ui/client/src/management-jobs/card/card.partial.html b/awx/ui/client/src/management-jobs/card/card.partial.html index cc39d59469..fc0f2b0c00 100644 --- a/awx/ui/client/src/management-jobs/card/card.partial.html +++ b/awx/ui/client/src/management-jobs/card/card.partial.html @@ -10,7 +10,7 @@
+ ng-repeat="card in mgmtCards track by card.id" ng-class="{'MgmtCards-card--selected': activeCard === card.id}">

{{ card.name }}

@@ -27,7 +27,7 @@