<!-- FIXME: make a common box.html instead of using the admin one -->
{% extends 'core_main_app/_render/admin/theme/tools/box.html' %}
{% load timestamptags %}
{% load tz %}

{% block box_title %}
    Version manager for {{ data.object_name | lower }} {{data.version_manager.title }}
{% endblock %}

{% block box_tools %}{% endblock %}

{% block box_body %}
<style>
    #model_version td.current {
        font-weight: bold;
        color: green;
    }

    #model_version td.uploaded {
        font-weight: bold;
        color: orange;
    }
</style>
<div id="model_version">
	<table class="table table-bordered table-hover">
        <thead>
            <tr>
                <th style="width: 15%">Version #</th>
                <th style="width: 20%">Status</th>
                <th style="width: 20%">Upload date</th>
                <th>Actions</th>
            </tr>
        </thead>
        <tbody>
	    {% for version in data.categorized_versions.available reversed %}
            <tr>
                <td>{{ version.index }}</td>
                {% if version.object == data.version_manager.current %}
                    <td class="current">Current</td>
                {% else %}
                    <td class="uploaded">Uploaded</td>
                {% endif %}

                <td>{{ version.creation_date|localtime }}</td>

                <td>
                {% block box_actions %}
                    <a class="btn btn-secondary results-xslt"
                       href="{% url 'core_main_app_template_xslt' version.object %}">
                        <i class="fas fa-file-code"></i> XSLT
                    </a>
                    {% if 'core_parser_app' in INSTALLED_APPS %}
                        <a class="btn btn-secondary modules"
                           href="{% url 'core_parser_app_template_modules' version.object %}">
                            <i class="fas fa-cubes"></i> Modules
                        </a>
                    {% endif %}
                    <a class="btn btn-secondary download"
                       href="{% url 'core_main_app_rest_template_download' version.object %}">
                        <i class="fas fa-download"></i> Download
                    </a>
                {% endblock %}
                </td>
            </tr>
        {% endfor %}
        </tbody>
   </table>
</div>
{% endblock %}
