From ae69ca8919502ce175ed6d2b6afce835da57365b Mon Sep 17 00:00:00 2001 From: jaredevantabor Date: Thu, 9 Feb 2017 13:11:29 -0800 Subject: [PATCH] fixing related searches w/ smart search --- .../src/shared/smart-search/smart-search.controller.js | 7 +++++++ 1 file changed, 7 insertions(+) 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 ff4c54b52c..bbac64b37d 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 @@ -249,6 +249,13 @@ export default ['$stateParams', '$scope', '$state', 'QuerySet', 'GetBasePath', ' params = _.merge(params, qs.encodeParam({term: term, searchTerm: true}), combineSameSearches); } } + // The related fields need to also be checked for related searches. + // The related fields for the search are retrieved from the API + // options endpoint, and are stored in the $scope.model. FYI, the + // Django search model is what sets the related fields on the model. + else if(_.contains($scope.models[$scope.list.name].related, root)) { + params = _.merge(params, qs.encodeParam({term: term, relatedSearchTerm: true}), combineSameSearches); + } // Its not a search term or a related search term - treat it as a string else { params = _.merge(params, setDefaults(term), combineSameSearches);