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
4b9ebba2
Commit
4b9ebba2
authored
Jul 17, 2015
by
Serge S. Koval
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #950 from pawl/add_category_icon
allow adding icons to menu categories
parents
d6a19325
8160c21d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
7 deletions
+18
-7
base.py
flask_admin/base.py
+8
-1
layout.html
flask_admin/templates/bootstrap2/admin/layout.html
+5
-3
layout.html
flask_admin/templates/bootstrap3/admin/layout.html
+5
-3
No files found.
flask_admin/base.py
View file @
4b9ebba2
...
@@ -454,7 +454,8 @@ class Admin(object):
...
@@ -454,7 +454,8 @@ class Admin(object):
endpoint
=
None
,
endpoint
=
None
,
static_url_path
=
None
,
static_url_path
=
None
,
base_template
=
None
,
base_template
=
None
,
template_mode
=
None
):
template_mode
=
None
,
category_icon_classes
=
None
):
"""
"""
Constructor.
Constructor.
...
@@ -482,6 +483,9 @@ class Admin(object):
...
@@ -482,6 +483,9 @@ class Admin(object):
:param template_mode:
:param template_mode:
Base template path. Defaults to `bootstrap2`. If you want to use
Base template path. Defaults to `bootstrap2`. If you want to use
Bootstrap 3 integration, change it to `bootstrap3`.
Bootstrap 3 integration, change it to `bootstrap3`.
:param category_icon_classes:
A dict of category names as keys and html classes as values to be added to menu category icons.
Example: {'Favorites': 'glyphicon glyphicon-star'}
"""
"""
self
.
app
=
app
self
.
app
=
app
...
@@ -503,6 +507,7 @@ class Admin(object):
...
@@ -503,6 +507,7 @@ class Admin(object):
self
.
subdomain
=
subdomain
self
.
subdomain
=
subdomain
self
.
base_template
=
base_template
or
'admin/base.html'
self
.
base_template
=
base_template
or
'admin/base.html'
self
.
template_mode
=
template_mode
or
'bootstrap2'
self
.
template_mode
=
template_mode
or
'bootstrap2'
self
.
category_icon_classes
=
category_icon_classes
or
dict
()
# Add predefined index view
# Add predefined index view
self
.
add_view
(
self
.
index_view
)
self
.
add_view
(
self
.
index_view
)
...
@@ -545,8 +550,10 @@ class Admin(object):
...
@@ -545,8 +550,10 @@ class Admin(object):
category
=
self
.
_menu_categories
.
get
(
cat_text
)
category
=
self
.
_menu_categories
.
get
(
cat_text
)
# create a new menu category if one does not exist already
if
category
is
None
:
if
category
is
None
:
category
=
MenuCategory
(
target_category
)
category
=
MenuCategory
(
target_category
)
category
.
class_name
=
self
.
category_icon_classes
.
get
(
cat_text
)
self
.
_menu_categories
[
cat_text
]
=
category
self
.
_menu_categories
[
cat_text
]
=
category
self
.
_menu
.
append
(
category
)
self
.
_menu
.
append
(
category
)
...
...
flask_admin/templates/bootstrap2/admin/layout.html
View file @
4b9ebba2
...
@@ -21,11 +21,13 @@
...
@@ -21,11 +21,13 @@
{%- if children %}
{%- if children %}
{% 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 dropdown
{% if class_name %} {{class_name}}{% endif %}
"
>
<li
class=
"active dropdown"
>
{% else -%}
{% else -%}
<li
class=
"dropdown
{% if class_name %} {{class_name}}{% endif %}
"
>
<li
class=
"dropdown"
>
{%- endif %}
{%- endif %}
<a
class=
"dropdown-toggle"
data-toggle=
"dropdown"
href=
"javascript:void(0)"
>
{{ menu_icon(item) }}{{ item.name }}
<b
class=
"caret"
></b></a>
<a
class=
"dropdown-toggle"
data-toggle=
"dropdown"
href=
"javascript:void(0)"
>
{% if item.class_name %}
<i
class=
"{{ item.class_name }}"
></i>
{% endif %}{{ item.name }}
<b
class=
"caret"
></b>
</a>
<ul
class=
"dropdown-menu"
>
<ul
class=
"dropdown-menu"
>
{%- for child in children -%}
{%- for child in children -%}
{% set class_name = child.get_class_name() %}
{% set class_name = child.get_class_name() %}
...
...
flask_admin/templates/bootstrap3/admin/layout.html
View file @
4b9ebba2
...
@@ -21,11 +21,13 @@
...
@@ -21,11 +21,13 @@
{%- if children %}
{%- if children %}
{% 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 dropdown
{% if class_name %} {{class_name}}{% endif %}
"
>
<li
class=
"active dropdown"
>
{% else -%}
{% else -%}
<li
class=
"dropdown
{% if class_name %} {{class_name}}{% endif %}
"
>
<li
class=
"dropdown"
>
{%- endif %}
{%- endif %}
<a
class=
"dropdown-toggle"
data-toggle=
"dropdown"
href=
"javascript:void(0)"
>
{{ menu_icon(item) }}{{ item.name }}
<b
class=
"caret"
></b></a>
<a
class=
"dropdown-toggle"
data-toggle=
"dropdown"
href=
"javascript:void(0)"
>
{% if item.class_name %}
<span
class=
"{{ item.class_name }}"
></span>
{% endif %}{{ item.name }}
<b
class=
"caret"
></b>
</a>
<ul
class=
"dropdown-menu"
>
<ul
class=
"dropdown-menu"
>
{%- for child in children -%}
{%- for child in children -%}
{% set class_name = child.get_class_name() %}
{% set class_name = child.get_class_name() %}
...
...
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