diff --git a/schema/base.py b/schema/base.py index 4de7b6b..adb6079 100644 --- a/schema/base.py +++ b/schema/base.py @@ -48,6 +48,8 @@ class IRelationSet(IList): target_types = Attribute('A list of names that denote types of ' 'loops objects (typically concept types) that may be used as ' '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): @@ -75,5 +77,6 @@ class RelationSet(List): def __init__(self, *args, **kw): self.target_types = kw.pop('target_types') + self.selection_view = kw.pop('selection_view', None) super(RelationSet, self).__init__(*args, **kw) diff --git a/schema/field.py b/schema/field.py index c9e2fa1..76ff78f 100644 --- a/schema/field.py +++ b/schema/field.py @@ -47,7 +47,8 @@ class BaseRelationFieldInstance(object): @Lazy def selection_view(self): - return getattr(self.context, 'selection_view', 'listConceptsForComboBox.js') + return (getattr(self.context, 'selection_view', None) or + 'listConceptsForComboBox.js') @Lazy def typesParams(self): diff --git a/search/browser.py b/search/browser.py index 06867fd..df25d54 100644 --- a/search/browser.py +++ b/search/browser.py @@ -89,7 +89,7 @@ class Search(BaseView): 'dojo.require("dojox.data.QueryReadStore");') cm.register('js-execute', jsCall, jsCall=jsCall) - def listConcepts(self): + def listConcepts(self, filterMethod=None): """ Used for dijit.FilteringSelect. """ request = self.request @@ -113,6 +113,8 @@ class Search(BaseView): for o in result: if o.getLoopsRoot() == self.loopsRoot: adObj = adapted(o, self.languageInfo) + if filterMethod is not None and not filterMethod(adObj): + continue name = self.getRowName(adObj) if title and title.endswith('*'): title = title[:-1]