diff --git a/horizon/static/horizon/js/horizon.forms.js b/horizon/static/horizon/js/horizon.forms.js index ac45d25e95..9be8877682 100644 --- a/horizon/static/horizon/js/horizon.forms.js +++ b/horizon/static/horizon/js/horizon.forms.js @@ -630,29 +630,6 @@ horizon.addInitFunction(horizon.forms.init = function () { } }); - // Handle field toggles for the Create Volume source type field - function update_volume_source_displayed_fields (field) { - var $this = $(field), - base_type = $this.val(); - - $this.find("option").each(function () { - if (this.value !== base_type) { - $("#id_" + this.value).closest(".form-group").hide(); - } else { - $("#id_" + this.value).closest(".form-group").show(); - } - }); - } - - $document.on('change', '#id_volume_source_type', function () { - update_volume_source_displayed_fields(this); - }); - - $('#id_volume_source_type').change(); - horizon.modals.addModalInitFunction(function (modal) { - $(modal).find("#id_volume_source_type").change(); - }); - /* Help tooltips */ // Apply standard handler for everything but checkboxes. diff --git a/openstack_dashboard/dashboards/project/volumes/forms.py b/openstack_dashboard/dashboards/project/volumes/forms.py index bd7a561b36..868719ff04 100644 --- a/openstack_dashboard/dashboards/project/volumes/forms.py +++ b/openstack_dashboard/dashboards/project/volumes/forms.py @@ -90,21 +90,33 @@ class CreateForm(forms.SelfHandlingForm): snapshot_source = forms.ChoiceField( label=_("Use snapshot as a source"), widget=forms.ThemableSelectWidget( - attrs={'class': 'snapshot-selector'}, + attrs={'class': 'snapshot-selector switched', + 'data-switch-on': 'source', + 'data-source-snapshot_source': + _("Use snapshot as a source"), + 'data-required-when-shown': 'true'}, data_attrs=('size', 'name'), transform=lambda x: "%s (%s GiB)" % (x.name, x.size)), required=False) image_source = forms.ChoiceField( label=_("Use image as a source"), widget=forms.ThemableSelectWidget( - attrs={'class': 'image-selector'}, + attrs={'class': 'image-selector switched', + 'data-switch-on': 'source', + 'data-source-image_source': + _("Use image as a source"), + 'data-required-when-shown': 'true'}, data_attrs=('size', 'name', 'min_disk'), transform=lambda x: "%s (%s)" % (x.name, filesizeformat(x.bytes))), required=False) volume_source = forms.ChoiceField( label=_("Use a volume as source"), widget=forms.ThemableSelectWidget( - attrs={'class': 'image-selector'}, + attrs={'class': 'image-selector switched', + 'data-switch-on': 'source', + 'data-source-volume_source': + _("Use a volume as source"), + 'data-required-when-shown': 'true'}, data_attrs=('size', 'name'), transform=lambda x: "%s (%s GiB)" % (x.name, x.size)), required=False)