{% extends "base.html" %}

{% block bodydata %} data-project-id="{{group.project.id}}" data-group-id="{{group.id}}"{% endblock %}
{% block title %} | User group: {{group.name}}{% 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' group.project.id %}">{{group.project.name}}</a></h1>
                        <a href="{% url 'admin:project_overview' group.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' group.project.id %}">Categories <span class="badge">{{ group.project.categories.count }}</span></a></li>
                        <li class="active"><a href="{% url 'admin:usergroup_list' group.project.id %}">User groups <span class="badge">{{ group.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">
                            <h6 class="item-info">User group</h6>
                            <h3>{{ group.name }}</h3>
                            {% if group.description %}<p>{{ group.description|linebreaksbr }}</p>{% endif %}
                        </div>
                        <div class="list-group">
                            <a href="{% url 'admin:usergroup_overview' group.project.id group.id %}" class="list-group-item">Members</a>
                            <a href="{% url 'admin:usergroup_permissions' group.project.id group.id %}" class="list-group-item">Permissions</a>
                            <a href="{% url 'admin:usergroup_data' group.project.id group.id %}" class="list-group-item">Data</a>
                            <a href="{% url 'admin:usergroup_settings' group.project.id group.id %}" class="list-group-item active">Settings</a>
                        </div>
                    </div>
                </div>
                <div class="col-sm-8">
                    <form  role="form" method="POST" action="{% url 'admin:usergroup_settings' group.project.id group.id %}" novalidate>
                        <h3 class="header">Settings</h3>
                        {% csrf_token %}
                        <div class="form-group">
                            <label for="name" class="control-label">Name (required)</label>
                            <input type="text" class="form-control input-lg" id="name" name="name" value="{{ group.name }}" maxlength="100" required>
                        </div>

                        <div class="form-group">
                            <label for="description" class="control-label">Description</label>
                            <textarea class="form-control input-lg" rows="5" name="description" id="description">{{ group.description }}</textarea>
                        </div>

                        <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 class="row">
                <div class="col-sm-8 col-sm-offset-4">
                    <div class="panel panel-danger">
                        <div class="panel-heading">
                            <h2 class="panel-title">Be careful!</h2>
                        </div>
                        <div class="panel-body becareful">
                            <div>
                                <strong>Delete user group</strong>
                                <p>Deleting a user group can not be undone.</p>
                                <a href="#" class="text-danger" data-toggle="modal" data-target="#delete-confirm">Delete this user group</a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
{% endblock %}

{% block modals %}
        <!-- Delete confirmation modal -->
        <div class="modal fade" id="delete-confirm" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content panel-danger">
                    <div class="modal-header panel-heading">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title" id="myModalLabel">Are you sure?</h4>
                    </div>
                    <div class="modal-body panel-body">
                        <p>You are about to delete the user group <strong>{{goup.name}}</strong>. This can not be undone.</p>
                    </div>
                    <div class="modal-footer panel-footer">
                        <a href="{% url 'admin:usergroup_delete' group.project.id group.id %}" class="btn btn-danger">I'm absolutely sure, delete the user group!</a>
                    </div>
                </div>
            </div>
        </div>
        <!-- /Delete confirmation modal -->
{% endblock %}

{% block libraries %}
            <script src="/static/js/admin.ui.forms.validate.js"></script>
{% endblock %}
