{% extends 'base.html' %}
{% load i18n %}

{% block breadcrumb %}
    <ol class="breadcrumb">
        <li><span class="glyphicon glyphicon-home"></span></li>
        <li class="active">{% trans 'Map settings' %}</li>
    </ol>
{% endblock %}

{% block page-header %}
    {% trans 'Map point' %}
{% endblock %}

{% block main %}
    {% with can_change_dot=perms.mapapp.change_dot can_delete_dot=perms.mapapp.delete_dot %}
    <div class="table-responsive">
        <table class="table table-striped table-bordered">
            <thead>
            <tr>
                <th>{% trans 'Title' %}</th>
                <th>{% trans 'Longitude' %}</th>
                <th>{% trans 'Latitude' %}</th>
                {% if can_change_dot or can_delete_dot %}<th width="90">#</th>{% endif %}
            </tr>
            </thead>
            <tbody>
            <tr>
                {% for dot in dots %}
                    <td>{{ dot.title }}</td>
                    <td>{{ dot.longitude }}</td>
                    <td>{{ dot.latitude }}</td>
                    {% if can_change_dot or can_delete_dot %}
                    <td colspan="2" class="btn-group btn-group-xs">

                        {% if can_change_dot %}
                        <a href="{% url 'mapapp:edit_dot' dot.id %}" title="{% trans 'Edit' %}" data-toggle="tooltip"
                           class="btn btn-primary">
                            <span class="glyphicon glyphicon-edit"></span>
                        </a>
                        {% endif %}

                        {% if can_delete_dot %}
                        <a href="{% url 'mapapp:remove_dot' dot.id %}" title="{% trans 'Delete' %}" data-toggle="tooltip"
                           class="btn btn-danger">
                            <span class="glyphicon glyphicon-remove"></span>
                        </a>
                        {% endif %}

                    </td>
                    {% endif %}
                </tr>
            {% empty %}
                <tr>
                    <td colspan="{% if can_change_dot or can_delete_dot %}4{% else %}3{% endif %}">
                        {% trans 'You have not created map points yet' %}
                        <a href="{% url 'mapapp:add_dot' %}">{% trans 'Create' %}</a>
                    </td>
                </tr>
            {% endfor %}
            </tbody>
            <tfoot>
            <tr>
                <td colspan="{% if can_change_dot or can_delete_dot %}4{% else %}3{% endif %}">
                    <a href="{% url 'mapapp:add_dot' %}" class="btn btn-sm btn-success">
                        <span class="glyphicon glyphicon-plus"></span>
                    </a>
                </td>
            </tr>
            </tfoot>
        </table>
    </div>
    {% endwith %}
{% endblock %}
