[Checkins] SVN: z3c.formext/branches/sagblmi-morecomponent/src/z3c/formext/ Refactor the hierarchy of IExtJSComponent adapters registered for IGroup and IForm
Laurent Mignon
Laurent.Mignon at softwareag.com
Fri Aug 28 06:31:43 EDT 2009
Log message for revision 103329:
Refactor the hierarchy of IExtJSComponent adapters registered for IGroup and IForm
Changed:
U z3c.formext/branches/sagblmi-morecomponent/src/z3c/formext/component.py
U z3c.formext/branches/sagblmi-morecomponent/src/z3c/formext/component.zcml
U z3c.formext/branches/sagblmi-morecomponent/src/z3c/formext/group.txt
U z3c.formext/branches/sagblmi-morecomponent/src/z3c/formext/testing.py
-=-
Modified: z3c.formext/branches/sagblmi-morecomponent/src/z3c/formext/component.py
===================================================================
--- z3c.formext/branches/sagblmi-morecomponent/src/z3c/formext/component.py 2009-08-28 01:26:48 UTC (rev 103328)
+++ z3c.formext/branches/sagblmi-morecomponent/src/z3c/formext/component.py 2009-08-28 10:31:42 UTC (rev 103329)
@@ -352,22 +352,24 @@
return items
-class Panel(Component):
- zope.interface.implements(interfaces.IExtJSComponent)
- zope.component.adapts(IForm)
+class Container(Component):
+ """Container config
+ """
- xtype = 'panel'
+ xtype = None
+ layout = None
def __init__(self, form):
self.form = form
def _getConfig(self):
- config = dict(
- xtype=self.xtype)
+ config = {}
+ if self.xtype:
+ config['xtype'] = self.xtype
+ if self.layout:
+ config['layout'] = self.layout
if self.form.label:
config['title'] = self.form.label
- else:
- config['xtype'] = 'container'
if not self.form.widgets:
self.form.updateWidgets()
items = getWidgetsConfig(self.form, asDict=False)
@@ -384,12 +386,19 @@
return config
-class GroupPanel(Panel):
+class Panel(Container):
zope.interface.implements(interfaces.IExtJSComponent)
+ zope.component.adapts(IForm)
+
+ xtype = 'panel'
+
+
+class Group(Container):
+ zope.interface.implements(interfaces.IExtJSComponent)
zope.component.adapts(IGroup)
def _getConfig(self):
- config = super(GroupPanel, self)._getConfig()
+ config = super(Group, self)._getConfig()
items = config.get("items", [])
items += getGroupsConfig(self.form)
config['items'] = items
Modified: z3c.formext/branches/sagblmi-morecomponent/src/z3c/formext/component.zcml
===================================================================
--- z3c.formext/branches/sagblmi-morecomponent/src/z3c/formext/component.zcml 2009-08-28 01:26:48 UTC (rev 103328)
+++ z3c.formext/branches/sagblmi-morecomponent/src/z3c/formext/component.zcml 2009-08-28 10:31:42 UTC (rev 103329)
@@ -8,7 +8,7 @@
factory=".component.Panel"
/>
<adapter
- factory=".component.GroupPanel"
+ factory=".component.Group"
/>
<adapter
factory=".component.FormPanel"
Modified: z3c.formext/branches/sagblmi-morecomponent/src/z3c/formext/group.txt
===================================================================
--- z3c.formext/branches/sagblmi-morecomponent/src/z3c/formext/group.txt 2009-08-28 01:26:48 UTC (rev 103328)
+++ z3c.formext/branches/sagblmi-morecomponent/src/z3c/formext/group.txt 2009-08-28 10:31:42 UTC (rev 103329)
@@ -154,8 +154,7 @@
'minLength': 0,
'name': 'form.widgets.address',
'xtype': 'textfield'}],
- 'title': u'License',
- 'xtype': 'panel'},
+ 'title': u'License'},
{'items': [{'allowBlank': False,
'fieldLabel': u'Model',
'id': 'form-widgets-model',
@@ -177,8 +176,7 @@
'minLength': 0,
'name': 'form.widgets.year',
'xtype': 'textfield'}],
- 'title': u'Car',
- 'xtype': 'panel'}]
+ 'title': u'Car'}]
Ext JS provide a lot of way to support grouping fields.
@@ -187,10 +185,10 @@
* TabPanel
* FieldSet
-By default, group are rendered as 'panel'
+By default, group are rendered without xtype
- >>> interfaces.IExtJSComponent(myForm.groups[0])._getConfig()['xtype']
- 'panel'
+ >>> 'xtype' not in interfaces.IExtJSComponent(myForm.groups[0])._getConfig().keys()
+ True
You can override this attribute by providing an adapter for IExtJSConfigValue
@@ -209,8 +207,8 @@
'tabpanel'
Only the LicenseGroup class is affected by the adapter
- >>> interfaces.IExtJSComponent(myForm.groups[1])._getConfig()['xtype']
- 'panel'
+ >>> 'xtype' not in interfaces.IExtJSComponent(myForm.groups[1])._getConfig()
+ True
>>> from zope.component import getGlobalSiteManager
>>> gsm = getGlobalSiteManager()
@@ -307,8 +305,7 @@
'minLength': 0,
'name': 'form.widgets.address',
'xtype': 'textfield'}],
- 'title': u'License',
- 'xtype': 'panel'},
+ 'title': u'License'},
{'items': [{'allowBlank': False,
'fieldLabel': u'Model',
'id': 'form-widgets-model',
@@ -330,8 +327,7 @@
'minLength': 0,
'name': 'form.widgets.year',
'xtype': 'textfield'}],
- 'title': u'Car',
- 'xtype': 'panel'}],
+ 'title': u'Car'}],
'xtype': 'tabpanel'}],
'submitURL': 'http://127.0.0.1',
'xtype': 'formpanel'}
Modified: z3c.formext/branches/sagblmi-morecomponent/src/z3c/formext/testing.py
===================================================================
--- z3c.formext/branches/sagblmi-morecomponent/src/z3c/formext/testing.py 2009-08-28 01:26:48 UTC (rev 103328)
+++ z3c.formext/branches/sagblmi-morecomponent/src/z3c/formext/testing.py 2009-08-28 10:31:42 UTC (rev 103329)
@@ -105,7 +105,7 @@
ISingleCheckBoxWidget, zope.schema.interfaces.IField),
interfaces.IExtJSComponent)
zope.component.provideAdapter(component.Panel)
- zope.component.provideAdapter(component.GroupPanel)
+ zope.component.provideAdapter(component.Group)
zope.component.provideAdapter(component.FormPanel)
zope.component.provideAdapter(component.ExtFormPanel)
zope.component.provideAdapter(component.Button)
More information about the checkins
mailing list