{% extends 'core_main_app/_render/admin/theme/tools/box.html' %}

{% block box_title %}Available{% endblock %}

{% block box_tools %}
    <a href="{% url 'core-admin:core_main_app_upload_template'%}" class="{% if BOOTSTRAP_VERSION|first == "4" %}float-right{% elif BOOTSTRAP_VERSION|first == "5"  %}float-end{% endif %} btn btn-secondary">
        <i class="fas fa-upload"></i> Upload {{ data.object_name }}
    </a>
{% endblock %}

{% block box_body %}
<p>
This page lists all Templates uploaded by admin users. Use drag and drop to update the order templates appear
on the website, then click on "Save ordering" when done.
</p>
<table class="table table-bordered table-striped table-hover" data-reorderable-rows="true">
    <tr>
        <th>Display order</th>
        <th width="35%">{{ data.object_name }}</th>
        <th>Actions</th>
    </tr>

    {% for object in data.available %}
        <tr object-id={{object.id}} draggable="true" ondragstart="start()"  ondragover="dragover()">

            <td>{% if object.display_rank %} {{object.display_rank}} {%else %} - {% endif %} </td>
            <td>{{ object.title }}</td>
            <td>
                {% block box_actions %}
                <a class="btn btn-secondary"
                   href="{% url 'core-admin:core_main_app_manage_template_versions' object.id %}">
                    <i class="fas fa-list"></i> Versions
                </a>
                {% url 'core_main_app_edit_template' object.id as edit_url %}
                {% include 'core_main_app/common/buttons/edit.html' %}
                <span class="icon legend delete" objectid="{{ object.id }}">
                    <button class="btn btn-danger"><i class="fas fa-trash"></i> Disable </button>
                </span>
                {% endblock %}
            </td>
        </tr>
    {% empty %}
        <tr>
            <td class="empty" colspan="100%">
                No {{ data.object_name }} uploaded.
            </td>
        </tr>
    {% endfor %}

</table>
<button  class="btn btn-primary mt-3 {% if BOOTSTRAP_VERSION|first == "4" %}float-right{% elif BOOTSTRAP_VERSION|first == "5"  %}float-end{% endif %} save-order-global"  disabled>
        <i class="fas fa-save"></i> Save ordering
</button>
{% endblock %}