Added list filter sticky option (only for django >= 3.1.2).

pull/107/head
Fabio Caccamo 2020-10-15 10:49:26 +02:00
parent 071fe476a6
commit d61ef86dd6
4 changed files with 43 additions and 1 deletions

View File

@ -112,7 +112,10 @@ class ThemeAdmin(admin.ModelAdmin):
}), }),
(_('List Filter'), { (_('List Filter'), {
'classes': ('wide', ), 'classes': ('wide', ),
'fields': ('list_filter_dropdown', ) 'fields': (
'list_filter_dropdown',
'list_filter_sticky',
)
}), }),
(_('Recent Actions'), { (_('Recent Actions'), {
'classes': ('wide', ), 'classes': ('wide', ),

View File

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('admin_interface', '0017_change_list_filter_dropdown'),
]
operations = [
migrations.AddField(
model_name='theme',
name='list_filter_sticky',
field=models.BooleanField(default=True, verbose_name='sticky position'),
),
]

View File

@ -291,6 +291,10 @@ class Theme(models.Model):
list_filter_dropdown = models.BooleanField( list_filter_dropdown = models.BooleanField(
default=True, default=True,
verbose_name=_('use dropdown')) verbose_name=_('use dropdown'))
list_filter_sticky = models.BooleanField(
default=True,
verbose_name=_('sticky position'))
recent_actions_visible = models.BooleanField( recent_actions_visible = models.BooleanField(
default=True, default=True,
verbose_name=_('visible')) verbose_name=_('visible'))

View File

@ -282,6 +282,21 @@
color:{{ theme.css_generic_link_hover_color }}; color:{{ theme.css_generic_link_hover_color }};
} }
/* list-filter sticky */
{% if theme.list_filter_sticky %}
@media (min-width: 768px) {
.admin-interface .module.filtered #changelist-filter {
position: sticky;
top: 40px;
}
/* feature not available for django < 3.1.2 */
.admin-interface .module.filtered #toolbar + #changelist-filter {
position: absolute;
top: 0px;
}
}
{% endif %}
.admin-interface .module.filtered #changelist-filter { .admin-interface .module.filtered #changelist-filter {
{% if theme.css_module_rounded_corners %} {% if theme.css_module_rounded_corners %}
border-bottom-left-radius: 4px; border-bottom-left-radius: 4px;