Commit b6ea1339 authored by Nicolas Joyard's avatar Nicolas Joyard
Browse files

Add sorting and CSV download

parent 129ffd04
{% load i18n %}
{% trans "Order by" %}
<div class="btn-group" id="orderby">
<button class="btn btn-default dropdown-toggle" type="button" id="orderby-button" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="true">
{% for field, label in sort.fields.items %}
{% if sort.field == field %}{% trans label %}{% endif %}
{% endfor %}
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="orderby-button">
{% for field, label in sort.fields.items %}
<li {% if sort.field == field %}class="disabled"{% endif %}>
<a href="?{{ sort_querystring.urlencode }}&sort_by={{ field }}">{% trans label %}</a>
</li>
{% endfor %}
</ul>
</div>
<div class="btn-group" id="orderdir">
<button class="btn btn-default dropdown-toggle" type="button" id="orderdir-button" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="true">
{% if sort.dir == 'asc' %}{% trans "ascending" %}{% else %}{% trans "descending" %}{% endif %}
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="orderdir-button">
<li {% if sort.dir == 'asc' %}class="disabled"{% endif %}>
<a href="?{{ sort_querystring.urlencode }}&sort_dir=asc">{% trans "ascending" %}</a>
</li>
<li {% if sort.dir == 'desc' %}class="disabled"{% endif %}>
<a href="?{{ sort_querystring.urlencode }}&sort_dir=asc">{% trans "descending" %}</a>
</li>
</ul>
</div>
\ No newline at end of file
{% if paginator and paginator.num_pages > 1 %}
<div class="container-fluid">
<div class="row">
{% include "blocks/_pagination.html" %}
</div>
</div>
{% endif %}
{% load bootstrap3 %}
{% load i18n %}
<div class="container-fluid" id="listheader">
<div class="row">
<div class="col-sm-8">
{% if sort.fields|length > 0 %}
{% include "blocks/_sorting.html" %}
{% endif %}
</div>
<div class="col-sm-4 text-right">
{% if csv or 1 %}
<a class="btn btn-default" role="button" href="?{{ csv_querystring.urlencode }}&csv">
{% bootstrap_icon "download-alt" %}
{% trans "Download CSV" %}
</a>
{% endif %}
</div>
</div>
</div>
{% if paginator and paginator.num_pages > 1 %}
<div class="container-fluid">
<div class="row">
{% include "blocks/_pagination.html" %}
</div>
</div>
{% endif %}
{% if paginator and paginator.num_pages > 1 %}
<nav class="text-center">
<ul class="pagination">
{% if page_obj.has_previous %}
<li><a href="?{{searchparameters.urlencode}}&page={{ page_obj.previous_page_number }}" aria-label="Previous">
<span aria-hidden="true">&laquo;</span></a>
</li>
{% else %}
<li class="disabled"><span aria-hidden="true">&laquo;</span></li>
{% endif %}
{% for page in paginator.page_range %}
{% if page_obj.number|add:"5" > page and page_obj.number|add:"-5" < page %}
<li {% if page == page_obj.number %}class="active"{% endif %}><a href="?{{searchparameters}}&page={{page}}">{{ page }}</a></li>
{% endif %}
{% endfor %}
{% if page_obj.has_next %}
<li>
<a href="?{{searchparameters}}&page={{ page_obj.next_page_number }}" aria-label="Next"><span aria-hidden="true">&raquo;</span></a>
</li>
{% else %}
<li class="disabled"><span aria-hidden="true">&raquo;</span></li>
{% endif %}
</ul>
</nav>
{% endif %}
......@@ -6,47 +6,13 @@
{% block container-class %}custom-listMEP{% endblock %}
{% block content %}
<h1 class="text-center">{% trans "Representatives" %}</h1>
<p class="lead text-center">
Found {{ paginator.count }} {% trans "representatives" %}.
</p>
<div class="row">
<a href="?{{ searchparameters }}&csv" class="btn btn-default">
<span class="glyphicon glyphicon-file"> {% trans "Download as CSV." %}</span>
</a>
{% comment %}
<!-- TODO: layout & ordering -->
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-default active">
<input type="radio" name="view" id="cards" autocomplete="off" checked>
<span class="glyphicon glyphicon-th"></span>
</label>
<label class="btn btn-default">
<input type="radio" name="view" id="lists" autocomplete="off">
<span class="glyphicon glyphicon-list"></span>
</label>
</div>
<div class="dropdown" style="display:inline-block;">
Order by
<button class="btn btn-default dropdown-toggle" type="button" id="orderby" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
Score
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="orderby">
<li class="disabled"><a href="#">Score</a></li>
<li><a href="#">Country</a></li>
<li><a href="#">Party</a></li>
<li><a href="#">Group</a></li>
</ul>
</div>
{% endcomment %}
</div>
{% include "blocks/listheader.html" %}
<div class="row">
{% for representative in object_list %}
......@@ -94,6 +60,6 @@
{% endfor %}
</div>
{% include "pagination.html" %}
{% include "blocks/listfooter.html" %}
{% endblock %}
......@@ -69,6 +69,6 @@
{% endfor %}
</div>
{% include "pagination.html" %}
{% include "blocks/_pagination.html" %}
{% endblock %}
Supports Markdown
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