Bugfixes in new sorting/filtering features.
This commit is contained in:
parent
f5a92b7cb0
commit
cb216a9e9c
|
@ -189,6 +189,15 @@ class Type:
|
||||||
res = True
|
res = True
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
def isSortable(self, usage='search'):
|
||||||
|
'''Can fields of this type be used for sorting purposes (when sorting
|
||||||
|
search results (p_usage="search") or when sorting reference fields
|
||||||
|
(p_usage="ref")?'''
|
||||||
|
if usage == 'search': return self.indexed
|
||||||
|
elif usage == 'ref':
|
||||||
|
return self.type in ('Integer', 'Float', 'Boolean', 'Date') or \
|
||||||
|
((self.type == 'String') and (self.format == 0))
|
||||||
|
|
||||||
class Integer(Type):
|
class Integer(Type):
|
||||||
def __init__(self, validator=None, multiplicity=(0,1), index=None,
|
def __init__(self, validator=None, multiplicity=(0,1), index=None,
|
||||||
default=None, optional=False, editDefault=False, show=True,
|
default=None, optional=False, editDefault=False, show=True,
|
||||||
|
|
|
@ -668,6 +668,13 @@ class AbstractMixin:
|
||||||
reverse = rq.get('reverse') == 'True'
|
reverse = rq.get('reverse') == 'True'
|
||||||
self.appy().sort(fieldName, sortKey=sortKey, reverse=reverse)
|
self.appy().sort(fieldName, sortKey=sortKey, reverse=reverse)
|
||||||
|
|
||||||
|
def isRefSortable(self, fieldName):
|
||||||
|
'''Can p_fieldName, which is a field defined on self, be used as a sort
|
||||||
|
key in a reference field?'''
|
||||||
|
appyType = self.getAppyType(fieldName, asDict=False)
|
||||||
|
if not appyType: return True # Probably implicit field 'title'.
|
||||||
|
return appyType.isSortable(usage='ref')
|
||||||
|
|
||||||
def getWorkflow(self, appy=True):
|
def getWorkflow(self, appy=True):
|
||||||
'''Returns the Appy workflow instance that is relevant for this
|
'''Returns the Appy workflow instance that is relevant for this
|
||||||
object. If p_appy is False, it returns the DC workflow.'''
|
object. If p_appy is False, it returns the DC workflow.'''
|
||||||
|
|
|
@ -857,7 +857,7 @@
|
||||||
class="listing nosort" width="100%" cellpadding="0" cellspacing="0">
|
class="listing nosort" width="100%" cellpadding="0" cellspacing="0">
|
||||||
<tal:comment replace="nothing">Every item in fieldDescr is a FieldDescr instance,
|
<tal:comment replace="nothing">Every item in fieldDescr is a FieldDescr instance,
|
||||||
excepted for workflow state (which is not a field): in this case it is simply the
|
excepted for workflow state (which is not a field): in this case it is simply the
|
||||||
string "workflowState".</tal:comment>
|
string "workflow_state".</tal:comment>
|
||||||
|
|
||||||
<tal:comment replace="nothing">Headers, with filters and sort arrows</tal:comment>
|
<tal:comment replace="nothing">Headers, with filters and sort arrows</tal:comment>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
|
@ -68,14 +68,12 @@
|
||||||
ref field according to the field that corresponds to this column.
|
ref field according to the field that corresponds to this column.
|
||||||
</tal:comment>
|
</tal:comment>
|
||||||
<metal:sortIcons define-macro="sortIcons"
|
<metal:sortIcons define-macro="sortIcons"
|
||||||
tal:define="ajaxBaseCall python: navBaseCall.replace('**v**', '\'%s\',\'SortReference\', {\'sortKey\':\'%s\', \'reverse\':\'**v**\'}' % (startNumber, shownField))">
|
tal:define="ajaxBaseCall python: navBaseCall.replace('**v**', '\'%s\',\'SortReference\', {\'sortKey\':\'%s\', \'reverse\':\'**v**\'}' % (startNumber, shownField))" tal:condition="python: canWrite and objs[0].isRefSortable(shownField)">
|
||||||
<img style="cursor:pointer"
|
<img style="cursor:pointer"
|
||||||
tal:attributes="src string:$portal_url/skyn/sortAsc.png;
|
tal:attributes="src string:$portal_url/skyn/sortAsc.png;
|
||||||
title python: tool.translate('sort_asc');
|
|
||||||
onClick python: ajaxBaseCall.replace('**v**', 'False')"/>
|
onClick python: ajaxBaseCall.replace('**v**', 'False')"/>
|
||||||
<img style="cursor:pointer"
|
<img style="cursor:pointer"
|
||||||
tal:attributes="src string:$portal_url/skyn/sortDesc.png;
|
tal:attributes="src string:$portal_url/skyn/sortDesc.png;
|
||||||
title python: tool.translate('sort_desc');
|
|
||||||
onClick python: ajaxBaseCall.replace('**v**', 'True')"/>
|
onClick python: ajaxBaseCall.replace('**v**', 'True')"/>
|
||||||
</metal:sortIcons>
|
</metal:sortIcons>
|
||||||
|
|
||||||
|
@ -122,9 +120,10 @@
|
||||||
flavour python:tool.getFlavour(contextObj);
|
flavour python:tool.getFlavour(contextObj);
|
||||||
linkedPortalType python:flavour.getPortalType(appyType['klass']);
|
linkedPortalType python:flavour.getPortalType(appyType['klass']);
|
||||||
addPermission python: '%s: Add %s' % (tool.getAppName(), linkedPortalType);
|
addPermission python: '%s: Add %s' % (tool.getAppName(), linkedPortalType);
|
||||||
|
canWrite python: not isBack and member.has_permission(contextObj.getField(fieldName).write_permission, contextObj);
|
||||||
multiplicity python:test(isBack, appyType['backd']['multiplicity'], appyType['multiplicity']);
|
multiplicity python:test(isBack, appyType['backd']['multiplicity'], appyType['multiplicity']);
|
||||||
maxReached python:(multiplicity[1] != None) and (len(objs) >= multiplicity[1]);
|
maxReached python:(multiplicity[1] != None) and (len(objs) >= multiplicity[1]);
|
||||||
showPlusIcon python:not isBack and appyType['add'] and not maxReached and member.has_permission(addPermission, folder);
|
showPlusIcon python:not isBack and appyType['add'] and not maxReached and member.has_permission(addPermission, folder) and canWrite;
|
||||||
atMostOneRef python: (multiplicity[1] == 1) and (len(objs)<=1);
|
atMostOneRef python: (multiplicity[1] == 1) and (len(objs)<=1);
|
||||||
label python: tool.translate(labelId);
|
label python: tool.translate(labelId);
|
||||||
description python: tool.translate(descrId);
|
description python: tool.translate(descrId);
|
||||||
|
|
Loading…
Reference in a new issue