{% extends "ui/panels/_base.html" %}
{% load perms %}
{% load i18n %}

{% block panel_content %}
  <table class="table table-hover attr-table">
    <thead>
      <tr class="border-bottom">
        <th>{% trans "Group" %}</th>
        <th>{% trans "Protocol" %}</th>
        <th>{% trans "Virtual IPs" %}</th>
        <th>{% trans "Priority" %}</th>
        <th aria-label="{% trans "Actions" %}"></th>
      </tr>
    </thead>
    <tbody>
      {% for assignment in object.fhrp_group_assignments.all %}
        <tr>
          <td>{{ assignment.group|linkify:"group_id" }}</td>
          <td>{{ assignment.group.get_protocol_display }}</td>
          <td>
            {% for ipaddress in assignment.group.ip_addresses.all %}
              {{ ipaddress|linkify }}{% if not forloop.last %}<br />{% endif %}
            {% endfor %}
          </td>
          <td>{{ assignment.priority }}</td>
          <td class="text-end d-print-none">
            {% if request.user|can_change:assignment %}
              <a href="{% url 'ipam:fhrpgroupassignment_edit' pk=assignment.pk %}?return_url={{ object.get_absolute_url }}" class="btn btn-sm btn-warning" title="{% trans "Edit" %}">
                <i class="mdi mdi-pencil" aria-hidden="true"></i>
              </a>
            {% endif %}
            {% if request.user|can_delete:assignment %}
              <a href="{% url 'ipam:fhrpgroupassignment_delete' pk=assignment.pk %}?return_url={{ object.get_absolute_url }}" class="btn btn-sm btn-danger" title="{% trans "Delete" %}">
                <i class="mdi mdi-trash-can-outline" aria-hidden="true"></i>
              </a>
            {% endif %}
          </td>
        </tr>
      {% empty %}
        <tr>
          <td colspan="5" class="text-muted">{% trans "None" %}</td>
        </tr>
      {% endfor %}
    </tbody>
  </table>
{% endblock panel_content %}
