Commit 012ec957 authored by Michael Bukachi's avatar Michael Bukachi

fix: Correct missing highlight for active menu items

parent a252b9cf
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
<body> <body>
{% block page_body %} {% block page_body %}
<div class="container{% if config.get('FLASK_ADMIN_FLUID_LAYOUT', False) %}-fluid{% endif %}"> <div class="container{% if config.get('FLASK_ADMIN_FLUID_LAYOUT', False) %}-fluid{% endif %}">
<nav class="navbar navbar-expand-lg navbar-dark bg-primary mb-2" role="navigation"> <nav class="navbar navbar-expand-lg navbar-dark bg-dark mb-2" role="navigation">
<!-- Brand and toggle get grouped for better mobile display --> <!-- Brand and toggle get grouped for better mobile display -->
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#admin-navbar-collapse" <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#admin-navbar-collapse"
aria-controls="admin-navbar-collapse" aria-expanded="false" aria-label="Toggle navigation"> aria-controls="admin-navbar-collapse" aria-expanded="false" aria-label="Toggle navigation">
......
{% macro menu_icon(item) -%} {% macro menu_icon(item) -%}
{% set icon_type = item.get_icon_type() %} {% set icon_type = item.get_icon_type() %}
{%- if icon_type %} {%- if icon_type %}
{% set icon_value = item.get_icon_value() %} {% set icon_value = item.get_icon_value() %}
{% if icon_type == 'glyph' %} {% if icon_type == 'glyph' %}
<i class="glyphicon {{ icon_value }}"></i> <i class="glyphicon {{ icon_value }}"></i>
{% elif icon_type == 'fa' %} {% elif icon_type == 'fa' %}
<i class="fa {{ icon_value }}"></i> <i class="fa {{ icon_value }}"></i>
{% elif icon_type == 'image' %} {% elif icon_type == 'image' %}
<img src="{{ url_for('static', filename=icon_value) }}" alt="menu image"> <img src="{{ url_for('static', filename=icon_value) }}" alt="menu image">
{% elif icon_type == 'image-url' %} {% elif icon_type == 'image-url' %}
<img src="{{ icon_value }}" alt="menu image"> <img src="{{ icon_value }}" alt="menu image">
{% endif %}
{% endif %} {% endif %}
{% endif %}
{%- endmacro %} {%- endmacro %}
{% macro menu(menu_root=None) %} {% macro menu(menu_root=None) %}
{% if menu_root is none %}{% set menu_root = admin_view.admin.menu() %}{% endif %} {% if menu_root is none %}{% set menu_root = admin_view.admin.menu() %}{% endif %}
...@@ -21,49 +21,52 @@ ...@@ -21,49 +21,52 @@
{%- if children %} {%- if children %}
{% set class_name = item.get_class_name() or '' %} {% set class_name = item.get_class_name() or '' %}
{%- if item.is_active(admin_view) %} {%- if item.is_active(admin_view) %}
<li class="active dropdown{% if class_name %} {{class_name}}{% endif %}"> <li class="active dropdown{% if class_name %} {{ class_name }}{% endif %}">
{% else -%} {% else -%}
<li class="dropdown{% if class_name %} {{class_name}}{% endif %}"> <li class="dropdown{% if class_name %} {{ class_name }}{% endif %}">
{%- endif %} {%- endif %}
<a class="dropdown-toggle nav-link" data-toggle="dropdown" href="javascript:void(0)"> <a class="dropdown-toggle nav-link" data-toggle="dropdown" href="javascript:void(0)">
{% if item.class_name %}<span class="{{ item.class_name }}"></span> {% endif %} {% if item.class_name %}<span class="{{ item.class_name }}"></span> {% endif %}
{{ menu_icon(item) }}{{ item.name }} {{ menu_icon(item) }}{{ item.name }}
{%- if 'dropdown-submenu' in class_name -%} {%- if 'dropdown-submenu' in class_name -%}
<i class="glyphicon glyphicon-chevron-right small"></i> <i class="glyphicon glyphicon-chevron-right small"></i>
{%- else -%} {%- else -%}
<i class="glyphicon glyphicon-chevron-down small"></i> <i class="glyphicon glyphicon-chevron-down small"></i>
{%- endif -%} {%- endif -%}
</a> </a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
{%- for child in children -%} {%- for child in children -%}
{%- if child.is_category() -%} {%- if child.is_category() -%}
{{ menu(menu_root=[child]) }} {{ menu(menu_root=[child]) }}
{% else %} {% else %}
{% set class_name = child.get_class_name() %} {% set class_name = child.get_class_name() %}
<li{% if class_name %} class="{{ class_name }}"{% endif %}>
{%- if child.is_active(admin_view) %} {%- if child.is_active(admin_view) %}
<li class="active{% if class_name %} {{class_name}}{% endif %}"> <a class="dropdown-item active" href="{{ child.get_url() }}"{% if child.target %}
target="{{ child.target }}"{% endif %}>
{{ menu_icon(child) }}{{ child.name }}</a>
{% else %} {% else %}
<li{% if class_name %} class="{{class_name}}"{% endif %}> <a class="dropdown-item" href="{{ child.get_url() }}"{% if child.target %}
target="{{ child.target }}"{% endif %}>
{{ menu_icon(child) }}{{ child.name }}</a>
{%- endif %} {%- endif %}
<a class="nav-link text-reset" href="{{ child.get_url() }}"{% if child.target %} </li>
target="{{ child.target }}"{% endif %}> {%- endif %}
{{ menu_icon(child) }}{{ child.name }}</a> {%- endfor %}
</li> </ul>
{%- endif %} </li>
{%- endfor %}
</ul>
</li>
{% endif %} {% endif %}
{%- else %} {%- else %}
{%- if item.is_accessible() and item.is_visible() -%} {%- if item.is_accessible() and item.is_visible() -%}
{% set class_name = item.get_class_name() %} {% set class_name = item.get_class_name() %}
{%- if item.is_active(admin_view) %} {%- if item.is_active(admin_view) %}
<li class="active{% if class_name %} {{class_name}}{% endif %}"> <li class="active{% if class_name %} {{ class_name }}{% endif %}">
{%- else %} {%- else %}
<li{% if class_name %} class="{{class_name}}"{% endif %}> <li{% if class_name %} class="{{ class_name }}"{% endif %}>
{%- endif %} {%- endif %}
<a class="nav-link" href="{{ item.get_url() }}"{% if item.target %} target="{{ item.target }}"{% endif %}>{{ menu_icon(item) }}{{ item.name }}</a> <a class="nav-link" href="{{ item.get_url() }}"{% if item.target %} target="{{ item.target }}"{% endif %}>
</li> {{ menu_icon(item) }}{{ item.name }}</a>
</li>
{%- endif -%} {%- endif -%}
{% endif -%} {% endif -%}
{% endfor %} {% endfor %}
...@@ -86,15 +89,15 @@ ...@@ -86,15 +89,15 @@
{% if messages %} {% if messages %}
{% for category, m in messages %} {% for category, m in messages %}
{% if category %} {% if category %}
{# alert-error changed to alert-danger in bootstrap 3, mapping is for backwards compatibility #} {# alert-error changed to alert-danger in bootstrap 3, mapping is for backwards compatibility #}
{% set mapping = {'message': 'info', 'error': 'danger'} %} {% set mapping = {'message': 'info', 'error': 'danger'} %}
<div class="alert alert-{{ mapping.get(category, category) }} alert-dismissable"> <div class="alert alert-{{ mapping.get(category, category) }} alert-dismissable">
{% else %} {% else %}
<div class="alert alert-dismissable"> <div class="alert alert-dismissable">
{% endif %} {% endif %}
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button> <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
{{ m }} {{ m }}
</div> </div>
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% endwith %} {% endwith %}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment