Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix filters always as query parameters #988

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 34 additions & 0 deletions Resources/views/layout.html.twig
Expand Up @@ -438,8 +438,10 @@
method = $('[name="header_method"]', this).val(),
self = this,
params = {},
filters = {},
formData = new FormData(),
doubledParams = {},
doubledFilters = {},
headers = {},
content = $(this).find('textarea.content').val(),
result_container = $('.result', $(this).parent());
Expand Down Expand Up @@ -527,6 +529,26 @@



// retrieve all the filters to send
$('.parameters .tuple.filter', $(this)).each(function() {
var key, value;

key = $('.key', $(this)).val();
value = $('.value', $(this)).val();

if (value) {
// temporary save all additional/doubled parameters
if (key in filters) {
doubledFilters[key] = value;
} else {
filters[key] = value;
}
}
});




// retrieve the additional headers to send
$('.headers .tuple', $(this)).each(function() {
var key, value;
Expand Down Expand Up @@ -575,6 +597,18 @@
}
{% endif %}

//add filters as GET params and remove them from params
if(method != 'GET'){
for (var filterKey in $.extend({}, filters)){
url += url.indexOf('?') > 0 ? '&' : '?';
url += filterKey + '=' + filters[filterKey];

if (params.hasOwnProperty(filterKey)){
delete(params[filterKey]);
}
}
}

// prepare final parameters
var body = {};
if(bodyFormat == 'json' && method != 'GET') {
Expand Down
2 changes: 1 addition & 1 deletion Resources/views/method.html.twig
Expand Up @@ -252,7 +252,7 @@
{% if data.filters is defined %}
<h4>Filters</h4>
{% for name, infos in data.filters %}
<p class="tuple">
<p class="tuple filter">
<input type="text" class="key" value="{{ name }}" placeholder="Key" />
<span>=</span>
<input type="text" class="value" placeholder="{% if infos.description is defined %}{{ infos.description }}{% else %}Value{% endif %}" {% if infos.default is defined %} value="{{ infos.default }}" {% endif %}/> <span class="remove">-</span>
Expand Down