{% extends "core_components/site_base.html" %}
{% block tabtitle %}Simmate{% endblock %}
{% block banner %}
    {% include "core_components/header.html" %}
{% endblock %}
{% block body %}
    <div class="row">
        {# Buttons & Sidebars #}
        <div class="col-8">
            <a href="{% url 'data_explorer:table-about' table.table_name %}"
               class="btn btn-primary my-1">
                <i class="mdi mdi-information"></i>&nbsp;&nbsp;Table Info</a>
            {# Quick Search Sidebar #}
            {% block quicksearch %}
                {% if table.html_form_view and "search" in table.html_enabled_forms %}
                    {% include "data_explorer/table_search.html" %}
                    {# ELSE: include "data_explorer/table_filters.html" (disabled for now) #}
                {% endif %}
            {% endblock %}
            {# Update Sidebar #}
            {% block updater %}
                {% if table.html_form_view and "update_many" in table.html_enabled_forms %}
                    {% include "data_explorer/table_update_many.html" %}
                {% endif %}
            {% endblock %}
            {# Add New Sidebar #}
            {% block addnew %}
                {% if table.html_form_view and "create" in table.html_enabled_forms %}
                    {% include "data_explorer/table_add_entry.html" %}
                {% endif %}
            {% endblock %}
        </div>
        {# Table Description #}
        <div class="col-4">
            <p class="lead text-muted">{{ table.html_description_short }}</p>
        </div>
    </div>
    {# Search Results #}
    {% block search_results %}
        {% load humanize %}
        <div id="search-results" class="row">
            {% if page.object_list %}
                <div class="alert alert-primary d-flex align-items-center mt-2"
                     role="alert">
                    <i class="mdi mdi-check-circle"></i>&nbsp;&nbsp;
                    <div>
                        Showing <b>{{ page.start_index }}-{{ page.end_index }}</b> of
                        {% with total=page.paginator.count %}
                            <b>
                                {# linting is disabled for this line to stop it from adding a space #}
                                {# djlint:off #}
                                        {% if total == 10000 %}&gt;{% endif %}{{ total|intcomma }}
                                {# djlint:on #}
                            </b> filtered results.
                            {% if total == 10000 %}
                                We limit searches to 10k results for our Web UI and API. Switch to Python or SQL if you need the full dataset.
                            {% endif %}
                            {# (total counts too slow) The full dataset has <b>{{ nentries_possible|intcomma }}</b> entries. #}
                        {% endwith %}
                    </div>
                </div>
                {% block search_results_table %}
                    {# we assume that if enable_select is used, then there is a viable update_many view #}
                    {% include table.html_entries_template with enable_select=True entries=page.object_list %}
                {% endblock %}
                {% include "data_explorer/pagination.html" %}
            {% else %}
                <div class="alert alert-danger d-flex align-items-center p-2" role="alert">
                    <div>
                        <i class="mdi mdi-alert-circle"></i>&nbsp;&nbsp;<b>No entries were found that match your search criteria!</b>
                    </div>
                </div>
            {% endif %}
        </div>
    {% endblock %}
{% endblock %}
