{% extends "mapentity/base.html" %}
{% load i18n static mapentity_tags leaflet_tags geojson_tags %}

{% block title %}{{ object }} | {{ block.super }}{% endblock title %}

{% block mainpanel %}
    <div class="details-panel detail span7 {{ modelname }}">

        <div class="download-group">
            <div class="btn-group pull-right">
                {% block download %}
                <a class="btn btn-mini" target="_blank" href="{{ object.get_document_url }}"><img src="{% static "paperclip/fileicons/odt.png" %}"/> {% trans "ODT" %}</a>
                <a class="btn btn-mini" target="_blank" href="{% url "mapentity:convert" %}?url={{ object.get_document_url|urlencode }}&to=doc"><img src="{% static "paperclip/fileicons/doc.png" %}"/> {% trans "DOC" %}</a>
                <a class="btn btn-mini" target="_blank" href="{% url "mapentity:convert" %}?url={{ object.get_document_url|urlencode }}"><img src="{% static "paperclip/fileicons/pdf.png" %}"/> {% trans "PDF" %}</a>
                {% endblock download %}
            </div>
        </div>

        <div class="tabbable">
            <ul class="nav nav-tabs">
                <li id="tab-properties" class="{% if activetab != "attachments" %}active{% endif %}">
                    <a href="#properties" data-toggle="tab"><i class="icon-tasks"></i> {% trans "Properties" %}
                    {% smart_include "propertiestab" %}
                    </a>
                </li>
                <li id="tab-attachments" class="{% if activetab == "attachments" %}active{% endif %}">
                    <a href="#attachments" data-toggle="tab"><i class="icon-file"></i> {% trans "Attached files" %} ({{ object.attachments.count }})</a>
                </li>
                {% if ACTION_HISTORY_ENABLED %}
                    <li id="tab-history">
                        <a href="#history" data-toggle="tab"><i class="icon-time"></i> {% trans "History" %}</a>
                    </li>
                {% endif %}
                {% if can_edit %}
                    <a class="btn btn-primary pull-right" href="{{ object.get_update_url }}"><i class="icon-pencil icon-white"></i> {% trans "Update" %}</a>
                {% else %}
                    <span class="btn disabled pull-right" href="#"><i class="icon-pencil"></i> {% trans "Update" %}</span>
                {% endif %}
            </ul>
            <div class="tab-content scrollable">
                <div id="properties" class="tab-pane {% if activetab != "attachments" %}active{% endif %}">
                    {% block detailspanel %}
                        {% smart_include "detail" %}
                    {% endblock detailspanel %}
                </div>

                <div id="attachments" class="tab-pane {% if activetab == "attachments" %}active{% endif %}">
                    {% block attachmentspanel %}
                        {% include 'paperclip/attachment_list.html' with attachment_form_next=object.get_detail_url|add:'?tab=attachments' %}
                    {% endblock attachmentspanel %}
                </div>

                {% if ACTION_HISTORY_ENABLED %}
                    <div id="history" class="tab-pane">
                        <table id="logentries-list" class="table table-striped table-bordered">
                            <thead>
                                <tr>
                                    <th>{% trans "Date" %}</th>
                                    <th>{% trans "User" %}</th>
                                    <th>{% trans "Action" %}</th>
                                </tr>
                            </thead>
                            <tbody>
                                {% for logentry in logentries %}
                                    <tr>
                                        <td>{{ logentry.action_time }} ({{ logentry.action_time|timesince }})</td>
                                        <td>{{ logentry.user }}</td>
                                        <td>{{ logentry.action_flag_display }}{% if logentry.change_message %} - {{ logentry.change_message }}{% endif %}</td>
                                    </tr>
                                {% empty %}
                                    <tr>
                                        <td colspan="3">{% trans "None" %}</td>
                                    </tr>
                                {% endfor %}
                                {% if logentries_hellip %}
                                    <tr>
                                        <td>&hellip;</td>
                                        <td>&hellip;</td>
                                        <td>&hellip;</td>
                                    </tr>
                                {% endif %}
                            </tbody>
                        </table>
                        <a href="{% url 'mapentity:logentry_list' %}?content_type={{ object.get_content_type_id }}&object_id={{ object.pk }}" class="btn btn-default">{% trans "Full history" %}</a>
                    </div>
                {% endif %}
            </div>
        </div>
    </div><!-- span7 -->

    <div class="map-panel detail span5">
        {% block mappanel %}
        {% if object.get_geom %}
            {% include "mapentity/mapgeometry_fragment.html" with mapname="detailmap" %}
        {% else %}
            <p class="nomap">{{ empty_map_message }}</p>
        {% endif %}
        {% endblock mappanel %}
    </div><!-- span5 -->

{% endblock mainpanel %}
