{% extends base_template %}

{% block crud_content %}

    {% block title %}
        {# Page title and any content around it #}
        {% if title %}
            <h1>{{title}}</h1>
        {% endif %}
    {% endblock %}

    {% block controls %}
        {# Top control bar with buttons #}
        <div class="row">
            <div class="col-md-12">
               {% include "crud/resource_controls.html" %}
            </div>
        </div>
    {% endblock controls %}

    {% block listing %}
        {# List all CRUD items in a table #}
        {% if count %}
            <div class="table-responsive">
                <table class="table listing listing-{{crud.id}}">
                    <thead>
                        {% for column in columns %}
                            {%  include column.header_template %}
                        {% endfor %}
                    </thead>

                    <tbody>
                        {% for obj in batch %}
                            <tr class="crud-row crud-row-{{ obj.id }}">
                                {% with instance=crud.wrap_to_resource(obj) %}
                                    {% for column in columns  %}
                                        {% include column.body_template %}
                                    {% endfor %}
                                {% endwith %}
                            </tr>
                        {% endfor %}
                    </tbody>
                </table>
            </div>
        {% endif %}
    {% endblock %}

    {% block count %}
        {# Display total count of items #}
        <div class="row">
            <div class="col-md-12 text-muted text-center">

            {% if not count %}
                <p id="crud-listing-no-items">
                    No items
                </p>
            {% else %}

                <div id="crud-listing-count">
                    Total {{count}} items
                </div>
            {% endif %}
            </div>
        </div>
    {% endblock %}

    {% block paginator %}
        {% include "crud/paginator.html" %}
    {% endblock %}
{% endblock crud_content %}