From bfe31035424a42b8841bb791a34cf72332d6f645 Mon Sep 17 00:00:00 2001 From: jaredevantabor Date: Fri, 3 Feb 2017 16:52:48 -0800 Subject: [PATCH 1/4] fix for #5181, about entering invalid search entries. --- awx/ui/client/src/shared/smart-search/queryset.service.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/awx/ui/client/src/shared/smart-search/queryset.service.js b/awx/ui/client/src/shared/smart-search/queryset.service.js index 877222da11..869d4e57a0 100644 --- a/awx/ui/client/src/shared/smart-search/queryset.service.js +++ b/awx/ui/client/src/shared/smart-search/queryset.service.js @@ -264,11 +264,11 @@ export default ['$q', 'Rest', 'ProcessErrors', '$rootScope', 'Wait', 'DjangoSear this.error(response.data, response.status); - return response; + throw response; }.bind(this)); }, error(data, status) { - ProcessErrors($rootScope, data, status, null, { + ProcessErrors($rootScope, null, status, null, { hdr: 'Error!', msg: 'Call to ' + this.url + '. GET returned: ' + status }); From f00214495ad59185a76440634a78ed1a98f6057b Mon Sep 17 00:00:00 2001 From: jaredevantabor Date: Fri, 3 Feb 2017 17:20:30 -0800 Subject: [PATCH 2/4] fix for #5179 for deleting tags for non search params --- .../shared/smart-search/smart-search.controller.js | 12 ++++++++++++ 1 file changed, 12 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 22a91ec61a..e16485550f 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 @@ -177,6 +177,18 @@ export default ['$stateParams', '$scope', '$state', 'QuerySet', 'GetBasePath', ' delete queryset[key]; } } + if(queryset.search && queryset.search){ + if (Array.isArray(queryset.search)){ + _.remove(queryset.search, (item) => item.indexOf(value) > -1); + // If the array is now empty, remove that key + if(queryset.search.length === 0) { + delete queryset.search; + } + } + else if(queryset.search.indexOf(key) > -1){ + delete queryset.search; + } + } else { delete queryset[key]; } From ab57396fcf77bfefee2a16ddac0025fcdb28670f Mon Sep 17 00:00:00 2001 From: jaredevantabor Date: Mon, 6 Feb 2017 10:53:42 -0800 Subject: [PATCH 3/4] Generalizing error message when user inputs an invalid search --- awx/ui/client/src/shared/smart-search/queryset.service.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awx/ui/client/src/shared/smart-search/queryset.service.js b/awx/ui/client/src/shared/smart-search/queryset.service.js index 869d4e57a0..10ae7ef3c8 100644 --- a/awx/ui/client/src/shared/smart-search/queryset.service.js +++ b/awx/ui/client/src/shared/smart-search/queryset.service.js @@ -270,7 +270,7 @@ export default ['$q', 'Rest', 'ProcessErrors', '$rootScope', 'Wait', 'DjangoSear error(data, status) { ProcessErrors($rootScope, null, status, null, { hdr: 'Error!', - msg: 'Call to ' + this.url + '. GET returned: ' + status + msg: "Invalid search term entered." }); } }; From 2a8bff824a237f59891338d2c21d468004e92902 Mon Sep 17 00:00:00 2001 From: jaredevantabor Date: Wed, 8 Feb 2017 11:57:01 -0800 Subject: [PATCH 4/4] fixing deletion after PR feedback from mabashian --- .../smart-search/smart-search.controller.js | 17 ++++------------- 1 file changed, 4 insertions(+), 13 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 e16485550f..b16a2a3893 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 @@ -166,8 +166,11 @@ export default ['$stateParams', '$scope', '$state', 'QuerySet', 'GetBasePath', ' else { encodeParams.searchTerm = true; } + removed = qs.encodeParam(encodeParams); + } + else { + removed = setDefaults(termParts[termParts.length-1]); } - removed = qs.encodeParam(encodeParams); } _.each(removed, (value, key) => { if (Array.isArray(queryset[key])){ @@ -177,18 +180,6 @@ export default ['$stateParams', '$scope', '$state', 'QuerySet', 'GetBasePath', ' delete queryset[key]; } } - if(queryset.search && queryset.search){ - if (Array.isArray(queryset.search)){ - _.remove(queryset.search, (item) => item.indexOf(value) > -1); - // If the array is now empty, remove that key - if(queryset.search.length === 0) { - delete queryset.search; - } - } - else if(queryset.search.indexOf(key) > -1){ - delete queryset.search; - } - } else { delete queryset[key]; }