{% extends 'base.html' %}

{% block bodydata %}
data-project-id="{{ project.id }}"
data-project-locked="{{ project.islocked }}"
data-subset-id="{{ subset.id }}"
{% endblock %}

{% block title %} | Project: {{ project.name }} - Subset: {{ subset.name }} - Settings{% endblock %}

{% block main %}
<div class="page-header">
    <div class="container">
        <h1 class="smaller">
            {% if project.islocked %}<span class="glyphicon glyphicon-lock" aria-hidden="true"></span>{% endif %}
            <a href="{% url 'admin:project_overview' project.id %}">{{ project.name }}</a>
        </h1>

        {% include 'projects/navigation.html' %}
    </div>
</div>

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

    <div class="row">
        <div class="col-sm-4">
            {% include 'subsets/subset_navigation.html' %}
        </div>

        <div class="col-sm-8">
            <h3 class="header">Subset settings</h3>

            <form id="settings" method="POST" action="{% url 'admin:subset_settings' project.id subset.id %}" novalidate>
                {% 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" maxlength="100" value="{{ subset.name }}" required />
                </div>

                <div class="form-group">
                    <label for="description" class="control-label">Description</label>
                    <textarea class="form-control input-lg" rows="5" id="description" name="description">{{ subset.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>

    {% if not project.islocked %}
        <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 subset</strong>
                            <p>Deleting this subset cannot be undone.</p>
                            <a href="#" class="text-danger" data-toggle="modal" data-target="#delete-confirm">Delete this subset</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    {% endif %}
</div>
{% endblock %}

{% block modals %}
<div role="dialog" class="modal fade" id="delete-confirm" tabindex="-1" 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">Are you sure?</h4>
            </div>

            <div class="modal-body panel-body">
                <p><strong>Before you delete the subset, please read through the consequences of this action:</strong></p>

                <ul>
                    <li>Deleting a subset cannot be undone.</li>
                    <li>Data accessible through this subset will not be deleted.</li>
                </ul>
            </div>

            <div class="modal-footer panel-footer">
                <a href="{% url 'admin:subset_delete' project.id subset.id %}" class="btn btn-danger">I'm absolutely sure, delete the subset!</a>
            </div>
        </div>
    </div>
</div>
{% endblock %}

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