{% load helpers %}
{# renders panel on object (device, module) with bios info assigned to it #}

<div class="card">
  <h5 class="card-header">
    BIOS
    {% if perms.netbox_firmware.change_bios %}
      <div class="card-actions">
        {% with object|meta:"model_name" as object_type %}
          <a href="{% url 'plugins:netbox_firmware:biosassignment_add' %}?{{object_type}}={{object.id}}" class="btn btn-sm btn-ghost-primary">
        {% endwith %}
          <i class="mdi mdi-vector-link" aria-hidden="true"></i> Add Assignment
        </a>
      </div>
    {% endif %}
  </h5>
  <!--check if bios item is filled and then show name version and status that is given-->
  {% if assignments %}
  <div class="card-body">
    <table class="table">
      <thead>
        <tr>
          <th>Name</th>
          <th>Status</th>
          <th>Description</th>
          <th>Patch date</th>
        </tr>
      </thead>
      <tbody>
        {% for assignment in assignments %}
        <tr>
          <td><a href="{% url 'plugins:netbox_firmware:bios' assignment.bios.id %}">{{ assignment.bios.name }}</a></td>
          <td>{{ assignment.bios.status }}</td>
          <td>{{ assignment.description }}</td>
          <td>{{ assignment.patch_date }}</td>
          {% if perms.netbox_firmware.change_biosassignment %}
            <td>
              <a href="{% url 'plugins:netbox_firmware:biosassignment_edit' assignment.id %}" class="btn btn-sm btn-ghost-primary">
                <i class="mdi mdi-pencil" aria-hidden="true"></i> Edit
              </a>
            </td>
          {% endif %}
        </tr>
        {% endfor %}
      </tbody>
    </table>
  </div>
{% else %}
  <div class="card-body">
    <p class="card-text">No BIOS assigned for {{ object }}</p>
  </div>
{% endif %}
</div>