src/pyams_content/component/paragraph/zmi/contact.py
changeset 1006 cbb65b4b8742
parent 1002 ab7787b3faf1
child 1082 18e6d6cddcc9
equal deleted inserted replaced
1005:107406cb705c 1006:cbb65b4b8742
    87     fields = field.Fields(IContactParagraph).omit(*PARAGRAPH_HIDDEN_FIELDS)
    87     fields = field.Fields(IContactParagraph).omit(*PARAGRAPH_HIDDEN_FIELDS)
    88     fields['renderer'].widgetFactory = RendererFieldWidget
    88     fields['renderer'].widgetFactory = RendererFieldWidget
    89 
    89 
    90     edit_permission = MANAGE_CONTENT_PERMISSION
    90     edit_permission = MANAGE_CONTENT_PERMISSION
    91 
    91 
       
    92     def get_ajax_output(self, changes):
       
    93         output = super(self.__class__, self).get_ajax_output(changes)
       
    94         updated = changes.get(IBaseParagraph, ())
       
    95         if 'title' in updated:
       
    96             output.setdefault('events', []).append(get_json_paragraph_refresh_event(self.context, self.request))
       
    97         updated = changes.get(IContactParagraph, ())
       
    98         if ('photo' in updated) or ('renderer' in updated):
       
    99             # we have to commit transaction to be able to handle blobs...
       
   100             if 'photo' in updated:
       
   101                 ITransactionManager(self.context).get().commit()
       
   102             output.setdefault('events', []).append(get_json_form_refresh_event(self.context, self.request,
       
   103                                                                                ContactParagraphInnerEditForm))
       
   104         return output
       
   105 
    92 
   106 
    93 @adapter_config(context=(IContactParagraph, IPyAMSLayer), provides=IParagraphInnerEditor)
   107 @adapter_config(context=(IContactParagraph, IPyAMSLayer), provides=IParagraphInnerEditor)
    94 @ajax_config(name='inner-properties.json', context=IContactParagraph, layer=IPyAMSLayer,
   108 @ajax_config(name='inner-properties.json', context=IContactParagraph, layer=IPyAMSLayer,
    95              base=BaseParagraphAJAXEditForm)
   109              base=BaseParagraphAJAXEditForm)
    96 @implementer(IInnerForm)
   110 @implementer(IInnerForm)
   103     def buttons(self):
   117     def buttons(self):
   104         if self.mode == INPUT_MODE:
   118         if self.mode == INPUT_MODE:
   105             return button.Buttons(IParagraphInnerEditFormButtons)
   119             return button.Buttons(IParagraphInnerEditFormButtons)
   106         else:
   120         else:
   107             return button.Buttons()
   121             return button.Buttons()
   108 
       
   109     def get_ajax_output(self, changes):
       
   110         output = super(self.__class__, self).get_ajax_output(changes)
       
   111         updated = changes.get(IBaseParagraph, ())
       
   112         if 'title' in updated:
       
   113             output.setdefault('events', []).append(get_json_paragraph_refresh_event(self.context, self.request))
       
   114         updated = changes.get(IContactParagraph, ())
       
   115         if ('photo' in updated) or ('renderer' in updated):
       
   116             # we have to commit transaction to be able to handle blobs...
       
   117             if 'photo' in updated:
       
   118                 ITransactionManager(self.context).get().commit()
       
   119             output.setdefault('events', []).append(get_json_form_refresh_event(self.context, self.request,
       
   120                                                                                ContactParagraphInnerEditForm))
       
   121         return output