{% extends 'ipam/iprange/base.html' %}
{% load helpers %}

{% block extra_controls %}
  {% if perms.ipam.add_ipaddress and active_tab == 'ip-addresses' and object.first_available_ip %}
    <a href="{% url 'ipam:ipaddress_add' %}?address={{ object.first_available_ip }}&vrf={{ object.vrf.pk }}&tenant_group={{ object.tenant.group.pk }}&tenant={{ object.tenant.pk }}" class="btn btn-sm btn-primary">
        <i class="mdi mdi-plus-thick" aria-hidden="true"></i> Add IP Address
    </a>
  {% endif %}
{% endblock %}

{% block content %}
  {% include 'inc/table_controls_htmx.html' with table_modal="IPAddressTable_config" %}
  
  <form method="post">
    {% csrf_token %}

    <div class="card">
      <div class="card-body" id="object_list">
        {% include 'htmx/table.html' %}
      </div>
    </div>

    <div class="noprint bulk-buttons">
      <div class="bulk-button-group">
        {% if perms.ipam.change_ipaddress %}
          <button type="submit" name="_edit" formaction="{% url 'ipam:ipaddress_bulk_edit' %}?return_url={% url 'ipam:iprange_ipaddresses' pk=object.pk %}" class="btn btn-warning btn-sm">
            <i class="mdi mdi-pencil" aria-hidden="true"></i> Edit
          </button>
        {% endif %}
        {% if perms.ipam.delete_ipaddress %}
          <button type="submit" name="_delete" formaction="{% url 'ipam:ipaddress_bulk_delete' %}?return_url={% url 'ipam:iprange_ipaddresses' pk=object.pk %}" class="btn btn-danger btn-sm">
            <i class="mdi mdi-trash-can-outline" aria-hidden="true"></i> Delete
          </button>
        {% endif %}
      </div>
    </div>
  </form>
{% endblock %}

{% block modals %}
  {{ block.super }}
  {% table_config_form table %}
{% endblock modals %}
