mirror of
https://github.com/ansible/awx.git
synced 2026-07-29 00:49:55 -02:30
Handle case where the user just hits enter without inputing a search string
This commit is contained in:
@@ -79,15 +79,6 @@ export default ['$stateParams', '$scope', '$state', 'QuerySet', 'GetBasePath', '
|
|||||||
let params = {},
|
let params = {},
|
||||||
origQueryset = _.clone(queryset);
|
origQueryset = _.clone(queryset);
|
||||||
|
|
||||||
_.forEach(terms.split(' '), (term) => {
|
|
||||||
// if only a value is provided, search using default keys
|
|
||||||
if (term.split(':').length === 1) {
|
|
||||||
params = _.merge(params, setDefaults(term));
|
|
||||||
} else {
|
|
||||||
params = _.merge(params, qs.encodeParam(term));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
function setDefaults(term) {
|
function setDefaults(term) {
|
||||||
// "name" and "description" are sane defaults for MOST models, but not ALL!
|
// "name" and "description" are sane defaults for MOST models, but not ALL!
|
||||||
// defaults may be configured in ListDefinition.defaultSearchParams
|
// defaults may be configured in ListDefinition.defaultSearchParams
|
||||||
@@ -101,6 +92,16 @@ export default ['$stateParams', '$scope', '$state', 'QuerySet', 'GetBasePath', '
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(terms && terms !== '') {
|
||||||
|
_.forEach(terms.split(' '), (term) => {
|
||||||
|
// if only a value is provided, search using default keys
|
||||||
|
if (term.split(':').length === 1) {
|
||||||
|
params = _.merge(params, setDefaults(term));
|
||||||
|
} else {
|
||||||
|
params = _.merge(params, qs.encodeParam(term));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
params.page = '1';
|
params.page = '1';
|
||||||
queryset = _.merge(queryset, params, (objectValue, sourceValue, key, object) => {
|
queryset = _.merge(queryset, params, (objectValue, sourceValue, key, object) => {
|
||||||
if (object[key] && object[key] !== sourceValue){
|
if (object[key] && object[key] !== sourceValue){
|
||||||
@@ -127,6 +128,7 @@ export default ['$stateParams', '$scope', '$state', 'QuerySet', 'GetBasePath', '
|
|||||||
|
|
||||||
$scope.searchTerm = null;
|
$scope.searchTerm = null;
|
||||||
$scope.searchTags = stripDefaultParams(queryset);
|
$scope.searchTags = stripDefaultParams(queryset);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.revertSearch = function(queryToBeRestored) {
|
$scope.revertSearch = function(queryToBeRestored) {
|
||||||
|
|||||||
Reference in New Issue
Block a user