[gen] Class.listColumns can now be a static method (accepting the tool as single arg). [gen] Indexed Ref fields are now sortable. For every such field, 2 indexes are created: a list index for searching, and a standard index for sorting (by their title).

This commit is contained in:
Gaetan Delannay 2014-11-28 14:42:32 +01:00
parent 5c41f1b3d2
commit c11002b7d5
8 changed files with 100 additions and 66 deletions

View file

@ -182,7 +182,7 @@ class Ref(Field):
# ref field according to the field that corresponds to this column.
pxSortIcons = Px('''
<x if="changeOrder and (len(objects) &gt; 1) and \
ztool.isSortable(refField.name, tiedClassName, 'ref')"
refField.isSortable(usage='ref')"
var2="ajaxBaseCall=navBaseCall.replace('**v**', '%s,%s,{%s:%s,%s:%s}'% \
(q(startNumber), q('sort'), q('sortKey'), q(refField.name), \
q('reverse'), q('**v**')))">
@ -963,10 +963,14 @@ class Ref(Field):
res = ['']
return res
else:
# For the global search: return linked objects' titles.
res = [o.title for o in self.getValue()]
if not res: res.append('')
return res
# For the global search: return linked objects' titles
return ' '.join([o.getShownValue('title') \
for o in self.getValue(obj, appy=False)])
def hasSortIndex(self):
'''An indexed Ref field is of type "ListIndex", which is not sortable.
So an additional FieldIndex is required.'''
return True
def validateValue(self, obj, value):
if not self.link: return