Skip to content

Commit a8dc60a

Browse files
committed
Fixes #17719: User settings for hover and stripe
1 parent b6c8502 commit a8dc60a

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

netbox/netbox/preferences.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,24 @@ def get_page_lengths():
5454
default='bottom',
5555
description=_('Where the paginator controls will be displayed relative to a table')
5656
),
57+
'ui.table.rows.hover': UserPreference(
58+
label=_('Hover table rows'),
59+
choices=(
60+
('', _('Disabled')),
61+
('true', _('Enabled')),
62+
),
63+
description=_('Show hover effect on table rows'),
64+
default=False,
65+
),
66+
'ui.table.rows.striped': UserPreference(
67+
label=_('Striped table rows'),
68+
choices=(
69+
('', _('Disabled')),
70+
('true', _('Enabled')),
71+
),
72+
description=_('Show striped effect on table rows'),
73+
default=False,
74+
),
5775

5876
# Miscellaneous
5977
'data_format': UserPreference(

netbox/netbox/tables/tables.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class BaseTable(tables.Table):
4747

4848
class Meta:
4949
attrs = {
50-
'class': 'table table-hover object-list',
50+
'class': 'table object-list',
5151
}
5252

5353
def __init__(self, *args, user=None, **kwargs):
@@ -163,6 +163,10 @@ def configure(self, request):
163163
columns = userconfig.get(f"tables.{self.name}.columns")
164164
if ordering is None:
165165
ordering = userconfig.get(f"tables.{self.name}.ordering")
166+
if userconfig.get("ui.table.rows.hover"):
167+
self.attrs['class'] += ' table-hover'
168+
if userconfig.get("ui.table.rows.striped"):
169+
self.attrs['class'] += ' table-striped'
166170

167171
# Fall back to the default columns & ordering
168172
if columns is None and hasattr(settings, 'DEFAULT_USER_PREFERENCES'):

netbox/users/forms/model_forms.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class UserConfigForm(forms.ModelForm, metaclass=UserConfigFormMetaclass):
5959
fieldsets = (
6060
FieldSet(
6161
'locale.language', 'pagination.per_page', 'pagination.placement', 'ui.htmx_navigation',
62+
'ui.table.rows.hover', 'ui.table.rows.striped',
6263
name=_('User Interface')
6364
),
6465
FieldSet('data_format', name=_('Miscellaneous')),

0 commit comments

Comments
 (0)