[gen] Bugfix while displaying possible values for a Ref field in edit mode.

This commit is contained in:
Gaetan Delannay 2014-03-06 23:08:14 +01:00
parent 2b33c420a4
commit 059828b319

View file

@ -289,10 +289,12 @@ class Ref(Field):
onchange=":field.getOnChange(zobj, layoutType)" onchange=":field.getOnChange(zobj, layoutType)"
multiple=":isMultiple"> multiple=":isMultiple">
<option value="" if="not isMultiple">:_('choose_a_value')</option> <option value="" if="not isMultiple">:_('choose_a_value')</option>
<option for="tied in objects" var2="uid=tied.uid" <option for="tied in objects"
var2="uid=tied.uid;
title=field.getReferenceLabel(tied, unlimited=True)"
selected=":inRequest and (uid in requestValue) or \ selected=":inRequest and (uid in requestValue) or \
(uid in uids)" (uid in uids)" value=":uid"
value=":uid">:field.getReferenceLabel(tied)</option> title=":title">:ztool.truncateValue(title, field.swidth)</option>
</select>''') </select>''')
pxSearch = Px(''' pxSearch = Px('''
@ -798,14 +800,12 @@ class Ref(Field):
value = self.xhtmlToText.sub(' ', value) value = self.xhtmlToText.sub(' ', value)
elif type(value) in sutils.sequenceTypes: elif type(value) in sutils.sequenceTypes:
value = ', '.join(value) value = ', '.join(value)
prefix = '' prefix = res and ' | ' or ''
if res:
prefix = ' | '
res += prefix + value res += prefix + value
if unlimited: return res if unlimited: return res
maxWidth = self.width or 30 maxWidth = self.width or 30
if len(res) > maxWidth: if len(res) > maxWidth:
res = res[:maxWidth-2] + '...' res = refObject.tool.o.truncateValue(res, maxWidth)
return res return res
def getIndexOf(self, obj, refObj): def getIndexOf(self, obj, refObj):