{% import 'macros/messages.html' as messages_macros with context -%}
{% import 'macros/filters.html' as filters_macros %}
{% import 'macros/list_actions.html' as list_actions_macros %}
{% import 'macros/batch_actions.html' as batch_actions_macros %}
{% import 'macros/pager.html' as pager_macros %}

{# In 0.6 list(configuration, pager) - title must be in configuration dictionary #}
{% macro list(title, configuration, pager) -%}
    <h1>{{ title }}</h1>

    {{ messages_macros.messages() }}

    {% if pager.is_filter() or pager.is_list_actions() %}
    <div class="btn-toolbar">
        <div class="btn-group">
            {% if pager.is_filter() %}{{ filters_macros.filter_button('filtersBootstrapGeneratorModal') }}{%  endif %}
        </div>
        {% if pager.is_list_actions() %}{{ list_actions_macros.list_actions(list_actions=pager.get_list_actions()) }}{% endif %}
    </div>
    {%  endif %}

    {% if pager.is_filter() %}
        {% set filter_element = pager.get_filter() %}
        {{ filters_macros.filter_modal(id='filtersBootstrapGeneratorModal', url=filter_element['url'], form=filter_element['form']) }}
    {% endif %}

    {% if pager.is_batch() %}{% set batch_element = pager.get_batch() %}<form class="form-inline" action="{{ batch_element['url'] }}" method="post">{% endif %}
        {{ pager_macros.get_list_page(configuration=configuration, pager=pager) }}
        {% if pager.is_batch() or pager.is_list_actions() %}
        <div class="btn-toolbar">
            <div class="btn-group">
                {% if pager.is_batch() %}{{ batch_actions_macros.batch_buttons(form=batch_element['form']) }}{% endif %}
            </div>
            {% if pager.is_list_actions() %}{{ list_actions_macros.list_actions(list_actions=pager.get_list_actions()) }}{% endif %}
       </div>
        {%  endif %}
    {% if pager.is_batch() %}</form>{% endif %}
{%- endmacro %}