mirror of
https://github.com/ansible/awx.git
synced 2026-03-27 22:05:07 -02:30
Changes a related search w/ two search params.
Changes from using a pattern like "search=A&search=B" to "search=A,B".
This commit is contained in:
@@ -44,38 +44,39 @@ function QuerysetService ($q, Rest, ProcessErrors, $rootScope, Wait, DjangoSearc
|
|||||||
replaceEncodedTokens(value) {
|
replaceEncodedTokens(value) {
|
||||||
return decodeURIComponent(value).replace(/"|'/g, "");
|
return decodeURIComponent(value).replace(/"|'/g, "");
|
||||||
},
|
},
|
||||||
encodeTerms (values, key) {
|
encodeTerms(value, key){
|
||||||
key = this.replaceDefaultFlags(key);
|
key = this.replaceDefaultFlags(key);
|
||||||
|
value = this.replaceDefaultFlags(value);
|
||||||
if (!Array.isArray(values)) {
|
var that = this;
|
||||||
values = [values];
|
if (Array.isArray(value)){
|
||||||
}
|
value = _.uniq(_.flattenDeep(value));
|
||||||
|
let concated = '';
|
||||||
return values
|
angular.forEach(value, function(item){
|
||||||
.map(value => {
|
if(item && typeof item === 'string') {
|
||||||
value = this.replaceDefaultFlags(value);
|
item = that.replaceEncodedTokens(item);
|
||||||
value = this.replaceEncodedTokens(value);
|
}
|
||||||
return [key, value];
|
concated += `${key}=${item}&`;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return concated;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(value && typeof value === 'string') {
|
||||||
|
value = this.replaceEncodedTokens(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return `${key}=${value}&`;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
// encodes ui-router params from {operand__key__comparator: value} pairs to API-consumable URL
|
// encodes ui-router params from {operand__key__comparator: value} pairs to API-consumable URL
|
||||||
encodeQueryset(params) {
|
encodeQueryset(params) {
|
||||||
if (typeof params !== 'object') {
|
let queryset;
|
||||||
return '';
|
queryset = _.reduce(params, (result, value, key) => {
|
||||||
}
|
return result + this.encodeTerms(value, key);
|
||||||
|
}, '');
|
||||||
|
queryset = queryset.substring(0, queryset.length - 1);
|
||||||
|
return angular.isObject(params) ? `?${queryset}` : '';
|
||||||
|
|
||||||
return _.reduce(params, (result, value, key) => {
|
|
||||||
if (result !== '?') {
|
|
||||||
result += '&';
|
|
||||||
}
|
|
||||||
|
|
||||||
const encodedTermString = this.encodeTerms(value, key)
|
|
||||||
.map(([key, value]) => `${key}=${value}`)
|
|
||||||
.join('&');
|
|
||||||
|
|
||||||
return result += encodedTermString;
|
|
||||||
}, '?');
|
|
||||||
},
|
},
|
||||||
// like encodeQueryset, but return an actual unstringified API-consumable http param object
|
// like encodeQueryset, but return an actual unstringified API-consumable http param object
|
||||||
encodeQuerysetObject(params) {
|
encodeQuerysetObject(params) {
|
||||||
|
|||||||
Reference in New Issue
Block a user