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

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

{% block box_tools %}

{% url 'admin:core_main_app_templates' as template_list_url %}
{% include 'core_main_app/common/buttons/go_to.html' with url=template_list_url label='Back to Templates' %}

{% if not data.version_manager.user %}
    <a href="{% url 'admin:core_main_app_upload_template_version' data.version_manager.id %}"
       class="pull-right btn btn-default">
        <i class="fa fa-upload"></i> Upload New Version
    </a>
{% endif %}
{% endblock %}

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

               <td>{{ version.object | print_timestamp }}</td>

               <td>
                   {% block box_actions %}
                       {% if version.object != data.version_manager.current %}
                        <span class='icon legend long current' objectid='{{ version.object }}'>
                           <a class="btn btn-default" href="#"><i class="fa fa-bookmark"></i> Set Current</a>
                        </span>
                        <span class='icon legend delete' objectid='{{ version.object }}'>
                           <a class="btn btn-danger" href="#"><i class="fa fa-trash"></i> Disable</a>
                        </span>
                        {% endif %}

                        {% if data.object_name == 'Template' %}
                        <a class="btn btn-default results-xslt"
                            href="{% url 'admin:core_main_app_template_xslt' version.object %}">
                            <i class="fa fa-file-code-o"></i> XSLT
                        </a>
                        {% endif %}
                        {% if 'core_parser_app' in INSTALLED_APPS %}
                            <a class="btn btn-default modules"
                                href="{% url data.module_url version.object %}">
                                <i class="fa fa-cubes"></i> Modules
                            </a>
                       {% endif %}
                   {% endblock %}
               </td>
           </tr>
       {% endfor %}
   </table>
</div>
{% endblock %}
