mirror of
https://github.com/ansible/awx.git
synced 2026-03-10 05:59:28 -02:30
Now handling multiple instances of the same query param with different values
This commit is contained in:
@@ -69,10 +69,12 @@ export default ['$q', 'Rest', 'ProcessErrors', '$rootScope', 'Wait', 'DjangoSear
|
|||||||
function encodeTerm(value, key){
|
function encodeTerm(value, key){
|
||||||
|
|
||||||
if (Array.isArray(value)){
|
if (Array.isArray(value)){
|
||||||
return _.map(value, function(item){
|
let concated = '';
|
||||||
|
angular.forEach(value, function(item){
|
||||||
item = item.replace(/"|'/g, "");
|
item = item.replace(/"|'/g, "");
|
||||||
return `${key}=${item}`.join('&') + '&';
|
concated += `${key}=${item}&`;
|
||||||
});
|
});
|
||||||
|
return concated;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
value = value.replace(/"|'/g, "");
|
value = value.replace(/"|'/g, "");
|
||||||
|
|||||||
@@ -120,23 +120,34 @@ export default ['$stateParams', '$scope', '$state', 'QuerySet', 'GetBasePath', '
|
|||||||
|
|
||||||
let termParts = SmartSearchService.splitTermIntoParts(term);
|
let termParts = SmartSearchService.splitTermIntoParts(term);
|
||||||
|
|
||||||
|
function combineSameSearches(a,b){
|
||||||
|
if (_.isArray(a)) {
|
||||||
|
return a.concat(b);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(a) {
|
||||||
|
return [a,b];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// if only a value is provided, search using default keys
|
// if only a value is provided, search using default keys
|
||||||
if (termParts.length === 1) {
|
if (termParts.length === 1) {
|
||||||
params = _.merge(params, setDefaults(term));
|
params = _.merge(params, setDefaults(term), combineSameSearches);
|
||||||
} else {
|
} else {
|
||||||
// Figure out if this is a search term
|
// Figure out if this is a search term
|
||||||
let root = termParts[0].split(".")[0].replace(/^-/, '');
|
let root = termParts[0].split(".")[0].replace(/^-/, '');
|
||||||
if(_.has($scope.options.actions.GET, root)) {
|
if(_.has($scope.options.actions.GET, root)) {
|
||||||
if($scope.options.actions.GET[root].type && $scope.options.actions.GET[root].type === 'field') {
|
if($scope.options.actions.GET[root].type && $scope.options.actions.GET[root].type === 'field') {
|
||||||
params = _.merge(params, qs.encodeParam({term: term, relatedSearchTerm: true}));
|
params = _.merge(params, qs.encodeParam({term: term, relatedSearchTerm: true}), combineSameSearches);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
params = _.merge(params, qs.encodeParam({term: term, searchTerm: true}));
|
params = _.merge(params, qs.encodeParam({term: term, searchTerm: true}), combineSameSearches);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Its not a search term or a related search term
|
// Its not a search term or a related search term
|
||||||
else {
|
else {
|
||||||
params = _.merge(params, qs.encodeParam({term: term}));
|
params = _.merge(params, qs.encodeParam({term: term}), combineSameSearches);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user