diff --git a/awx/ui/client/src/inventories/manage/groups/groups-list.controller.js b/awx/ui/client/src/inventories/manage/groups/groups-list.controller.js index d6c70479c0..3b5bd9c318 100644 --- a/awx/ui/client/src/inventories/manage/groups/groups-list.controller.js +++ b/awx/ui/client/src/inventories/manage/groups/groups-list.controller.js @@ -12,6 +12,10 @@ view = generateList, pageSize = 20; $scope.inventory_id = $stateParams.inventory_id; + if($state.current.name === "inventoryManage.editGroup") { + $scope.rowBeingEdited = $state.params.group_id; + $scope.listBeingEdited = "groups"; + } $scope.groupSelect = function(id){ var group = $stateParams.group === undefined ? [id] : _($stateParams.group).concat(id).value(); $state.go('inventoryManage', {inventory_id: $stateParams.inventory_id, group: group}, {reload: true}); @@ -152,6 +156,22 @@ $state.go('inventoryManage.copyMoveGroup', {group_id: id, groups: $stateParams.groups}); }; + var cleanUpStateChangeListener = $rootScope.$on('$stateChangeSuccess', function(event, toState, toParams) { + if (toState.name === "inventoryManage.editGroup") { + $scope.rowBeingEdited = toParams.group_id; + $scope.listBeingEdited = "groups"; + } + else { + delete $scope.rowBeingEdited; + delete $scope.listBeingEdited; + } + }); + + // Remove the listener when the scope is destroyed to avoid a memory leak + $scope.$on('$destroy', function() { + cleanUpStateChangeListener(); + }); + var init = function(){ list.basePath = groupsUrl; view.inject(list,{ diff --git a/awx/ui/client/src/inventories/manage/hosts/hosts-list.controller.js b/awx/ui/client/src/inventories/manage/hosts/hosts-list.controller.js index 74532071c2..dcd35f68bb 100644 --- a/awx/ui/client/src/inventories/manage/hosts/hosts-list.controller.js +++ b/awx/ui/client/src/inventories/manage/hosts/hosts-list.controller.js @@ -11,6 +11,10 @@ var list = InventoryHosts, view = generateList, pageSize = 20; + if($state.current.name === "inventoryManage.editHost") { + $scope.rowBeingEdited = $state.params.host_id; + $scope.listBeingEdited = "hosts"; + } $scope.createHost = function(){ $state.go('inventoryManage.addHost'); }; @@ -63,6 +67,20 @@ $scope.$on('PostRefresh', ()=>{ _.forEach($scope.hosts, (host) => SetStatus({scope: $scope, host: host})); }); + var cleanUpStateChangeListener = $rootScope.$on('$stateChangeSuccess', function(event, toState, toParams) { + if (toState.name === "inventoryManage.editHost") { + $scope.rowBeingEdited = toParams.host_id; + $scope.listBeingEdited = "hosts"; + } + else { + delete $scope.rowBeingEdited; + delete $scope.listBeingEdited; + } + }); + // Remove the listener when the scope is destroyed to avoid a memory leak + $scope.$on('$destroy', function() { + cleanUpStateChangeListener(); + }); var init = function(){ list.basePath = hostsUrl; view.inject(list,{