{% set page_title = active_nav.get('title') %}

{% 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">{{ active_nav.get('title') }}</li>
</ol>
{% endblock %}

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


<div class="col-md-3 settings-col">
    <div class="nav-sidebar">
        <ul class="nav">
        <li class="nav-header">FlaskBB Settings</li>
        {% for group in all_groups %}
            {% if group.key == active_nav.get('key') %}
                <li class="active"><a href="{{ url_for('management.settings', slug=group.key) }}">{{ group.name }}</a></li>
            {% else %}
                <li><a href="{{ url_for('management.settings', slug=group.key) }}">{{ group.name }}</a></li>
            {% endif %}
        {% endfor %}
        {% if all_plugins %}
        <li class="nav-header">Plugin Settings</li>
        {% for plugin in all_plugins %}
            {% if plugin.name == active_nav.get('key') %}
                <li class="active"><a href="{{ url_for('management.settings', plugin=plugin.name) }}">{{ plugin.name.title() }}</a></li>
            {% else %}
                <li><a href="{{ url_for('management.settings', plugin=plugin.name) }}">{{ plugin.name.title() }}</a></li>
            {% endif %}
        {% endfor %}
        {% endif %}
        </ul>
    </div>
</div><!--/.col-md-3 -->

<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-cogs"></span> {{ active_nav.get('title') }}
        </div>
        <div class="panel-body settings-body">
            <div class="settings-content">
                <form class="form-horizontal settings-form" role="form" method="post">
                    <div class="col-md-12 col-sm-12 col-xs-12">

                        {{ form.hidden_tag() }}
                        {% for field in form %}
                            {% if field.type not in ["TextField", "IntegerField"] %}
                                {% if field.type == "BooleanField" %}
                                    {{ render_boolean_field(field) }}
                                {% endif %}

                                {% if field.type in ["SelectField", "SelectMultipleField"] %}
                                    {{ render_select_field(field) }}
                                {% endif %}
                            {% else %}
                                {{ render_field(field) }}
                            {% endif %}
                        {% endfor %}

                        <div class="form-group">
                            <div class="col-sm-5">
                                <button type="submit" class="btn btn-success">
                                    {% trans %}Save{% endtrans %}
                                </button>
                            </div>
                        </div>

                    </div> <!-- end col-md-12...-->
                </form>

            </div>
        </div> <!-- end settings-body -->
    </div>
</div>
{% endblock %}
