Updated object widgets for z3c.form >= 4.1
authorThierry Florac <tflorac@ulthar.net>
Tue, 30 Jun 2020 13:49:33 +0200
changeset 68 b0a03a00c83e
parent 67 42cb3f558fc8
child 69 5046bae5973f
Updated object widgets for z3c.form >= 4.1
src/pyams_gis/zmi/widget/area.py
src/pyams_gis/zmi/widget/point.py
src/pyams_gis/zmi/widget/templates/geoarea-input.pt
src/pyams_gis/zmi/widget/templates/geopoint-input.pt
--- a/src/pyams_gis/zmi/widget/area.py	Fri Jan 18 15:36:50 2019 +0100
+++ b/src/pyams_gis/zmi/widget/area.py	Tue Jun 30 13:49:33 2020 +0200
@@ -10,28 +10,25 @@
 # FOR A PARTICULAR PURPOSE.
 #
 
-__docformat__ = 'restructuredtext'
-
-
-# import standard library
 import json
 
-# import interfaces
-from pyams_form.interfaces.form import IFormLayer, IForm
+from z3c.form.browser.object import ObjectWidget
+from z3c.form.interfaces import IFieldWidget, IObjectFactory
+from z3c.form.object import getIfName
+from z3c.form.widget import FieldWidget
+from zope.interface import Interface, alsoProvides, implementer_only
+
+from pyams_form.interfaces.form import IForm, IFormLayer
+from pyams_form.widget import widgettemplate_config
+from pyams_gis.area import GeoArea
 from pyams_gis.interfaces import IGeoArea
 from pyams_gis.interfaces.widget import IGeoAreaWidget
 from pyams_gis.schema import IGeoAreaField
+from pyams_utils.adapter import adapter_config
 from pyams_utils.interfaces.data import IObjectData
-from z3c.form.interfaces import IFieldWidget, IObjectFactory
 
-# import packages
-from pyams_form.widget import widgettemplate_config
-from pyams_gis.area import GeoArea
-from pyams_utils.adapter import adapter_config
-from z3c.form.browser.object import ObjectWidget
-from z3c.form.object import getIfName
-from z3c.form.widget import FieldWidget
-from zope.interface import implementer_only, alsoProvides, Interface
+
+__docformat__ = 'restructuredtext'
 
 
 @adapter_config(name=getIfName(IGeoArea),
@@ -56,7 +53,7 @@
 
     def updateWidgets(self, setErrors=True):
         super(GeoAreaWidget, self).updateWidgets()
-        widgets = self.subform.widgets
+        widgets = self.widgets
         x1 = widgets['x1']
         x1.input_css_class = 'col-md-2'
         x1.object_data = {'ams-change-handler': 'PyAMS_GIS.area.changedCoordinate'}
--- a/src/pyams_gis/zmi/widget/point.py	Fri Jan 18 15:36:50 2019 +0100
+++ b/src/pyams_gis/zmi/widget/point.py	Tue Jun 30 13:49:33 2020 +0200
@@ -10,28 +10,25 @@
 # FOR A PARTICULAR PURPOSE.
 #
 
-__docformat__ = 'restructuredtext'
-
-
-# import standard library
 import json
 
-# import interfaces
-from pyams_gis.interfaces import IGeoPointZ
-from pyams_form.interfaces.form import IFormLayer, IForm
-from pyams_gis.interfaces.widget import IGeoPointWidget, IGeoPointZWidget
-from pyams_gis.schema import IGeoPoint, IGeoPointField, IGeoPointZField
-from pyams_utils.interfaces.data import IObjectData
+from z3c.form.browser.object import ObjectWidget
 from z3c.form.interfaces import IFieldWidget, IObjectFactory
-
-# import packages
-from pyams_form.widget import widgettemplate_config
-from pyams_gis.point import GeoPoint, GeoPointZ
-from pyams_utils.adapter import adapter_config
-from z3c.form.browser.object import ObjectWidget
 from z3c.form.object import getIfName
 from z3c.form.widget import FieldWidget
-from zope.interface import implementer_only, alsoProvides, Interface
+from zope.interface import Interface, alsoProvides, implementer_only
+
+from pyams_form.interfaces.form import IForm, IFormLayer
+from pyams_form.widget import widgettemplate_config
+from pyams_gis.interfaces import IGeoPointZ
+from pyams_gis.interfaces.widget import IGeoPointWidget, IGeoPointZWidget
+from pyams_gis.point import GeoPoint, GeoPointZ
+from pyams_gis.schema import IGeoPoint, IGeoPointField, IGeoPointZField
+from pyams_utils.adapter import adapter_config
+from pyams_utils.interfaces.data import IObjectData
+
+
+__docformat__ = 'restructuredtext'
 
 
 @adapter_config(name=getIfName(IGeoPoint),
@@ -56,7 +53,7 @@
 
     def updateWidgets(self, setErrors=True):
         super(GeoPointWidget, self).updateWidgets(setErrors)
-        widgets = self.subform.widgets
+        widgets = self.widgets
         longitude = widgets['longitude']
         longitude.label_css_class = 'control-label col-md-3'
         longitude.input_css_class = 'col-md-2'
@@ -113,7 +110,7 @@
 
     def updateWidgets(self, setErrors=True):
         super(GeoPointZWidget, self).updateWidgets(setErrors)
-        widgets = self.subform.widgets
+        widgets = self.widgets
         longitude = widgets['longitude']
         longitude.label_css_class = 'control-label col-md-3'
         longitude.input_css_class = 'col-md-2'
--- a/src/pyams_gis/zmi/widget/templates/geoarea-input.pt	Fri Jan 18 15:36:50 2019 +0100
+++ b/src/pyams_gis/zmi/widget/templates/geoarea-input.pt	Tue Jun 30 13:49:33 2020 +0200
@@ -51,7 +51,7 @@
 			</div>
 		</div>
 		<div class="clearfix-xs clearfix-sm"></div>
-		<tal:loop repeat="widget view/subform/widgets/values">
+		<tal:loop repeat="widget view/widgets/values">
 			<input type="hidden"
 				   tal:condition="python:widget.mode == 'hidden'"
 				   tal:replace="structure widget/render" />
--- a/src/pyams_gis/zmi/widget/templates/geopoint-input.pt	Fri Jan 18 15:36:50 2019 +0100
+++ b/src/pyams_gis/zmi/widget/templates/geopoint-input.pt	Tue Jun 30 13:49:33 2020 +0200
@@ -53,7 +53,7 @@
 			</div>
 		</div>
 		<div class="clearfix-xs clearfix-sm"></div>
-		<tal:loop repeat="widget view/subform/widgets/values">
+		<tal:loop repeat="widget view/widgets/values">
 			<input type="hidden"
 				   tal:condition="python:widget.mode == 'hidden'"
 				   tal:replace="structure widget/render" />