Commit 6a019144 authored by Serge S. Koval's avatar Serge S. Koval

Merge branch 'master' of github.com:flask-admin/flask-admin

parents 1e95669b d86035e6
...@@ -432,6 +432,20 @@ class BaseModelView(BaseView, ActionsMixin): ...@@ -432,6 +432,20 @@ class BaseModelView(BaseView, ActionsMixin):
Controls if the primary key should be displayed in the list view. Controls if the primary key should be displayed in the list view.
""" """
column_display_actions = True
"""
Controls the display of the row actions (edit, delete, details, etc.)
column in the list view.
Useful for preventing a blank column from displaying if your view does
not use any build-in or custom row actions.
This column is not hidden automatically due to backwards compatibility.
Note: This only affects display and does not control whether the row
actions endpoints are accessible.
"""
simple_list_pager = False simple_list_pager = False
""" """
Enable or disable simple list pager. Enable or disable simple list pager.
......
...@@ -70,7 +70,9 @@ ...@@ -70,7 +70,9 @@
</th> </th>
{% endif %} {% endif %}
{% block list_row_actions_header %} {% block list_row_actions_header %}
<th class="span1">&nbsp;</th> {% if admin_view.column_display_actions %}
<th class="span1">&nbsp;</th>
{% endif %}
{% endblock %} {% endblock %}
{% set column = 0 %} {% set column = 0 %}
{% for c, name in list_columns %} {% for c, name in list_columns %}
...@@ -112,42 +114,44 @@ ...@@ -112,42 +114,44 @@
</td> </td>
{% endif %} {% endif %}
{% block list_row_actions_column scoped %} {% block list_row_actions_column scoped %}
<td class="list-buttons-column"> {% if admin_view.column_display_actions %}
{% block list_row_actions scoped %} <td class="list-buttons-column">
{%- if admin_view.can_view_details -%} {% block list_row_actions scoped %}
{%- if admin_view.details_modal -%} {%- if admin_view.can_view_details -%}
{{ lib.add_modal_button(url=get_url('.details_view', id=get_pk_value(row), url=return_url, modal=True), title=_gettext('View Record'), content='<span class="fa fa-eye glyphicon icon-eye-open"></span>') }} {%- if admin_view.details_modal -%}
{% else %} {{ lib.add_modal_button(url=get_url('.details_view', id=get_pk_value(row), url=return_url, modal=True), title=_gettext('View Record'), content='<span class="fa fa-eye glyphicon icon-eye-open"></span>') }}
<a class="icon" href="{{ get_url('.details_view', id=get_pk_value(row), url=return_url) }}" title="{{ _gettext('View Record') }}"> {% else %}
<span class="fa fa-eye icon-eye-open"></span> <a class="icon" href="{{ get_url('.details_view', id=get_pk_value(row), url=return_url) }}" title="{{ _gettext('View Record') }}">
</a> <span class="fa fa-eye icon-eye-open"></span>
</a>
{%- endif -%}
{%- endif -%} {%- endif -%}
{%- endif -%} {%- if admin_view.can_edit -%}
{%- if admin_view.can_edit -%} {%- if admin_view.edit_modal -%}
{%- if admin_view.edit_modal -%} {{ lib.add_modal_button(url=get_url('.edit_view', id=get_pk_value(row), url=return_url, modal=True), title=_gettext('Edit Record'), content='<i class="fa fa-pencil icon-pencil"></i>') }}
{{ lib.add_modal_button(url=get_url('.edit_view', id=get_pk_value(row), url=return_url, modal=True), title=_gettext('Edit Record'), content='<i class="fa fa-pencil icon-pencil"></i>') }} {% else %}
{% else %} <a class="icon" href="{{ get_url('.edit_view', id=get_pk_value(row), url=return_url) }}" title="{{ _gettext('Edit Record') }}">
<a class="icon" href="{{ get_url('.edit_view', id=get_pk_value(row), url=return_url) }}" title="{{ _gettext('Edit Record') }}"> <i class="fa fa-pencil icon-pencil"></i>
<i class="fa fa-pencil icon-pencil"></i> </a>
</a> {%- endif -%}
{%- endif -%} {%- endif -%}
{%- endif -%} {%- if admin_view.can_delete -%}
{%- if admin_view.can_delete -%} <form class="icon" method="POST" action="{{ get_url('.delete_view') }}">
<form class="icon" method="POST" action="{{ get_url('.delete_view') }}"> {{ delete_form.id(value=get_pk_value(row)) }}
{{ delete_form.id(value=get_pk_value(row)) }} {{ delete_form.url(value=return_url) }}
{{ delete_form.url(value=return_url) }} {% if delete_form.csrf_token %}
{% if delete_form.csrf_token %} {{ delete_form.csrf_token }}
{{ delete_form.csrf_token }} {% elif csrf_token %}
{% elif csrf_token %} <input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/> {% endif %}
{% endif %} <button onclick="return confirm('{{ _gettext('Are you sure you want to delete this record?') }}');" title="{{ _gettext('Delete record') }}">
<button onclick="return confirm('{{ _gettext('Are you sure you want to delete this record?') }}');" title="{{ _gettext('Delete record') }}"> <i class="fa fa-trash icon-trash"></i>
<i class="fa fa-trash icon-trash"></i> </button>
</button> </form>
</form> {%- endif -%}
{%- endif -%} {% endblock %}
{% endblock %} </td>
</td> {%- endif -%}
{% endblock %} {% endblock %}
{% for c, name in list_columns %} {% for c, name in list_columns %}
......
...@@ -70,7 +70,9 @@ ...@@ -70,7 +70,9 @@
</th> </th>
{% endif %} {% endif %}
{% block list_row_actions_header %} {% block list_row_actions_header %}
<th class="col-md-1">&nbsp;</th> {% if admin_view.column_display_actions %}
<th class="col-md-1">&nbsp;</th>
{% endif %}
{% endblock %} {% endblock %}
{% set column = 0 %} {% set column = 0 %}
{% for c, name in list_columns %} {% for c, name in list_columns %}
...@@ -112,42 +114,44 @@ ...@@ -112,42 +114,44 @@
</td> </td>
{% endif %} {% endif %}
{% block list_row_actions_column scoped %} {% block list_row_actions_column scoped %}
<td class="list-buttons-column"> {% if admin_view.column_display_actions %}
{% block list_row_actions scoped %} <td class="list-buttons-column">
{%- if admin_view.can_view_details -%} {% block list_row_actions scoped %}
{%- if admin_view.details_modal -%} {%- if admin_view.can_view_details -%}
{{ lib.add_modal_button(url=get_url('.details_view', id=get_pk_value(row), url=return_url, modal=True), title=_gettext('View Record'), content='<span class="fa fa-eye glyphicon glyphicon-eye-open"></span>') }} {%- if admin_view.details_modal -%}
{% else %} {{ lib.add_modal_button(url=get_url('.details_view', id=get_pk_value(row), url=return_url, modal=True), title=_gettext('View Record'), content='<span class="fa fa-eye glyphicon glyphicon-eye-open"></span>') }}
<a class="icon" href="{{ get_url('.details_view', id=get_pk_value(row), url=return_url) }}" title="{{ _gettext('View Record') }}"> {% else %}
<span class="fa fa-eye glyphicon glyphicon-eye-open"></span> <a class="icon" href="{{ get_url('.details_view', id=get_pk_value(row), url=return_url) }}" title="{{ _gettext('View Record') }}">
</a> <span class="fa fa-eye glyphicon glyphicon-eye-open"></span>
</a>
{%- endif -%}
{%- endif -%} {%- endif -%}
{%- endif -%} {%- if admin_view.can_edit -%}
{%- if admin_view.can_edit -%} {%- if admin_view.edit_modal -%}
{%- if admin_view.edit_modal -%} {{ lib.add_modal_button(url=get_url('.edit_view', id=get_pk_value(row), url=return_url, modal=True), title=_gettext('Edit Record'), content='<span class="fa fa-pencil glyphicon glyphicon-pencil"></span>') }}
{{ lib.add_modal_button(url=get_url('.edit_view', id=get_pk_value(row), url=return_url, modal=True), title=_gettext('Edit Record'), content='<span class="fa fa-pencil glyphicon glyphicon-pencil"></span>') }} {% else %}
{% else %} <a class="icon" href="{{ get_url('.edit_view', id=get_pk_value(row), url=return_url) }}" title="{{ _gettext('Edit Record') }}">
<a class="icon" href="{{ get_url('.edit_view', id=get_pk_value(row), url=return_url) }}" title="{{ _gettext('Edit Record') }}"> <span class="fa fa-pencil glyphicon glyphicon-pencil"></span>
<span class="fa fa-pencil glyphicon glyphicon-pencil"></span> </a>
</a> {%- endif -%}
{%- endif -%} {%- endif -%}
{%- endif -%} {%- if admin_view.can_delete -%}
{%- if admin_view.can_delete -%} <form class="icon" method="POST" action="{{ get_url('.delete_view') }}">
<form class="icon" method="POST" action="{{ get_url('.delete_view') }}"> {{ delete_form.id(value=get_pk_value(row)) }}
{{ delete_form.id(value=get_pk_value(row)) }} {{ delete_form.url(value=return_url) }}
{{ delete_form.url(value=return_url) }} {% if delete_form.csrf_token %}
{% if delete_form.csrf_token %} {{ delete_form.csrf_token }}
{{ delete_form.csrf_token }} {% elif csrf_token %}
{% elif csrf_token %} <input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/> {% endif %}
{% endif %} <button onclick="return confirm('{{ _gettext('Are you sure you want to delete this record?') }}');" title="Delete record">
<button onclick="return confirm('{{ _gettext('Are you sure you want to delete this record?') }}');" title="Delete record"> <span class="fa fa-trash glyphicon glyphicon-trash"></span>
<span class="fa fa-trash glyphicon glyphicon-trash"></span> </button>
</button> </form>
</form> {%- endif -%}
{%- endif -%} {% endblock %}
{% endblock %} </td>
</td> {%- endif -%}
{% endblock %} {% endblock %}
{% for c, name in list_columns %} {% for c, name in list_columns %}
<td class="col-{{c}}"> <td class="col-{{c}}">
......
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