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
a70cf604
Commit
a70cf604
authored
Jul 06, 2015
by
Paul Brown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add file_admin modals, simplify existing modals
parent
27f9baff
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
336 additions
and
80 deletions
+336
-80
fileadmin.py
flask_admin/contrib/fileadmin.py
+26
-9
edit.html
flask_admin/templates/bootstrap2/admin/file/edit.html
+34
-5
form.html
flask_admin/templates/bootstrap2/admin/file/form.html
+24
-3
list.html
flask_admin/templates/bootstrap2/admin/file/list.html
+38
-9
rename.html
flask_admin/templates/bootstrap2/admin/file/rename.html
+26
-3
lib.html
flask_admin/templates/bootstrap2/admin/lib.html
+2
-2
create.html
flask_admin/templates/bootstrap2/admin/model/create.html
+3
-6
edit.html
flask_admin/templates/bootstrap2/admin/model/edit.html
+20
-7
edit.html
flask_admin/templates/bootstrap3/admin/file/edit.html
+39
-5
form.html
flask_admin/templates/bootstrap3/admin/file/form.html
+29
-3
list.html
flask_admin/templates/bootstrap3/admin/file/list.html
+38
-9
rename.html
flask_admin/templates/bootstrap3/admin/file/rename.html
+30
-4
lib.html
flask_admin/templates/bootstrap3/admin/lib.html
+2
-2
create.html
flask_admin/templates/bootstrap3/admin/model/create.html
+4
-7
edit.html
flask_admin/templates/bootstrap3/admin/model/edit.html
+19
-6
list.html
flask_admin/templates/bootstrap3/admin/model/list.html
+2
-0
No files found.
flask_admin/contrib/fileadmin.py
View file @
a70cf604
...
@@ -136,6 +136,19 @@ class FileAdmin(BaseView, ActionsMixin):
...
@@ -136,6 +136,19 @@ class FileAdmin(BaseView, ActionsMixin):
"""
"""
# Modals
rename_modal
=
False
"""Setting this to true will display the rename view as a modal dialog."""
upload_modal
=
False
"""Setting this to true will display the upload view as a modal dialog."""
mkdir_modal
=
False
"""Setting this to true will display the mkdir view as a modal dialog."""
edit_modal
=
False
"""Setting this to true will display the edit view as a modal dialog."""
def
__init__
(
self
,
base_path
,
base_url
=
None
,
def
__init__
(
self
,
base_path
,
base_url
=
None
,
name
=
None
,
category
=
None
,
endpoint
=
None
,
url
=
None
,
name
=
None
,
category
=
None
,
endpoint
=
None
,
url
=
None
,
verify_path
=
True
,
menu_class_name
=
None
,
menu_icon_type
=
None
,
menu_icon_value
=
None
):
verify_path
=
True
,
menu_class_name
=
None
,
menu_icon_type
=
None
,
menu_icon_value
=
None
):
...
@@ -422,7 +435,7 @@ class FileAdmin(BaseView, ActionsMixin):
...
@@ -422,7 +435,7 @@ class FileAdmin(BaseView, ActionsMixin):
Additional arguments
Additional arguments
"""
"""
if
not
path
:
if
not
path
:
return
self
.
get_url
(
endpoint
)
return
self
.
get_url
(
endpoint
,
**
kwargs
)
else
:
else
:
if
self
.
_on_windows
:
if
self
.
_on_windows
:
path
=
path
.
replace
(
'
\\
'
,
'/'
)
path
=
path
.
replace
(
'
\\
'
,
'/'
)
...
@@ -431,7 +444,7 @@ class FileAdmin(BaseView, ActionsMixin):
...
@@ -431,7 +444,7 @@ class FileAdmin(BaseView, ActionsMixin):
return
self
.
get_url
(
endpoint
,
**
kwargs
)
return
self
.
get_url
(
endpoint
,
**
kwargs
)
def
_get_file_url
(
self
,
path
):
def
_get_file_url
(
self
,
path
,
**
kwargs
):
"""
"""
Return static file url
Return static file url
...
@@ -443,7 +456,7 @@ class FileAdmin(BaseView, ActionsMixin):
...
@@ -443,7 +456,7 @@ class FileAdmin(BaseView, ActionsMixin):
else
:
else
:
route
=
'.download'
route
=
'.download'
return
self
.
get_url
(
route
,
path
=
path
)
return
self
.
get_url
(
route
,
path
=
path
,
**
kwargs
)
def
_normalize_path
(
self
,
path
):
def
_normalize_path
(
self
,
path
):
"""
"""
...
@@ -641,11 +654,14 @@ class FileAdmin(BaseView, ActionsMixin):
...
@@ -641,11 +654,14 @@ class FileAdmin(BaseView, ActionsMixin):
if
self
.
validate_form
(
form
):
if
self
.
validate_form
(
form
):
try
:
try
:
self
.
_save_form_files
(
directory
,
path
,
form
)
self
.
_save_form_files
(
directory
,
path
,
form
)
flash
(
gettext
(
'Successfully saved file:
%(name)
s'
,
name
=
form
.
upload
.
data
.
filename
))
return
redirect
(
self
.
_get_dir_url
(
'.index'
,
path
))
return
redirect
(
self
.
_get_dir_url
(
'.index'
,
path
))
except
Exception
as
ex
:
except
Exception
as
ex
:
flash
(
gettext
(
'Failed to save file:
%(error)
s'
,
error
=
ex
),
'error'
)
flash
(
gettext
(
'Failed to save file:
%(error)
s'
,
error
=
ex
),
'error'
)
return
self
.
render
(
self
.
upload_template
,
form
=
form
)
return
self
.
render
(
self
.
upload_template
,
form
=
form
,
header_text
=
gettext
(
'Upload File'
))
@
expose
(
'/download/<path:path>'
)
@
expose
(
'/download/<path:path>'
)
def
download
(
self
,
path
=
None
):
def
download
(
self
,
path
=
None
):
...
@@ -696,15 +712,16 @@ class FileAdmin(BaseView, ActionsMixin):
...
@@ -696,15 +712,16 @@ class FileAdmin(BaseView, ActionsMixin):
try
:
try
:
os
.
mkdir
(
op
.
join
(
directory
,
form
.
name
.
data
))
os
.
mkdir
(
op
.
join
(
directory
,
form
.
name
.
data
))
self
.
on_mkdir
(
directory
,
form
.
name
.
data
)
self
.
on_mkdir
(
directory
,
form
.
name
.
data
)
flash
(
gettext
(
'Successfully created directory:
%(directory)
s'
,
directory
=
form
.
name
.
data
))
return
redirect
(
dir_url
)
return
redirect
(
dir_url
)
except
Exception
as
ex
:
except
Exception
as
ex
:
flash
(
gettext
(
'Failed to create directory:
%(error)
s'
,
error
=
ex
),
'error'
)
flash
(
gettext
(
'Failed to create directory:
%(error)
s'
,
error
=
ex
),
'error'
)
else
:
else
:
helpers
.
flash_errors
(
form
,
message
=
'Failed to create directory:
%(error)
s'
)
helpers
.
flash_errors
(
form
,
message
=
'Failed to create directory:
%(error)
s'
)
return
self
.
render
(
self
.
mkdir_template
,
return
self
.
render
(
self
.
mkdir_template
,
form
=
form
,
dir_url
=
dir_url
,
form
=
form
,
header_text
=
gettext
(
'Create Directory'
))
dir_url
=
dir_url
)
@
expose
(
'/delete/'
,
methods
=
(
'POST'
,))
@
expose
(
'/delete/'
,
methods
=
(
'POST'
,))
def
delete
(
self
):
def
delete
(
self
):
...
@@ -789,8 +806,8 @@ class FileAdmin(BaseView, ActionsMixin):
...
@@ -789,8 +806,8 @@ class FileAdmin(BaseView, ActionsMixin):
os
.
rename
(
full_path
,
op
.
join
(
dir_base
,
filename
))
os
.
rename
(
full_path
,
op
.
join
(
dir_base
,
filename
))
self
.
on_rename
(
full_path
,
dir_base
,
filename
)
self
.
on_rename
(
full_path
,
dir_base
,
filename
)
flash
(
gettext
(
'Successfully renamed "
%(src)
s" to "
%(dst)
s"'
,
flash
(
gettext
(
'Successfully renamed "
%(src)
s" to "
%(dst)
s"'
,
src
=
op
.
basename
(
path
),
src
=
op
.
basename
(
path
),
dst
=
filename
))
dst
=
filename
))
except
Exception
as
ex
:
except
Exception
as
ex
:
flash
(
gettext
(
'Failed to rename:
%(error)
s'
,
error
=
ex
),
'error'
)
flash
(
gettext
(
'Failed to rename:
%(error)
s'
,
error
=
ex
),
'error'
)
...
...
flask_admin/templates/bootstrap2/admin/file/edit.html
View file @
a70cf604
{% extends 'admin/master.html' %}
{%- if not request.args.get('modal') -%}
{% extends 'admin/master.html' %}
{%- endif -%}
{% import 'admin/lib.html' as lib with context %}
{% import 'admin/lib.html' as lib with context %}
{% block body %}
{% macro check_error(error) %}
<h3>
{{ _gettext('You are editing %(path)s', path=path) }}
</h3>
{% if error %}
{% if error %}
<span>
This file cannot be edited for now.
</span>
<span>
{{ _gettext('This file cannot be edited for now.') }}
</span>
{% else %}
{% else %}
{{ lib.render_form(form, dir_url
) }}
{{ caller(
) }}
{% endif %}
{% endif %}
{% endmacro %}
{% block body %}
{% call check_error(error) %}
{%- if request.args.get('modal') -%}
{# content added to modal-content #}
{{ lib.render_form(form, dir_url, action=request.url, is_modal=True) }}
{%- else -%}
{% block header_text -%}
<h3>
{{ _gettext('Editing %(path)s', path=path) }}
<h3>
{%- endblock %}
{{ lib.render_form(form, dir_url) }}
{%- endif -%}
{% endcall %}
{% endblock %}
{% block tail %}
{%- if request.args.get('modal') -%}
<script>
// fill the header of modal dynamically
$
(
'.modal-header h3'
).
html
(
'{{ self.header_text() }}'
);
// fixes "remote modal shows same content every time"
$
(
'.modal'
).
on
(
'hidden'
,
function
()
{
$
(
this
).
removeData
(
'modal'
);
});
</script>
{%- endif -%}
{% endblock %}
{% endblock %}
flask_admin/templates/bootstrap2/admin/file/form.html
View file @
a70cf604
{% extends 'admin/master.html' %}
{%- if not request.args.get('modal') -%}
{% extends 'admin/master.html' %}
{%- endif -%}
{% import 'admin/lib.html' as lib with context %}
{% import 'admin/lib.html' as lib with context %}
{% block body %}
{% block body %}
{{ lib.render_form(form, dir_url) }}
{%- if request.args.get('modal') -%}
{% endblock %}
{{ lib.render_form(form, dir_url, action=request.url, is_modal=True) }}
\ No newline at end of file
{%- else -%}
<h3>
{{ header_text }}
</h3>
{{ lib.render_form(form, dir_url) }}
{%- endif -%}
{% endblock %}
{% block tail %}
{%- if request.args.get('modal') -%}
<script>
// fill the header of modal dynamically
$
(
'.modal-header h3'
).
html
(
'{{ header_text }}'
);
// fixes "remote modal shows same content every time"
$
(
'.modal'
).
on
(
'hidden'
,
function
()
{
$
(
this
).
removeData
(
'modal'
);
});
</script>
{%- endif -%}
{% endblock %}
flask_admin/templates/bootstrap2/admin/file/list.html
View file @
a70cf604
...
@@ -50,9 +50,15 @@
...
@@ -50,9 +50,15 @@
<td>
<td>
{% block list_row_actions scoped %}
{% block list_row_actions scoped %}
{% if admin_view.can_rename and path and name != '..' %}
{% if admin_view.can_rename and path and name != '..' %}
<a
class=
"icon"
href=
"{{ get_url('.rename', path=path) }}"
>
{%- if admin_view.rename_modal -%}
<i
class=
"fa fa-pencil icon-pencil"
></i>
{{ lib.add_modal_button(url=get_url('.rename', path=path, modal=True),
</a>
title=_gettext('Rename File'),
content='
<i
class=
"fa fa-pencil icon-pencil"
></i>
') }}
{% else %}
<a
class=
"icon"
href=
"{{ get_url('.rename', path=path) }}"
title=
"{{ _gettext('Rename File') }}"
>
<i
class=
"fa fa-pencil icon-pencil"
></i>
</a>
{%- endif -%}
{% endif %}
{% endif %}
{%- if admin_view.can_delete and path -%}
{%- if admin_view.can_delete and path -%}
{% if is_dir %}
{% if is_dir %}
...
@@ -86,9 +92,14 @@
...
@@ -86,9 +92,14 @@
{% else %}
{% else %}
<td>
<td>
{% if admin_view.can_download %}
{% if admin_view.can_download %}
<a
href=
"{{ get_file_url(path)|safe }}"
>
{{ name }}
</a>
{%- if admin_view.edit_modal and admin_view.is_file_editable(path) -%}
{{ lib.add_modal_button(url=get_file_url(path, modal=True)|safe,
btn_class='', content=name) }}
{% else %}
<a
href=
"{{ get_file_url(path)|safe }}"
>
{{ name }}
</a>
{%- endif -%}
{% else %}
{% else %}
{{ name }}
{{ name }}
{% endif %}
{% endif %}
</td>
</td>
<td>
<td>
...
@@ -104,12 +115,24 @@
...
@@ -104,12 +115,24 @@
<div
class=
"btn-toolbar"
>
<div
class=
"btn-toolbar"
>
{% if admin_view.can_upload %}
{% if admin_view.can_upload %}
<div
class=
"btn-group"
>
<div
class=
"btn-group"
>
<a
class=
"btn btn-large"
href=
"{{ get_dir_url('.upload', path=dir_path) }}"
>
{{ _gettext('Upload File') }}
</a>
{%- if admin_view.upload_modal -%}
{{ lib.add_modal_button(url=get_dir_url('.upload', path=dir_path, modal=True),
btn_class="btn btn-large",
content=_gettext('Upload File')) }}
{% else %}
<a
class=
"btn btn-large"
href=
"{{ get_dir_url('.upload', path=dir_path) }}"
>
{{ _gettext('Upload File') }}
</a>
{%- endif -%}
</div>
</div>
{% endif %}
{% endif %}
{% if admin_view.can_mkdir %}
{% if admin_view.can_mkdir %}
<div
class=
"btn-group"
>
<div
class=
"btn-group"
>
<a
class=
"btn btn-large"
href=
"{{ get_dir_url('.mkdir', path=dir_path) }}"
>
{{ _gettext('Create Directory') }}
</a>
{%- if admin_view.mkdir_modal -%}
{{ lib.add_modal_button(url=get_dir_url('.mkdir', path=dir_path, modal=True),
btn_class="btn btn-large",
content=_gettext('Create Directory')) }}
{% else %}
<a
class=
"btn btn-large"
href=
"{{ get_dir_url('.mkdir', path=dir_path) }}"
>
{{ _gettext('Create Directory') }}
</a>
{%- endif -%}
</div>
</div>
{% endif %}
{% endif %}
{% if actions %}
{% if actions %}
...
@@ -119,14 +142,20 @@
...
@@ -119,14 +142,20 @@
{% endif %}
{% endif %}
</div>
</div>
{% endblock %}
{% endblock %}
{% block actions %}
{% block actions %}
{{ actionslib.form(actions, get_url('.action_view')) }}
{{ actionslib.form(actions, get_url('.action_view')) }}
{% endblock %}
{% endblock %}
{%- if admin_view.rename_modal or admin_view.mkdir_modal
or admin_view.upload_modal or admin_view.edit_modal -%}
{{ lib.add_modal_window() }}
{%- endif -%}
{% endblock %}
{% endblock %}
{% block tail %}
{% block tail %}
{{ super() }}
{{ super() }}
{{ actionslib.script(_gettext('Please select at least one file.'),
{{ actionslib.script(_gettext('Please select at least one file.'),
actions,
actions,
actions_confirmation) }}
actions_confirmation) }}
{% endblock %}
{% endblock %}
flask_admin/templates/bootstrap2/admin/file/rename.html
View file @
a70cf604
{% extends 'admin/master.html' %}
{%- if not request.args.get('modal') -%}
{% extends 'admin/master.html' %}
{%- endif -%}
{% import 'admin/lib.html' as lib with context %}
{% import 'admin/lib.html' as lib with context %}
{% block body %}
{% block body %}
<h3>
{{ _gettext('Please provide new name for %(name)s', name=name) }}
</h3>
{%- if request.args.get('modal') -%}
{# content added to modal-content #}
{{ lib.render_form(form, dir_url, action=request.url, is_modal=True) }}
{%- else -%}
{% block header_text -%}
{{ _gettext('Rename %(name)s', name=name) }}
{%- endblock %}
{{ lib.render_form(form, dir_url) }}
{{ lib.render_form(form, dir_url) }}
{% endblock %}
{%- endif -%}
\ No newline at end of file
{% endblock %}
{% block tail %}
{%- if request.args.get('modal') -%}
<script>
// fill the header of modal dynamically
$
(
'.modal-header h3'
).
html
(
'{{ self.header_text() }}'
);
// fixes "remote modal shows same content every time"
$
(
'.modal'
).
on
(
'hidden'
,
function
()
{
$
(
this
).
removeData
(
'modal'
);
});
</script>
{%- endif -%}
{% endblock %}
flask_admin/templates/bootstrap2/admin/lib.html
View file @
a70cf604
...
@@ -113,8 +113,8 @@
...
@@ -113,8 +113,8 @@
</div>
</div>
{% endmacro %}
{% endmacro %}
{% macro add_modal_button(url='', title='', content='', modal_window_id='fa_modal_window') %}
{% macro add_modal_button(url='', title='', content='', modal_window_id='fa_modal_window'
, btn_class='icon'
) %}
<a
class=
"
icon
"
href=
"#"
data-toggle=
"modal"
title=
"{{ title }}"
data-target=
"#{{ modal_window_id }}"
data-remote=
"{{ url }}"
>
<a
class=
"
{{ btn_class }}
"
href=
"#"
data-toggle=
"modal"
title=
"{{ title }}"
data-target=
"#{{ modal_window_id }}"
data-remote=
"{{ url }}"
>
{{ content|safe }}
{{ content|safe }}
</a>
</a>
{% endmacro %}
{% endmacro %}
...
...
flask_admin/templates/bootstrap2/admin/model/create.html
View file @
a70cf604
...
@@ -17,8 +17,7 @@
...
@@ -17,8 +17,7 @@
{% block body %}
{% block body %}
{%- if request.args.get('modal') -%}
{%- if request.args.get('modal') -%}
{{ lib.render_form(form, return_url, extra=None, form_opts=form_opts,
{{ lib.render_form(form, return_url, extra=None, form_opts=form_opts,
action=url_for('.create_view', url=return_url),
action=request.url, is_modal=True) }}
is_modal=request.args.get('modal')) }}
{%- else -%}
{%- else -%}
{% block navlinks %}
{% block navlinks %}
<ul
class=
"nav nav-tabs"
>
<ul
class=
"nav nav-tabs"
>
...
@@ -31,9 +30,7 @@
...
@@ -31,9 +30,7 @@
</ul>
</ul>
{% endblock %}
{% endblock %}
{{ lib.render_form(form, return_url, extra(), form_opts=form_opts,
{{ lib.render_form(form, return_url, extra(), form_opts=form_opts) }}
action=url_for('.create_view', url=return_url),
is_modal=request.args.get('modal')) }}
{%- endif -%}
{%- endif -%}
{% endblock %}
{% endblock %}
...
@@ -41,7 +38,7 @@
...
@@ -41,7 +38,7 @@
{%- if request.args.get('modal') -%}
{%- if request.args.get('modal') -%}
<script>
<script>
// fill the header of modal dynamically
// fill the header of modal dynamically
$
(
'.modal-header h3'
).
html
(
'{% block
modal_header
%}<h3>{{ _gettext('
Create
New
Record
') }}</h3>{% endblock %}'
);
$
(
'.modal-header h3'
).
html
(
'{% block
header_text
%}<h3>{{ _gettext('
Create
New
Record
') }}</h3>{% endblock %}'
);
// fixes "remote modal shows same content every time"
// fixes "remote modal shows same content every time"
$
(
'.modal'
).
on
(
'hidden'
,
function
()
{
$
(
'.modal'
).
on
(
'hidden'
,
function
()
{
...
...
flask_admin/templates/bootstrap2/admin/model/edit.html
View file @
a70cf604
...
@@ -18,12 +18,23 @@
...
@@ -18,12 +18,23 @@
{%- if request.args.get('modal') -%}
{%- if request.args.get('modal') -%}
{# remove save and continue button for modal (it won't function properly) #}
{# remove save and continue button for modal (it won't function properly) #}
{{ lib.render_form(form, return_url, extra=None, form_opts=form_opts,
{{ lib.render_form(form, return_url, extra=None, form_opts=form_opts,
action=url_for('.edit_view', id=request.args.get('id'), url=return_url),
action=request.url, is_modal=True) }}
is_modal=request.args.get('modal')) }}
{%- else -%}
{%- else -%}
{{ lib.render_form(form, return_url, extra(), form_opts,
{% block navlinks %}
action=url_for('.edit_view', id=request.args.get('id'), url=return_url),
<ul
class=
"nav nav-tabs"
>
is_modal=request.args.get('modal')) }}
<li>
<a
href=
"{{ return_url }}"
>
{{ _gettext('List') }}
</a>
</li>
<li>
<a
href=
"{{ get_url('.create_view', url=return_url) }}"
>
{{ _gettext('Create') }}
</a>
</li>
<li
class=
"active"
>
<a
href=
"javascript:void(0)"
>
{{ _gettext('Edit') }}
</a>
</li>
</ul>
{% endblock %}
{{ lib.render_form(form, return_url, extra(), form_opts) }}
{%- endif -%}
{%- endif -%}
{% endblock %}
{% endblock %}
...
@@ -31,7 +42,9 @@
...
@@ -31,7 +42,9 @@
{%- if request.args.get('modal') -%}
{%- if request.args.get('modal') -%}
<script>
<script>
// fill the header of modal dynamically
// fill the header of modal dynamically
$
(
'.modal-header h3'
).
html
(
'{% block modal_header %}<h3>{{ _gettext('
Edit
Record
') + '
#
' + request.args.get('
id
') }}</h3>{% endblock %}'
);
$
(
'.modal-header h3'
).
html
(
'{% block header_text -%}
{{ _gettext('
Edit
Record
') + '
#
' + request.args.get('
id
') }}
{%- endblock %}'
);
// fixes "remote modal shows same content every time"
// fixes "remote modal shows same content every time"
$
(
'.modal'
).
on
(
'hidden'
,
function
()
{
$
(
'.modal'
).
on
(
'hidden'
,
function
()
{
...
@@ -47,4 +60,4 @@
...
@@ -47,4 +60,4 @@
{{ super() }}
{{ super() }}
{{ lib.form_js() }}
{{ lib.form_js() }}
{%- endif -%}
{%- endif -%}
{% endblock %}
{% endblock %}
\ No newline at end of file
flask_admin/templates/bootstrap3/admin/file/edit.html
View file @
a70cf604
{% extends 'admin/master.html' %}
{%- if not request.args.get('modal') -%}
{% extends 'admin/master.html' %}
{%- endif -%}
{% import 'admin/lib.html' as lib with context %}
{% import 'admin/lib.html' as lib with context %}
{% block body %}
{% macro check_error(error) %}
<h3>
{{ _gettext('You are editing %(path)s', path=path) }}
</h3>
{% if error %}
{% if error %}
<span>
This file cannot be edited for now.
</span>
<span>
{{ _gettext('This file cannot be edited for now.') }}
</span>
{% else %}
{% else %}
{{ lib.render_form(form, dir_url
) }}
{{ caller(
) }}
{% endif %}
{% endif %}
{% endmacro %}
{% block body %}
{%- if request.args.get('modal') -%}
{# content added to modal-content #}
<div
class=
"modal-header"
>
<button
type=
"button"
class=
"close"
data-dismiss=
"modal"
aria-label=
"Close"
><span
aria-hidden=
"true"
>
×
</span></button>
{% block header_text %}
<h3>
{{ _gettext('Editing %(path)s', path=path) }}
</h3>
{% endblock %}
</div>
<div
class=
"modal-body"
>
{% call check_error(error) %}
{{ lib.render_form(form, dir_url, action=request.url, is_modal=True) }}
{% endcall %}
</div>
{%- else -%}
{{ self.header_text() }}
{% call check_error(error) %}
{{ lib.render_form(form, dir_url) }}
{% endcall %}
{%- endif -%}
{% endblock %}
{% block tail %}
{%- if request.args.get('modal') -%}
<script>
// fixes "remote modal shows same content every time", avoiding the flicker
$
(
'body'
).
on
(
'hidden.bs.modal'
,
'.modal'
,
function
()
{
$
(
this
).
removeData
(
'bs.modal'
).
find
(
".modal-content"
).
empty
();
});
</script>
{%- endif -%}
{% endblock %}
{% endblock %}
flask_admin/templates/bootstrap3/admin/file/form.html
View file @
a70cf604
{% extends 'admin/master.html' %}
{%- if not request.args.get('modal') -%}
{% extends 'admin/master.html' %}
{%- endif -%}
{% import 'admin/lib.html' as lib with context %}
{% import 'admin/lib.html' as lib with context %}
{% block body %}
{% block body %}
{{ lib.render_form(form, dir_url) }}
{%- if request.args.get('modal') -%}
{% endblock %}
{# content added to modal-content #}
\ No newline at end of file
<div
class=
"modal-header"
>
<button
type=
"button"
class=
"close"
data-dismiss=
"modal"
aria-label=
"Close"
><span
aria-hidden=
"true"
>
×
</span></button>
<h3>
{{ header_text }}
</h3>
</div>
<div
class=
"modal-body"
>
{{ lib.render_form(form, dir_url, action=request.url, is_modal=True) }}
</div>
{%- else -%}
<h3>
{{ header_text }}
</h3>
{{ lib.render_form(form, dir_url) }}
{%- endif -%}
{% endblock %}
{% block tail %}
{%- if request.args.get('modal') -%}
<script>
// fixes "remote modal shows same content every time", avoiding the flicker
$
(
'body'
).
on
(
'hidden.bs.modal'
,
'.modal'
,
function
()
{
$
(
this
).
removeData
(
'bs.modal'
).
find
(
".modal-content"
).
empty
();
});
</script>
{%- endif -%}
{% endblock %}
flask_admin/templates/bootstrap3/admin/file/list.html
View file @
a70cf604
...
@@ -50,9 +50,15 @@
...
@@ -50,9 +50,15 @@
<td>
<td>
{% block list_row_actions scoped %}
{% block list_row_actions scoped %}
{% if admin_view.can_rename and path and name != '..' %}
{% if admin_view.can_rename and path and name != '..' %}
<a
class=
"icon"
href=
"{{ get_url('.rename', path=path) }}"
>
{%- if admin_view.rename_modal -%}
<i
class=
"fa fa-pencil glyphicon glyphicon-pencil"
></i>
{{ lib.add_modal_button(url=get_url('.rename', path=path, modal=True),
</a>
title=_gettext('Rename File'),
content='
<i
class=
"fa fa-pencil glyphicon glyphicon-pencil"
></i>
') }}
{% else %}
<a
class=
"icon"
href=
"{{ get_url('.rename', path=path) }}"
title=
"{{ _gettext('Rename File') }}"
>
<i
class=
"fa fa-pencil glyphicon glyphicon-pencil"
></i>
</a>
{%- endif -%}
{% endif %}
{% endif %}
{%- if admin_view.can_delete and path -%}
{%- if admin_view.can_delete and path -%}
{% if is_dir %}
{% if is_dir %}
...
@@ -86,9 +92,14 @@
...
@@ -86,9 +92,14 @@
{% else %}
{% else %}
<td>
<td>
{% if admin_view.can_download %}
{% if admin_view.can_download %}
<a
href=
"{{ get_file_url(path)|safe }}"
>
{{ name }}
</a>
{%- if admin_view.edit_modal and admin_view.is_file_editable(path) -%}
{{ lib.add_modal_button(url=get_file_url(path, modal=True)|safe,
btn_class='', content=name) }}
{% else %}
<a
href=
"{{ get_file_url(path)|safe }}"
>
{{ name }}
</a>
{%- endif -%}
{% else %}
{% else %}
{{ name }}
{{ name }}
{% endif %}
{% endif %}
</td>
</td>
<td>
<td>
...
@@ -104,12 +115,24 @@
...
@@ -104,12 +115,24 @@
<div
class=
"btn-toolbar"
>
<div
class=
"btn-toolbar"
>
{% if admin_view.can_upload %}
{% if admin_view.can_upload %}
<div
class=
"btn-group"
>
<div
class=
"btn-group"
>
<a
class=
"btn btn-default btn-large"
href=
"{{ get_dir_url('.upload', path=dir_path) }}"
>
{{ _gettext('Upload File') }}
</a>
{%- if admin_view.upload_modal -%}
{{ lib.add_modal_button(url=get_dir_url('.upload', path=dir_path, modal=True),
btn_class="btn btn-default btn-large",
content=_gettext('Upload File')) }}
{% else %}
<a
class=
"btn btn-default btn-large"
href=
"{{ get_dir_url('.upload', path=dir_path) }}"
>
{{ _gettext('Upload File') }}
</a>
{%- endif -%}
</div>
</div>
{% endif %}
{% endif %}
{% if admin_view.can_mkdir %}
{% if admin_view.can_mkdir %}
<div
class=
"btn-group"
>
<div
class=
"btn-group"
>
<a
class=
"btn btn-default btn-large"
href=
"{{ get_dir_url('.mkdir', path=dir_path) }}"
>
{{ _gettext('Create Directory') }}
</a>
{%- if admin_view.mkdir_modal -%}
{{ lib.add_modal_button(url=get_dir_url('.mkdir', path=dir_path, modal=True),
btn_class="btn btn-default btn-large",
content=_gettext('Create Directory')) }}
{% else %}
<a
class=
"btn btn-default btn-large"
href=
"{{ get_dir_url('.mkdir', path=dir_path) }}"
>
{{ _gettext('Create Directory') }}
</a>
{%- endif -%}
</div>
</div>
{% endif %}
{% endif %}
{% if actions %}
{% if actions %}
...
@@ -119,14 +142,20 @@
...
@@ -119,14 +142,20 @@
{% endif %}
{% endif %}
</div>
</div>
{% endblock %}
{% endblock %}
{% block actions %}
{% block actions %}
{{ actionslib.form(actions, get_url('.action_view')) }}
{{ actionslib.form(actions, get_url('.action_view')) }}
{% endblock %}
{% endblock %}
{%- if admin_view.rename_modal or admin_view.mkdir_modal
or admin_view.upload_modal or admin_view.edit_modal -%}
{{ lib.add_modal_window() }}
{%- endif -%}
{% endblock %}
{% endblock %}
{% block tail %}
{% block tail %}
{{ super() }}
{{ super() }}
{{ actionslib.script(_gettext('Please select at least one file.'),
{{ actionslib.script(_gettext('Please select at least one file.'),
actions,
actions,
actions_confirmation) }}
actions_confirmation) }}
{% endblock %}
{% endblock %}
flask_admin/templates/bootstrap3/admin/file/rename.html
View file @
a70cf604
{% extends 'admin/master.html' %}
{%- if not request.args.get('modal') -%}
{% extends 'admin/master.html' %}
{%- endif -%}
{% import 'admin/lib.html' as lib with context %}
{% import 'admin/lib.html' as lib with context %}
{% block body %}
{% block body %}
<h3>
{{ _gettext('Please provide new name for %(name)s', name=name) }}
</h3>
{%- if request.args.get('modal') -%}
{{ lib.render_form(form, dir_url) }}
{# content added to modal-content #}
{% endblock %}
<div
class=
"modal-header"
>
\ No newline at end of file
<button
type=
"button"
class=
"close"
data-dismiss=
"modal"
aria-label=
"Close"
><span
aria-hidden=
"true"
>
×
</span></button>
{% block header_text %}
<h3>
{{ _gettext('Rename %(name)s', name=name) }}
</h3>
{% endblock %}
</div>
<div
class=
"modal-body"
>
{{ lib.render_form(form, dir_url, action=request.url, is_modal=True) }}
</div>
{%- else -%}
<h3>
{{ self.header_text() }}
</h3>
{{ lib.render_form(form, dir_url) }}
{%- endif -%}
{% endblock %}
{% block tail %}
{%- if request.args.get('modal') -%}
<script>
// fixes "remote modal shows same content every time", avoiding the flicker
$
(
'body'
).
on
(
'hidden.bs.modal'
,
'.modal'
,
function
()
{
$
(
this
).
removeData
(
'bs.modal'
).
find
(
".modal-content"
).
empty
();
});
</script>
{%- endif -%}
{% endblock %}
flask_admin/templates/bootstrap3/admin/lib.html
View file @
a70cf604
...
@@ -108,8 +108,8 @@
...
@@ -108,8 +108,8 @@
</div>
</div>
{% endmacro %}
{% endmacro %}
{% macro add_modal_button(url='', title='', content='', modal_window_id='fa_modal_window') %}
{% macro add_modal_button(url='', title='', content='', modal_window_id='fa_modal_window'
, btn_class='icon'
) %}
<a
class=
"
icon
"
data-target=
"#{{ modal_window_id }}"
title=
"{{ title }}"
href=
"{{ url }}"
data-toggle=
"modal"
>
<a
class=
"
{{ btn_class }}
"
data-target=
"#{{ modal_window_id }}"
title=
"{{ title }}"
href=
"{{ url }}"
data-toggle=
"modal"
>
{{ content|safe }}
{{ content|safe }}
</a>
</a>
{% endmacro %}
{% endmacro %}
...
...
flask_admin/templates/bootstrap3/admin/model/create.html
View file @
a70cf604
...
@@ -18,13 +18,12 @@
...
@@ -18,13 +18,12 @@
{%- if request.args.get('modal') -%}
{%- if request.args.get('modal') -%}
<div
class=
"modal-header"
>
<div
class=
"modal-header"
>
<button
type=
"button"
class=
"close"
data-dismiss=
"modal"
aria-label=
"Close"
><span
aria-hidden=
"true"
>
×
</span></button>
<button
type=
"button"
class=
"close"
data-dismiss=
"modal"
aria-label=
"Close"
><span
aria-hidden=
"true"
>
×
</span></button>
{% block
modal_header
%}
<h3>
{{ _gettext('Create New Record') }}
</h3>
{% endblock %}
{% block
header_text
%}
<h3>
{{ _gettext('Create New Record') }}
</h3>
{% endblock %}
</div>
</div>
<div
class=
"modal-body"
>
<div
class=
"modal-body"
>
{# remove save and continue button for modal (it won't function properly) #}
{# remove save and continue button for modal (it won't function properly) #}
{{ lib.render_form(form, return_url, extra=None, form_opts=form_opts,
{{ lib.render_form(form, return_url, extra(), form_opts=form_opts,
action=url_for('.create_view', url=return_url),
action=request.url, is_modal=True) }}
is_modal=request.args.get('modal')) }}
</div>
</div>
{%- else -%}
{%- else -%}
{% block navlinks %}
{% block navlinks %}
...
@@ -38,9 +37,7 @@
...
@@ -38,9 +37,7 @@
</ul>
</ul>
{% endblock %}
{% endblock %}
{{ lib.render_form(form, return_url, extra(), form_opts=form_opts,
{{ lib.render_form(form, return_url, extra(), form_opts=form_opts) }}
action=url_for('.create_view', url=return_url),
is_modal=request.args.get('modal')) }}
{%- endif -%}
{%- endif -%}
{% endblock %}
{% endblock %}
...
...
flask_admin/templates/bootstrap3/admin/model/edit.html
View file @
a70cf604
...
@@ -19,18 +19,31 @@
...
@@ -19,18 +19,31 @@
{# content added to modal-content #}
{# content added to modal-content #}
<div
class=
"modal-header"
>
<div
class=
"modal-header"
>
<button
type=
"button"
class=
"close"
data-dismiss=
"modal"
aria-label=
"Close"
><span
aria-hidden=
"true"
>
×
</span></button>
<button
type=
"button"
class=
"close"
data-dismiss=
"modal"
aria-label=
"Close"
><span
aria-hidden=
"true"
>
×
</span></button>
{% block modal_header %}
<h3>
{{ _gettext('Edit Record') + ' #' + request.args.get('id') }}
</h3>
{% endblock %}
{% block header_text %}
<h3>
{{ _gettext('Edit Record') + ' #' + request.args.get('id') }}
</h3>
{% endblock %}
</div>
</div>
<div
class=
"modal-body"
>
<div
class=
"modal-body"
>
{# remove save and continue button for modal (it won't function properly) #}
{# remove save and continue button for modal (it won't function properly) #}
{{ lib.render_form(form, return_url, extra=None, form_opts=form_opts,
{{ lib.render_form(form, return_url, extra=None, form_opts=form_opts,
action=url_for('.edit_view', id=request.args.get('id'), url=return_url),
action=request.url, is_modal=True) }}
is_modal=request.args.get('modal')) }}
</div>
</div>
{%- else -%}
{%- else -%}
{{ lib.render_form(form, return_url, extra(), form_opts,
{% block navlinks %}
action=url_for('.edit_view', id=request.args.get('id'), url=return_url),
<ul
class=
"nav nav-tabs"
>
is_modal=request.args.get('modal')) }}
<li>
<a
href=
"{{ return_url }}"
>
{{ _gettext('List') }}
</a>
</li>
<li>
<a
href=
"{{ get_url('.create_view', url=return_url) }}"
>
{{ _gettext('Create') }}
</a>
</li>
<li
class=
"active"
>
<a
href=
"javascript:void(0)"
>
{{ _gettext('Edit') }}
</a>
</li>
</ul>
{% endblock %}
{{ lib.render_form(form, return_url, extra(), form_opts) }}
{%- endif -%}
{%- endif -%}
{% endblock %}
{% endblock %}
...
...
flask_admin/templates/bootstrap3/admin/model/list.html
View file @
a70cf604
...
@@ -168,7 +168,9 @@
...
@@ -168,7 +168,9 @@
{% endblock %}
{% endblock %}
{% endblock %}
{% endblock %}
{% block actions %}
{{ actionlib.form(actions, get_url('.action_view')) }}
{{ actionlib.form(actions, get_url('.action_view')) }}
{% endblock %}
{%- if admin_view.edit_modal or admin_view.create_modal -%}
{%- if admin_view.edit_modal or admin_view.create_modal -%}
{{ lib.add_modal_window() }}
{{ lib.add_modal_window() }}
...
...
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