diff --git a/Resources/public/css/screen.css b/Resources/public/css/screen.css index e076719..234b5c5 100644 --- a/Resources/public/css/screen.css +++ b/Resources/public/css/screen.css @@ -440,7 +440,7 @@ li.operation.patch div.content h4 { } .pane.sandbox legend { - margin-bottom: 5px; + padding-bottom: 5px; } .remove { @@ -451,12 +451,22 @@ li.operation.patch div.content h4 { display: none; } -.parameters { +form .parameters, +form .headers, +form .request-content { float: left; - width: 50%; + width: 33%; } .buttons { clear: both; padding-top: 10px; } + +.request-content textarea { + width:100%; + min-width:100%; + max-width:100%; + height:5em; + margin-bottom:10px; +} diff --git a/Resources/views/layout.html.twig b/Resources/views/layout.html.twig index 6afc12b..7354892 100644 --- a/Resources/views/layout.html.twig +++ b/Resources/views/layout.html.twig @@ -132,6 +132,7 @@ _format: 'json' // default format if not overriden in the form }, headers = {}, + content = $(this).find('textarea.content').val(); result_container = $('.result', $(this).parent()); // retrieve all the parameters to send @@ -173,13 +174,13 @@ $.ajax({ url: '{{ sandboxTarget }}' + url, type: method, - data: params, + data: content.length ? content : params, headers: headers, complete: function(xhr) { displayResponse(xhr, method, url, result_container); // and enable them back - $('input, button', $(self)).removeAttr('disabled'); + $('input:not(.content-type), button', $(self)).removeAttr('disabled'); } }); @@ -226,6 +227,36 @@ $('.pane.sandbox').on('click', '.remove', function() { $(this).parent().remove(); }); + + $('.pane.sandbox').on('click', '.set-content-type', function(e) { + var html; + var $element; + var $headers = $(this).parents('form').find('.headers'); + var content_type = $(this).prev('input.value').val(); + + e.preventDefault(); + + if (content_type.length === 0) { + return; + } + + $headers.find('input.key').each(function() { + if ($.trim($(this).val().toLowerCase()) === 'content-type') { + $element = $(this).parents('p'); + return false; + } + }); + + if (typeof $element === 'undefined') { + html = $(this).parents('.pane').find('.tuple_template').html(); + + $element = $headers.find('legend').after(html).next('p'); + } + + $element.find('input.key').val('Content-Type'); + $element.find('input.value').val(content_type); + + }); diff --git a/Resources/views/method.html.twig b/Resources/views/method.html.twig index 673848e..144eddd 100644 --- a/Resources/views/method.html.twig +++ b/Resources/views/method.html.twig @@ -136,8 +136,20 @@ -
+
+ Content + + +

+ + = + + Replaces header if set +

+
+ +