mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 15:51:48 +03:00
Merge pull request #36 from gordalina/1.0.x
Add content textarea to sandbox
This commit is contained in:
commit
736cf22bfb
@ -1186,7 +1186,7 @@ body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operatio
|
|||||||
}
|
}
|
||||||
|
|
||||||
.pane.sandbox legend {
|
.pane.sandbox legend {
|
||||||
margin-bottom: 5px;
|
padding-bottom: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.remove {
|
.remove {
|
||||||
@ -1197,12 +1197,22 @@ body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operatio
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.parameters {
|
form .parameters,
|
||||||
|
form .headers,
|
||||||
|
form .request-content {
|
||||||
float: left;
|
float: left;
|
||||||
width: 50%;
|
width: 33%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.buttons {
|
.buttons {
|
||||||
clear: both;
|
clear: both;
|
||||||
padding-top: 10px;
|
padding-top: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.request-content textarea {
|
||||||
|
width:100%;
|
||||||
|
min-width:100%;
|
||||||
|
max-width:100%;
|
||||||
|
height:5em;
|
||||||
|
margin-bottom:10px;
|
||||||
|
}
|
||||||
|
@ -132,6 +132,7 @@
|
|||||||
_format: 'json' // default format if not overriden in the form
|
_format: 'json' // default format if not overriden in the form
|
||||||
},
|
},
|
||||||
headers = {},
|
headers = {},
|
||||||
|
content = $(this).find('textarea.content').val();
|
||||||
result_container = $('.result', $(this).parent());
|
result_container = $('.result', $(this).parent());
|
||||||
|
|
||||||
// retrieve all the parameters to send
|
// retrieve all the parameters to send
|
||||||
@ -173,13 +174,13 @@
|
|||||||
$.ajax({
|
$.ajax({
|
||||||
url: '{{ sandboxTarget }}' + url,
|
url: '{{ sandboxTarget }}' + url,
|
||||||
type: method,
|
type: method,
|
||||||
data: params,
|
data: content.length ? content : params,
|
||||||
headers: headers,
|
headers: headers,
|
||||||
complete: function(xhr) {
|
complete: function(xhr) {
|
||||||
displayResponse(xhr, method, url, result_container);
|
displayResponse(xhr, method, url, result_container);
|
||||||
|
|
||||||
// and enable them back
|
// 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() {
|
$('.pane.sandbox').on('click', '.remove', function() {
|
||||||
$(this).parent().remove();
|
$(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);
|
||||||
|
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -127,8 +127,20 @@
|
|||||||
<button class="add">New header</button>
|
<button class="add">New header</button>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<div class="buttons">
|
<fieldset class="request-content">
|
||||||
|
<legend>Content</legend>
|
||||||
|
|
||||||
|
<textarea class="content" placeholder="Content set here will override the parameters that do not match the url"></textarea>
|
||||||
|
|
||||||
|
<p class="tuple">
|
||||||
|
<input type="text" class="key content-type" value="Content-Type" disabled="disabled" />
|
||||||
|
<span>=</span>
|
||||||
|
<input type="text" class="value" placeholder="Value" />
|
||||||
|
<button class="set-content-type">Set header</button> <small>Replaces header if set</small>
|
||||||
|
</p>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<div class="buttons">
|
||||||
<input type="submit" value="Try!" />
|
<input type="submit" value="Try!" />
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user