{{ asset_add("scripts.js", "streams::js/table/table.js") }}

{% if not actions.isEmpty() %}
    {{ asset_add("scripts.js", "streams::js/table/actions.js") }}
{% endif %}

{% if table.options.sortable %}
    {{ asset_add("scripts.js", "streams::js/table/sortable.js") }}
{% endif %}

<div class="{{ table.options.container_class ?: 'container-fluid' }}">

    {{ view("streams::table/partials/filters", {'table': table}) }}
    {{ view("streams::table/partials/views", {'table': table}) }}

    {{ view(table.options.heading ?: "streams::table/partials/heading", {'table': table}) }}

    {% if not table.rows.isEmpty() %}
        {% block card %}
            <div class="card">

                {{ form_open({ 'url': table.options.url ?: url_full() }) }}
                <div class="table-stack">
                    <table
                            class="
                                {{ table.options.class ?: 'table' }}
                                {{ table.options.sortable ? 'table--sortable' }}
                                "
                            {{ table.options.sortable ? 'data-sortable' }}
                            {{ html_attributes(table.options.attributes) }}>

                        {{ view("streams::table/partials/header", {'table': table}) }}

                        {% block body %}
                            {{ view("streams::table/partials/body", {'table': table}) }}
                        {% endblock %}

                        {{ view("streams::table/partials/footer", {'table': table}) }}

                    </table>
                </div>
                {{ form_close() }}

            </div>
        {% endblock %}
    {% else %}

        {% block no_results %}
            <div class="card">
                <div class="card-block card-body">
                    {{ trans(table.options.get('no_results_message', 'streams::message.no_results')) }}
                </div>
            </div>
        {% endblock %}

    {% endif %}

</div>
