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

Closes #5429: Enable toggling the placement of table paginators

This commit is contained in:
jeremystretch
2022-01-19 09:14:38 -05:00
parent 3fcae36cf1
commit bf6345aa90
5 changed files with 23 additions and 2 deletions

View File

@ -8,6 +8,7 @@ The `users.UserConfig` model holds individual preferences for each user in the f
|--------------------------|---------------------------------------------------------------| |--------------------------|---------------------------------------------------------------|
| data_format | Preferred format when rendering raw data (JSON or YAML) | | data_format | Preferred format when rendering raw data (JSON or YAML) |
| pagination.per_page | The number of items to display per page of a paginated table | | pagination.per_page | The number of items to display per page of a paginated table |
| pagination.placement | Where to display the paginator controls relative to the table |
| tables.${table}.columns | The ordered list of columns to display when viewing the table | | tables.${table}.columns | The ordered list of columns to display when viewing the table |
| tables.${table}.ordering | A list of column names by which the table should be ordered | | tables.${table}.ordering | A list of column names by which the table should be ordered |
| ui.colormode | Light or dark mode in the user interface | | ui.colormode | Light or dark mode in the user interface |

View File

@ -60,6 +60,7 @@ Inventory item templates can be arranged hierarchically within a device type, an
### Enhancements ### Enhancements
* [#5429](https://github.com/netbox-community/netbox/issues/5429) - Enable toggling the placement of table paginators
* [#6954](https://github.com/netbox-community/netbox/issues/6954) - Remember users' table ordering preferences * [#6954](https://github.com/netbox-community/netbox/issues/6954) - Remember users' table ordering preferences
* [#7650](https://github.com/netbox-community/netbox/issues/7650) - Add support for local account password validation * [#7650](https://github.com/netbox-community/netbox/issues/7650) - Add support for local account password validation
* [#7679](https://github.com/netbox-community/netbox/issues/7679) - Add actions menu to all object tables * [#7679](https://github.com/netbox-community/netbox/issues/7679) - Add actions menu to all object tables

View File

@ -26,6 +26,16 @@ PREFERENCES = {
description='The number of objects to display per page', description='The number of objects to display per page',
coerce=lambda x: int(x) coerce=lambda x: int(x)
), ),
'pagination.placement': UserPreference(
label='Paginator placement',
choices=(
('bottom', 'Bottom'),
('top', 'Top'),
('both', 'Both'),
),
description='Where the paginator controls will be displayed relative to a table',
default='bottom'
),
# Miscellaneous # Miscellaneous
'data_format': UserPreference( 'data_format': UserPreference(

View File

@ -1,5 +1,13 @@
{# Render an HTMX-enabled table with paginator #} {# Render an HTMX-enabled table with paginator #}
{% load helpers %}
{% load render_table from django_tables2 %} {% load render_table from django_tables2 %}
{% render_table table 'inc/table_htmx.html' %} {% with preferences|get_key:"pagination.placement" as paginator_placement %}
{% include 'inc/paginator_htmx.html' with paginator=table.paginator page=table.page %} {% if paginator_placement == 'top' or paginator_placement == 'both' %}
{% include 'inc/paginator_htmx.html' with paginator=table.paginator page=table.page %}
{% endif %}
{% render_table table 'inc/table_htmx.html' %}
{% if paginator_placement != 'top' %}
{% include 'inc/paginator_htmx.html' with paginator=table.paginator page=table.page %}
{% endif %}
{% endwith %}

View File

@ -47,6 +47,7 @@ class UserConfigForm(BootstrapMixin, forms.ModelForm, metaclass=UserConfigFormMe
fieldsets = ( fieldsets = (
('User Interface', ( ('User Interface', (
'pagination.per_page', 'pagination.per_page',
'pagination.placement',
'ui.colormode', 'ui.colormode',
)), )),
('Miscellaneous', ( ('Miscellaneous', (