use keytable field for datatable data
This commit is contained in:
parent
15f622f373
commit
99d027efe4
3 changed files with 39 additions and 17 deletions
|
@ -159,6 +159,10 @@ table.listing th span.descending {
|
|||
background-repeat: no-repeat;
|
||||
}
|
||||
|
||||
table.records {
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
table.records input, table.records textarea {
|
||||
border: none;
|
||||
padding: 0;
|
||||
|
@ -167,13 +171,13 @@ table.records input, table.records textarea {
|
|||
}
|
||||
|
||||
table.records th {
|
||||
background-color: lightgrey;
|
||||
background-color: #fefefe;
|
||||
}
|
||||
|
||||
table.records th, table.records td {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
border: 1px solid black;
|
||||
border: 1px solid lightgrey;
|
||||
}
|
||||
|
||||
table.report td {
|
||||
|
@ -509,6 +513,14 @@ div.comment {
|
|||
color: #666666;
|
||||
}
|
||||
|
||||
/* microart */
|
||||
|
||||
.micropart {
|
||||
background-color: #f7f7f7;
|
||||
padding: 0 5px 0 5px;
|
||||
margin: 5px 0 5px 0;
|
||||
}
|
||||
|
||||
/* calendar, work items */
|
||||
|
||||
.today {
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
<!-- $Id$ -->
|
||||
|
||||
<configure
|
||||
xmlns="http://namespaces.zope.org/zope"
|
||||
xmlns:i18n="http://namespaces.zope.org/i18n"
|
||||
|
@ -355,6 +353,8 @@
|
|||
name="grid" />
|
||||
<adapter factory="cybertools.composer.schema.grid.field.RecordsFieldInstance"
|
||||
name="records" />
|
||||
<adapter factory="cybertools.composer.schema.grid.field.ContextBasedKeyTableFieldInstance"
|
||||
name="keytable" />
|
||||
<adapter factory="loops.schema.field.RelationSetFieldInstance"
|
||||
name="relationset" />
|
||||
<adapter factory="loops.schema.field.RelationFieldInstance"
|
||||
|
@ -366,14 +366,10 @@
|
|||
for="loops.interfaces.IResource" />
|
||||
<adapter factory="loops.schema.factory.FileSchemaFactory" />
|
||||
<adapter factory="loops.schema.factory.NoteSchemaFactory" />
|
||||
<adapter factory="loops.table.DataTableSchemaFactory" />
|
||||
|
||||
<adapter factory="loops.setup.SetupManager" />
|
||||
|
||||
<!-- obsolete:
|
||||
<adapter factory="loops.external.NodesLoader" />
|
||||
<adapter factory="loops.external.NodesExporter" />
|
||||
<adapter factory="loops.external.NodesImporter" />-->
|
||||
|
||||
<!-- obsolete - remove: -->
|
||||
<adapter factory="loops.target.DocumentProxy"
|
||||
permission="zope.ManageContent" />
|
||||
|
|
30
table.py
30
table.py
|
@ -18,16 +18,16 @@
|
|||
|
||||
"""
|
||||
Data (keyword-based) table definition and implementation.
|
||||
|
||||
$Id$
|
||||
"""
|
||||
|
||||
from BTrees.OOBTree import OOBTree
|
||||
from zope import schema, component
|
||||
from zope.interface import Interface, Attribute, implements
|
||||
from zope import component, schema
|
||||
from zope.component import adapts
|
||||
from zope.interface import implements, Interface, Attribute
|
||||
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.interfaces import IConcept, IConceptSchema, ILoopsAdapter
|
||||
from loops.type import TypeInterfaceSourceList
|
||||
|
@ -47,8 +47,6 @@ class IDataTable(IConceptSchema, ILoopsAdapter):
|
|||
default=u'',
|
||||
required=False)
|
||||
|
||||
# better: specify column names (and possibly labels, types)
|
||||
# in Python code and reference by name here
|
||||
columns = schema.List(
|
||||
title=_(u'Columns'),
|
||||
description=_(u'The names of the columns of the data table. '
|
||||
|
@ -57,10 +55,12 @@ class IDataTable(IConceptSchema, ILoopsAdapter):
|
|||
default=['key', 'value'],
|
||||
required=True)
|
||||
|
||||
data = Records(title=_(u'Table Data'),
|
||||
data = KeyTable(title=_(u'Table Data'),
|
||||
description=_(u'Table Data'),
|
||||
required=False)
|
||||
|
||||
IDataTable['columns'].hidden = True
|
||||
|
||||
|
||||
class DataTable(AdapterBase):
|
||||
|
||||
|
@ -75,6 +75,8 @@ class DataTable(AdapterBase):
|
|||
self.context._columns = value
|
||||
columns = property(getColumns, setColumns)
|
||||
|
||||
columnNames = columns
|
||||
|
||||
def getData(self):
|
||||
data = getattr(self.context, '_data', None)
|
||||
if data is None:
|
||||
|
@ -87,3 +89,15 @@ class DataTable(AdapterBase):
|
|||
|
||||
|
||||
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