{% 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-md-7">
      <div class="card">
        <h5 class="card-header">{% trans "Contact" %}</h5>
        <div class="card-body">
          <table class="table table-hover attr-table">
            <tr>
              <td>{% trans "Group" %}</td>
              <td>{{ object.group|linkify|placeholder }}</td>
            </tr>
            <tr>
              <td>{% trans "Name" %}</td>
              <td>{{ object.name }}</td>
            </tr>
            <tr>
              <td>{% trans "Title" %}</td>
              <td>{{ object.title|placeholder }}</td>
            </tr>
            <tr>
              <td>{% trans "Phone" %}</td>
              <td>
                {% if object.phone %}
                  <a href="tel:{{ object.phone }}">{{ object.phone }}</a>
                {% else %}
                  {{ ''|placeholder }}
                {% endif %}
              </td>
            </tr>
            <tr>
              <td>{% trans "Email" %}</td>
              <td>
                {% if object.email %}
                  <a href="mailto:{{ object.email }}">{{ object.email }}</a>
                {% else %}
                  {{ ''|placeholder }}
                {% endif %}
              </td>
            </tr>
            <tr>
              <td>{% trans "Address" %}</td>
              <td>{{ object.address|linebreaksbr|placeholder }}</td>
            </tr>
            <tr>
              <td>{% trans "Link" %}</td>
              <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>
      </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">
        <h5 class="card-header">{% trans "Assignments" %}</h5>
        <div class="card-body htmx-container table-responsive"
          hx-get="{% url 'tenancy:contactassignment_list' %}?contact_id={{ object.pk }}"
          hx-trigger="load"
        ></div>
      </div>
      {% plugin_full_width_page object %}
    </div>
  </div>
{% endblock %}
