{% extends 'generic/object_edit.html' %}
{% load form_helpers %}

{% block form %}
    {% render_errors form %}
    
    <div class="field-group my-5">
      <div class="row mb-2">
        <h5 class="offset-sm-3">Device</h5>
      </div>
      {% render_field form.name %}
      {% render_field form.device_role %}
      {% render_field form.tags %}
    </div>
    
    <div class="field-group my-5">
      <div class="row mb-2">
        <h5 class="offset-sm-3">Hardware</h5>
      </div>
      {% render_field form.manufacturer %}
      {% render_field form.device_type %}
      {% render_field form.airflow %}
      {% render_field form.serial %}
      {% render_field form.asset_tag %}
    </div>
    
    <div class="field-group my-5">
      <div class="row mb-2">
        <h5 class="offset-sm-3">Location</h5>
      </div>
      {% render_field form.region %}
      {% render_field form.site_group %}
      {% render_field form.site %}
      {% render_field form.location %}
      {% render_field form.rack %}

      {% if object.device_type.is_child_device and object.parent_bay %}
        <div class="row mb-3">
          <label class="col-sm-3 col-form-label">Parent Device</label>
          <div class="col">
            <input class="form-control" value="{{ object.parent_bay.device }}" disabled />
          </div>
        </div>
        <div class="row mb-3">
          <label class="col-sm-3 col-form-label">Parent Bay</label>
          <div class="col">
            <div class="input-group">
              <input class="form-control" value="{{ object.parent_bay.name }}" disabled />
              <a href="{% url 'dcim:devicebay_depopulate' pk=object.parent_bay.pk %}" title="Regenerate Slug" class="btn btn-danger d-inline-flex align-items-center">
                <i class="mdi mdi-close-thick"></i>&nbsp;Remove
              </a>
            </div>
            </div>
          </div>
      {% else %}
        {% render_field form.face %}
        {% render_field form.position %}
      {% endif %}
    </div>
    
    <div class="field-group my-5">
      <div class="row mb-2">
        <h5 class="offset-sm-3">Management</h5>
      </div>
      {% render_field form.status %}
      {% render_field form.platform %}
      {% if object.pk %}
        {% render_field form.primary_ip4 %}
        {% render_field form.primary_ip6 %}
      {% endif %}
    </div>
    
    <div class="field-group my-5">
      <div class="row mb-2">
        <h5 class="offset-sm-3">Virtualization</h5>
      </div>
      {% render_field form.cluster_group %}
      {% render_field form.cluster %}
    </div>
    
    <div class="field-group my-5">
      <div class="row mb-2">
        <h5 class="offset-sm-3">Tenancy</h5>
      </div>
      {% render_field form.tenant_group %}
      {% render_field form.tenant %}
    </div>

    {% if form.custom_fields %}
      <div class="field-group my-5">
        <div class="row mb-2">
          <h5 class="offset-sm-3">Custom Fields</h5>
        </div>
        {% render_custom_fields form %}
      </div>
    {% endif %}

    <div class="field-group my-5">
      <h5 class="text-center">Local Config Context Data</h5>
      {% render_field form.local_context_data %}
    </div>

    <div class="field-group mb-5">
      <h5 class="text-center">Comments</h5>
      {% render_field form.comments %}
    </div>

{% endblock %}
