{% extends "core/site_base.html" %}
{% block tabtitle %}{{ table.table_name }} Data - Simmate{% endblock %}
{% block body %}
    <div class="row">
        {# Buttons & Sidebars #}
        <div class="col-12 py-3">
            <a href="{% url 'data_explorer:table-about' table.table_name %}"
               class="btn btn-primary my-1">
                <i class="bi bi-info-circle"></i>&nbsp;&nbsp;Table Info</a>
            {% block quicksearch %}
                {% if table.html_form_component 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 %}
            {% block updater %}
                {% if table.html_form_component and "update_many" in table.html_enabled_forms %}
                    {% include "data_explorer/table_update_many.html" %}
                {% endif %}
            {% endblock %}
            {% block addnew %}
                {% if table.html_form_component and "create" in table.html_enabled_forms %}
                    {% include "data_explorer/table_add_entry.html" %}
                {% endif %}
            {% endblock %}
            <a class="btn btn-secondary my-1"
               href="#"
               role="button"
               data-bs-toggle="dropdown">
                <i class="bi bi-download"></i>&nbsp;&nbsp;Download
            </a>
            <ul class="dropdown-menu">
                <li>
                    <h6 class="dropdown-header">
                        <i class="bi bi-stars"></i> Curated <i class="bi bi-stars"></i>
                    </h6>
                </li>
                <li>
                    <a class="dropdown-item" href="{% update_url format='curated-csv' %}"><i class="bi bi-file-earmark-spreadsheet"></i> CSV</a>
                </li>
                <li>
                    <hr class="dropdown-divider">
                </li>
                <li>
                    <h6 class="dropdown-header">
                        REST API <small>(raw data)</small>
                    </h6>
                </li>
                <li>
                    <a class="dropdown-item" href="{% update_url format='csv' %}"><i class="bi bi-file-earmark-spreadsheet"></i> CSV</a>
                </li>
                <li>
                    <a class="dropdown-item" href="{% update_url format='json' %}"><i class="bi bi-braces"></i> JSON</a>
                </li>
                {% comment %}
                    <li>
                        <a class="dropdown-item" href="#"><i class="bi bi-box"></i> CIF</a>
                    </li>
                    <li>
                        <a class="dropdown-item" href="#"><i class="bi bi-flask"></i> SDF</a>
                    </li>
                {% endcomment %}
                <li>
                    <hr class="dropdown-divider">
                </li>
                <li>
                    <h6 class="dropdown-header">
                        Other <small>(requires install)</small>
                    </h6>
                </li>
                <li>
                    <a class="dropdown-item"
                       href="https://jacksund.github.io/simmate/full_guides/database/basic_use/"
                       target="_blank"><i class="bi bi-code"></i> Python</a>
                </li>
                <li>
                    <a class="dropdown-item"
                       href="https://jacksund.github.io/simmate/getting_started/database/quickstart/"
                       target="_blank"><i class="bi bi-database"></i> SQL</a>
                </li>
            </ul>
            {% include "core/basic_elements/toggle_width_button.html" %}
        </div>
    </div>
    {# Search Results #}
    {% block search_results %}
        <div id="search-results" class="row">
            {% if page.object_list %}
                {% block search_results_table %}
                    {% if table.html_form_component and "update_many" in table.html_enabled_forms %}
                        {% include table.html_entries_template with enable_select=True entries=page.object_list %}
                    {% else %}
                        {% include table.html_entries_template with enable_select=False entries=page.object_list %}
                    {% endif %}
                {% endblock %}
                {% include "data_explorer/pagination.html" %}
            {% else %}
                <div class="alert alert-danger d-flex align-items-center p-2" role="alert">
                    <div>
                        <i class="bi bi-exclamation-triangle"></i>&nbsp;&nbsp;<b>No entries were found that match your search criteria!</b>&nbsp;&nbsp;
                        <a class="text-dark text-decoration-underline" href=".">
                            Clear Filters<i class="bi bi-arrow-clockwise"></i>
                        </a>
                    </div>
                </div>
            {% endif %}
        </div>
    {% endblock %}
{% endblock %}
