{% set page_title = _("Groups") %}

{% extends theme("management/management_layout.html") %}

{% block breadcrumb %}
<ol class="breadcrumb flaskbb-breadcrumb">
    <li><a href="{{ url_for('forum.index') }}">{% trans %}Forum{% endtrans %}</a></li>
    <li><a href="{{ url_for('management.overview') }}">{% trans %}Management{% endtrans %}</a></li>
    <li class="active">{% trans %}Manage Groups{% endtrans %}</li>
</ol>
{% endblock %}

{% block management_content %}
{% from theme('macros.html') import render_pagination, navlink with context %}

<div class="col-md-3 settings-col">
    <div class="nav-sidebar">
        <ul class="nav">
            {{ navlink('management.groups', _("Manage Groups")) }}
            {{ navlink('management.add_group', _("Add Group")) }}
        </ul>
    </div>
</div>

<div class="col-md-9 settings-col with-left-border">
    <div class="panel settings-panel">
        <div class="panel-heading settings-head">
            <span class="fa fa-users"></span> {% trans %}Groups{% endtrans %}
        </div>
        <div class="panel-body settings-body">
            <div class="settings-content">
                <div class="settings-meta row">
                    <div class="col-md-1 col-sm-1 col-xs-1 meta-item"><input type="checkbox" name="rowtoggle" class="action-checkall" title="Select All"/></div>
                    <div class="col-md-4 col-sm-4 col-xs-5 meta-item">{% trans %}Group Name{% endtrans %}</div>
                    <div class="col-md-5 col-sm-5 hidden-xs meta-item">{% trans %}Description{% endtrans %}</div>
                    <div class="col-md-2 col-sm-2 col-xs-5">
                        <div class="btn-group">
                            <button type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown">
                                <span class="fa fa-fw fa-cog"></span> {% trans %}Actions{% endtrans %}
                            </button>
                            <ul class="dropdown-menu slidedown">
                                <li>
                                    <button class="btn btn-link" onclick="return bulk_actions.execute('{{ url_for('management.delete_group') }}')">
                                        <span class="fa fa-fw fa-trash text-danger"></span> {% trans %}Delete selected Groups{% endtrans %}
                                    </button>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>

            {% for group in groups.items %}
                <div class="row settings-row hover clearfix">
                    <div class="col-md-1 col-sm-1 col-xs-1"><input type="checkbox" name="rowid" class="action-checkbox" value="{{ group.id }}" title="Select Group"/></div>
                    <div class="col-md-4 col-sm-4 col-xs-5">{{ group.name }}</div>
                    <div class="col-md-5 col-sm-5 hidden-xs">{{ group.description }}</div>
                    <div class="col-md-2 col-sm-2 col-xs-5">
                        <a href="{{ url_for('management.edit_group', group_id = group.id) }}" class="btn btn-icon">
                            <span class="fa fa-pencil text-primary" data-toggle="tooltip" data-placement="top" title="{% trans %}Edit{% endtrans %}"></span>
                        </a>
                        {# only display "Delete" if group is not part of the standard groups. #}
                        {% if group.id > 6 %}
                        <form class="inline-form" id="delete-{{group.id}}" method="post" action="{{ url_for('management.delete_group', group_id=group.id) }}">
                            <input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
                            <button class="btn btn-icon" name="confirmDialog" data-toggle="tooltip" data-placement="top" title="{% trans %}Delete{% endtrans %}">
                                <span class="fa fa-trash text-danger"></span>
                            </button>
                        </form>
                        {% endif %}
                    </div>
                </div>
            {% else %}
                <div class="row settings-row clearfix">
                    <div class="col-md-12 col-sm-12 col-xs-12">{% trans %}No groups found.{% endtrans %}</div>
                </div>
            {% endfor %}
            </div>
        </div>
        <div class="panel-footer settings-footer">
            {{ render_pagination(groups, url_for('management.groups')) }}
        </div>
    </div>
</div>
{% include theme('confirm_dialog.html') %}
{% endblock %}

{% block scripts %}
    <script>
    var bulk_actions = new BulkActions();
    </script>
{% endblock %}
