From e2c3d7ce94470a5cdad9f7eeff44854229716946 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Solt=C3=A9sz=20Bal=C3=A1zs?= Date: Wed, 18 Nov 2015 16:23:44 +0100 Subject: [PATCH 1/2] Make filters always be passed as query string parameters in sandbox requests. --- Resources/views/layout.html.twig | 34 ++++++++++++++++++++++++++++++++ Resources/views/method.html.twig | 2 +- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/Resources/views/layout.html.twig b/Resources/views/layout.html.twig index e2c00c0..e35eb19 100644 --- a/Resources/views/layout.html.twig +++ b/Resources/views/layout.html.twig @@ -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()); @@ -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; @@ -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') { diff --git a/Resources/views/method.html.twig b/Resources/views/method.html.twig index c92027d..54fafeb 100644 --- a/Resources/views/method.html.twig +++ b/Resources/views/method.html.twig @@ -252,7 +252,7 @@ {% if data.filters is defined %}

Filters

{% for name, infos in data.filters %} -

+

= - From 33307d750ecb85c8e9d0068b8e3fab35de8a9be3 Mon Sep 17 00:00:00 2001 From: Lukas Kahwe Smith Date: Fri, 28 Apr 2017 15:58:38 +0200 Subject: [PATCH 2/2] fix typo to force filters as query parameters --- Resources/views/layout.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/views/layout.html.twig b/Resources/views/layout.html.twig index e35eb19..b905fea 100644 --- a/Resources/views/layout.html.twig +++ b/Resources/views/layout.html.twig @@ -530,7 +530,7 @@ // retrieve all the filters to send - $('.parameters .tuple .filter', $(this)).each(function() { + $('.parameters .tuple.filter', $(this)).each(function() { var key, value; key = $('.key', $(this)).val();