Skip to content

Commit fbbc094

Browse files
committed
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
1 parent 8291f16 commit fbbc094

2 files changed

Lines changed: 19 additions & 4 deletions

File tree

ietf/doc/views_search.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,10 +349,19 @@ def sort_key(d):
349349
if hasattr(form.data, "urlencode"): # form was fed a Django QueryDict, not local plain dict
350350
d = form.data.copy()
351351
for h in meta['headers']:
352-
d["sort"] = h["key"]
353-
h["sort_url"] = "?" + d.urlencode()
354-
if h['key'] == query.get('sort'):
352+
sort = query.get('sort')
353+
if sort.endswith(h['key']):
355354
h['sorted'] = True
355+
if sort.startswith('-'):
356+
h['direction'] = 'desc'
357+
d["sort"] = h["key"]
358+
else:
359+
h['direction'] = 'asc'
360+
d["sort"] = "-" + h["key"]
361+
else:
362+
d["sort"] = h["key"]
363+
h["sort_url"] = "?" + d.urlencode()
364+
356365
return (results, meta)
357366

358367

ietf/templates/doc/search/search_results.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,13 @@
2626
<th data-header="{{ h.key }}">
2727
{% if "sort_url" in h %}
2828
<a href="{{ h.sort_url }}">{{ h.title }}
29-
{% if h.sorted %}<span class="fa fa-caret-down"></span>{% endif %}
29+
{% if h.sorted and meta.max %}
30+
{% if h.direction == "asc" %}
31+
<span class="fa fa-caret-up"></span>
32+
{% else %}
33+
<span class="fa fa-caret-down"></span>
34+
{% endif %}
35+
{% endif %}
3036
</a>
3137
{% else %}
3238
{{ h.title }}

0 commit comments

Comments
 (0)