Ability to sort using form fields (for mobile portrait mode)

We now display sort options as a select box plus a descending checkbox, which
means you can apply sort orders even in portrait mode on a mobile phone where
the column headers are hidden.

Closes #199
This commit is contained in:
Simon Willison 2018-04-09 17:30:44 -07:00
commit 57b19f09d1
No known key found for this signature in database
GPG key ID: 17E2DEA2588B7F52
4 changed files with 46 additions and 5 deletions

View file

@ -66,7 +66,22 @@
{% endfor %}
</select>
</div><input type="text" name="_filter_value" class="filter-value">
<input type="submit" value="{% if filters.has_selections() %}Apply filters{% else %}Add filter{% endif %}">
</div>
<div class="filter-row">
{% if is_sortable %}
<div class="select-wrapper">
<select name="_sort" id="sort_by">
<option value="">Sort...</option>
{% for column in display_columns %}
{% if column.sortable %}
<option value="{{ column.name }}"{% if column.name == sort or column.name == sort_desc %} selected{% endif %}>Sort by {{ column.name }}</option>
{% endif %}
{% endfor %}
</select>
</div>
<label class="sort_by_desc"><input type="checkbox" name="_sort_by_desc"{% if sort_desc %} checked{% endif %}> descending</label>
{% endif %}
<input type="submit" value="Apply">
</div>
</form>