improve records field; allow explicit inclusion of fields in schema factory
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@3647 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
c88082e338
commit
07ef19a946
2 changed files with 43 additions and 14 deletions
|
@ -77,9 +77,12 @@ class SchemaFactory(object):
|
||||||
fieldMapping = self.fieldMapping
|
fieldMapping = self.fieldMapping
|
||||||
fields = []
|
fields = []
|
||||||
omit = kw.pop('omit', [])
|
omit = kw.pop('omit', [])
|
||||||
|
include = kw.pop('include', [])
|
||||||
for fname in schema.getFieldNamesInOrder(interface):
|
for fname in schema.getFieldNamesInOrder(interface):
|
||||||
if fname in omit:
|
if fname in omit:
|
||||||
continue
|
continue
|
||||||
|
if include and fname not in include:
|
||||||
|
continue
|
||||||
field = interface[fname]
|
field = interface[fname]
|
||||||
info = fieldMapping.get(field.__class__)
|
info = fieldMapping.get(field.__class__)
|
||||||
f = createField(field, info)
|
f = createField(field, info)
|
||||||
|
|
|
@ -39,30 +39,56 @@
|
||||||
|
|
||||||
|
|
||||||
<metal:input define-macro="input_records"
|
<metal:input define-macro="input_records"
|
||||||
tal:define="fieldInstance python: field.getFieldInstance(view.instance);
|
tal:define="fieldInstance python: field.getFieldInstance(item.instance);
|
||||||
columns fieldInstance/columnTypes">
|
columns fieldInstance/columnTypes;
|
||||||
<table>
|
rows data/?name">
|
||||||
|
<table class="records">
|
||||||
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<tal:header repeat="column columns">
|
<tal:header repeat="column columns">
|
||||||
<th width="auto" editable="true"
|
<th width="auto" editable="true"
|
||||||
tal:attributes="field column/name"
|
tal:attributes="field column/name;
|
||||||
|
style string:width: ${column/baseField/width|string:auto};"
|
||||||
tal:content="column/title">Column Title</th>
|
tal:content="column/title">Column Title</th>
|
||||||
</tal:header>
|
</tal:header>
|
||||||
</tr>
|
</tr>
|
||||||
<tr tal:repeat="row data/?name">
|
</thead>
|
||||||
|
<tbody tal:attributes="id string:tbody.$name">
|
||||||
|
<tr tal:repeat="row rows">
|
||||||
<td tal:repeat="column columns">
|
<td tal:repeat="column columns">
|
||||||
<input type="text" size="14"
|
<input type="text"
|
||||||
tal:define="cname column/name"
|
tal:define="cname column/name"
|
||||||
tal:attributes="value row/?cname;
|
tal:attributes="value row/?cname;
|
||||||
name string:$name.$cname:records" /></td>
|
name string:$name.$cname:records;" /></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr tal:attributes="id string:$name.empty">
|
<tal:empty condition="python: not field.cardinality
|
||||||
<td tal:repeat="column columns">
|
or field.cardinality > len(rows)">
|
||||||
<input type="text" size="14"
|
<tr>
|
||||||
tal:define="cname column/name"
|
<td tal:repeat="column columns">
|
||||||
tal:attributes="name string:$name.$cname:records" /></td>
|
<input type="text"
|
||||||
</tr>
|
tal:define="cname column/name"
|
||||||
</table><br />
|
tal:attributes="name string:$name.$cname:records" /></td>
|
||||||
|
</tr>
|
||||||
|
<tr style="display: none"
|
||||||
|
tal:attributes="id string:$name.empty">
|
||||||
|
<td tal:repeat="column columns">
|
||||||
|
<input type="text"
|
||||||
|
tal:define="cname column/name"
|
||||||
|
tal:attributes="name string:$name.$cname:records" /></td>
|
||||||
|
</tr>
|
||||||
|
</tal:empty>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<div>
|
||||||
|
<input type="button" value="+"
|
||||||
|
tal:condition="python: not field.cardinality
|
||||||
|
or field.cardinality > len(rows) + 1"
|
||||||
|
tal:attributes="onclick string:
|
||||||
|
n = dojo.byId('$name.empty').cloneNode(true);;
|
||||||
|
n.id = null;;
|
||||||
|
n.style.display = '';;
|
||||||
|
dojo.byId('tbody.$name').appendChild(n);;" />
|
||||||
|
</div><br />
|
||||||
</metal:input>
|
</metal:input>
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue