diff --git a/awx/ui/client/src/inventories-hosts/inventories/smart-inventory/add/smart-inventory-add.controller.js b/awx/ui/client/src/inventories-hosts/inventories/smart-inventory/add/smart-inventory-add.controller.js index ff0e6f6aad..533bf256a9 100644 --- a/awx/ui/client/src/inventories-hosts/inventories/smart-inventory/add/smart-inventory-add.controller.js +++ b/awx/ui/client/src/inventories-hosts/inventories/smart-inventory/add/smart-inventory-add.controller.js @@ -54,10 +54,7 @@ function SmartInventoryAdd($scope, $location, data.variables = ToJSON($scope.parseType, $scope.smartinventory_variables, true); - let decodedHostFilter = decodeURIComponent($scope.smart_hosts.host_filter); - decodedHostFilter = decodedHostFilter.replace(/__icontains_DEFAULT/g, "__icontains"); - decodedHostFilter = decodedHostFilter.replace(/__search_DEFAULT/g, "__search"); - data.host_filter = decodedHostFilter; + data.host_filter = decodeURIComponent($scope.smart_hosts.host_filter); data.kind = "smart"; diff --git a/awx/ui/client/src/inventories-hosts/inventories/smart-inventory/smart-inventory-host-filter/smart-inventory-host-filter.controller.js b/awx/ui/client/src/inventories-hosts/inventories/smart-inventory/smart-inventory-host-filter/smart-inventory-host-filter.controller.js index 22b915471c..e9222f8b0c 100644 --- a/awx/ui/client/src/inventories-hosts/inventories/smart-inventory/smart-inventory-host-filter/smart-inventory-host-filter.controller.js +++ b/awx/ui/client/src/inventories-hosts/inventories/smart-inventory/smart-inventory-host-filter/smart-inventory-host-filter.controller.js @@ -21,10 +21,7 @@ export default ['$scope', 'QuerySet', 'InventoryHostsStrings', $.each(searchParam, function(index, param) { let paramParts = decodeURIComponent(param).split(/=(.+)/); - paramParts[0] = paramParts[0].replace(/__icontains(_DEFAULT)?/g, ""); - paramParts[0] = paramParts[0].replace(/__search(_DEFAULT)?/g, ""); - let reconstructedSearchString = qs.decodeParam(paramParts[1], paramParts[0]); - $scope.hostFilterTags.push(reconstructedSearchString); + $scope.hostFilterTags.push(qs.decodeParam(paramParts[1], paramParts[0])); }); $scope.hostFilterTags = $scope.hostFilterTags.concat(qs.stripDefaultParams(hostFilterCopy)); diff --git a/awx/ui/client/src/shared/smart-search/queryset.service.js b/awx/ui/client/src/shared/smart-search/queryset.service.js index ec54dfd4c7..4b9595e639 100644 --- a/awx/ui/client/src/shared/smart-search/queryset.service.js +++ b/awx/ui/client/src/shared/smart-search/queryset.service.js @@ -80,10 +80,20 @@ export default ['$q', 'Rest', 'ProcessErrors', '$rootScope', 'Wait', 'DjangoSear let valueString = paramParts[1]; if(keySplit.length === 1) { if(params.searchTerm && !lessThanGreaterThan) { - paramString += keySplit[0] + '__icontains_DEFAULT'; + if(params.singleSearchParam) { + paramString += keySplit[0] + '__icontains'; + } + else { + paramString += keySplit[0] + '__icontains_DEFAULT'; + } } else if(params.relatedSearchTerm) { - paramString += keySplit[0] + '__search_DEFAULT'; + if(params.singleSearchParam) { + paramString += keySplit[0] + '__search'; + } + else { + paramString += keySplit[0] + '__search_DEFAULT'; + } } else { paramString += keySplit[0]; diff --git a/awx/ui/client/src/shared/smart-search/smart-search.controller.js b/awx/ui/client/src/shared/smart-search/smart-search.controller.js index c889a0b98b..5b47b77ece 100644 --- a/awx/ui/client/src/shared/smart-search/smart-search.controller.js +++ b/awx/ui/client/src/shared/smart-search/smart-search.controller.js @@ -236,7 +236,14 @@ export default ['$stateParams', '$scope', '$state', 'GetBasePath', 'QuerySet', ' return sourceValue; } else { - return object[key] + "%20and%20" + sourceValue; + let singleSearchParamKeys = object[key].split("%20and%20"); + + if(_.includes(singleSearchParamKeys, sourceValue)) { + return object[key]; + } + else { + return object[key] + "%20and%20" + sourceValue; + } } } // Start the array of keys