Menu reorganization.
The "About" menu has been renamed to "System". The "Tools" and "Setup" sub menus, were moved from the "Profile" menu to the "System" menu. The "Profile" menu has been renamed to "User". Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -30,7 +30,10 @@ Other Changes
|
||||
of documents.
|
||||
- Make sure lookup selection widgets also trigger the metadata update
|
||||
checkbox on change.
|
||||
|
||||
- Menu reorganization. The "About" menu has been renamed to "System". The
|
||||
"Tools" and "Setup" sub menus, were moved from the "Profile" menu to the
|
||||
"System" menu. The "Profile" menu has been renamed to "User".
|
||||
- Usability improvements on small displays.
|
||||
|
||||
|
||||
Removals
|
||||
|
||||
@@ -175,3 +175,8 @@ a i {
|
||||
#toast-container > div {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.link-text-span {
|
||||
padding-left: 10px;
|
||||
padding-right: 20px;
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
{# TODO: don't use hardcoded main:home use settings.LOGIN_REDIRECT_URL #}
|
||||
<a class="navbar-brand" href="{% url 'common:home' %}">{% project_name %}{% if debug %} <i class="fa fa-bug"></i>{% endif %}</a>
|
||||
<a class="navbar-brand" href="{% url 'common:home' %}">{% project_name %}</a>
|
||||
</div>
|
||||
<div id="navbar" class="navbar-collapse collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
@@ -80,39 +80,6 @@
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="true">
|
||||
{% trans 'Profile' %} <i class="fa fa-user-circle-o"></i>
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li class="text-center" style="padding-left: 10px; padding-right: 20px;">
|
||||
{% if not request.user.is_authenticated %}
|
||||
{% trans 'Anonymous' %}
|
||||
{% else %}
|
||||
{{ request.user.get_full_name|default:request.user }}
|
||||
{% endif %}
|
||||
</li>
|
||||
<li role="separator" class="divider"></li>
|
||||
|
||||
{% get_menu_links 'user menu' as menu_links %}
|
||||
{% for link_set in menu_links %}
|
||||
{% for link in link_set %}
|
||||
{% with 'true' as as_li %}
|
||||
{% with 'true' as hide_active_anchor %}
|
||||
{% with 'first' as li_class_first %}
|
||||
{% with ' ' as link_classes %}
|
||||
{% include 'navigation/generic_subnavigation.html' %}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
{% if link.separator %}
|
||||
<li role="separator" class="divider"></li>
|
||||
{% elif link.text_span %}
|
||||
<li class="text-center link-text-span" >{{ link.text }}</li>
|
||||
{% else %}
|
||||
{% if link.disabled %}
|
||||
<a class="{% if link_classes %}{{ link_classes }} {% else %}btn {% if 'dangerous' in link.tags %}btn-danger{% else %}btn-primary{% endif %} btn-xs{% endif %} {% if link.active %}{{ link_class_active }}{% endif %} {% if 'new_window' in link.tags %}new_window{% endif %} disabled" disabled='disabled' style="cursor: default;" href="#">{% if link.icon %}<i class="hidden-xs hidden-sm {{ link.icon }}"></i> {% endif %}{{ link.text }}{% if link.error %} - {{ link.error }}{% endif %}</a>{% if horizontal %}{% if not forloop.last %} {% endif %}{% endif %}
|
||||
<a class="{% if link_classes %}{{ link_classes }} {% else %}btn {% if 'dangerous' in link.tags %}btn-danger{% else %}btn-primary{% endif %} btn-xs{% endif %} {% if link.active %}{{ link_class_active }}{% endif %} {% if 'new_window' in link.tags %}new_window{% endif %} disabled" disabled='disabled' style="cursor: default;" href="#">{% if link.icon %}<i class="hidden-xs hidden-sm hidden-md {{ link.icon }}"></i> {% endif %}{{ link.text }}{% if link.error %} - {{ link.error }}{% endif %}</a>{% if horizontal %}{% if not forloop.last %} {% endif %}{% endif %}
|
||||
{% else %}
|
||||
<a class="{% if link_classes %}{{ link_classes }} {% else %}btn {% if 'dangerous' in link.tags %}btn-danger{% else %}btn-primary{% endif %} btn-xs{% endif %} {% if link.active %}{{ link_class_active }}{% endif %} {% if 'new_window' in link.tags %}new_window{% endif %}" href="{{ link.url }}">{% if link.icon %}<i class="hidden-xs hidden-sm {{ link.icon }}"></i> {% endif %}{{ link.text }}{% if link.error %} - {{ link.error }}{% endif %}</a>{% if horizontal %}{% if not forloop.last %} {% endif %}{% endif %}
|
||||
<a class="{% if link_classes %}{{ link_classes }} {% else %}btn {% if 'dangerous' in link.tags %}btn-danger{% else %}btn-primary{% endif %} btn-xs{% endif %} {% if link.active %}{{ link_class_active }}{% endif %} {% if 'new_window' in link.tags %}new_window{% endif %}" href="{{ link.url }}">{% if link.icon %}<i class="hidden-xs hidden-sm hidden-md {{ link.icon }}"></i> {% endif %}{{ link.text }}{% if link.error %} - {{ link.error }}{% endif %}</a>{% if horizontal %}{% if not forloop.last %} {% endif %}{% endif %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="true">
|
||||
{% if link.icon %}
|
||||
<i class="hidden-xs hidden-sm {{ link.icon }}"></i>
|
||||
<i class="hidden-xs hidden-sm hidden-md {{ link.icon }}"></i>
|
||||
{% endif %}
|
||||
|
||||
{{ link.label }}
|
||||
|
||||
@@ -14,7 +14,7 @@ from django.utils.encoding import force_text
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from mayan.celery import app
|
||||
from navigation.classes import Separator
|
||||
from navigation.classes import Separator, Text
|
||||
from rest_api.classes import APIEndPoint
|
||||
|
||||
from .handlers import (
|
||||
@@ -73,6 +73,13 @@ class CommonApp(MayanAppConfig):
|
||||
name = 'common'
|
||||
verbose_name = _('Common')
|
||||
|
||||
@staticmethod
|
||||
def get_user_label_text(context):
|
||||
if not context['request'].user.is_authenticated:
|
||||
return _('Anonymous')
|
||||
else:
|
||||
return context['request'].user.get_full_name() or context['request'].user
|
||||
|
||||
def ready(self):
|
||||
super(CommonApp, self).ready()
|
||||
|
||||
@@ -111,21 +118,22 @@ class CommonApp(MayanAppConfig):
|
||||
)
|
||||
menu_user.bind_links(
|
||||
links=(
|
||||
Text(text=CommonApp.get_user_label_text), Separator(),
|
||||
link_current_user_details, link_current_user_edit,
|
||||
link_current_user_locale_profile_edit, link_tools, link_setup,
|
||||
link_current_user_locale_profile_edit,
|
||||
Separator()
|
||||
)
|
||||
)
|
||||
|
||||
menu_about.bind_links(
|
||||
links=(
|
||||
link_about, link_support, link_documentation, link_forum,
|
||||
link_code, link_license, link_packages_licenses,
|
||||
link_check_version
|
||||
link_tools, link_setup, link_about, link_support,
|
||||
link_documentation, link_forum, link_code, link_license,
|
||||
link_packages_licenses, link_check_version
|
||||
)
|
||||
)
|
||||
|
||||
menu_main.bind_links(links=(menu_about,), position=99)
|
||||
menu_main.bind_links(links=(menu_about, menu_user,), position=99)
|
||||
|
||||
menu_tools.bind_links(
|
||||
links=(link_filters,)
|
||||
|
||||
@@ -9,7 +9,7 @@ __all__ = (
|
||||
'menu_secondary', 'menu_setup', 'menu_sidebar', 'menu_tools', 'menu_user'
|
||||
)
|
||||
|
||||
menu_about = Menu(icon='fa fa-info', label=_('About'), name='about menu')
|
||||
menu_about = Menu(icon='fa fa-info', label=_('System'), name='about menu')
|
||||
menu_facet = Menu(name='object facet')
|
||||
menu_object = Menu(name='object menu')
|
||||
menu_main = Menu(name='main menu')
|
||||
@@ -18,4 +18,6 @@ menu_secondary = Menu(name='secondary menu')
|
||||
menu_setup = Menu(name='setup menu')
|
||||
menu_sidebar = Menu(name='sidebar menu')
|
||||
menu_tools = Menu(name='tools menu')
|
||||
menu_user = Menu(name='user menu')
|
||||
menu_user = Menu(
|
||||
icon='fa fa-user-circle-o', name='user menu', label=_('User')
|
||||
)
|
||||
|
||||
@@ -26,6 +26,8 @@ class ResolvedLink(object):
|
||||
self.disabled = False
|
||||
self.link = link
|
||||
self.url = '#'
|
||||
self.context = None
|
||||
self.request = None
|
||||
|
||||
@property
|
||||
def active(self):
|
||||
@@ -45,7 +47,10 @@ class ResolvedLink(object):
|
||||
|
||||
@property
|
||||
def text(self):
|
||||
return self.link.text
|
||||
try:
|
||||
return self.link.text(context=self.context)
|
||||
except TypeError:
|
||||
return self.link.text
|
||||
|
||||
|
||||
class Menu(object):
|
||||
@@ -174,7 +179,7 @@ class Menu(object):
|
||||
resolved_links = []
|
||||
# View links
|
||||
for link in self.bound_links.get(current_view, []):
|
||||
resolved_link = link.resolve(context)
|
||||
resolved_link = link.resolve(context=context)
|
||||
if resolved_link:
|
||||
resolved_links.append(resolved_link)
|
||||
|
||||
@@ -188,7 +193,7 @@ class Menu(object):
|
||||
if isinstance(link, Menu):
|
||||
resolved_link = link
|
||||
else:
|
||||
resolved_link = link.resolve(context)
|
||||
resolved_link = link.resolve(context=context)
|
||||
|
||||
if resolved_link:
|
||||
resolved_links.append(resolved_link)
|
||||
@@ -372,10 +377,14 @@ class Link(object):
|
||||
urlencode(parsed_query_string, doseq=True)
|
||||
)
|
||||
|
||||
resolved_link.context = context
|
||||
return resolved_link
|
||||
|
||||
|
||||
class Separator(Link):
|
||||
"""
|
||||
Menu separator. Renders to an <hr> tag
|
||||
"""
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.icon = None
|
||||
self.text = None
|
||||
@@ -428,3 +437,19 @@ class SourceColumn(object):
|
||||
result = self.func(context=context)
|
||||
|
||||
return result
|
||||
|
||||
|
||||
class Text(Link):
|
||||
"""
|
||||
Menu text. Renders to a plain <li> tag
|
||||
"""
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.icon = None
|
||||
self.text = kwargs.get('text')
|
||||
self.view = None
|
||||
|
||||
def resolve(self, *args, **kwargs):
|
||||
result = ResolvedLink(current_view=None, link=self)
|
||||
result.context = kwargs.get('context')
|
||||
result.text_span = True
|
||||
return result
|
||||
|
||||
@@ -18,7 +18,7 @@ def get_menus_links(context, names, source=None):
|
||||
result = []
|
||||
|
||||
for name in names.split(','):
|
||||
for links in Menu.get(name=name).resolve(context):
|
||||
for links in Menu.get(name=name).resolve(context=context):
|
||||
if links:
|
||||
result.append(links)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user