From d1e7e8d237e381ab3c5f476c2330c2594ddc88e8 Mon Sep 17 00:00:00 2001 From: mabashian Date: Wed, 26 Jul 2017 16:48:53 -0400 Subject: Maintain selected host/group rows on pagination and search changes --- .../inventories/related/groups/list/groups-list.controller.js | 10 ++++++++-- .../nested-groups/group-nested-groups-list.controller.js | 10 ++++++++-- .../related/nested-hosts/group-nested-hosts-list.controller.js | 5 +++++ .../inventories/related/hosts/list/host-list.controller.js | 5 +++++ 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/awx/ui/client/src/inventories-hosts/inventories/related/groups/list/groups-list.controller.js b/awx/ui/client/src/inventories-hosts/inventories/related/groups/list/groups-list.controller.js index 78a0969009..cddd4b276b 100644 --- a/awx/ui/client/src/inventories-hosts/inventories/related/groups/list/groups-list.controller.js +++ b/awx/ui/client/src/inventories-hosts/inventories/related/groups/list/groups-list.controller.js @@ -33,7 +33,7 @@ $scope.inventory_id = $stateParams.inventory_id; $scope.$watchCollection(list.name, function(){ - _.forEach($scope[list.name], buildStatusIndicators); + _.forEach($scope[list.name], processRow); }); $scope.$on('selectedOrDeselected', function(e, value) { @@ -54,11 +54,17 @@ } - function buildStatusIndicators(group){ + function processRow(group){ if (group === undefined || group === null) { group = {}; } + angular.forEach($scope.groupsSelected, function(selectedGroup){ + if(selectedGroup.id === group.id) { + group.isSelected = true; + } + }); + let hosts_status; hosts_status = GetHostsStatusMsg({ diff --git a/awx/ui/client/src/inventories-hosts/inventories/related/groups/related/nested-groups/group-nested-groups-list.controller.js b/awx/ui/client/src/inventories-hosts/inventories/related/groups/related/nested-groups/group-nested-groups-list.controller.js index d5e5c39ffb..0b645ba12d 100644 --- a/awx/ui/client/src/inventories-hosts/inventories/related/groups/related/nested-groups/group-nested-groups-list.controller.js +++ b/awx/ui/client/src/inventories-hosts/inventories/related/groups/related/nested-groups/group-nested-groups-list.controller.js @@ -34,7 +34,7 @@ $scope.inventory_id = $stateParams.inventory_id; $scope.$watchCollection(list.name, function(){ - _.forEach($scope[list.name], buildStatusIndicators); + _.forEach($scope[list.name], processRow); }); $scope.$on('selectedOrDeselected', function(e, value) { @@ -55,11 +55,17 @@ } - function buildStatusIndicators(group){ + function processRow(group){ if (group === undefined || group === null) { group = {}; } + angular.forEach($scope.groupsSelected, function(selectedGroup){ + if(selectedGroup.id === group.id) { + group.isSelected = true; + } + }); + let hosts_status; hosts_status = GetHostsStatusMsg({ diff --git a/awx/ui/client/src/inventories-hosts/inventories/related/groups/related/nested-hosts/group-nested-hosts-list.controller.js b/awx/ui/client/src/inventories-hosts/inventories/related/groups/related/nested-hosts/group-nested-hosts-list.controller.js index a4e449f88b..a6adaad5a2 100644 --- a/awx/ui/client/src/inventories-hosts/inventories/related/groups/related/nested-hosts/group-nested-hosts-list.controller.js +++ b/awx/ui/client/src/inventories-hosts/inventories/related/groups/related/nested-hosts/group-nested-hosts-list.controller.js @@ -34,6 +34,11 @@ export default ['$scope', 'NestedHostsListDefinition', '$rootScope', 'GetBasePat value.can_disassociate = true; } }); + angular.forEach($scope.hostsSelected, function(selectedHost){ + if(selectedHost.id === value.id) { + value.isSelected = true; + } + }); return value; }); setJobStatus(); diff --git a/awx/ui/client/src/inventories-hosts/inventories/related/hosts/list/host-list.controller.js b/awx/ui/client/src/inventories-hosts/inventories/related/hosts/list/host-list.controller.js index d1dfbbaac1..7f51502a20 100644 --- a/awx/ui/client/src/inventories-hosts/inventories/related/hosts/list/host-list.controller.js +++ b/awx/ui/client/src/inventories-hosts/inventories/related/hosts/list/host-list.controller.js @@ -31,6 +31,11 @@ export default ['$scope', 'ListDefinition', '$rootScope', 'GetBasePath', $scope[list.name] = _.map($scope.hosts, function(value) { value.inventory_name = value.summary_fields.inventory.name; value.inventory_id = value.summary_fields.inventory.id; + angular.forEach($scope.hostsSelected, function(selectedHost){ + if(selectedHost.id === value.id) { + value.isSelected = true; + } + }); return value; }); setJobStatus(); -- cgit v1.2.3