{% extends "base.html" %}

{% block bodydata %} data-project-id="{{project.id}}"{% endblock %}
{% block title %} | Project: {{project.name}}{% endblock %}

{% block main %}
    {% csrf_token %}
        <div class="page-header">
            <div class="container">
                <div class="row">
                    <div class="col-sm-6">
                        <h1 class="smaller"><a href="{% url 'admin:project_overview' project.id %}">{{project.name}}</a></h1>
                        <a href="{% url 'admin:project_overview' project.id %}"><span class="glyphicon glyphicon-arrow-left"></span> Project home page</a>
                    </div>
                    <ul class="header-nav">
                    <li><a href="{% url 'admin:category_list' project.id %}">Categories <span class="badge">{{ project.categories.count }}</span></a></li>
                    <li><a href="{% url 'admin:usergroup_list' project.id %}">User groups <span class="badge">{{ project.usergroups.count }}</span></a></li>
                </ul>
                </div>
            </div>
        </div>

        <div class="container">
            {% include 'snippets/messages.html' %}

            <div class="row">
                <div class="col-sm-4">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <h3 class="panel-title">Manage Project</h3>
                        </div>
                        <div class="list-group">
                            <a href="{% url 'admin:category_list' project.id %}" class="list-group-item"><span class="badge">{{ project.categories.count }}</span>Categories</a>
                            <a href="{% url 'admin:usergroup_list' project.id %}" class="list-group-item"><span class="badge">{{ project.usergroups.count }}</span>User groups</a>
                            <a href="{% url 'admin:project_extend' project.id %}" class="list-group-item active">Geographic extent</a>
                            <a href="{% url 'admin:project_settings' project.id %}" class="list-group-item">Settings</a>
                        </div>
                    </div>
                </div>

                <div class="col-sm-8">
                    <h3 class="header">Geographic Extent</h3>
                    <div id="map"></div>
                    <form method="POST" action="{% url 'admin:project_extend' project.id %}" novalidate>
                        {% csrf_token %}
                        <input type="hidden" name="geometry" id="geometry" value="{{ project.geographic_extend.json }}">
                        <div class="form-group">
                            <button type="submit" class="btn btn-primary">Save</button>
                            <button type="reset" class="btn btn-link">Reset</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
{% endblock %}

{% block libraries %}
    <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.css">
    <script src="//cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.js"></script>
    <link href="//cdnjs.cloudflare.com/ajax/libs/leaflet.draw/0.2.3/leaflet.draw.css" rel="stylesheet">
    <script src="//cdnjs.cloudflare.com/ajax/libs/leaflet.draw/0.2.3/leaflet.draw.js"></script>
    <script src="/static/js/admin.ui.project.extent.js"></script>
{% endblock %}
