src/pyams_content/shared/logo/zmi/paragraph.py
changeset 1006 cbb65b4b8742
parent 1002 ab7787b3faf1
child 1207 a97f2023131a
equal deleted inserted replaced
1005:107406cb705c 1006:cbb65b4b8742
    92     fields = field.Fields(ILogosParagraph).omit(*PARAGRAPH_HIDDEN_FIELDS)
    92     fields = field.Fields(ILogosParagraph).omit(*PARAGRAPH_HIDDEN_FIELDS)
    93     fields['renderer'].widgetFactory = RendererFieldWidget
    93     fields['renderer'].widgetFactory = RendererFieldWidget
    94 
    94 
    95     edit_permission = MANAGE_CONTENT_PERMISSION
    95     edit_permission = MANAGE_CONTENT_PERMISSION
    96 
    96 
       
    97     def get_ajax_output(self, changes):
       
    98         output = super(self.__class__, self).get_ajax_output(changes)
       
    99         if 'renderer' in changes.get(ILogosParagraph, ()):
       
   100             output.setdefault('events', []).append(
       
   101                 get_json_widget_refresh_event(self.context, self.request,
       
   102                                               LogosParagraphInnerEditForm, 'renderer'))
       
   103         return output
       
   104 
    97 
   105 
    98 @adapter_config(context=(ILogosParagraph, IPyAMSLayer), provides=IParagraphInnerEditor)
   106 @adapter_config(context=(ILogosParagraph, IPyAMSLayer), provides=IParagraphInnerEditor)
    99 @ajax_config(name='inner-properties.json', context=ILogosParagraph, layer=IPyAMSLayer,
   107 @ajax_config(name='inner-properties.json', context=ILogosParagraph, layer=IPyAMSLayer,
   100              base=BaseParagraphAJAXEditForm)
   108              base=BaseParagraphAJAXEditForm)
   101 @implementer(IInnerForm)
   109 @implementer(IInnerForm)
   108     def buttons(self):
   116     def buttons(self):
   109         if self.mode == INPUT_MODE:
   117         if self.mode == INPUT_MODE:
   110             return button.Buttons(IParagraphInnerEditFormButtons)
   118             return button.Buttons(IParagraphInnerEditFormButtons)
   111         else:
   119         else:
   112             return button.Buttons()
   120             return button.Buttons()
   113 
       
   114 
       
   115 @view_config(name='inner-properties.json', context=ILogosParagraph, request_type=IPyAMSLayer,
       
   116              permission=MANAGE_CONTENT_PERMISSION, renderer='json', xhr=True)
       
   117 class LogosParagraphInnerAJAXEditForm(BaseParagraphAJAXEditForm, LogosParagraphInnerEditForm):
       
   118     """Logos paragraph properteis inner edit form, JSON renderer"""
       
   119 
       
   120     def get_ajax_output(self, changes):
       
   121         output = super(LogosParagraphInnerAJAXEditForm, self).get_ajax_output(changes)
       
   122         updated = changes.get(ILogosParagraph, ())
       
   123         if 'renderer' in updated:
       
   124             output.setdefault('events', []).append(
       
   125                 get_json_widget_refresh_event(self.context, self.request,
       
   126                                               LogosParagraphInnerEditForm, 'renderer'))
       
   127         return output