{% extends "edit_object.html" %}

{% load i18n %}

{% block title %}{{  block.super }}{% endblock %}

{% block header %}{{ block.super }} {% endblock %}

{% block footer %}{{ block.super }}{% endblock %}

{% block sidebar %}{{ block.super }}{% endblock %}

{% block content %}
    {% if my_object %}
        <!-- wrapper for scrollable items -->
        <ul class="nav nav-tabs" id="objecttab">
            <li><a href="#general" data-toggle="tab">{% trans "General" %}</a></li>
            <li><a href="#members" data-toggle="tab">{% trans "Members" %}</a></li>
            <li><a href="#memberof" data-toggle="tab">{% trans "Member Of" %}</a></li>
            <li><a href="#advanced" data-toggle="tab">{% trans "Advanced" %}</a></li>
        </ul>
        <form class="form-horizontal" action="#" method="POST">
            {% csrf_token %}
            <div class="tab-content">


                <div class="tab-pane" id="general">
                    <fieldset>
                        {% include "bootstrap_field.html" with field=form.hostgroup_name %}
                        {% include "bootstrap_field.html" with field=form.alias %}
                    </fieldset>

                    <div class="form-actions">
                        <button class="btn btn-primary" type="submit">{% trans "Save changes" %}</button>
                    </div>
                </div>

                <div class="tab-pane" id="memberof">
                    <fieldset>
                        <!-- Display All Hostgroups if this is that kind of an object -->
                        <div class="effective_memberof">
                            <fieldset id="id_effective_memberof" class="attribute_{{object_type}}">
                                {% trans "Following is a list of all hostgroups that" %} <i>{{ my_object.hostgroup_name }}</i> {% trans "is a member of." %}
                                <p></p>
                                {% if effective_memberof %}
                                    <p>
                                        {% for group in effective_memberof %}
                                            <label><a href="{% url "adagios.objectbrowser.views.edit_object" group.id %}">{{group.hostgroup_name}}</a></label>
                                        {% endfor %}
                                    </p>
                                {% endif %}
                            </fieldset>
                        </div>

                    </fieldset>

                    <div class="form-actions">
                        <button class="btn btn-primary" type="submit">{% trans "Save changes" %}</button>
                    </div>
                </div>


                <div class="tab-pane" id="members">
                    <fieldset>
                        {% include "bootstrap_field.html" with field=form.members %}
                        {% include "bootstrap_field.html" with field=form.hostgroup_members %}
                    </fieldset>

                    <div class="effective_hosts">
                        <fieldset id="id_effective_hosts" class="attribute_{{object_type}}">
                            <legend>{% trans "Effective Members of this group" %}</legend>
                            {% trans 'Group membership can be defined in multiple ways, for example by editing the host and editing the "hostgroups" attribute. For your convenience, here is a list of all hosts for this hostgroup.' %}
                            <p></p>
                            {% if effective_hosts %}
                                <p>
                                    {% for i in effective_hosts %}
                                        <label><a href="{% url "adagios.objectbrowser.views.edit_object" i.id %}">{{i.host_name}}</a></label>
                                    {% endfor %}
                                </p>
                            {% endif %}
                        </fieldset>
                    </div>

                    <div class="form-actions">
                        <button class="btn btn-primary" type="submit">{% trans "Save changes" %}</button>
                    </div>
                </div>
        </form>
        <div class="tab-pane" id="advanced">
            <!-- All Attributes -->
            <h2>All Attributes</h2>
            <form action="{% url "objectbrowser.views.advanced_edit" my_object.id %}" method="post" class="form-horizontal">{% csrf_token %}
                {% include "bootstrap_fields.html" with fields=advanced_form %}
                <div class="form-actions">
                    <button class="btn btn-primary" type="submit">{% trans "Submit" %}</button>
                </div>
            </form>
        </div>
        </div>



    {% else %}
        <p>{% trans "Object not found" %} </p>
    {% endif %}


{% endblock content %}
