From c454e72bcfbc7401eac3814414166c8fafc89faa Mon Sep 17 00:00:00 2001 From: Kevin Fox Date: Mon, 24 Aug 2015 15:02:54 -0700 Subject: [PATCH] A few fixes to make the App Catalog plugin work. This fixes passing params to stack and image creation form dialogs. It also fixes a bug with nested dialogs. Partial-Bug: 1481518 Change-Id: Ie6965ad7c8a738f8b88927077884bba621f2eb6b --- horizon/static/horizon/js/horizon.modals.js | 7 +++++-- .../dashboards/project/images/images/views.py | 17 +++++++++++++++++ .../dashboards/project/stacks/views.py | 11 +++++++++++ .../app/tech-debt/image-form.controller.js | 7 +++++-- 4 files changed, 38 insertions(+), 4 deletions(-) diff --git a/horizon/static/horizon/js/horizon.modals.js b/horizon/static/horizon/js/horizon.modals.js index a0535de340..1cce0b3696 100644 --- a/horizon/static/horizon/js/horizon.modals.js +++ b/horizon/static/horizon/js/horizon.modals.js @@ -42,8 +42,11 @@ horizon.modals.create = function (title, body, confirm, cancel) { horizon.modals.success = function (data) { var modal; - $('#modal_wrapper').append(data); - modal = $('.modal:last'); + var modal_wrapper = $('#modal_wrapper'); + // Moves the modal_wrapper to the bottom. This shows it over other dialogs. + modal_wrapper.parent().append(modal_wrapper); + modal_wrapper.append(data); + modal = $('#modal_wrapper > .modal:last'); modal.modal(); $(modal).trigger("new_modal", modal); return modal; diff --git a/openstack_dashboard/dashboards/project/images/images/views.py b/openstack_dashboard/dashboards/project/images/images/views.py index d803168662..0cdd5e7ca4 100644 --- a/openstack_dashboard/dashboards/project/images/images/views.py +++ b/openstack_dashboard/dashboards/project/images/images/views.py @@ -49,6 +49,23 @@ class CreateView(forms.ModalFormView): success_url = reverse_lazy("horizon:project:images:index") page_title = _("Create An Image") + def get_initial(self): + initial = {} + for name in [ + 'name', + 'description', + 'image_url', + 'source_type', + 'architecture', + 'disk_format', + 'minimum_disk', + 'minimum_ram' + ]: + tmp = self.request.GET.get(name) + if tmp: + initial[name] = tmp + return initial + class UpdateView(forms.ModalFormView): form_class = project_forms.UpdateImageForm diff --git a/openstack_dashboard/dashboards/project/stacks/views.py b/openstack_dashboard/dashboards/project/stacks/views.py index dc34564ebe..5b0f21dd97 100644 --- a/openstack_dashboard/dashboards/project/stacks/views.py +++ b/openstack_dashboard/dashboards/project/stacks/views.py @@ -95,6 +95,17 @@ class SelectTemplateView(forms.ModalFormView): success_url = reverse_lazy('horizon:project:stacks:launch') page_title = _("Select Template") + def get_initial(self): + initial = {} + for name in [ + 'template_url', + 'template_source' + ]: + tmp = self.request.GET.get(name) + if tmp: + initial[name] = tmp + return initial + def get_form_kwargs(self): kwargs = super(SelectTemplateView, self).get_form_kwargs() kwargs['next_view'] = CreateStackView diff --git a/openstack_dashboard/static/app/tech-debt/image-form.controller.js b/openstack_dashboard/static/app/tech-debt/image-form.controller.js index 9b3237ef25..e5eca99de5 100644 --- a/openstack_dashboard/static/app/tech-debt/image-form.controller.js +++ b/openstack_dashboard/static/app/tech-debt/image-form.controller.js @@ -18,9 +18,12 @@ .module('horizon.app.tech-debt') .controller('ImageFormController', ImageFormController); - function ImageFormController() { - var ctrl = this; + ImageFormController.$inject = ['$element']; + function ImageFormController($element) { + var ctrl = this; + ctrl.copyFrom = $element('.image_url').val(); + ctrl.diskFormat = $element('.disk_format').val(); ctrl.selectImageFormat = function (path) { if (!path) { return; } var format = path.substr(path.lastIndexOf(".") + 1)