{% extends 'utilities/obj_edit.html' %}
{% load static from staticfiles %}
{% load form_helpers %}
{% load helpers %}

{% block tabs %}
    {% if not obj.pk %}
        {% include 'ipam/inc/ipadress_edit_header.html' with active_tab='add' %}
    {% endif %}
{% endblock %}

{% block form %}
    <div class="panel panel-default">
        <div class="panel-heading"><strong>IP Address</strong></div>
        <div class="panel-body">
            {% render_field form.address %}
            {% render_field form.status %}
            {% render_field form.role %}
            {% render_field form.vrf %}
            {% render_field form.description %}
        </div>
    </div>
    <div class="panel panel-default">
        <div class="panel-heading"><strong>Tenancy</strong></div>
        <div class="panel-body">
            {% render_field form.tenant_group %}
            {% render_field form.tenant %}
        </div>
    </div>
    {% if obj.interface %}
        <div class="panel panel-default">
            <div class="panel-heading">
                <strong>Interface Assignment</strong>
            </div>
            <div class="panel-body">
                <div class="form-group">
                    <label class="col-md-3 control-label">{{ obj.interface.parent|model_name|bettertitle }}</label>
                    <div class="col-md-9">
                        <p class="form-control-static">
                            <a href="{{ obj.interface.parent.get_absolute_url }}">{{ obj.interface.parent }}</a>
                        </p>
                    </div>
                </div>
                {% render_field form.interface %}
                {% render_field form.primary_for_parent %}
            </div>
        </div>
    {% endif %}
    <div class="panel panel-default">
        <div class="panel-heading"><strong>NAT IP (Inside)</strong></div>
        <div class="panel-body">
            <ul class="nav nav-tabs" role="tablist">
                <li role="presentation" class="active"><a href="#select" aria-controls="home" role="tab" data-toggle="tab">By Device</a></li>
                <li role="presentation"><a href="#search" aria-controls="search" role="tab" data-toggle="tab">By IP</a></li>
            </ul>
            <div class="tab-content">
                <div class="tab-pane active" id="select">
                    {% render_field form.nat_site %}
                    {% render_field form.nat_rack %}
                    {% render_field form.nat_device %}
                </div>
                <div class="tab-pane" id="search">
                    {% render_field form.livesearch %}
                </div>
            </div>
            {% render_field form.nat_inside %}
        </div>
    </div>
    {% if form.custom_fields %}
        <div class="panel panel-default">
            <div class="panel-heading"><strong>Custom Fields</strong></div>
            <div class="panel-body">
                {% render_custom_fields form %}
            </div>
        </div>
    {% endif %}
{% endblock %}

{% block javascript %}
<script src="{% static 'js/livesearch.js' %}?v{{ settings.VERSION }}"></script>
{% endblock %}
