src/pyams_content/component/paragraph/zmi/keypoint.py
changeset 1243 837612af4dc3
parent 1083 112b6aa11de4
--- a/src/pyams_content/component/paragraph/zmi/keypoint.py	Thu Jan 17 12:41:14 2019 +0100
+++ b/src/pyams_content/component/paragraph/zmi/keypoint.py	Thu Jan 17 16:42:32 2019 +0100
@@ -12,18 +12,16 @@
 
 __docformat__ = 'restructuredtext'
 
-from z3c.form import button, field
+from z3c.form import button
 from z3c.form.interfaces import INPUT_MODE
 from zope.interface import implementer
 
-from pyams_content.component.paragraph.interfaces import IParagraphContainer, IParagraphContainerTarget, \
-    PARAGRAPH_HIDDEN_FIELDS
+from pyams_content.component.paragraph.interfaces import IParagraphContainerTarget
 from pyams_content.component.paragraph.interfaces.keypoint import IKeypointsParagraph, KEYPOINTS_PARAGRAPH_TYPE
 from pyams_content.component.paragraph.keypoint import KeypointsParagraph
 from pyams_content.component.paragraph.zmi import BaseParagraphAJAXAddForm, BaseParagraphAJAXEditForm, \
-    BaseParagraphAddMenu, BaseParagraphPropertiesEditForm, IParagraphInnerEditFormButtons
+    BaseParagraphAddForm, BaseParagraphAddMenu, BaseParagraphPropertiesEditForm, IParagraphInnerEditFormButtons
 from pyams_content.component.paragraph.zmi.interfaces import IParagraphContainerView, IParagraphInnerEditor
-from pyams_content.features.renderer.zmi.widget import RendererFieldWidget
 from pyams_content.interfaces import MANAGE_CONTENT_PERMISSION
 from pyams_form.form import ajax_config
 from pyams_form.interfaces.form import IInnerForm
@@ -33,7 +31,6 @@
 from pyams_skin.layer import IPyAMSLayer
 from pyams_utils.adapter import adapter_config
 from pyams_viewlet.viewlet import viewlet_config
-from pyams_zmi.form import AdminDialogAddForm
 
 from pyams_content import _
 
@@ -53,26 +50,18 @@
                 permission=MANAGE_CONTENT_PERMISSION)
 @ajax_config(name='add-keypoints-paragraph.json', context=IParagraphContainerTarget, layer=IPyAMSLayer,
              base=BaseParagraphAJAXAddForm)
-class KeypointsParagraphAddForm(AdminDialogAddForm):
+class KeypointsParagraphAddForm(BaseParagraphAddForm):
     """Key points paragraph add form"""
 
     legend = _("Add new key points paragraph")
-    icon_css_class = 'fa fa-fw ' + KeypointsParagraph.icon_class
 
-    fields = field.Fields(IKeypointsParagraph).omit(*PARAGRAPH_HIDDEN_FIELDS)
-    edit_permission = MANAGE_CONTENT_PERMISSION
+    content_interface = IKeypointsParagraph
 
     def updateWidgets(self, prefix=None):
         super(KeypointsParagraphAddForm, self).updateWidgets(prefix)
         if 'body' in self.widgets:
             self.widgets['body'].widget_css_class = 'input height-100'
 
-    def create(self, data):
-        return KeypointsParagraph()
-
-    def add(self, object):
-        IParagraphContainer(self.context).append(object)
-
 
 @pagelet_config(name='properties.html', context=IKeypointsParagraph, layer=IPyAMSLayer,
                 permission=MANAGE_CONTENT_PERMISSION)
@@ -84,12 +73,8 @@
     prefix = 'keypoints_properties.'
 
     legend = _("Edit key points paragraph properties")
-    icon_css_class = 'fa fa-fw ' + KeypointsParagraph.icon_class
 
-    fields = field.Fields(IKeypointsParagraph).omit(*PARAGRAPH_HIDDEN_FIELDS)
-    fields['renderer'].widgetFactory = RendererFieldWidget
-
-    edit_permission = MANAGE_CONTENT_PERMISSION
+    content_interface = IKeypointsParagraph
 
     def updateWidgets(self, prefix=None):
         super(KeypointsParagraphPropertiesEditForm, self).updateWidgets(prefix)