mirror of
https://github.com/ansible/awx.git
synced 2026-01-12 18:40:01 -03:30
Prevent duplicate host filter strings
This commit is contained in:
parent
e1ee95234e
commit
5be6d5bf26
@ -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";
|
||||
|
||||
|
||||
@ -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));
|
||||
|
||||
@ -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];
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user