Basic horizontal menu implementation
parent
32e4afd90f
commit
e286950f78
|
|
@ -19,6 +19,7 @@ https://github.com/fabiocaccamo/django-admin-interface
|
||||||
{% include "admin_interface/css/list-filter-dropdown.css" %}
|
{% include "admin_interface/css/list-filter-dropdown.css" %}
|
||||||
{% include "admin_interface/css/recent-actions.css" %}
|
{% include "admin_interface/css/recent-actions.css" %}
|
||||||
{% include "admin_interface/css/related-modal.css" %}
|
{% include "admin_interface/css/related-modal.css" %}
|
||||||
|
{% include "admin_interface/css/menu.css" %}
|
||||||
{% include "admin_interface/css/jquery.ui.tabs.css" %}
|
{% include "admin_interface/css/jquery.ui.tabs.css" %}
|
||||||
{% include "admin_interface/css/modeltranslation.css" %}
|
{% include "admin_interface/css/modeltranslation.css" %}
|
||||||
{% include "admin_interface/css/sorl-thumbnail.css" %}
|
{% include "admin_interface/css/sorl-thumbnail.css" %}
|
||||||
|
|
@ -70,3 +71,28 @@ https://github.com/fabiocaccamo/django-admin-interface
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if theme.env_visible_in_header %}<span class="environment-label {{ theme.env_name }}"></span> - {% endif %}{{ block.super }}<br>
|
{% if theme.env_visible_in_header %}<span class="environment-label {{ theme.env_name }}"></span> - {% endif %}{{ block.super }}<br>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block nav-global %}
|
||||||
|
{% if not is_popup %}
|
||||||
|
{% get_admin_interface_menu as menu %}
|
||||||
|
{% if menu %}
|
||||||
|
<div id="menu">
|
||||||
|
<div class="singlelink"><a href="{% url 'admin:index' %}">Dashboard</a></div>
|
||||||
|
{% for app in menu %}
|
||||||
|
{% if app.has_module_perms %}
|
||||||
|
<div class="dropdown">
|
||||||
|
<button class="dropbtn">{{ app.name }}</button>
|
||||||
|
<div class="dropdown-content">
|
||||||
|
{% for model in app.models %}
|
||||||
|
{% if model.perms.view or model.perms.change %}
|
||||||
|
<a href="{{ model.admin_url }}">{{ model.name }}</a>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,86 @@
|
||||||
|
#menu {
|
||||||
|
flex: 1 1 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
background-color: {{ theme.css_header_background_color }};
|
||||||
|
margin-top: 10px;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#menu a {
|
||||||
|
float: left;
|
||||||
|
font-size: 14px;
|
||||||
|
color: white;
|
||||||
|
text-align: center;
|
||||||
|
padding: 14px 16px;
|
||||||
|
text-decoration: none;
|
||||||
|
background-color: {{ theme.css_module_background_color }};
|
||||||
|
}
|
||||||
|
|
||||||
|
#menu a:first-child {
|
||||||
|
border-radius: 4px 0 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#menu .dropdown {
|
||||||
|
float: left;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
#menu .dropdown:first-child {
|
||||||
|
border-radius: 4px 0 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#menu .dropdown:last-child {
|
||||||
|
border-radius: 0 4px 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#menu .dropdown .dropbtn {
|
||||||
|
font-size: 14px;
|
||||||
|
border: none;
|
||||||
|
outline: none;
|
||||||
|
color: {{ theme.css_module_text_color }};
|
||||||
|
padding: 14px 16px;
|
||||||
|
font-family: inherit;
|
||||||
|
margin: 0;
|
||||||
|
background-color: {{ theme.css_module_background_color }};
|
||||||
|
}
|
||||||
|
|
||||||
|
#menu a:hover, .dropdown:hover .dropbtn {
|
||||||
|
background-color: {{ theme.css_generic_link_hover_color }};
|
||||||
|
}
|
||||||
|
|
||||||
|
#menu .dropdown-content {
|
||||||
|
display: none;
|
||||||
|
position: absolute;
|
||||||
|
background-color: {{ theme.css_generic_link_hover_color }};
|
||||||
|
min-width: 160px;
|
||||||
|
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#menu .dropdown-content a {
|
||||||
|
border-radius: unset;
|
||||||
|
float: none;
|
||||||
|
color: {{ theme.css_module_text_color }};
|
||||||
|
padding: 12px 16px;
|
||||||
|
text-decoration: none;
|
||||||
|
display: block;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
#menu .dropdown-content a:hover {
|
||||||
|
background-color: #ddd;
|
||||||
|
}
|
||||||
|
|
||||||
|
#menu .dropdown:hover .dropdown-content {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.arrow-down {
|
||||||
|
width: 0;
|
||||||
|
height: 0;
|
||||||
|
border-left: 5px solid transparent;
|
||||||
|
border-right: 5px solid transparent;
|
||||||
|
|
||||||
|
border-top: 5px solid white;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -2,11 +2,14 @@
|
||||||
|
|
||||||
import django
|
import django
|
||||||
from django import template, VERSION
|
from django import template, VERSION
|
||||||
|
from django.apps import apps
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
if django.VERSION < (1, 10):
|
if django.VERSION < (1, 10):
|
||||||
from django.core.urlresolvers import NoReverseMatch, reverse
|
from django.core.urlresolvers import NoReverseMatch, reverse
|
||||||
else:
|
else:
|
||||||
from django.urls import NoReverseMatch, reverse
|
from django.urls import NoReverseMatch, reverse
|
||||||
|
from django.contrib import admin
|
||||||
|
from django.contrib.admin.sites import all_sites
|
||||||
from django.utils import translation
|
from django.utils import translation
|
||||||
|
|
||||||
from admin_interface.cache import get_cached_active_theme, set_cached_active_theme
|
from admin_interface.cache import get_cached_active_theme, set_cached_active_theme
|
||||||
|
|
@ -78,3 +81,14 @@ def get_admin_interface_theme(context):
|
||||||
@simple_tag(takes_context=False)
|
@simple_tag(takes_context=False)
|
||||||
def get_admin_interface_version():
|
def get_admin_interface_version():
|
||||||
return __version__
|
return __version__
|
||||||
|
|
||||||
|
|
||||||
|
@simple_tag(takes_context=True)
|
||||||
|
def get_admin_interface_menu(context):
|
||||||
|
request = context['request']
|
||||||
|
if request.user and request.user.is_staff:
|
||||||
|
current_app = request.current_app if hasattr(request, 'current_app') else 'admin' # Fallback on default admin for WSGI requests from not-admin views
|
||||||
|
for admin_site in all_sites:
|
||||||
|
if admin_site.name == current_app:
|
||||||
|
return admin_site.get_app_list(request)
|
||||||
|
return []
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue