1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Closes #1870: Add per-page toggle to object lists

This commit is contained in:
Jeremy Stretch
2019-01-04 11:07:55 -05:00
parent 0a820d9c98
commit 848aa0b098
7 changed files with 39 additions and 15 deletions

View File

@ -3,6 +3,7 @@ v2.5.3 (FUTURE)
## Enhancements ## Enhancements
* [#1630](https://github.com/digitalocean/netbox/issues/1630) - Enable bulk editing of prefix/IP mask length * [#1630](https://github.com/digitalocean/netbox/issues/1630) - Enable bulk editing of prefix/IP mask length
* [#1870](https://github.com/digitalocean/netbox/issues/1870) - Add per-page toggle to object lists
* [#1871](https://github.com/digitalocean/netbox/issues/1871) - Enable filtering sites by parent region * [#1871](https://github.com/digitalocean/netbox/issues/1871) - Enable filtering sites by parent region
* [#2693](https://github.com/digitalocean/netbox/issues/2693) - Additional cable colors * [#2693](https://github.com/digitalocean/netbox/issues/2693) - Additional cable colors
* [#2726](https://github.com/digitalocean/netbox/issues/2726) - Include cables in global search * [#2726](https://github.com/digitalocean/netbox/issues/2726) - Include cables in global search

View File

@ -246,6 +246,14 @@ LOGIN_URL = '/{}login/'.format(BASE_PATH)
# Secrets # Secrets
SECRETS_MIN_PUBKEY_SIZE = 2048 SECRETS_MIN_PUBKEY_SIZE = 2048
# Pagination
PER_PAGE_DEFAULTS = [
25, 50, 100, 250, 500, 1000
]
if PAGINATE_COUNT not in PER_PAGE_DEFAULTS:
PER_PAGE_DEFAULTS.append(PAGINATE_COUNT)
PER_PAGE_DEFAULTS = sorted(PER_PAGE_DEFAULTS)
# Django filters # Django filters
FILTERS_NULL_CHOICE_LABEL = 'None' FILTERS_NULL_CHOICE_LABEL = 'None'
FILTERS_NULL_CHOICE_VALUE = 'null' FILTERS_NULL_CHOICE_VALUE = 'null'

View File

@ -140,6 +140,9 @@ table.attr-table td:nth-child(1) {
div.paginator { div.paginator {
margin-bottom: 20px; margin-bottom: 20px;
} }
div.paginator form {
margin-bottom: 6px;
}
nav ul.pagination { nav ul.pagination {
margin-top: 0; margin-top: 0;
margin-bottom: 8px !important; margin-bottom: 8px !important;

View File

@ -1,5 +1,10 @@
$(document).ready(function() { $(document).ready(function() {
// Pagination
$('select#per_page').change(function() {
this.form.submit();
});
// "Toggle" checkbox for object lists (PK column) // "Toggle" checkbox for object lists (PK column)
$('input:checkbox.toggle').click(function() { $('input:checkbox.toggle').click(function() {
$(this).closest('table').find('input:checkbox[name=pk]').prop('checked', $(this).prop('checked')); $(this).closest('table').find('input:checkbox[name=pk]').prop('checked', $(this).prop('checked'));

View File

@ -1,6 +1,6 @@
{% load helpers %} {% load helpers %}
<div class="paginator pull-right"> <div class="paginator pull-right text-right">
{% if paginator.num_pages > 1 %} {% if paginator.num_pages > 1 %}
<nav> <nav>
<ul class="pagination pull-right"> <ul class="pagination pull-right">
@ -19,6 +19,13 @@
{% endif %} {% endif %}
</ul> </ul>
</nav> </nav>
<form method="get">
<select name="per_page" id="per_page">
{% for n in settings.PER_PAGE_DEFAULTS %}
<option value="{{ n }}"{% if page.paginator.per_page == n %} selected="selected"{% endif %}>{{ n }}</option>
{% endfor %}
</select> per page
</form>
{% endif %} {% endif %}
{% if page %} {% if page %}
<div class="text-right text-muted"> <div class="text-right text-muted">

View File

@ -3,6 +3,3 @@
<div class="table-responsive"> <div class="table-responsive">
{% render_table table 'inc/table.html' %} {% render_table table 'inc/table.html' %}
</div> </div>
{% with paginator=table.paginator page=table.page %}
{% include 'inc/paginator.html' %}
{% endwith %}

View File

@ -28,19 +28,22 @@
</div> </div>
{% endif %} {% endif %}
{% include table_template|default:'responsive_table.html' %} {% include table_template|default:'responsive_table.html' %}
{% block extra_actions %}{% endblock %} <div class="pull-left">
{% if bulk_edit_url and permissions.change %} {% block extra_actions %}{% endblock %}
<button type="submit" name="_edit" formaction="{% url bulk_edit_url %}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}" class="btn btn-warning btn-sm"> {% if bulk_edit_url and permissions.change %}
<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Edit Selected <button type="submit" name="_edit" formaction="{% url bulk_edit_url %}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}" class="btn btn-warning btn-sm">
</button> <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Edit Selected
{% endif %} </button>
{% if bulk_delete_url and permissions.delete %} {% endif %}
<button type="submit" name="_delete" formaction="{% url bulk_delete_url %}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}" class="btn btn-danger btn-sm"> {% if bulk_delete_url and permissions.delete %}
<span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Delete Selected <button type="submit" name="_delete" formaction="{% url bulk_delete_url %}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}" class="btn btn-danger btn-sm">
</button> <span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Delete Selected
{% endif %} </button>
{% endif %}
</div>
</form> </form>
{% else %} {% else %}
{% include table_template|default:'responsive_table.html' %} {% include table_template|default:'responsive_table.html' %}
{% endif %} {% endif %}
{% include 'inc/paginator.html' with paginator=table.paginator page=table.page %}
<div class="clearfix"></div> <div class="clearfix"></div>