From b344eb9af0092e0d4ad13c0365c1940d4ae8b4b0 Mon Sep 17 00:00:00 2001 From: kialam Date: Mon, 4 Jun 2018 12:05:18 -0400 Subject: [PATCH] Fix failing test by only preserving `credential_type` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Reset `defaults` object’s own `credential_type` value to that of `queryset`’s. --- .../shared/smart-search/smart-search.controller.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 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 69b5ee9b02..2ac0550a2b 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,15 +235,15 @@ function SmartSearchController ( }; $scope.clearAllTerms = () => { - const cleared = {}; - - _.forOwn(defaults, function(value, key) { - if (key !== "page") { - cleared[key] = _.has(queryset, key) ? queryset[key] : value; + _.forOwn(defaults, (value, key) => { + // preserve the `credential_type` queryset param if it exists + if (key === 'credential_type') { + defaults[key] = queryset[key]; } }); - - queryset = _(cleared).omit(_.isNull).value(); + const cleared = _(defaults).omit(_.isNull).value(); + delete cleared.page; + queryset = cleared; if (!$scope.querySet) { $state.go('.', { [searchKey]: queryset });