{% extends "base.html" %}

{% block title %} | Data groupings{% endblock %}

{% block main %}
        <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 class="active"><a href="{% url 'admin:grouping_list' project.id %}">Data groupings <span class="badge">{{ project.groupings.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-8">
                    <h3 class="header">Data groupings
                        {% if project.groupings.all %}
                            <a href="{% url 'admin:grouping_create' project.id %}" class="btn btn-sm btn-success pull-right"><span class="glyphicon glyphicon-plus"></span> Create new data grouping</a>
                        {% endif %}
                    </h3>
                    {% for grouping in project.groupings.all %}

                    {% if forloop.first %}
                    <ul class="list-unstyled overview-list">
                    {% endif %}

                    <li>
                        <h4><a href="{% url 'admin:grouping_overview' grouping.project.id grouping.id %}">{{grouping.name}}</a></h4>
                        {% if grouping.description %}<p>{{grouping.description}}</p>{% endif %}
                    </li>

                    {% if forloop.last %}
                    </ul>
                    {% endif %}

                    {% empty %}
                        <div class="well empty-list">
                            <p class="lead">We couldn't find any data groupings for this project.</p>
                            <p>You can use data groupings to provide users access to a subset of all data contributed to the project. For instance, you can create a data grouping that includes all tube stations that were added during the last seven days.</p>
                            {% if project.categories.all %}
                                <a href="{% url 'admin:grouping_create' project.id %}" class="btn btn-success btn-lg">Create new data grouping</a>
                            {% endif %}
                        </div>

                        {% if not project.categories.all %}
                        <div class="alert alert-info">
                            <p>However, before you can add a grouping to the project, you need to create at least one category.</p>
                            <p><a href="{% url 'admin:category_create' project.id %}" class="btn btn-success">Create new category</a></p>
                        </div>
                        {% endif %}
                    {% endfor %}
                </div>

                <div class="col-sm-4">
                    <div class="alert alert-info">
                        You can use data groupings to provide users access to a subset of all data contributed to the project. For instance, you can create a data grouping that includes all tube stations that were added during the last seven days.
                    </div>
                </div>
            </div>
        </div>
{% endblock %}
