Added sort direction to truncated search result views, and aligned the sort direction arrow with that used for the client-side tablesorter for untruncated results.
- Legacy-Id: 10910
This commit is contained in:
parent
8291f169ae
commit
fbbc094086
|
@ -349,10 +349,19 @@ def retrieve_search_results(form, all_types=False):
|
|||
if hasattr(form.data, "urlencode"): # form was fed a Django QueryDict, not local plain dict
|
||||
d = form.data.copy()
|
||||
for h in meta['headers']:
|
||||
d["sort"] = h["key"]
|
||||
h["sort_url"] = "?" + d.urlencode()
|
||||
if h['key'] == query.get('sort'):
|
||||
sort = query.get('sort')
|
||||
if sort.endswith(h['key']):
|
||||
h['sorted'] = True
|
||||
if sort.startswith('-'):
|
||||
h['direction'] = 'desc'
|
||||
d["sort"] = h["key"]
|
||||
else:
|
||||
h['direction'] = 'asc'
|
||||
d["sort"] = "-" + h["key"]
|
||||
else:
|
||||
d["sort"] = h["key"]
|
||||
h["sort_url"] = "?" + d.urlencode()
|
||||
|
||||
return (results, meta)
|
||||
|
||||
|
||||
|
|
|
@ -26,7 +26,13 @@
|
|||
<th data-header="{{ h.key }}">
|
||||
{% if "sort_url" in h %}
|
||||
<a href="{{ h.sort_url }}">{{ h.title }}
|
||||
{% if h.sorted %}<span class="fa fa-caret-down"></span>{% endif %}
|
||||
{% if h.sorted and meta.max %}
|
||||
{% if h.direction == "asc" %}
|
||||
<span class="fa fa-caret-up"></span>
|
||||
{% else %}
|
||||
<span class="fa fa-caret-down"></span>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</a>
|
||||
{% else %}
|
||||
{{ h.title }}
|
||||
|
|
Loading…
Reference in a new issue