provide display rendering for relation property with link (like for relation set)
This commit is contained in:
parent
153f0ee0e7
commit
907e9c4da8
4 changed files with 16 additions and 6 deletions
|
@ -158,7 +158,7 @@ class Search(BaseView):
|
||||||
adObj = adapted(o, self.languageInfo)
|
adObj = adapted(o, self.languageInfo)
|
||||||
if filterMethod is not None and not filterMethod(adObj):
|
if filterMethod is not None and not filterMethod(adObj):
|
||||||
continue
|
continue
|
||||||
name = self.getRowName(adObj)
|
name = self.getRowName(adObj) or u''
|
||||||
if title and title.endswith('*'):
|
if title and title.endswith('*'):
|
||||||
title = title[:-1]
|
title = title[:-1]
|
||||||
sort = ((title and name.startswith(title) and '0' or '1')
|
sort = ((title and name.startswith(title) and '0' or '1')
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
# Copyright (c) 2009 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
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -18,8 +18,6 @@
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Specialized field definitions.
|
Specialized field definitions.
|
||||||
|
|
||||||
$Id$
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from zope.component import adapts
|
from zope.component import adapts
|
||||||
|
@ -59,7 +57,8 @@ class Relation(Field):
|
||||||
__typeInfo__ = ('relation',
|
__typeInfo__ = ('relation',
|
||||||
FieldType('relation', 'relation',
|
FieldType('relation', 'relation',
|
||||||
u'A field representing a related object.',
|
u'A field representing a related object.',
|
||||||
instanceName='relation'))
|
instanceName='relation',
|
||||||
|
displayRenderer='display_relation'))
|
||||||
|
|
||||||
def __init__(self, *args, **kw):
|
def __init__(self, *args, **kw):
|
||||||
self.target_types = kw.pop('target_types', ())
|
self.target_types = kw.pop('target_types', ())
|
||||||
|
|
|
@ -93,9 +93,14 @@ class RelationFieldInstance(FieldInstance, BaseRelationFieldInstance):
|
||||||
|
|
||||||
def display(self, value):
|
def display(self, value):
|
||||||
if value:
|
if value:
|
||||||
return value.title
|
nodeView = self.clientInstance.view.nodeView
|
||||||
|
return dict(url=nodeView.getUrlForTarget(baseObject(value)),
|
||||||
|
label=value.title)
|
||||||
return u''
|
return u''
|
||||||
|
|
||||||
def unmarshall(self, value):
|
def unmarshall(self, value):
|
||||||
return util.getObjectForUid(value)
|
return util.getObjectForUid(value)
|
||||||
|
|
||||||
|
def getRenderer(self, name):
|
||||||
|
return relation_macros.macros[name]
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,12 @@
|
||||||
</metal:display>
|
</metal:display>
|
||||||
|
|
||||||
|
|
||||||
|
<metal:display define-macro="display_relation">
|
||||||
|
<a tal:attributes="href value/url"
|
||||||
|
tal:content="value/label"></a>
|
||||||
|
</metal:display>
|
||||||
|
|
||||||
|
|
||||||
<metal:input define-macro="input_relationset"
|
<metal:input define-macro="input_relationset"
|
||||||
tal:define="fieldInstance field/getFieldInstance;
|
tal:define="fieldInstance field/getFieldInstance;
|
||||||
types fieldInstance/typesParams">
|
types fieldInstance/typesParams">
|
||||||
|
|
Loading…
Add table
Reference in a new issue