Fixes #17719: User setting table stripe

This commit is contained in:
Tobias Genannt 2025-05-16 20:29:56 +02:00 committed by Tobias Genannt
parent b3d318cbe1
commit 626e42145a
3 changed files with 12 additions and 0 deletions

View File

@ -54,6 +54,15 @@ PREFERENCES = {
default='bottom',
description=_('Where the paginator controls will be displayed relative to a table')
),
'ui.table.rows.striped': UserPreference(
label=_('Striped table rows'),
choices=(
('', _('Disabled')),
('true', _('Enabled')),
),
description=_('Show striped effect on table rows'),
default=False,
),
# Miscellaneous
'data_format': UserPreference(

View File

@ -163,6 +163,8 @@ class BaseTable(tables.Table):
columns = userconfig.get(f"tables.{self.name}.columns")
if ordering is None:
ordering = userconfig.get(f"tables.{self.name}.ordering")
if userconfig.get("ui.table.rows.striped"):
self.attrs['class'] += ' table-striped'
# Fall back to the default columns & ordering
if columns is None and hasattr(settings, 'DEFAULT_USER_PREFERENCES'):

View File

@ -59,6 +59,7 @@ class UserConfigForm(forms.ModelForm, metaclass=UserConfigFormMetaclass):
fieldsets = (
FieldSet(
'locale.language', 'pagination.per_page', 'pagination.placement', 'ui.htmx_navigation',
'ui.table.rows.striped',
name=_('User Interface')
),
FieldSet('data_format', name=_('Miscellaneous')),