Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
flask-admin
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Python-Dev
flask-admin
Commits
012ec957
Commit
012ec957
authored
Aug 08, 2020
by
Michael Bukachi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: Correct missing highlight for active menu items
parent
a252b9cf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
53 deletions
+56
-53
base.html
flask_admin/templates/bootstrap4/admin/base.html
+1
-1
layout.html
flask_admin/templates/bootstrap4/admin/layout.html
+55
-52
No files found.
flask_admin/templates/bootstrap4/admin/base.html
View file @
012ec957
...
...
@@ -39,7 +39,7 @@
<body>
{% block page_body %}
<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 -->
<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"
>
...
...
flask_admin/templates/bootstrap4/admin/layout.html
View file @
012ec957
{% macro menu_icon(item) -%}
{% set icon_type = item.get_icon_type() %}
{%- if icon_type %}
{% set icon_value = item.get_icon_value() %}
{% if icon_type == 'glyph' %}
<i
class=
"glyphicon {{ icon_value }}"
></i>
{% elif icon_type == 'fa' %}
<i
class=
"fa {{ icon_value }}"
></i>
{% elif icon_type == 'image' %}
<img
src=
"{{ url_for('static', filename=icon_value) }}"
alt=
"menu image"
>
{% elif icon_type == 'image-url' %}
<img
src=
"{{ icon_value }}"
alt=
"menu image"
>
{% set icon_type = item.get_icon_type() %}
{%- if icon_type %}
{% set icon_value = item.get_icon_value() %}
{% if icon_type == 'glyph' %}
<i
class=
"glyphicon {{ icon_value }}"
></i>
{% elif icon_type == 'fa' %}
<i
class=
"fa {{ icon_value }}"
></i>
{% elif icon_type == 'image' %}
<img
src=
"{{ url_for('static', filename=icon_value) }}"
alt=
"menu image"
>
{% elif icon_type == 'image-url' %}
<img
src=
"{{ icon_value }}"
alt=
"menu image"
>
{% endif %}
{% endif %}
{% endif %}
{%- endmacro %}
{% macro menu(menu_root=None) %}
{% if menu_root is none %}{% set menu_root = admin_view.admin.menu() %}{% endif %}
...
...
@@ -21,49 +21,52 @@
{%- if children %}
{% set class_name = item.get_class_name() or '' %}
{%- if item.is_active(admin_view) %}
<li
class=
"active dropdown{% if class_name %} {{class_name
}}{% endif %}"
>
{% else -%}
<li
class=
"dropdown{% if class_name %} {{class_name
}}{% endif %}"
>
<li
class=
"active dropdown{% if class_name %} {{ class_name
}}{% endif %}"
>
{% else -%}
<li
class=
"dropdown{% if class_name %} {{ class_name
}}{% endif %}"
>
{%- endif %}
<a
class=
"dropdown-toggle nav-link"
data-toggle=
"dropdown"
href=
"javascript:void(0)"
>
{% if item.class_name %}
<span
class=
"{{ item.class_name }}"
></span>
{% endif %}
{{ menu_icon(item) }}{{ item.name }}
{%- if 'dropdown-submenu' in class_name -%}
<i
class=
"glyphicon glyphicon-chevron-right small"
></i>
{%- else -%}
<i
class=
"glyphicon glyphicon-chevron-down small"
></i>
{%- endif -%}
</a>
<ul
class=
"dropdown-menu"
>
{%- for child in children -%}
{%- if child.is_category() -%}
{{ menu(menu_root=[child]) }}
{% else %}
{% set class_name = child.get_class_name() %}
<a
class=
"dropdown-toggle nav-link"
data-toggle=
"dropdown"
href=
"javascript:void(0)"
>
{% if item.class_name %}
<span
class=
"{{ item.class_name }}"
></span>
{% endif %}
{{ menu_icon(item) }}{{ item.name }}
{%- if 'dropdown-submenu' in class_name -%}
<i
class=
"glyphicon glyphicon-chevron-right small"
></i>
{%- else -%}
<i
class=
"glyphicon glyphicon-chevron-down small"
></i>
{%- endif -%}
</a>
<ul
class=
"dropdown-menu"
>
{%- for child in children -%}
{%- if child.is_category() -%}
{{ menu(menu_root=[child]) }}
{% else %}
{% set class_name = child.get_class_name() %}
<li
{%
if
class_name
%}
class=
"{{ class_name }}"
{%
endif
%}
>
{%- 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 %}
<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 %}
<a
class=
"nav-link text-reset"
href=
"{{ child.get_url() }}"
{%
if
child
.
target
%}
target=
"{{ child.target }}"
{%
endif
%}
>
{{ menu_icon(child) }}{{ child.name }}
</a>
</li>
{%- endif %}
{%- endfor %}
</ul>
</li>
</li>
{%- endif %}
{%- endfor %}
</ul>
</li>
{% endif %}
{%- else %}
{%- if item.is_accessible() and item.is_visible() -%}
{% set class_name = item.get_class_name() %}
{%- if item.is_active(admin_view) %}
<li
class=
"active{% if class_name %} {{class_name
}}{% endif %}"
>
{%- else %}
<li
{%
if
class_name
%}
class=
"{{class_name
}}"
{%
endif
%}
>
<li
class=
"active{% if class_name %} {{ class_name
}}{% endif %}"
>
{%- else %}
<li
{%
if
class_name
%}
class=
"{{ class_name
}}"
{%
endif
%}
>
{%- endif %}
<a
class=
"nav-link"
href=
"{{ item.get_url() }}"
{%
if
item
.
target
%}
target=
"{{ item.target }}"
{%
endif
%}
>
{{ menu_icon(item) }}{{ item.name }}
</a>
</li>
<a
class=
"nav-link"
href=
"{{ item.get_url() }}"
{%
if
item
.
target
%}
target=
"{{ item.target }}"
{%
endif
%}
>
{{ menu_icon(item) }}{{ item.name }}
</a>
</li>
{%- endif -%}
{% endif -%}
{% endfor %}
...
...
@@ -86,15 +89,15 @@
{% if messages %}
{% for category, m in messages %}
{% if category %}
{# alert-error changed to alert-danger in bootstrap 3, mapping is for backwards compatibility #}
{% set mapping = {'message': 'info', 'error': 'danger'} %}
<div
class=
"alert alert-{{ mapping.get(category, category) }} alert-dismissable"
>
{# alert-error changed to alert-danger in bootstrap 3, mapping is for backwards compatibility #}
{% set mapping = {'message': 'info', 'error': 'danger'} %}
<div
class=
"alert alert-{{ mapping.get(category, category) }} alert-dismissable"
>
{% else %}
<div
class=
"alert alert-dismissable"
>
<div
class=
"alert alert-dismissable"
>
{% endif %}
<button
type=
"button"
class=
"close"
data-dismiss=
"alert"
aria-hidden=
"true"
>
×
</button>
{{ m }}
</div>
<button
type=
"button"
class=
"close"
data-dismiss=
"alert"
aria-hidden=
"true"
>
×
</button>
{{ m }}
</div>
{% endfor %}
{% endif %}
{% endwith %}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment