use keytable field for datatable data
This commit is contained in:
		
							parent
							
								
									9397df0afa
								
							
						
					
					
						commit
						bd2cb55f16
					
				
					 3 changed files with 33 additions and 17 deletions
				
			
		|  | @ -159,6 +159,10 @@ table.listing th span.descending { | ||||||
|     background-repeat: no-repeat; |     background-repeat: no-repeat; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | table.records { | ||||||
|  |     border-collapse: collapse; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| table.records input, table.records textarea { | table.records input, table.records textarea { | ||||||
|     border: none; |     border: none; | ||||||
|     padding: 0; |     padding: 0; | ||||||
|  | @ -167,13 +171,13 @@ table.records input, table.records textarea { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| table.records th { | table.records th { | ||||||
|     background-color: lightgrey; |     background-color: #fefefe; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| table.records th, table.records td { | table.records th, table.records td { | ||||||
|     padding: 0; |     padding: 0; | ||||||
|     margin: 0; |     margin: 0; | ||||||
|     border: 1px solid black; |     border: 1px solid lightgrey; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| table.report td { | table.report td { | ||||||
|  |  | ||||||
|  | @ -1,5 +1,3 @@ | ||||||
| <!-- $Id$ --> |  | ||||||
| 
 |  | ||||||
| <configure | <configure | ||||||
|    xmlns="http://namespaces.zope.org/zope" |    xmlns="http://namespaces.zope.org/zope" | ||||||
|    xmlns:i18n="http://namespaces.zope.org/i18n" |    xmlns:i18n="http://namespaces.zope.org/i18n" | ||||||
|  | @ -355,6 +353,8 @@ | ||||||
|            name="grid" /> |            name="grid" /> | ||||||
|   <adapter factory="cybertools.composer.schema.grid.field.RecordsFieldInstance" |   <adapter factory="cybertools.composer.schema.grid.field.RecordsFieldInstance" | ||||||
|            name="records" /> |            name="records" /> | ||||||
|  |   <adapter factory="cybertools.composer.schema.grid.field.ContextBasedKeyTableFieldInstance" | ||||||
|  |            name="keytable" /> | ||||||
|   <adapter factory="loops.schema.field.RelationSetFieldInstance" |   <adapter factory="loops.schema.field.RelationSetFieldInstance" | ||||||
|            name="relationset" /> |            name="relationset" /> | ||||||
|   <adapter factory="loops.schema.field.RelationFieldInstance" |   <adapter factory="loops.schema.field.RelationFieldInstance" | ||||||
|  | @ -366,14 +366,10 @@ | ||||||
|            for="loops.interfaces.IResource" /> |            for="loops.interfaces.IResource" /> | ||||||
|   <adapter factory="loops.schema.factory.FileSchemaFactory" /> |   <adapter factory="loops.schema.factory.FileSchemaFactory" /> | ||||||
|   <adapter factory="loops.schema.factory.NoteSchemaFactory" /> |   <adapter factory="loops.schema.factory.NoteSchemaFactory" /> | ||||||
|  |   <adapter factory="loops.table.DataTableSchemaFactory" /> | ||||||
| 
 | 
 | ||||||
|   <adapter factory="loops.setup.SetupManager" /> |   <adapter factory="loops.setup.SetupManager" /> | ||||||
| 
 | 
 | ||||||
|   <!-- obsolete: |  | ||||||
|   <adapter factory="loops.external.NodesLoader" /> |  | ||||||
|   <adapter factory="loops.external.NodesExporter" /> |  | ||||||
|   <adapter factory="loops.external.NodesImporter" />--> |  | ||||||
| 
 |  | ||||||
|   <!-- obsolete - remove: --> |   <!-- obsolete - remove: --> | ||||||
|   <adapter factory="loops.target.DocumentProxy" |   <adapter factory="loops.target.DocumentProxy" | ||||||
|            permission="zope.ManageContent" /> |            permission="zope.ManageContent" /> | ||||||
|  | @ -432,10 +428,12 @@ | ||||||
|   <!-- utilities --> |   <!-- utilities --> | ||||||
| 
 | 
 | ||||||
|   <utility |   <utility | ||||||
|  |       provides="cybertools.storage.interfaces.IExternalStorage" | ||||||
|       factory="cybertools.storage.filesystem.instanceVarSubdirectoryStorage" |       factory="cybertools.storage.filesystem.instanceVarSubdirectoryStorage" | ||||||
|       name="varsubdir" /> |       name="varsubdir" /> | ||||||
| 
 | 
 | ||||||
|   <utility |   <utility | ||||||
|  |       provides="cybertools.storage.interfaces.IExternalStorage" | ||||||
|       factory="cybertools.storage.filesystem.fullPathStorage" |       factory="cybertools.storage.filesystem.fullPathStorage" | ||||||
|       name="fullpath" /> |       name="fullpath" /> | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
							
								
								
									
										30
									
								
								table.py
									
										
									
									
									
								
							
							
						
						
									
										30
									
								
								table.py
									
										
									
									
									
								
							|  | @ -18,16 +18,16 @@ | ||||||
| 
 | 
 | ||||||
| """ | """ | ||||||
| Data (keyword-based) table definition and implementation. | Data (keyword-based) table definition and implementation. | ||||||
| 
 |  | ||||||
| $Id$ |  | ||||||
| """ | """ | ||||||
| 
 | 
 | ||||||
| from BTrees.OOBTree import OOBTree | from BTrees.OOBTree import OOBTree | ||||||
| from zope import schema, component | from zope import component, schema | ||||||
| from zope.interface import Interface, Attribute, implements | from zope.component import adapts | ||||||
|  | from zope.interface import implements, Interface, Attribute | ||||||
| from zope.cachedescriptors.property import Lazy | from zope.cachedescriptors.property import Lazy | ||||||
| 
 | 
 | ||||||
| from cybertools.composer.schema.grid.interfaces import Records | from cybertools.composer.schema.factory import SchemaFactory | ||||||
|  | from cybertools.composer.schema.grid.interfaces import KeyTable | ||||||
| from loops.common import AdapterBase | from loops.common import AdapterBase | ||||||
| from loops.interfaces import IConcept, IConceptSchema, ILoopsAdapter | from loops.interfaces import IConcept, IConceptSchema, ILoopsAdapter | ||||||
| from loops.type import TypeInterfaceSourceList | from loops.type import TypeInterfaceSourceList | ||||||
|  | @ -47,8 +47,6 @@ class IDataTable(IConceptSchema, ILoopsAdapter): | ||||||
|         default=u'', |         default=u'', | ||||||
|         required=False) |         required=False) | ||||||
| 
 | 
 | ||||||
|     # better: specify column names (and possibly labels, types) |  | ||||||
|     # in Python code and reference by name here |  | ||||||
|     columns = schema.List( |     columns = schema.List( | ||||||
|         title=_(u'Columns'), |         title=_(u'Columns'), | ||||||
|         description=_(u'The names of the columns of the data table. ' |         description=_(u'The names of the columns of the data table. ' | ||||||
|  | @ -57,10 +55,12 @@ class IDataTable(IConceptSchema, ILoopsAdapter): | ||||||
|         default=['key', 'value'], |         default=['key', 'value'], | ||||||
|         required=True) |         required=True) | ||||||
| 
 | 
 | ||||||
|     data = Records(title=_(u'Table Data'), |     data = KeyTable(title=_(u'Table Data'), | ||||||
|         description=_(u'Table Data'), |         description=_(u'Table Data'), | ||||||
|         required=False) |         required=False) | ||||||
| 
 | 
 | ||||||
|  | IDataTable['columns'].hidden = True | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| class DataTable(AdapterBase): | class DataTable(AdapterBase): | ||||||
| 
 | 
 | ||||||
|  | @ -75,6 +75,8 @@ class DataTable(AdapterBase): | ||||||
|         self.context._columns = value |         self.context._columns = value | ||||||
|     columns = property(getColumns, setColumns) |     columns = property(getColumns, setColumns) | ||||||
| 
 | 
 | ||||||
|  |     columnNames = columns | ||||||
|  | 
 | ||||||
|     def getData(self): |     def getData(self): | ||||||
|         data = getattr(self.context, '_data', None) |         data = getattr(self.context, '_data', None) | ||||||
|         if data is None: |         if data is None: | ||||||
|  | @ -87,3 +89,15 @@ class DataTable(AdapterBase): | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| TypeInterfaceSourceList.typeInterfaces += (IDataTable,) | TypeInterfaceSourceList.typeInterfaces += (IDataTable,) | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | class DataTableSchemaFactory(SchemaFactory): | ||||||
|  | 
 | ||||||
|  |     adapts(IDataTable) | ||||||
|  | 
 | ||||||
|  |     def __call__(self, interface, **kw): | ||||||
|  |         schema = super(DataTableSchemaFactory, self).__call__(interface, **kw) | ||||||
|  |         schema.fields.remove('columns') | ||||||
|  |         schema.fields.remove('viewName') | ||||||
|  |         return schema | ||||||
|  | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue