make search (i.e. vocabulary) for relation set fields/widgets configurable

git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@3691 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
helmutm 2010-01-20 14:40:32 +00:00
parent 6e5e52a329
commit f049e2fff4
3 changed files with 8 additions and 2 deletions

View file

@ -48,6 +48,8 @@ class IRelationSet(IList):
target_types = Attribute('A list of names that denote types of ' target_types = Attribute('A list of names that denote types of '
'loops objects (typically concept types) that may be used as ' 'loops objects (typically concept types) that may be used as '
'targets for the relations.') 'targets for the relations.')
selection_view = Attribute('The name of a view that provides a collection '
'of candidates to select from, in JSON format.')
class Relation(Field): class Relation(Field):
@ -75,5 +77,6 @@ class RelationSet(List):
def __init__(self, *args, **kw): def __init__(self, *args, **kw):
self.target_types = kw.pop('target_types') self.target_types = kw.pop('target_types')
self.selection_view = kw.pop('selection_view', None)
super(RelationSet, self).__init__(*args, **kw) super(RelationSet, self).__init__(*args, **kw)

View file

@ -47,7 +47,8 @@ class BaseRelationFieldInstance(object):
@Lazy @Lazy
def selection_view(self): def selection_view(self):
return getattr(self.context, 'selection_view', 'listConceptsForComboBox.js') return (getattr(self.context, 'selection_view', None) or
'listConceptsForComboBox.js')
@Lazy @Lazy
def typesParams(self): def typesParams(self):

View file

@ -89,7 +89,7 @@ class Search(BaseView):
'dojo.require("dojox.data.QueryReadStore");') 'dojo.require("dojox.data.QueryReadStore");')
cm.register('js-execute', jsCall, jsCall=jsCall) cm.register('js-execute', jsCall, jsCall=jsCall)
def listConcepts(self): def listConcepts(self, filterMethod=None):
""" Used for dijit.FilteringSelect. """ Used for dijit.FilteringSelect.
""" """
request = self.request request = self.request
@ -113,6 +113,8 @@ class Search(BaseView):
for o in result: for o in result:
if o.getLoopsRoot() == self.loopsRoot: if o.getLoopsRoot() == self.loopsRoot:
adObj = adapted(o, self.languageInfo) adObj = adapted(o, self.languageInfo)
if filterMethod is not None and not filterMethod(adObj):
continue
name = self.getRowName(adObj) name = self.getRowName(adObj)
if title and title.endswith('*'): if title and title.endswith('*'):
title = title[:-1] title = title[:-1]