{% load humanize %}
{% load chemical_formula_filter %}
{% if "Structure" in table.get_mixin_names %}
    <table id="SearchResultsTable"
           class="table table-striped"
           style="width:100%">
        <thead>
            <tr>
                <th>ID</th>
                <th>Dashboards</th>
                <th>Full Formula</th>
                <th>Spacegroup</th>
                <th>Density</th>
            </tr>
        </thead>
        <tbody>
            {% for entry in entries %}
                <tr>
                    <td>{{ entry.id }}</td>
                    <td>
                        <a href="{{ entry.id }}">simmate</a> / <a href="{{ entry.external_link }}" target="_blank">provider</a>
                    </td>
                    <td>{{ entry.formula_full | chemical_formula }}</td>
                    <td>{{ entry.spacegroup.number }}</td>
                    <td>{{ entry.density | floatformat:3 }}</td>
                </tr>
            {% endfor %}
        </tbody>
    </table>
{% elif "Molecule" in table.get_mixin_names %}
    {% load draw_molecule %}
    {% for entry in entries %}
        <div class="col-auto">
            <div class="card border-secondary border ribbon-box" style="width: 12rem;">
                <div class="card-body">
                    <div class="row">
                        <div class="py-1 text-light bg-primary text-center fw-bold rounded col-12">id = {{ entry.id }}</div>
                    </div>
                    <div class="row text-center my-2">
                        <div class="col-12">{% draw_molecule entry width=150 height=150 %}</div>
                    </div>
                    <div class="row text-center">
                        <div class="col">
                            <a role="button"
                               class="btn btn-outline-primary btn-sm"
                               href="{{ entry.id }}">View  <i class="mdi mdi-open-in-new"></i></a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    {% endfor %}
{% else %}
    <div class="alert alert-danger d-flex align-items-center">
        <div>
            <small>
                <b>ALERT:</b> No default <em>`html_entries_template`</em> has been set for this table, which is why you only
                see the ID column displayed below. Contact your admin to have this updated.
            </small>
        </div>
    </div>
    <table id="SearchResultsTable" class="table table-striped">
        <thead>
            <tr>
                <th>ID</th>
                <th></th>
            </tr>
        </thead>
        <tbody>
            {% for entry in entries %}
                <tr>
                    <td>{{ entry.id }}</td>
                    <td>
                        <a role="button"
                           class="btn btn-outline-primary btn-sm"
                           href="{{ entry.id }}"><i class="mdi mdi-open-in-new"></i></a>
                    </td>
                </tr>
            {% endfor %}
        </tbody>
    </table>
{% endif %}
