Commit 25bb3b15 by Tom Christie

Use chevron control for row linking, rather than hyperlinking first item

parent 90f2e266
......@@ -730,12 +730,10 @@ class AdminRenderer(BrowsableAPIRenderer):
columns = [key for key in header.keys() if key != 'url']
details = [key for key in header.keys() if key != 'url']
linked = [columns[0]] if columns else []
context['style'] = style
context['columns'] = columns
context['details'] = details
context['linked'] = linked
context['results'] = results
return context
......
{% load rest_framework %}
<table class="table table-striped">
<thead>
<tr>{% for column in columns%}<th>{{ column|capfirst }}</th>{% endfor %}</tr>
<tr>{% for column in columns%}<th>{{ column|capfirst }}</th>{% endfor %}<th></th></tr>
</thead>
<tbody>
{% for row in results %}
......@@ -9,12 +9,12 @@
{% for key, value in row.items %}
{% if key in columns %}
<td {{ value|add_nested_class }} >
{% if key in linked %}<a href="{{ row.url }}">{% endif %}
{{ value|format_value }}
{% if key in linked %}</a>{% endif %}
</td>
{% endif %}
{% endfor %}
<td><a href="{{ row.url }}"><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
</a></td>
</tr>
{% endfor %}
</tbody>
......
......@@ -134,7 +134,9 @@ def format_value(value):
@register.filter
def add_nested_class(value):
if isinstance(value, (list, dict)):
if isinstance(value, dict):
return 'class=nested'
if isinstance(value, list) and any([isinstance(item, (list, dict)) for item in value]):
return 'class=nested'
return ''
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment