{% extends '_base.html' %}
{% load static from staticfiles %}
{% load form_helpers %}

{% block title %}Assign an IP Address{% endblock %}

{% block content %}
<form action="." method="post" class="form form-horizontal">
    {% csrf_token %}
    <div class="row">
        <div class="col-md-6 col-md-offset-3">
            {% if form.non_field_errors %}
                <div class="panel panel-danger">
                    <div class="panel-heading"><strong>Errors</strong></div>
                    <div class="panel-body">
                        {{ form.non_field_errors }}
                    </div>
                </div>
            {% endif %}
            <div class="panel panel-default">
                <div class="panel-heading">
                    <strong>Assign an IP Address</strong>
                </div>
                <div class="panel-body">
                    <div class="form-group">
                        <label class="col-md-3 control-label">IP Address</label>
                        <div class="col-md-9">
                            <p class="form-control-static">{{ ipaddress }}</p>
                        </div>
                        <label class="col-md-3 control-label">VRF</label>
                        <div class="col-md-9">
                            <p class="form-control-static">
                                {% if ipaddress.vrf %}
                                    <a href="{% url 'ipam:vrf' pk=ipaddress.vrf.pk %}">{{ ipaddress.vrf }}</a> ({{ ipaddress.vrf.rd }})
                                {% else %}
                                    <span>Global</span>
                                {% endif %}
                            </p>
                        </div>
                    </div>
                    <ul class="nav nav-tabs" role="tablist">
                        <li role="presentation" class="active"><a href="#search" aria-controls="search" role="tab" data-toggle="tab">Search</a></li>
                        <li role="presentation"><a href="#select" aria-controls="home" role="tab" data-toggle="tab">Select</a></li>
                    </ul>
                    <div class="tab-content">
                        <div class="tab-pane active" id="search">
                            {% render_field form.livesearch %}
                        </div>
                        <div class="tab-pane" id="select">
                            {% render_field form.site %}
                            {% render_field form.rack %}
                            {% render_field form.device %}
                        </div>
                    </div>
                    {% render_field form.interface %}
                    {% render_field form.set_as_primary %}
                </div>
            </div>
		    <div class="form-group">
                <div class="col-md-9 col-md-offset-3">
                    <button type="submit" name="_assign" class="btn btn-primary">Assign</button>
                    <a href="{{ return_url }}" class="btn btn-default">Cancel</a>
                </div>
		    </div>
        </div>
    </div>
</form>
{% endblock %}

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