diff --git a/awx/ui/client/src/shared/smart-search/django-search-model.class.js b/awx/ui/client/src/shared/smart-search/django-search-model.class.js index 81984e662e..f26dba3918 100644 --- a/awx/ui/client/src/shared/smart-search/django-search-model.class.js +++ b/awx/ui/client/src/shared/smart-search/django-search-model.class.js @@ -16,6 +16,7 @@ class DjangoSearchModel { return relatedSearchField.replace(/\__search$/, ""); } this.name = name; + this.searchExamples = []; this.related = _.map(relatedSearchFields, trimRelated); // Remove "object" type fields from this list for (var key in baseFields) { @@ -27,5 +28,23 @@ class DjangoSearchModel { } delete baseFields.url; this.base = baseFields; + if(baseFields.id) { + this.searchExamples.push("id:>10"); + } + // Loop across the base fields and try find one of type = string and one of type = datetime + let stringFound = false, + dateTimeFound = false; + + _.forEach(baseFields, (value, key) => { + if(!stringFound && value.type === 'string') { + this.searchExamples.push(key + ":foobar"); + stringFound = true; + } + if(!dateTimeFound && value.type === 'datetime') { + this.searchExamples.push(key + ":>=\"2000-01-01T00:00:00Z\""); + this.searchExamples.push(key + ":<2000-01-01"); + dateTimeFound = true; + } + }); } } 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 35f2b088f1..57bc43aae6 100644 --- a/awx/ui/client/src/shared/smart-search/queryset.service.js +++ b/awx/ui/client/src/shared/smart-search/queryset.service.js @@ -65,7 +65,7 @@ export default ['$q', 'Rest', 'ProcessErrors', '$rootScope', 'Wait', 'DjangoSear let concated = ''; angular.forEach(value, function(item){ if(item && typeof item === 'string') { - item = item.replace(/"|'/g, ""); + item = decodeURIComponent(item).replace(/"|'/g, ""); } concated += `${key}=${item}&`; }); @@ -73,7 +73,7 @@ export default ['$q', 'Rest', 'ProcessErrors', '$rootScope', 'Wait', 'DjangoSear } else { if(value && typeof value === 'string') { - value = value.replace(/"|'/g, ""); + value = decodeURIComponent(value).replace(/"|'/g, ""); } return `${key}=${value}&`; } @@ -128,7 +128,7 @@ export default ['$q', 'Rest', 'ProcessErrors', '$rootScope', 'Wait', 'DjangoSear } } - return {[paramString] : valueString}; + return {[paramString] : encodeURIComponent(valueString)}; }, // decodes a django queryset param into a ui smart-search tag or set of tags decodeParam(value, key){ @@ -164,7 +164,10 @@ export default ['$q', 'Rest', 'ProcessErrors', '$rootScope', 'Wait', 'DjangoSear decodedParam = '<=' + decodedParam; split = split.splice(0, split.length-1); } - return exclude ? `-${split.join('.')}:${decodedParam}` : `${split.join('.')}:${decodedParam}`; + + let uriDecodedParam = decodeURIComponent(decodedParam); + + return exclude ? `-${split.join('.')}:${uriDecodedParam}` : `${split.join('.')}:${uriDecodedParam}`; } }; diff --git a/awx/ui/client/src/shared/smart-search/smart-search.partial.html b/awx/ui/client/src/shared/smart-search/smart-search.partial.html index 13a5562aaa..2ef80c8744 100644 --- a/awx/ui/client/src/shared/smart-search/smart-search.partial.html +++ b/awx/ui/client/src/shared/smart-search/smart-search.partial.html @@ -39,9 +39,7 @@