{% extends 'dcim/devicetype/base.html' %}
{% load render_table from django_tables2 %}
{% load helpers %}

{% block content %}
  {% if perms.dcim.change_devicetype %}
    <form method="post">
        {% csrf_token %}
        <div class="card">
            <h5 class="card-header">{{ title }}</h5>
            <div class="card-body" id="object_list">
              {% include 'htmx/table.html' %}
            </div>
            <div class="card-footer noprint">
                {% if table.rows %}
                    <button type="submit" name="_edit" formaction="{% url table.Meta.model|viewname:"bulk_rename" %}?return_url={{ return_url }}" class="btn btn-sm btn-warning">
                        <span class="mdi mdi-pencil-outline" aria-hidden="true"></span> Rename
                    </button>
                    <button type="submit" name="_edit" formaction="{% url table.Meta.model|viewname:"bulk_edit" %}?return_url={{ return_url }}" class="btn btn-sm btn-warning">
                        <span class="mdi mdi-pencil" aria-hidden="true"></span> Edit
                    </button>
                    <button type="submit" name="_delete" formaction="{% url table.Meta.model|viewname:"bulk_delete" %}?return_url={{ return_url }}" class="btn btn-sm btn-danger">
                        <i class="mdi mdi-trash-can-outline" aria-hidden="true"></i> Delete
                    </button>
                {% endif %}
                <div class="float-end">
                    <a href="{% url table.Meta.model|viewname:"add" %}?device_type={{ object.pk }}&return_url={{ return_url }}" class="btn btn-primary btn-sm">
                        <i class="mdi mdi-plus-thick" aria-hidden="true"></i>
                        Add {{ title }}
                    </a>
                </div>
                <div class="clearfix"></div>
            </div>
        </div>
    </form>
  {% else %}
    <div class="card">
      <h5 class="card-header">{{ title }}</h5>
      <div class="card-body" id="object_list">
        {% include 'htmx/table.html' %}
      </div>
    </div>
  {% endif %}
{% endblock content %}
