[gen] More work on Refs with popup='true'.
This commit is contained in:
parent
a14bff45a7
commit
0bcd0055a3
7 changed files with 80 additions and 37 deletions
|
@ -286,11 +286,8 @@ class Field:
|
|||
|
||||
def isMultiValued(self):
|
||||
'''Does this type definition allow to define multiple values?'''
|
||||
res = False
|
||||
maxOccurs = self.multiplicity[1]
|
||||
if (maxOccurs == None) or (maxOccurs > 1):
|
||||
res = True
|
||||
return res
|
||||
return (maxOccurs == None) or (maxOccurs > 1)
|
||||
|
||||
def isSortable(self, usage):
|
||||
'''Can fields of this type be used for sorting purposes (when sorting
|
||||
|
|
|
@ -1273,7 +1273,7 @@ class Ref(Field):
|
|||
# No object can be selected if the popup has not been opened yet.
|
||||
if 'semantics' not in rq:
|
||||
# In this case, display already linked objects if any.
|
||||
if not obj.isEmpty(self.name): return getattr(obj, self.name)
|
||||
if not obj.isEmpty(self.name): return self.getValue(obj.o)
|
||||
return res
|
||||
uids = rq['selected'].split(',')
|
||||
tool = obj.tool
|
||||
|
|
|
@ -24,16 +24,16 @@ from group import Group
|
|||
# ------------------------------------------------------------------------------
|
||||
class Search:
|
||||
'''Used for specifying a search for a given class.'''
|
||||
def __init__(self, name, group=None, sortBy='', sortOrder='asc', limit=None,
|
||||
default=False, colspan=1, translated=None, show=True,
|
||||
translatedDescr=None, checkboxes=False, checkboxesDefault=True,
|
||||
**fields):
|
||||
def __init__(self, name, group=None, sortBy='', sortOrder='asc',
|
||||
maxPerPage=30, default=False, colspan=1, translated=None,
|
||||
show=True, translatedDescr=None, checkboxes=False,
|
||||
checkboxesDefault=True, **fields):
|
||||
self.name = name
|
||||
# Searches may be visually grouped in the portlet.
|
||||
self.group = Group.get(group)
|
||||
self.sortBy = sortBy
|
||||
self.sortOrder = sortOrder
|
||||
self.limit = limit
|
||||
self.maxPerPage = maxPerPage
|
||||
# If this search is the default one, it will be triggered by clicking
|
||||
# on main link.
|
||||
self.default = default
|
||||
|
@ -188,4 +188,19 @@ class UiSearch:
|
|||
_ = tool.translate
|
||||
self.translated = label and _(label) or ''
|
||||
self.translatedDescr = labelDescr and _(labelDescr) or ''
|
||||
|
||||
def setInitiator(self, initiator, field):
|
||||
'''If the search is defined in an attribute Ref.select, we receive here
|
||||
the p_initiator object and its Ref p_field.'''
|
||||
self.initiator = initiator
|
||||
self.initiatorField = field
|
||||
|
||||
def showCheckboxes(self):
|
||||
'''If checkboxes are enabled for this search (and if an initiator field
|
||||
is there), they must be visible only if the initiator field is
|
||||
multivalued. Indeed, if it is not the case, it has no sense to select
|
||||
multiple objects. But in this case, we still want checkboxes to be in
|
||||
the DOM because they store object UIDs.'''
|
||||
if not self.search.checkboxes: return
|
||||
return not self.initiator or self.initiatorField.isMultiValued()
|
||||
# ------------------------------------------------------------------------------
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue