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
4c443713
Unverified
Commit
4c443713
authored
Aug 08, 2020
by
Serge S. Koval
Committed by
GitHub
Aug 08, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2012 from michaelbukachi/bootstrap4
fix: Correct navbar styling issue
parents
c5f44b10
012ec957
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
62 additions
and
57 deletions
+62
-57
app.py
examples/bootstrap4/app.py
+5
-3
base.html
flask_admin/templates/bootstrap4/admin/base.html
+1
-1
layout.html
flask_admin/templates/bootstrap4/admin/layout.html
+55
-52
layout.html
flask_admin/templates/bootstrap4/admin/model/layout.html
+1
-1
No files found.
examples/bootstrap4/app.py
View file @
4c443713
...
...
@@ -12,7 +12,7 @@ app = Flask(__name__)
# Create dummy secrey key so we can use sessions
app
.
config
[
'SECRET_KEY'
]
=
'123456790'
app
.
config
[
'FLASK_ADMIN_SWATCH'
]
=
'
F
latly'
app
.
config
[
'FLASK_ADMIN_SWATCH'
]
=
'
f
latly'
# Create in-memory database
app
.
config
[
'DATABASE_FILE'
]
=
'sample_db.sqlite'
...
...
@@ -48,6 +48,8 @@ class CustomView(ModelView):
class
UserAdmin
(
CustomView
):
column_searchable_list
=
(
'name'
,)
column_filters
=
(
'name'
,
'email'
)
can_export
=
True
export_types
=
[
'csv'
,
'xlsx'
]
# Flask views
...
...
@@ -62,8 +64,8 @@ def index():
admin
=
admin
.
Admin
(
app
,
'Example: Bootstrap4'
,
template_mode
=
'bootstrap4'
)
# Add views
admin
.
add_view
(
UserAdmin
(
User
,
db
.
session
))
admin
.
add_view
(
CustomView
(
Page
,
db
.
session
))
admin
.
add_view
(
UserAdmin
(
User
,
db
.
session
,
category
=
'Menu'
))
admin
.
add_view
(
CustomView
(
Page
,
db
.
session
,
category
=
'Menu'
))
def
build_sample_db
():
...
...
flask_admin/templates/bootstrap4/admin/base.html
View file @
4c443713
...
...
@@ -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
"
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 @
4c443713
{% macro menu_icon(item) -%}
{% set icon_type = item.get_icon_type() %}
{%- if icon_type %}
{% 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>
...
...
@@ -11,7 +11,7 @@
{% 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,9 +21,9 @@
{%- 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 %}"
>
<li
class=
"active dropdown{% if class_name %} {{ class_name
}}{% endif %}"
>
{% else -%}
<li
class=
"dropdown{% if class_name %} {{class_name
}}{% endif %}"
>
<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 %}
...
...
@@ -40,14 +40,16 @@
{{ 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
%}
>
{%- endif %}
<a
class=
"nav-link"
href=
"{{ child.get_url() }}"
{%
if
child
.
target
%}
<a
class=
"dropdown-item"
href=
"{{ child.get_url() }}"
{%
if
child
.
target
%}
target=
"{{ child.target }}"
{%
endif
%}
>
{{ menu_icon(child) }}{{ child.name }}
</a>
{%- endif %}
</li>
{%- endif %}
{%- endfor %}
...
...
@@ -58,11 +60,12 @@
{%- 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 %}"
>
<li
class=
"active{% if class_name %} {{ class_name
}}{% endif %}"
>
{%- else %}
<li
{%
if
class_name
%}
class=
"{{class_name
}}"
{%
endif
%}
>
<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>
<a
class=
"nav-link"
href=
"{{ item.get_url() }}"
{%
if
item
.
target
%}
target=
"{{ item.target }}"
{%
endif
%}
>
{{ menu_icon(item) }}{{ item.name }}
</a>
</li>
{%- endif -%}
{% endif -%}
...
...
flask_admin/templates/bootstrap4/admin/model/layout.html
View file @
4c443713
...
...
@@ -22,7 +22,7 @@
</li>
{% else %}
<li>
<a
href=
"{{ get_url('.export', export_type=admin_view.export_types[0], **request.args) }}"
<a
class=
"nav-link"
href=
"{{ get_url('.export', export_type=admin_view.export_types[0], **request.args) }}"
title=
"{{ _gettext('Export') }}"
>
{{ _gettext('Export') }}
</a>
</li>
{% endif %}
...
...
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