Merge "Fix dynamic select layout when help block is displayed"

This commit is contained in:
Jenkins 2014-10-24 17:55:28 +00:00 committed by Gerrit Code Review
commit f151ff4e42
4 changed files with 18 additions and 30 deletions

View File

@ -116,17 +116,6 @@ horizon.forms = {
} }
}; };
horizon.forms.bind_add_item_handlers = function (el) {
var $selects = $(el).find('select[data-add-item-url]');
$selects.each(function () {
var $this = $(this);
$button = $("<a href='" + $this.attr("data-add-item-url") + "' " +
"data-add-to-field='" + $this.attr("id") + "' " +
"class='btn ajax-add ajax-modal btn-default'>+</a>");
$this.after($button);
});
};
horizon.forms.prevent_multiple_submission = function (el) { horizon.forms.prevent_multiple_submission = function (el) {
// Disable multiple submissions when launching a form. // Disable multiple submissions when launching a form.
var $form = $(el).find("form"); var $form = $(el).find("form");
@ -199,9 +188,6 @@ horizon.addInitFunction(horizon.forms.init = function () {
horizon.forms.prevent_multiple_submission($('body')); horizon.forms.prevent_multiple_submission($('body'));
horizon.modals.addModalInitFunction(horizon.forms.prevent_multiple_submission); horizon.modals.addModalInitFunction(horizon.forms.prevent_multiple_submission);
horizon.forms.bind_add_item_handlers($("body"));
horizon.modals.addModalInitFunction(horizon.forms.bind_add_item_handlers);
horizon.forms.init_examples($("body")); horizon.forms.init_examples($("body"));
horizon.modals.addModalInitFunction(horizon.forms.init_examples); horizon.modals.addModalInitFunction(horizon.forms.init_examples);

View File

@ -55,7 +55,20 @@
{% endif %} {% endif %}
<div class="{{ classes.value }} {{ field|wrapper_classes }}"> <div class="{{ classes.value }} {{ field|wrapper_classes }}">
{{ field|add_bootstrap_class }} {% with add_item_link=field|add_item_url %}
{% if add_item_link %}
<div class='input-group'>
{{ field|add_bootstrap_class }}
<span class="input-group-btn">
<a href="{{ add_item_link }}" data-add-to-field="{{ field.auto_id }}" class='btn btn-default ajax-add ajax-modal'>
<span class="glyphicon glyphicon-plus"></span>
</a>
</span>
</div>
{% else %}
{{ field|add_bootstrap_class }}
{% endif %}
{% endwith %}
{% for error in field.errors %} {% for error in field.errors %}
<span class="help-block alert alert-danger {{ form.error_css_class }}">{{ error }}</span> <span class="help-block alert alert-danger {{ form.error_css_class }}">{{ error }}</span>
{% endfor %} {% endfor %}

View File

@ -56,8 +56,10 @@ def is_file(field):
@register.filter @register.filter
def is_dynamic_select(field): def add_item_url(field):
return hasattr(field.field.widget, 'add_item_link') if hasattr(field.field.widget, 'get_add_item_url'):
return field.field.widget.get_add_item_url()
return None
@register.filter @register.filter
@ -65,6 +67,4 @@ def wrapper_classes(field):
classes = [] classes = []
if is_multiple_checkbox(field): if is_multiple_checkbox(field):
classes.append('multiple-checkbox') classes.append('multiple-checkbox')
if is_dynamic_select(field):
classes.append('dynamic-select')
return ' '.join(classes) return ' '.join(classes)

View File

@ -801,17 +801,6 @@ form label {
display: inline-block; display: inline-block;
} }
form .form-group > div.dynamic-select {
display: table;
border-collapse: separate;
> * {
display: table-cell;
}
> a {
width: 1%;
}
}
.modal.fullscreen .modal-dialog { .modal.fullscreen .modal-dialog {
width: 90%; width: 90%;
margin: auto; margin: auto;