{% extends 'generic/object.html' %}
{% load helpers %}
{% load plugins %}
{% load render_table from django_tables2 %}
{% load i18n %}

{% block breadcrumbs %}
  {{ block.super }}
  {% if object.group %}
    <li class="breadcrumb-item"><a href="{% url 'tenancy:contact_list' %}?group_id={{ object.group.pk }}">{{ object.group }}</a></li>
  {% endif %}
{% endblock breadcrumbs %}

{% block content %}
  <div class="row">
    <div class="col col-12 col-md-7">
      <div class="card">
        <h2 class="card-header">{% trans "Contact" %}</h2>
        <table class="table table-hover attr-table">
          <tr>
            <th scope="row">{% trans "Groups" %}</th>
            <td>
              {% if object.groups.all|length > 0 %}
                <ol class="list-unstyled mb-0">
                  {% for group in object.groups.all %}
                    <li>{{ group|linkify|placeholder }}</li>
                  {% endfor %}
                </ol>
              {% else %}
                {{ ''|placeholder }}
              {% endif %}
            </td>
          </tr>
          <tr>
            <th scope="row">{% trans "Name" %}</th>
            <td>{{ object.name }}</td>
          </tr>
          <tr>
            <th scope="row">{% trans "Title" %}</th>
            <td>{{ object.title|placeholder }}</td>
          </tr>
          <tr>
            <th scope="row">{% trans "Phone" %}</th>
            <td>
              {% if object.phone %}
                <a href="tel:{{ object.phone }}">{{ object.phone }}</a>
              {% else %}
                {{ ''|placeholder }}
              {% endif %}
            </td>
          </tr>
          <tr>
            <th scope="row">{% trans "Email" %}</th>
            <td>
              {% if object.email %}
                <a href="mailto:{{ object.email }}">{{ object.email }}</a>
              {% else %}
                {{ ''|placeholder }}
              {% endif %}
            </td>
          </tr>
          <tr>
            <th scope="row">{% trans "Address" %}</th>
            <td>{{ object.address|linebreaksbr|placeholder }}</td>
          </tr>
          <tr>
            <th scope="row">{% trans "Link" %}</th>
            <td>
              {% if object.link %}
                <a href="{{ object.link }}">{{ object.link }}</a>
              {% else %}
                {{ ''|placeholder }}
              {% endif %}
            </td>
          </tr>
          <tr>
            <th scope="row">{% trans "Description" %}</th>
            <td>{{ object.description|placeholder }}</td>
          </tr>
        </table>
      </div>
      {% include 'inc/panels/tags.html' %}
      {% plugin_left_page object %}
    </div>
    <div class="col col-md-5">
      {% include 'inc/panels/comments.html' %}
      {% include 'inc/panels/custom_fields.html' %}
      {% plugin_right_page object %}
    </div>
  </div>
  <div class="row mb-3">
    <div class="col col-md-12">
      <div class="card">
        <h2 class="card-header">{% trans "Assignments" %}</h2>
        {% htmx_table 'tenancy:contactassignment_list' contact_id=object.pk %}
      </div>
      {% plugin_full_width_page object %}
    </div>
  </div>
{% endblock %}
