Added FormManager support in portlet renderer properties edit form
authorThierry Florac <tflorac@ulthar.net>
Wed, 27 Jan 2021 15:43:26 +0100
changeset 282 5c1cccd7fba8
parent 281 1c1ac829aa6e
child 283 cd30e57eae92
Added FormManager support in portlet renderer properties edit form
src/pyams_portal/zmi/portlet.py
--- a/src/pyams_portal/zmi/portlet.py	Wed Nov 25 13:02:44 2020 +0100
+++ b/src/pyams_portal/zmi/portlet.py	Wed Jan 27 15:43:26 2021 +0100
@@ -24,7 +24,7 @@
 from pyams_form.form import ajax_config
 from pyams_form.help import FormHelp
 # import interfaces
-from pyams_form.interfaces.form import IInnerTabForm, IFormHelp
+from pyams_form.interfaces.form import IFormManager, IInnerTabForm, IFormHelp
 from pyams_pagelet.pagelet import pagelet_config
 from pyams_portal import _
 from pyams_portal.interfaces import IPortlet, IPortalTemplate, IPortalPage, MANAGE_TEMPLATE_PERMISSION, \
@@ -176,8 +176,16 @@
     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):
+        if self.manager is not None:
+            return self.manager.getFields()
         renderer = self.context.get_renderer(self.request)
         return field.Fields(renderer.settings_interface or Interface)
 
@@ -185,3 +193,27 @@
 
     def getContent(self):
         return IPortletRendererSettings(self.context)
+
+    def update(self):
+        if self.manager is not None:
+            self.manager.update()
+        else:
+            super(PortletRendererPropertiesEditForm, self).update()
+
+    def updateWidgets(self, prefix=None):
+        if self.manager is not None:
+            self.manager.updateWidgets(prefix)
+        else:
+            super(PortletRendererPropertiesEditForm, self).updateWidgets(prefix)
+
+    def updateActions(self):
+        if self.manager is not None:
+            self.manager.updateActions()
+        else:
+            super(PortletRendererPropertiesEditForm, self).updateActions()
+
+    def updateGroups(self):
+        if self.manager is not None:
+            self.manager.updateGroups()
+        else:
+            super(PortletRendererPropertiesEditForm, self).updateGroups()