provide basic functionality for rendering of complex relations.
- provide controlling of rendering macro via field instance method getRenderer() - add getRelations() method to child relation set
This commit is contained in:
parent
268a1e47ed
commit
78abe5f55d
4 changed files with 34 additions and 21 deletions
|
@ -50,10 +50,13 @@
|
|||
<tal:row repeat="field fields">
|
||||
<tr tal:define="fieldName field/name;
|
||||
value nocall:data/?fieldName;
|
||||
renderer field/displayRenderer"
|
||||
fieldInstance field/getFieldInstance;
|
||||
rendererName field/displayRenderer;
|
||||
renderer python:fieldInstance.getRenderer(rendererName) or
|
||||
view.concept_macros[rendererName]"
|
||||
tal:condition="nocall:value">
|
||||
<td><b tal:content="field/title" i18n:translate="" />:</td>
|
||||
<td><span metal:use-macro="view/concept_macros/?renderer" /></td>
|
||||
<td><span metal:use-macro="renderer" /></td>
|
||||
</tr>
|
||||
</tal:row>
|
||||
</table>
|
||||
|
@ -77,15 +80,6 @@
|
|||
</metal:email>
|
||||
|
||||
|
||||
<metal:email define-macro="display_relationset">
|
||||
<span tal:repeat="elem value">
|
||||
<a tal:attributes="href elem/url"
|
||||
tal:content="elem/label"></a>
|
||||
<tal:separator condition="not:repeat/elem/end"> | </tal:separator>
|
||||
</span>
|
||||
</metal:email>
|
||||
|
||||
|
||||
<metal:parents define-macro="conceptparents">
|
||||
<div tal:attributes="class string:content-$level;
|
||||
ondblclick python: item.openEditWindow('configure.html')">
|
||||
|
|
10
common.py
10
common.py
|
@ -412,6 +412,16 @@ class ChildRelationSet(RelationSet):
|
|||
for c in self.context.getChildren([self.predicate]):
|
||||
yield adapted(c, langInfo=self.langInfo)
|
||||
|
||||
def getRelations(self, check=None, noSecurityCheck=None):
|
||||
if self.adapted.__is_dummy__:
|
||||
return
|
||||
if noSecurityCheck is None:
|
||||
noSecurityCheck = self.noSecurityCheck
|
||||
for r in self.context.getChildRelations([self.predicate],
|
||||
noSecurityCheck=noSecurityCheck):
|
||||
if check is None or check(r):
|
||||
yield r
|
||||
|
||||
|
||||
# property descriptors
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (c) 2008 Helmut Merz helmutm@cy55.de
|
||||
# Copyright (c) 2011 Helmut Merz helmutm@cy55.de
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
@ -18,8 +18,6 @@
|
|||
|
||||
"""
|
||||
Field and field instance classes for grids.
|
||||
|
||||
$Id$
|
||||
"""
|
||||
|
||||
from zope import component
|
||||
|
@ -79,11 +77,13 @@ class RelationSetFieldInstance(ListFieldInstance, BaseRelationFieldInstance):
|
|||
nodeView = self.clientInstance.view.nodeView
|
||||
return [dict(url=nodeView.getUrlForTarget(baseObject(v)),
|
||||
label=v.title) for v in value]
|
||||
#return ' | '.join([v.title for v in value])
|
||||
|
||||
def unmarshall(self, value):
|
||||
return [util.getObjectForUid(v) for v in value]
|
||||
|
||||
def getRenderer(self, name):
|
||||
return relation_macros.macros[name]
|
||||
|
||||
|
||||
class RelationFieldInstance(FieldInstance, BaseRelationFieldInstance):
|
||||
|
||||
|
|
|
@ -3,7 +3,16 @@
|
|||
<body>
|
||||
|
||||
|
||||
<metal:textline define-macro="input_relationset"
|
||||
<metal:display define-macro="display_relationset">
|
||||
<span tal:repeat="elem value">
|
||||
<a tal:attributes="href elem/url"
|
||||
tal:content="elem/label"></a>
|
||||
<tal:separator condition="not:repeat/elem/end"> · </tal:separator>
|
||||
</span>
|
||||
</metal:display>
|
||||
|
||||
|
||||
<metal:input define-macro="input_relationset"
|
||||
tal:define="fieldInstance field/getFieldInstance;
|
||||
types fieldInstance/typesParams">
|
||||
<div dojoType="dojox.data.QueryReadStore" jsId="conceptSearch"
|
||||
|
@ -31,10 +40,10 @@
|
|||
name string:${name}_search;
|
||||
id string:${name}_search;
|
||||
onChange string:addRelation('$name')" />
|
||||
</metal:textline>
|
||||
</metal:input>
|
||||
|
||||
|
||||
<metal:textline define-macro="input_relation"
|
||||
<metal:input define-macro="input_relation"
|
||||
tal:define="fieldInstance field/getFieldInstance;
|
||||
types fieldInstance/typesParams">
|
||||
<div dojoType="dojox.data.QueryReadStore" jsId="conceptSearch"
|
||||
|
@ -57,7 +66,7 @@
|
|||
name string:${name}_search;
|
||||
id string:${name}_search;
|
||||
onChange string:setRelation('$name')" />
|
||||
</metal:textline>
|
||||
</metal:input>
|
||||
|
||||
|
||||
</body>
|
||||
|
|
Loading…
Add table
Reference in a new issue