{% macro modal_dialog(id, title, submit='Submit', class="primary") -%}
<div class="modal fade" id="{{ id }}" tabindex="-1" role="dialog"
    aria-labelledby="{{ id }}-title" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <form action="#" method="post" role="form" autocomplete="off"
                class="form-horizontal">
	            <div class="modal-header">
	                <button type="button" class="close" data-dismiss="modal">
	                    <span aria-hidden="true">&times;</span><span class="sr-only">{% trans %}Close{% endtrans %}</span>
	                </button>
	                <h4 class="modal-title" id="{{ id }}-title">{{ title }}</h4>
	            </div>
	            <div class="modal-body">{{ caller() }}</div>
	            <div class="modal-footer">
	                <button type="button" class="btn btn-default"
	                    data-dismiss="modal">{% trans %}Close{% endtrans %}</button>
	                <button type="submit" class="btn btn-{{ class }}">{{ submit }}</button>
	            </div>
            </form>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>
<!-- /.modal -->
{%- endmacro %}

{# Button to confirm deletion. #}
{% macro delete_confirm(label, message, href='#', action='delete', class='danger', hiddens={}) -%}
<form action="{{ href }}" method="post" role="form" autocomplete="off" style="display: inline;">
    <div style="margin:0;padding:0;display:inline">
    {% for key, value in hiddens.items() %}
    <input type="hidden" name="{{ key }}" value="{{ value }}" >
    {% endfor %}
    </div>
    <button type="submit" class="btn btn-xs btn-{{ class }}" data-confirm="{{ message }}">{{ label }}</button>
</form>
{%- endmacro %}

{# modal dialog for confirmation #}
{% macro data_confirm_modal(title, submit, id='data-confirm-modal') -%}
{% call modal_dialog(id, title, submit) %}
{% endcall%}
{%- endmacro %}

{# Bootstrap panel #}
{% macro panel(title, class='default') -%}
<div class="panel panel-{{ class }}">
    <div class="panel-heading">{{ title }}</div>
    {{ caller() }}
</div>
{%- endmacro %}