Use form manager to handle specific renderer settings edit forms
authorThierry Florac <thierry.florac@onf.fr>
Wed, 18 Jul 2018 15:49:51 +0200
changeset 860 9d1653c0e04d
parent 859 5139e1da058e
child 861 36f6bb152718
Use form manager to handle specific renderer settings edit forms
src/pyams_content/features/renderer/zmi/__init__.py
--- a/src/pyams_content/features/renderer/zmi/__init__.py	Tue Jul 17 18:08:54 2018 +0200
+++ b/src/pyams_content/features/renderer/zmi/__init__.py	Wed Jul 18 15:49:51 2018 +0200
@@ -9,6 +9,9 @@
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE.
 #
+from pyramid.decorator import reify
+
+from pyams_form.interfaces.form import IFormManager
 
 __docformat__ = 'restructuredtext'
 
@@ -70,12 +73,45 @@
     legend = _("Edit renderer properties")
     icon_css_class = 'fa fa-fw fa-pencil-square-o'
 
-    @property
+    @reify
+    def manager(self):
+        content = self.getContent()
+        return self.request.registry.queryMultiAdapter((content, self.request, self), IFormManager)
+
+    @reify
     def fields(self):
-        renderer = IContentRenderer(self.context)
-        return field.Fields(renderer.settings_interface or Interface)
+        if self.manager is not None:
+            return self.manager.getFields()
+        else:
+            renderer = IContentRenderer(self.context)
+            return field.Fields(renderer.settings_interface or Interface)
 
     edit_permission = MANAGE_CONTENT_PERMISSION
 
     def getContent(self):
         return IRendererSettings(self.context)
+
+    def update(self):
+        if self.manager is not None:
+            self.manager.update()
+        else:
+            super(RendererPropertiesEditForm, self).update()
+
+    def updateWidgets(self, prefix=None):
+        if self.manager is not None:
+            self.manager.updateWidgets(prefix)
+        else:
+            super(RendererPropertiesEditForm, self).updateWidgets(prefix)
+
+    def updateActions(self):
+        if self.manager is not None:
+            self.manager.updateActions()
+        else:
+            super(RendererPropertiesEditForm, self).updateActions()
+
+    def updateGroups(self):
+        if self.manager is not None:
+            self.manager.updateGroups()
+        else:
+            super(RendererPropertiesEditForm, self).updateGroups()
+