mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-27 08:29:59 +03:00
Added tabs between PUT and PATCH forms and better PATCH form handing
This commit is contained in:
parent
a1c322c346
commit
e53b66bed8
|
@ -3,3 +3,11 @@ prettyPrint();
|
||||||
$('.js-tooltip').tooltip({
|
$('.js-tooltip').tooltip({
|
||||||
delay: 1000
|
delay: 1000
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#patch-form').find('.field-switcher').on('change', function() {
|
||||||
|
var $this = $(this);
|
||||||
|
$('#patch-form').find('#'+$this.attr('data-field-id'))
|
||||||
|
.prop('disabled', !$this.prop('checked'));
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#form-method-switcher a:first').tab('show');
|
||||||
|
|
|
@ -147,8 +147,15 @@
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if put_form %}
|
{% if put_form or patch_form %}
|
||||||
<div class="well">
|
<div class="well">
|
||||||
|
<ul class="nav nav-pills" id="form-method-switcher">
|
||||||
|
{% if put_form %}<li><a href="#put-form" data-toggle="pill">PUT Form</a></li>{% endif %}
|
||||||
|
{% if patch_form %}<li><a href="#patch-form" data-toggle="pill">PATCH Form</a></li>{% endif %}
|
||||||
|
</ul>
|
||||||
|
<div class="tab-content">
|
||||||
|
{% if put_form %}
|
||||||
|
<div class="tab-pane" id="put-form">
|
||||||
<form action="{{ request.get_full_path }}" method="POST" {% if put_form.is_multipart %}enctype="multipart/form-data"{% endif %} class="form-horizontal">
|
<form action="{{ request.get_full_path }}" method="POST" {% if put_form.is_multipart %}enctype="multipart/form-data"{% endif %} class="form-horizontal">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<input type="hidden" name="{{ api_settings.FORM_METHOD_OVERRIDE }}" value="PUT" />
|
<input type="hidden" name="{{ api_settings.FORM_METHOD_OVERRIDE }}" value="PUT" />
|
||||||
|
@ -167,14 +174,12 @@
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<button class="btn btn-primary js-tooltip" title="Make a PUT request on the {{ name }} resource">PUT</button>
|
<button class="btn btn-primary js-tooltip" title="Make a PUT request on the {{ name }} resource">PUT</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if patch_form %}
|
{% if patch_form %}
|
||||||
<div class="well">
|
<div class="tab-pane" id="patch-form">
|
||||||
<form action="{{ request.get_full_path }}" method="POST" {% if patch_form.is_multipart %}enctype="multipart/form-data"{% endif %} class="form-horizontal">
|
<form action="{{ request.get_full_path }}" method="POST" {% if patch_form.is_multipart %}enctype="multipart/form-data"{% endif %} class="form-horizontal">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<input type="hidden" name="{{ api_settings.FORM_METHOD_OVERRIDE }}" value="PATCH" />
|
<input type="hidden" name="{{ api_settings.FORM_METHOD_OVERRIDE }}" value="PATCH" />
|
||||||
|
@ -184,7 +189,7 @@
|
||||||
<div class="control-group"> <!--{% if field.errors %}error{% endif %}-->
|
<div class="control-group"> <!--{% if field.errors %}error{% endif %}-->
|
||||||
{{ field.label_tag|add_class:"control-label" }}
|
{{ field.label_tag|add_class:"control-label" }}
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
{{ field }}
|
{{ field }} <input checked="checked" type="checkbox" id="{{ field.html_name }}_field_sent" class="field-switcher" data-field-id="{{ field.auto_id }}">
|
||||||
<span class='help-inline'>{{ field.help_text }}</span>
|
<span class='help-inline'>{{ field.help_text }}</span>
|
||||||
<!--{{ field.errors|add_class:"help-block" }}-->
|
<!--{{ field.errors|add_class:"help-block" }}-->
|
||||||
</div>
|
</div>
|
||||||
|
@ -193,11 +198,13 @@
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<button class="btn btn-primary js-tooltip" title="Make a PATCH request on the {{ name }} resource">PATCH</button>
|
<button class="btn btn-primary js-tooltip" title="Make a PATCH request on the {{ name }} resource">PATCH</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user