From 99ea28c3fd095eefa8d3b124a84c92015dcdb780 Mon Sep 17 00:00:00 2001 From: kialam Date: Fri, 1 Jun 2018 16:39:04 -0400 Subject: [PATCH] Check `defaults` against `query set` to make sure `credential_type` does not get overwritten - We want to preserve the existing `credential_type` param that already exists in `queryset` and not have `defaults ` overwrite it. We first loop through the `defaults` object keys and check it against the the keys of `queryset` and if the keys match, then set the value to `queryset[key]`. --- .../src/shared/smart-search/smart-search.controller.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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 ad14dd5344..69b5ee9b02 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 @@ -235,11 +235,15 @@ function SmartSearchController ( }; $scope.clearAllTerms = () => { - const cleared = _(defaults).omit(_.isNull).value(); + const cleared = {}; - delete cleared.page; + _.forOwn(defaults, function(value, key) { + if (key !== "page") { + cleared[key] = _.has(queryset, key) ? queryset[key] : value; + } + }); - queryset = cleared; + queryset = _(cleared).omit(_.isNull).value(); if (!$scope.querySet) { $state.go('.', { [searchKey]: queryset });