{% load i18n %}

{% load common_tags %}
{% load navigation_tags %}
{% load smart_settings_tags %}

{% smart_setting "COMMON_PROJECT_TITLE" as common_project_title %}

{% spaceless %}
    <div aria-multiselectable="true" class="panel-group" id="accordion-sidebar" role="tablist">
        <div class="panel-heading" id="menu-main-button-close" role="tab">
            <h4 class="panel-title">
                <a class="disabled" href="">
                    <i class="fa fa-angle-double-left"></i>
                </a>
            </h4>
        </div>
        {% navigation_resolve_menu name='main' as main_menus_results %}
        {% for main_menu_results in main_menus_results %}
            {% for link_group in main_menu_results.link_groups %}
                {% for link in link_group.links %}
                    {% with 'active' as li_class_active %}
                    {% with ' ' as link_classes %}
                        {% if link|common_get_type == "<class 'mayan.apps.navigation.menus.Menu'>" %}
                            <div class="panel panel-default">
                                <div class="panel-heading" id="heading-{{ link.name }}" role="tab" >
                                    <h4 class="panel-title">
                                        <a aria-controls="collapse-{{ link.name }}" aria-expanded="false" class="non-ajax collapsed" data-parent="#accordion-sidebar" data-toggle="collapse" href="#accordion-body-{{ forloop.counter }}" role="button">
                                            <div class="pull-left">
                                                {% navigation_link_get_icon link=link as link_icon %}
                                                {% if link_icon %}{{ link_icon.render }}{% endif %}
                                                {{ link.label }}
                                            </div>
                                            <div class="accordion-indicator pull-right"><span class="caret"></span></div>
                                            <div class="clearfix"></div>
                                        </a>
                                    </h4>
                                </div>
                                <div aria-labelledby="heading-{{ link.name }}" class="panel-collapse collapse" id="accordion-body-{{ forloop.counter }}" role="tabpanel">
                                    <div class="panel-body">
                                        <ul class="list-unstyled">
                                            {% navigation_resolve_menu name=link.name as sub_menus_results %}
                                            {% for sub_menu_results in sub_menus_results %}
                                                {% for link_group in sub_menu_results.link_groups %}
                                                    {% with '' as link_class_active %}
                                                    {% with 'a-main-menu-accordion-link' as link_classes %}
                                                    {% with 'true' as as_li %}
                                                    {% with link_group.links as object_navigation_links %}
                                                        {% include 'navigation/generic_navigation.html' %}
                                                    {% endwith %}
                                                    {% endwith %}
                                                    {% endwith %}
                                                    {% endwith %}
                                                {% endfor %}
                                            {% endfor %}
                                        </ul>
                                    </div>
                                </div>
                            </div>
                        {% else %}
                            <div class="panel panel-default">
                                <div class="panel-heading" role="tab">
                                    <h4 class="panel-title">
                                        {% with 'a-main-menu-accordion-link' as link_classes %}
                                            {% include 'navigation/generic_link_instance.html' %}
                                        {% endwith %}
                                    </h4>
                                </div>
                            </div>
                        {% endif %}
                    {% endwith %}
                    {% endwith %}
                {% endfor %}
            {% endfor %}
        {% endfor %}

        <div class="footer navbar-fixed-bottom text-center" id="main-menu-footer">
            <hr>
            <span class="text-center">
                {% if common_project_title %}<p>{{ common_project_title }}</p>{% endif %}
                <p id="main-menu-footer-copyright"><a class="new_window" href="{% common_project_information '__website__' %}">{% common_project_information '__title__' %}</a></p>
                <p>{% common_project_information '__copyright__' %}</p>
            </span>
        </div>

    </div>
{% endspaceless %}
