diff --git a/awx/ui/client/src/inventories-hosts/hosts/related/groups/hosts-related-groups-associate.route.js b/awx/ui/client/src/inventories-hosts/hosts/related/groups/hosts-related-groups-associate.route.js index 169a9d6b7a..c1567200d2 100644 --- a/awx/ui/client/src/inventories-hosts/hosts/related/groups/hosts-related-groups-associate.route.js +++ b/awx/ui/client/src/inventories-hosts/hosts/related/groups/hosts-related-groups-associate.route.js @@ -13,7 +13,7 @@ export default { controller: function($scope, $q, GroupsService, $state){ $scope.associateGroups = function(selectedItems){ var deferred = $q.defer(); - return $q.all( _.map(selectedItems, (id) => GroupsService.associateHost({id: parseInt($state.params.host_id)}, id)) ) + return $q.all( _.map(selectedItems, (selectedItem) => GroupsService.associateHost({id: parseInt($state.params.host_id)}, selectedItem.id)) ) .then( () =>{ deferred.resolve(); }, (error) => { diff --git a/awx/ui/client/src/inventories-hosts/inventories/related/groups/related/nested-groups/group-nested-groups-associate.route.js b/awx/ui/client/src/inventories-hosts/inventories/related/groups/related/nested-groups/group-nested-groups-associate.route.js index 6125e02da7..294dcf031c 100644 --- a/awx/ui/client/src/inventories-hosts/inventories/related/groups/related/nested-groups/group-nested-groups-associate.route.js +++ b/awx/ui/client/src/inventories-hosts/inventories/related/groups/related/nested-groups/group-nested-groups-associate.route.js @@ -13,7 +13,7 @@ export default { controller: function($scope, $q, GroupsService, $state){ $scope.associateGroups = function(selectedItems){ var deferred = $q.defer(); - return $q.all( _.map(selectedItems, (id) => GroupsService.associateGroup({id: id}, $state.params.group_id)) ) + return $q.all( _.map(selectedItems, (selectedItem) => GroupsService.associateGroup({id: selectedItem.id}, $state.params.group_id)) ) .then( () =>{ deferred.resolve(); }, (error) => { diff --git a/awx/ui/client/src/inventories-hosts/inventories/related/groups/related/nested-hosts/group-nested-hosts-associate.route.js b/awx/ui/client/src/inventories-hosts/inventories/related/groups/related/nested-hosts/group-nested-hosts-associate.route.js index df09d30d80..959055ad02 100644 --- a/awx/ui/client/src/inventories-hosts/inventories/related/groups/related/nested-hosts/group-nested-hosts-associate.route.js +++ b/awx/ui/client/src/inventories-hosts/inventories/related/groups/related/nested-hosts/group-nested-hosts-associate.route.js @@ -13,7 +13,7 @@ export default { controller: function($scope, $q, GroupsService, $state){ $scope.associateHosts = function(selectedItems){ var deferred = $q.defer(); - return $q.all( _.map(selectedItems, (id) => GroupsService.associateHost({id: id}, $state.params.group_id)) ) + return $q.all( _.map(selectedItems, (selectedItem) => GroupsService.associateHost({id: selectedItem.id}, $state.params.group_id)) ) .then( () =>{ deferred.resolve(); }, (error) => { diff --git a/awx/ui/client/src/inventories-hosts/inventories/related/hosts/related/nested-groups/host-nested-groups-associate.route.js b/awx/ui/client/src/inventories-hosts/inventories/related/hosts/related/nested-groups/host-nested-groups-associate.route.js index 2b9a865b18..d17a181687 100644 --- a/awx/ui/client/src/inventories-hosts/inventories/related/hosts/related/nested-groups/host-nested-groups-associate.route.js +++ b/awx/ui/client/src/inventories-hosts/inventories/related/hosts/related/nested-groups/host-nested-groups-associate.route.js @@ -13,7 +13,7 @@ export default { controller: function($scope, $q, GroupsService, $state){ $scope.associateGroups = function(selectedItems){ var deferred = $q.defer(); - return $q.all( _.map(selectedItems, (id) => GroupsService.associateHost({id: parseInt($state.params.host_id)}, id)) ) + return $q.all( _.map(selectedItems, (selectedItem) => GroupsService.associateHost({id: parseInt($state.params.host_id)}, selectedItem.id)) ) .then( () =>{ deferred.resolve(); }, (error) => { diff --git a/awx/ui/client/src/inventories-hosts/shared/associate-groups/associate-groups.controller.js b/awx/ui/client/src/inventories-hosts/shared/associate-groups/associate-groups.controller.js index ec06428d96..f6f4fc4bed 100644 --- a/awx/ui/client/src/inventories-hosts/shared/associate-groups/associate-groups.controller.js +++ b/awx/ui/client/src/inventories-hosts/shared/associate-groups/associate-groups.controller.js @@ -35,6 +35,10 @@ list.multiSelect = true; list.fields.name.ngClick = 'linkoutGroup(associate_group.id)'; list.trackBy = 'associate_group.id'; + list.multiSelectPreview = { + selectedRows: 'selectedItems', + availableRows: 'associate_groups' + }; delete list.actions; delete list.fieldActions; delete list.fields.failed_hosts; @@ -58,9 +62,11 @@ $scope.$watchCollection('associate_groups', function () { if($scope.selectedItems) { $scope.associate_groups.forEach(function(row, i) { - if (_.includes($scope.selectedItems, row.id)) { - $scope.associate_groups[i].isSelected = true; - } + $scope.selectedItems.forEach(function(selectedItem) { + if(selectedItem.id === row.id) { + $scope.associate_groups[i].isSelected = true; + } + }); }); } }); @@ -72,14 +78,14 @@ let item = value.value; if (value.isSelected) { - $scope.selectedItems.push(item.id); + $scope.selectedItems.push(item); } else { // _.remove() Returns the new array of removed elements. // This will pull all the values out of the array that don't // match the deselected item effectively removing it $scope.selectedItems = _.remove($scope.selectedItems, function(selectedItem) { - return selectedItem !== item.id; + return selectedItem.id !== item.id; }); } }); diff --git a/awx/ui/client/src/inventories-hosts/shared/associate-groups/associate-groups.partial.html b/awx/ui/client/src/inventories-hosts/shared/associate-groups/associate-groups.partial.html index 02a493af8c..54c3533f25 100644 --- a/awx/ui/client/src/inventories-hosts/shared/associate-groups/associate-groups.partial.html +++ b/awx/ui/client/src/inventories-hosts/shared/associate-groups/associate-groups.partial.html @@ -3,7 +3,7 @@