Commit e6baed0c authored by Paul Brown's avatar Paul Brown

move request.args.get('modal') into base, only use 'modal' in templates

parent 353e644e
......@@ -661,7 +661,8 @@ class FileAdmin(BaseView, ActionsMixin):
flash(gettext('Failed to save file: %(error)s', error=ex), 'error')
return self.render(self.upload_template, form=form,
header_text=gettext('Upload File'))
header_text=gettext('Upload File'),
modal=request.args.get('modal'))
@expose('/download/<path:path>')
def download(self, path=None):
......@@ -721,7 +722,8 @@ class FileAdmin(BaseView, ActionsMixin):
helpers.flash_errors(form, message='Failed to create directory: %(error)s')
return self.render(self.mkdir_template, form=form, dir_url=dir_url,
header_text=gettext('Create Directory'))
header_text=gettext('Create Directory'),
modal=request.args.get('modal'))
@expose('/delete/', methods=('POST',))
def delete(self):
......@@ -819,7 +821,8 @@ class FileAdmin(BaseView, ActionsMixin):
form=form,
path=op.dirname(path),
name=op.basename(path),
dir_url=return_url)
dir_url=return_url,
modal=request.args.get('modal'))
@expose('/edit/', methods=('GET', 'POST'))
def edit(self):
......@@ -887,7 +890,8 @@ class FileAdmin(BaseView, ActionsMixin):
form.content.data = content
return self.render(self.edit_template, dir_url=dir_url, path=path,
form=form, error=error)
form=form, error=error,
modal=request.args.get('modal'))
@expose('/action/', methods=('POST',))
def action_view(self):
......
......@@ -1611,7 +1611,8 @@ class BaseModelView(BaseView, ActionsMixin):
return self.render(self.create_template,
form=form,
form_opts=form_opts,
return_url=return_url)
return_url=return_url,
modal=request.args.get('modal'))
@expose('/edit/', methods=('GET', 'POST'))
def edit_view(self):
......@@ -1654,7 +1655,8 @@ class BaseModelView(BaseView, ActionsMixin):
model=model,
form=form,
form_opts=form_opts,
return_url=return_url)
return_url=return_url,
modal=request.args.get('modal'))
@expose('/delete/', methods=('POST',))
def delete_view(self):
......
{%- if not request.args.get('modal') -%}
{%- if not modal -%}
{% extends 'admin/master.html' %}
{%- endif -%}
{% import 'admin/lib.html' as lib with context %}
......@@ -13,7 +13,7 @@
{% block body %}
{% call check_error(error) %}
{%- if request.args.get('modal') -%}
{%- if modal -%}
{# content added to modal-content #}
{{ lib.render_form(form, dir_url, action=request.url, is_modal=True) }}
{%- else -%}
......@@ -26,7 +26,7 @@
{% endblock %}
{% block tail %}
{%- if request.args.get('modal') -%}
{%- if modal -%}
<script>
// fill the header of modal dynamically
$('.modal-header h3').html('{{ self.header_text() }}');
......
{%- if not request.args.get('modal') -%}
{%- if not modal -%}
{% extends 'admin/master.html' %}
{%- endif -%}
{% import 'admin/lib.html' as lib with context %}
{% block body %}
{%- if request.args.get('modal') -%}
{%- if modal -%}
{{ lib.render_form(form, dir_url, action=request.url, is_modal=True) }}
{%- else -%}
<h3>{{ header_text }}</h3>
......@@ -13,7 +13,7 @@
{% endblock %}
{% block tail %}
{%- if request.args.get('modal') -%}
{%- if modal -%}
<script>
// fill the header of modal dynamically
$('.modal-header h3').html('{{ header_text }}');
......
{%- if not request.args.get('modal') -%}
{%- if not modal -%}
{% extends 'admin/master.html' %}
{%- endif -%}
{% import 'admin/lib.html' as lib with context %}
{% block body %}
{%- if request.args.get('modal') -%}
{%- if modal -%}
{# content added to modal-content #}
{{ lib.render_form(form, dir_url, action=request.url, is_modal=True) }}
{%- else -%}
{% block header_text -%}
<h3>{% block header_text -%}
{{ _gettext('Rename %(name)s', name=name) }}
{%- endblock %}
{%- endblock %}</h3>
{{ lib.render_form(form, dir_url) }}
{%- endif -%}
{% endblock %}
{% block tail %}
{%- if request.args.get('modal') -%}
{%- if modal -%}
<script>
// fill the header of modal dynamically
$('.modal-header h3').html('{{ self.header_text() }}');
......
{%- if not request.args.get('modal') -%}
{%- if not modal -%}
{% extends 'admin/master.html' %}
{%- endif -%}
{% import 'admin/lib.html' as lib with context %}
......@@ -8,14 +8,14 @@
{% endmacro %}
{% block head %}
{%- if not request.args.get('modal') -%}
{%- if not modal -%}
{{ super() }}
{{ lib.form_css() }}
{%- endif -%}
{% endblock %}
{% block body %}
{%- if request.args.get('modal') -%}
{%- if modal -%}
{{ lib.render_form(form, return_url, extra=None, form_opts=form_opts,
action=request.url, is_modal=True) }}
{%- else -%}
......@@ -35,7 +35,7 @@
{% endblock %}
{% block tail %}
{%- if request.args.get('modal') -%}
{%- if modal -%}
<script>
// fill the header of modal dynamically
$('.modal-header h3').html('{% block header_text %}<h3>{{ _gettext('Create New Record') }}</h3>{% endblock %}');
......
{%- if not request.args.get('modal') -%}
{%- if not modal -%}
{% extends 'admin/master.html' %}
{%- endif -%}
{% import 'admin/lib.html' as lib with context %}
......@@ -8,14 +8,14 @@
{% endmacro %}
{% block head %}
{%- if not request.args.get('modal') -%}
{%- if not modal -%}
{{ super() }}
{{ lib.form_css() }}
{%- endif -%}
{% endblock %}
{% block body %}
{%- if request.args.get('modal') -%}
{%- if modal -%}
{# remove save and continue button for modal (it won't function properly) #}
{{ lib.render_form(form, return_url, extra=None, form_opts=form_opts,
action=request.url, is_modal=True) }}
......@@ -39,7 +39,7 @@
{% endblock %}
{% block tail %}
{%- if request.args.get('modal') -%}
{%- if modal -%}
<script>
// fill the header of modal dynamically
$('.modal-header h3').html('{% block header_text -%}
......
{%- if not request.args.get('modal') -%}
{%- if not modal -%}
{% extends 'admin/master.html' %}
{%- endif -%}
{% import 'admin/lib.html' as lib with context %}
......@@ -12,7 +12,7 @@
{% endmacro %}
{% block body %}
{%- if request.args.get('modal') -%}
{%- if 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">&times;</span></button>
......@@ -34,7 +34,7 @@
{% endblock %}
{% block tail %}
{%- if request.args.get('modal') -%}
{%- if modal -%}
<script>
// fixes "remote modal shows same content every time", avoiding the flicker
$('body').on('hidden.bs.modal', '.modal', function() {
......
{%- if not request.args.get('modal') -%}
{%- if not modal -%}
{% extends 'admin/master.html' %}
{%- endif -%}
{% import 'admin/lib.html' as lib with context %}
{% block body %}
{%- if request.args.get('modal') -%}
{%- if 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">&times;</span></button>
......@@ -21,7 +21,7 @@
{% endblock %}
{% block tail %}
{%- if request.args.get('modal') -%}
{%- if modal -%}
<script>
// fixes "remote modal shows same content every time", avoiding the flicker
$('body').on('hidden.bs.modal', '.modal', function() {
......
{%- if not request.args.get('modal') -%}
{%- if not modal -%}
{% extends 'admin/master.html' %}
{%- endif -%}
{% import 'admin/lib.html' as lib with context %}
{% block body %}
{%- if request.args.get('modal') -%}
{%- if 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">&times;</span></button>
......@@ -22,7 +22,7 @@
{% endblock %}
{% block tail %}
{%- if request.args.get('modal') -%}
{%- if modal -%}
<script>
// fixes "remote modal shows same content every time", avoiding the flicker
$('body').on('hidden.bs.modal', '.modal', function() {
......
{%- if not request.args.get('modal') -%}
{%- if not modal -%}
{% extends 'admin/master.html' %}
{%- endif -%}
{% import 'admin/lib.html' as lib with context %}
......@@ -8,14 +8,14 @@
{% endmacro %}
{% block head %}
{%- if not request.args.get('modal') -%}
{%- if not modal -%}
{{ super() }}
{{ lib.form_css() }}
{%- endif -%}
{% endblock %}
{% block body %}
{%- if request.args.get('modal') -%}
{%- if modal -%}
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
{% block header_text %}<h3>{{ _gettext('Create New Record') }}</h3>{% endblock %}
......@@ -42,7 +42,7 @@
{% endblock %}
{% block tail %}
{%- if request.args.get('modal') -%}
{%- if modal -%}
<script>
// fixes "remote modal shows same content every time", avoiding the flicker
$('body').on('hidden.bs.modal', '.modal', function () {
......
{%- if not request.args.get('modal') -%}
{%- if not modal -%}
{% extends 'admin/master.html' %}
{%- endif -%}
{% import 'admin/lib.html' as lib with context %}
......@@ -8,14 +8,14 @@
{% endmacro %}
{% block head %}
{%- if not request.args.get('modal') -%}
{%- if not modal -%}
{{ super() }}
{{ lib.form_css() }}
{%- endif -%}
{% endblock %}
{% block body %}
{%- if request.args.get('modal') -%}
{%- if 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">&times;</span></button>
......@@ -48,7 +48,7 @@
{% endblock %}
{% block tail %}
{%- if request.args.get('modal') -%}
{%- if modal -%}
<script>
// fixes "remote modal shows same content every time", avoiding the flicker
$('body').on('hidden.bs.modal', '.modal', function () {
......
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