Add sticky action button option.

pull/110/head
theSinner 2021-01-24 19:30:32 +03:30
parent ed25f0fdde
commit 41e50e358a
5 changed files with 54 additions and 1 deletions

View File

@ -121,6 +121,10 @@ class ThemeAdmin(admin.ModelAdmin):
'classes': ('wide', ),
'fields': ('recent_actions_visible', )
}),
(_('Action Buttons'), {
'classes': ('wide', ),
'fields': ('action_buttons_sticky', )
}),
)
save_on_top = True

View File

@ -0,0 +1,18 @@
# Generated by Django 3.1.5 on 2021-01-22 11:04
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('admin_interface', '0018_theme_list_filter_sticky'),
]
operations = [
migrations.AddField(
model_name='theme',
name='action_buttons_sticky',
field=models.BooleanField(default=False, verbose_name='sticky position'),
),
]

View File

@ -299,6 +299,10 @@ class Theme(models.Model):
default=True,
verbose_name=_('visible'))
action_buttons_sticky = models.BooleanField(
default=False,
verbose_name=_('sticky position'))
def set_active(self):
self.active = True
self.save()

View File

@ -52,7 +52,7 @@ https://github.com/fabiocaccamo/django-admin-interface
{% include "admin_interface/related-modal.html" %}
{% endblock %}
{% block bodyclass %}admin-interface flat-theme {% get_admin_interface_theme as theme %}{% if theme.name %}{{ theme.name|slugify }}-theme{% endif %}{% endblock %}
{% block bodyclass %}admin-interface flat-theme {% get_admin_interface_theme as theme %}{% if theme.name %}{{ theme.name|slugify }}-theme{% endif %}{% if theme.action_buttons_sticky %} sticky-action-buttons {% endif %}{% endblock %}
{% block branding %}
{% get_admin_interface_theme as theme %}

View File

@ -412,6 +412,19 @@ body.admin-interface .paginator a.showall:visited {
max-width: 100%;
}
.admin-interface.sticky-action-buttons.change-form:not(.popup) #main > #nav-sidebar + .content {
padding-bottom: 4rem;
}
.admin-interface.sticky-action-buttons.change-form:not(.popup) #main > #nav-sidebar + .content .submit-row {
width: 100%;
max-width: calc(100% - 28px);
bottom: 0;
right: 0;
margin-bottom: 0;
position: fixed;
}
/* hide nav-sidebar below 1280px to prevent horizontal overflow issues */
@media (max-width:1279px) {
.admin-interface #nav-sidebar,
@ -449,6 +462,12 @@ body.admin-interface .paginator a.showall:visited {
.admin-interface.change-form:not(.popup) #main.shifted > #nav-sidebar + .content {
max-width: calc(100% - 360px);
}
.admin-interface.sticky-action-buttons.change-form:not(.popup) #main.shifted > #nav-sidebar + .content .submit-row {
max-width: calc(100% - 388px);
right: 0;
bottom: 0;
}
}
/* fixed related widget and select2 */
@ -537,4 +556,12 @@ body.admin-interface .paginator a.showall:visited {
.admin-interface .aligned .form-row .file-upload input[type="file"] {
margin-top: 5px;
}
.admin-interface.sticky-action-buttons.change-form:not(.popup) #main > #nav-sidebar + .content {
padding-bottom: 12rem;
}
.admin-interface.sticky-action-buttons.change-form:not(.popup) #main > #nav-sidebar + .content .submit-row {
max-width: calc(100% - 20px);
}
}