[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:
parent
5c41f1b3d2
commit
c11002b7d5
8 changed files with 100 additions and 66 deletions
|
@ -380,11 +380,12 @@ class ToolWrapper(AbstractWrapper):
|
|||
</th>
|
||||
<th for="column in columns"
|
||||
var2="field=column.field;
|
||||
sortable=ztool.isSortable(field.name, className, 'search');
|
||||
sortable=field.isSortable(usage='search');
|
||||
filterable=field.filterable"
|
||||
width=":column.width" align=":column.align">
|
||||
<x>::ztool.truncateText(_(field.labelId))</x>
|
||||
<x>:tool.pxSortAndFilter</x><x>:tool.pxShowDetails</x>
|
||||
<x if="totalNumber > 1">:tool.pxSortAndFilter</x>
|
||||
<x>:tool.pxShowDetails</x>
|
||||
</th>
|
||||
</tr>
|
||||
|
||||
|
|
|
@ -694,6 +694,8 @@ class AbstractWrapper(object):
|
|||
n = field.name
|
||||
indexName = 'get%s%s' % (n[0].upper(), n[1:])
|
||||
res[indexName] = field.getIndexType()
|
||||
# Add the secondary index if present
|
||||
if field.hasSortIndex(): res['%s_sort' % indexName] = 'FieldIndex'
|
||||
return res
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
|
@ -1065,8 +1067,16 @@ class AbstractWrapper(object):
|
|||
method in those cases.
|
||||
'''
|
||||
if fields:
|
||||
# Get names of indexes from field names.
|
||||
indexes = [Search.getIndexName(name) for name in fields]
|
||||
# Get names of indexes from field names
|
||||
indexes = []
|
||||
for name in fields:
|
||||
field = self.getField(name)
|
||||
if not field.indexed: continue
|
||||
# A field may have 2 different indexes
|
||||
iName = field.getIndexName(usage='search')
|
||||
indexes.append(iName)
|
||||
sName = field.getIndexName(usage='sort')
|
||||
if sName != iName: indexes.append(sName)
|
||||
else:
|
||||
indexes = None
|
||||
self.o.reindex(indexes=indexes, unindex=unindex)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue