diff --git a/horizon/static/horizon/js/horizon.forms.js b/horizon/static/horizon/js/horizon.forms.js index f40a488f8..16ac48cef 100644 --- a/horizon/static/horizon/js/horizon.forms.js +++ b/horizon/static/horizon/js/horizon.forms.js @@ -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 = $("+"); - $this.after($button); - }); -}; - horizon.forms.prevent_multiple_submission = function (el) { // Disable multiple submissions when launching a form. var $form = $(el).find("form"); @@ -199,9 +188,6 @@ horizon.addInitFunction(horizon.forms.init = function () { horizon.forms.prevent_multiple_submission($('body')); 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.modals.addModalInitFunction(horizon.forms.init_examples); diff --git a/horizon/templates/horizon/common/_form_field.html b/horizon/templates/horizon/common/_form_field.html index c67dc47b1..ceae03cd7 100644 --- a/horizon/templates/horizon/common/_form_field.html +++ b/horizon/templates/horizon/common/_form_field.html @@ -55,7 +55,20 @@ {% endif %}
- {{ field|add_bootstrap_class }} + {% with add_item_link=field|add_item_url %} + {% if add_item_link %} +
+ {{ field|add_bootstrap_class }} + + + + + +
+ {% else %} + {{ field|add_bootstrap_class }} + {% endif %} + {% endwith %} {% for error in field.errors %} {{ error }} {% endfor %} diff --git a/horizon/templatetags/form_helpers.py b/horizon/templatetags/form_helpers.py index eb57ea881..2f1ab5e8e 100644 --- a/horizon/templatetags/form_helpers.py +++ b/horizon/templatetags/form_helpers.py @@ -56,8 +56,10 @@ def is_file(field): @register.filter -def is_dynamic_select(field): - return hasattr(field.field.widget, 'add_item_link') +def add_item_url(field): + if hasattr(field.field.widget, 'get_add_item_url'): + return field.field.widget.get_add_item_url() + return None @register.filter @@ -65,6 +67,4 @@ def wrapper_classes(field): classes = [] if is_multiple_checkbox(field): classes.append('multiple-checkbox') - if is_dynamic_select(field): - classes.append('dynamic-select') return ' '.join(classes) diff --git a/openstack_dashboard/static/dashboard/scss/horizon.scss b/openstack_dashboard/static/dashboard/scss/horizon.scss index 092acc020..4d3ec48ab 100644 --- a/openstack_dashboard/static/dashboard/scss/horizon.scss +++ b/openstack_dashboard/static/dashboard/scss/horizon.scss @@ -801,17 +801,6 @@ form label { display: inline-block; } -form .form-group > div.dynamic-select { - display: table; - border-collapse: separate; - > * { - display: table-cell; - } - > a { - width: 1%; - } -} - .modal.fullscreen .modal-dialog { width: 90%; margin: auto;