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

{% block content %}
  <div class="row">
    <div class="col col-md-6">
      <div class="card">
        <h5 class="card-header">
          Tag
        </h5>
        <div class="card-body">
          <table class="table table-hover panel-body attr-table">
            <tr>
              <th scope="row">Name</th>
              <td>
                {{ object.name }}
              </td>
            </tr>
            <tr>
              <th scope="row">Description</th>
              <td>
                  {{ object.description|placeholder }}
              </td>
            </tr>
            <tr>
              <th scope="row">Color</th>
              <td>
                  <span class="color-label" style="background-color: #{{ object.color }}">&nbsp;</span>
              </td>
            </tr>
            <tr>
              <th scope="row">Tagged Items</th>
              <td>
                  {{ taggeditem_table.rows|length }}
              </td>
            </tr>
          </table>
        </div>
      </div>
    </div>
    <div class="col col-md-6">
      <div class="card">
        <h5 class="card-header">
          Tagged Item Types
        </h5>
        <div class="card-body">
          <table class="table table-hover panel-body attr-table">
            {% for object_type in object_types %}
              <tr>
                <td>{{ object_type.content_type.name|bettertitle }}</td>
                <td>
                  {% with viewname=object_type.content_type.model_class|validated_viewname:"list" %}
                    {% if viewname %}
                      <a href="{% url viewname %}?tag={{ object.slug }}">{{ object_type.item_count }}</a>
                    {% else %}
                      {{ object_type.item_count }}
                    {% endif %}
                  {% endwith %}
                </td>
              </tr>
            {% endfor %}
          </table>
        </div>
      </div>
    </div>
  </div>
  <div class="row">
    <div class="col col-md-12">
      <div class="card">
        <h5 class="card-header">Tagged Objects</h5>
        <div class="card-body table-responsive">
          {% render_table taggeditem_table 'inc/table.html' %}
          {% include 'inc/paginator.html' with paginator=taggeditem_table.paginator page=taggeditem_table.page %}
        </div>
      </div>
      {% plugin_full_width_page object %}
    </div>
  </div>
{% endblock %}
