{% extends "base.html" %}
{% from 'macros/ui.html' import group_panel %}

{% block heading %}
    <a href="/users">Users</a>
{% endblock %}

{% block subheading %}
    {{user.username}} {% if not user.enabled %}<small>(disabled)</small>{% endif %}
{% endblock %}

{% block headingbuttons %}
    {% if current_user.user_admin %}
        {% if user.enabled %}
            <button class="btn btn-danger" data-toggle="modal" data-target="#disableModal">
                <i class="fa fa-minus"></i> Disable
            </button>
        {% elif not user.enabled %}
            <button class="btn btn-warning" data-toggle="modal" data-target="#enableModal">
                <i class="fa fa-plus"></i> Enable
            </button>
        {% endif %}
    {% endif %}
{% endblock %}

{% block content %}

<div class="row">
    <div class="col-md-5">
        {{ group_panel(400, groups, True) }}
    </div>
</div>


<div class="modal fade" id="enableModal" tabindex="-1" role="dialog"
      aria-labelledby="enableModal" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">
                    <span aria-hidden="true">&times;</span>
                    <span class="sr-only">Close</span>
                </button>
                <h4 class="modal-title">Enable Group</h4>
           </div>
            <div class="modal-body">
                <p>Are you sure you want to Enable this user?</p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default"
                        data-dismiss="modal">Close</button>
                <form action="/users/{{user.id}}/enable" method="post"
                      style="display: inline;">
                    {{ xsrf_form() }}
                    <button type="submit" class="btn btn-primary">Enable</button>
                </form>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="disableModal" tabindex="-1" role="dialog"
      aria-labelledby="disableModal" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">
                    <span aria-hidden="true">&times;</span>
                    <span class="sr-only">Close</span>
                </button>
                <h4 class="modal-title">Disable Group</h4>
           </div>
            <div class="modal-body">
                <p>Are you sure you want to Disable this user?</p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default"
                        data-dismiss="modal">Close</button>
                <form action="/users/{{user.id}}/disable" method="post"
                      style="display: inline;">
                    {{ xsrf_form() }}
                    <button type="submit" class="btn btn-primary">Disable</button>
                </form>
            </div>
        </div>
    </div>
</div>

{% endblock %}
