[openstack-dev] Horizon pop-up window

Bhandaru, Malini K malini.k.bhandaru at intel.com
Mon Aug 20 19:43:05 UTC 2012


Thank you for responding Gabriel!

The window pop-up issue, I have the ajax-modal and ModalFormView .. had copied it from your code, I must be missing something else, may be url?

flavors/url.py
urlpatterns = patterns('horizon.dashboards.syspanel.flavors.views',
    url(r'^$', IndexView.as_view(), name='index'),
    url(r'^create/$', CreateView.as_view(), name='create'),
    url(r'^(?P<id>[^/]+)/edit/$', EditView.as_view(), name='edit'),
    url(r'^(?P<id>[^/]+)/extra_spec_create/$', CreateExtraSpecView.as_view(), name='extra_spec_create'),

)



flavors/views.py

class CreateExtraSpecView(forms.ModalFormView):
    form_class = CreateExtraSpec
    template_name = 'syspanel/flavors/create_extra_spec.html'
    success_url = reverse_lazy('horizon:syspanel:flavors:index')


yours:
class CreateExtraSpecView(forms.ModalFormView):
    form_class = CreateExtraSpec
    template_name = 'syspanel/flavors/create_extra_spec.html'
    success_url = reverse_lazy('horizon:syspanel:flavors:index')



==============
flavors/tables.py


class CreateExtraSpec(tables.LinkAction):
    name = "extra_spec_create"
    verbose_name = _("Create Extra Spec")
    url = "horizon:syspanel:flavors:extra_spec_create"
    classes = ("ajax-modal", "btn-create")


yours:
class CreateFlavor(tables.LinkAction):
    name = "create"
    verbose_name = _("Create Flavor")
    url = "horizon:syspanel:flavors:create"
    classes = ("ajax-modal", "btn-create")

==================
flavors/form.py

class CreateExtraSpec(forms.SelfHandlingForm):
    key = forms.CharField(max_length="25", label=_("Key"))
    value = forms.CharField(max_length="25", label=_("Value"))

    def handle(self, request, data):
        try:
            # db api call here
            msg = _('Created extra spec "%s".') % data['key']
            messages.success(request, msg)
            return flavor
        except:
            exceptions.handle(request, _("Unable to create extra spec."))


class CreateFlavor(forms.SelfHandlingForm):
    name = forms.CharField(max_length="25", label=_("Name"))
    ...


________________________________
From: Gabriel Hurley [Gabriel.Hurley at nebula.com]
Sent: Sunday, August 19, 2012 7:21 PM
To: OpenStack Development Mailing List
Subject: Re: [openstack-dev] Horizon pop-up window

Malini,


1.       You either need to add the “ajax-modal” class to the action, or you need to inherit from ModalFormView for your view.

2.       Yes, tables can be displayed in modals (see the volume attachments and security group rules for examples of this). They are somewhat more complicated than I’d like and this is an area we’re going to significantly improve in Grizzly.

All the best,


-          Gabriel

From: Bhandaru, Malini K [mailto:malini.k.bhandaru at intel.com]
Sent: Friday, August 17, 2012 8:39 PM
To: openstack-dev at lists.openstack.org
Subject: [openstack-dev] Horizon pop-up window

Greetings! Newbie question!

1)      I created a new action on the flavors page, but my new action displays at the bottom of the flavors page .. believe my view and form and url all mimic the working entries

Why does it not popup in  a new window.



2)      Can tables be displayed in pop-up windows, and without the left navigation pane. For instance I have a collection of key-value pairs that I want to display in a table in a pop up window and provide buttons to delete, edit etc.



Regards

Malini



More information about the OpenStack-dev mailing list