src/pyams_content/component/gallery/zmi/paragraph.py
changeset 527 5dd1aa8bedd9
parent 487 093f201e3168
child 550 9658debb49a3
equal deleted inserted replaced
526:b15153f45957 527:5dd1aa8bedd9
    30 from z3c.form.interfaces import INPUT_MODE
    30 from z3c.form.interfaces import INPUT_MODE
    31 
    31 
    32 # import packages
    32 # import packages
    33 from pyams_content.component.gallery.paragraph import Gallery
    33 from pyams_content.component.gallery.paragraph import Gallery
    34 from pyams_content.component.paragraph.zmi import BaseParagraphAJAXAddForm, BaseParagraphAJAXEditForm, \
    34 from pyams_content.component.paragraph.zmi import BaseParagraphAJAXAddForm, BaseParagraphAJAXEditForm, \
    35     BaseParagraphAddMenu, BaseParagraphPropertiesEditForm
    35     BaseParagraphAddMenu, BaseParagraphPropertiesEditForm, get_json_paragraph_refresh_event
    36 from pyams_content.features.renderer.zmi import BaseRenderedContentRenderer
    36 from pyams_content.features.renderer.zmi import BaseRenderedContentRenderer
    37 from pyams_content.features.renderer.zmi.widget import RendererFieldWidget
    37 from pyams_content.features.renderer.zmi.widget import RendererFieldWidget
    38 from pyams_content.shared.common.zmi import WfSharedContentPermissionMixin
    38 from pyams_content.shared.common.zmi import WfSharedContentPermissionMixin
    39 from pyams_pagelet.pagelet import pagelet_config
    39 from pyams_pagelet.pagelet import pagelet_config
    40 from pyams_skin.viewlet.toolbar import ToolbarAction
    40 from pyams_skin.viewlet.toolbar import ToolbarAction
    94 @pagelet_config(name='properties.html', context=IGalleryParagraph, layer=IPyAMSLayer,
    94 @pagelet_config(name='properties.html', context=IGalleryParagraph, layer=IPyAMSLayer,
    95                 permission=MANAGE_CONTENT_PERMISSION)
    95                 permission=MANAGE_CONTENT_PERMISSION)
    96 class GalleryPropertiesEditForm(BaseParagraphPropertiesEditForm):
    96 class GalleryPropertiesEditForm(BaseParagraphPropertiesEditForm):
    97     """Gallery properties edit form"""
    97     """Gallery properties edit form"""
    98 
    98 
       
    99     prefix = 'gallery_properties.'
       
   100 
    99     legend = _("Edit gallery properties")
   101     legend = _("Edit gallery properties")
   100     icon_css_class = 'fa fa-fw fa-picture-o'
   102     icon_css_class = 'fa fa-fw fa-picture-o'
   101 
   103 
   102     fields = field.Fields(IGalleryParagraph).omit('__parent__', '__name__', 'visible')
   104     fields = field.Fields(IGalleryParagraph).omit('__parent__', '__name__', 'visible')
   103     fields['renderer'].widgetFactory = RendererFieldWidget
   105     fields['renderer'].widgetFactory = RendererFieldWidget
   117     """Gallery paragraph properties edit form, JSON renderer"""
   119     """Gallery paragraph properties edit form, JSON renderer"""
   118 
   120 
   119     def get_ajax_output(self, changes):
   121     def get_ajax_output(self, changes):
   120         updated = changes.get(IBaseGallery, ())
   122         updated = changes.get(IBaseGallery, ())
   121         if 'title' in updated:
   123         if 'title' in updated:
   122             return {'status': 'success',
   124             return {
   123                     'events': [{
   125                 'status': 'success',
   124                         'event': 'myams.refresh',
   126                 'events': [get_json_paragraph_refresh_event(self.context, self.request), ]
   125                         'options': {
   127             }
   126                             'handler': 'PyAMS_content.paragraphs.refreshParagraph',
       
   127                             'object_name': self.context.__name__,
       
   128                             'title': II18n(self.context).query_attribute('title', request=self.request),
       
   129                             'visible': self.context.visible
       
   130                         }
       
   131                     }]}
       
   132         else:
   128         else:
   133             return super(GalleryPropertiesAJAXEditForm, self).get_ajax_output(changes)
   129             return super(GalleryPropertiesAJAXEditForm, self).get_ajax_output(changes)
   134 
   130 
   135 
   131 
   136 @adapter_config(context=(IGalleryParagraph, IPyAMSLayer), provides=IParagraphInnerEditor)
   132 @adapter_config(context=(IGalleryParagraph, IPyAMSLayer), provides=IParagraphInnerEditor)