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

{% block tabs %}
  {% include 'netbox_inventory/inc/asset_edit_header.html' with active_tab='add' %}
{% endblock tabs %}

{% block form %}
    <div class="field-group my-5">
        <div class="row mb-2">
          <h5 class="offset-sm-3">General</h5>
        </div>
        {% render_field form.name %}
        {% render_field form.asset_tag %}
        {% render_field form.tags %}
        {% render_field form.status %}
    </div>

    <div class="field-group my-5">
        <div class="row mb-2">
          <h5 class="offset-sm-3">Hardware</h5>
        </div>
        {% render_field form.serial %}
        {% render_field form.manufacturer %}
        <div class="row mb-2 offset-sm-3">
          <ul class="nav nav-pills" role="tablist">
            <li role="presentation" class="nav-item">
                <button role="tab" type="button" id="device_type_tab" data-bs-toggle="tab" aria-controls="device_type" data-bs-target="#device_type" class="nav-link {% if form.initial.device_type or form.no_hardware_type %}active{% endif %}">
                  Device
                </button>
              </li>
            <li role="presentation" class="nav-item">
                <button role="tab" type="button" id="module_type_tab" data-bs-toggle="tab" aria-controls="module_type" data-bs-target="#module_type" class="nav-link {% if form.initial.module_type %}active{% endif %}">
                  Module
                </button>
              </li>
            <li role="presentation" class="nav-item">
                <button role="tab" type="button" id="inventoryitem_type_tab" data-bs-toggle="tab" aria-controls="inventoryitem_type" data-bs-target="#inventoryitem_type" class="nav-link {% if form.initial.inventoryitem_type %}active{% endif %}">
                  Inventory Item
                </button>
              </li>
          </ul>
        </div>
        <div class="tab-content p-0 border-0">
          <div class="tab-pane {% if form.initial.device_type or form.no_hardware_type %}active{% endif %}" id="device_type" role="tabpanel" aria-labeled-by="device_type_tab">
            {% render_field form.device_type %}
          </div>
          <div class="tab-pane {% if form.initial.module_type %}active{% endif %}" id="module_type" role="tabpanel" aria-labeled-by="module_type_tab">
            {% render_field form.module_type %}
          </div>
          <div class="tab-pane {% if form.initial.inventoryitem_type %}active{% endif %}" id="inventoryitem_type" role="tabpanel" aria-labeled-by="inventoryitem_type_tab">
            {% render_field form.inventoryitem_type %}
          </div>
        </div>
    </div>

    <div class="field-group my-5">
        <div class="row mb-2">
          <h5 class="offset-sm-3">Purchase</h5>
        </div>
        {% render_field form.owner %}
        {% render_field form.purchase %}
        {% render_field form.delivery %}
        {% render_field form.warranty_start %}
        {% render_field form.warranty_end %}
    </div>

    <div class="field-group my-5">
        <div class="row mb-2">
          <h5 class="offset-sm-3">Assigned to</h5>
        </div>
        {% render_field form.tenant %}
        {% render_field form.contact %}
    </div>

    <div class="field-group my-5">
        <div class="row mb-2">
          <h5 class="offset-sm-3">Location</h5>
        </div>
        {% render_field form.storage_site %}
        {% render_field form.storage_location %}
    </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 mb-5">
        <h5 class="text-center">Comments</h5>
        {% render_field form.comments %}
    </div>

{% endblock %}
