1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-02 01:21:21 +03:00

Fixed host_filter searching related fields

This commit is contained in:
mabashian 2017-09-26 16:51:08 -04:00
parent 2ec675cf54
commit 1752a97315
No known key found for this signature in database
GPG Key ID: 436B8D5EDC704CE3
2 changed files with 17 additions and 2 deletions

View File

@ -93,7 +93,7 @@ export default ['$q', 'Rest', 'ProcessErrors', '$rootScope', 'Wait', 'DjangoSear
}
else if(params.relatedSearchTerm) {
if(params.singleSearchParam) {
paramString += keySplit[0] + '__search';
paramString += keySplit[0];
}
else {
paramString += keySplit[0] + '__search_DEFAULT';

View File

@ -193,7 +193,22 @@ export default ['$stateParams', '$scope', '$state', 'GetBasePath', 'QuerySet', '
params = _.merge(params, searchWithoutKey(term), combineSameSearches);
}
else {
params = _.merge(params, qs.encodeParam({term: term, searchTerm: true, singleSearchParam: $scope.singleSearchParam ? $scope.singleSearchParam : false}), combineSameSearches);
let root = termParts[0].split(".")[0].replace(/^-/, '');
if(_.has($scope.models[$scope.list.name].base, root)) {
if($scope.models[$scope.list.name].base[root].type && $scope.models[$scope.list.name].base[root].type === 'field') {
params = _.merge(params, qs.encodeParam({term: term, relatedSearchTerm: true, singleSearchParam: $scope.singleSearchParam ? $scope.singleSearchParam : false}), combineSameSearches);
}
else {
params = _.merge(params, qs.encodeParam({term: term, searchTerm: true, singleSearchParam: $scope.singleSearchParam ? $scope.singleSearchParam : false}), combineSameSearches);
}
}
else if(_.contains($scope.models[$scope.list.name].related, root)) {
params = _.merge(params, qs.encodeParam({term: term, relatedSearchTerm: true, singleSearchParam: $scope.singleSearchParam ? $scope.singleSearchParam : false}), combineSameSearches);
}
// Its not a search term or a related search term - treat it as a string
else {
params = _.merge(params, searchWithoutKey(term), combineSameSearches);
}
}
}