{% extends "django_tables2/table.html" %}
{% load docbow %}
{% load i18n %}
{% load humanize %}

{% block table.tbody.row %}
  <tr class="js-mailbox-row {% cycle "odd" "even" as parity %}"
      data-id="{{ row.record.id }}"
  >
    {% for column, cell in row.items %}
      <td {{ column.attrs.td.as_html }}>
        {{ cell }}
        {% if column.name == 'filetype' and row.record.comment %}
          <span class="tooltip"><i class="fa fa-eye plus"></i>
            <p>{{ row.record.comment }}</p>
          </span>
        {% endif %}
      </td>
    {% endfor %}
  </tr>
  {% block replies %}
    {% for reply in row.record.document.replies.all %}
      <tr class="{{parity }} reply">
        <td class="reply" colspan="7">
          <a href="{% url 'outbox-by-document-message' document_id=reply.id %}">
            {% blocktrans with sender=reply|doc_real_sender date=reply.date|naturalday:"SHORT_DATE_FORMAT" time=reply.date|time:"H:i" %}Reply sent by {{ sender }} on {{ date }} at {{ time }}{% endblocktrans %}
          </a>
        </td>
      </tr>
    {% endfor %}
  {% endblock %}
{% endblock %}

{% block pagination %}
  {% with num_page=table.page.number total_page=table.paginator.num_pages num_doc=table.page.object_list.data.count total_doc=table.paginator.count%}
    <ul class="pagination">
      {% if table.page.has_previous %}
        {% block pagination.previous %}{{ block.super }}{% endblock pagination.previous %}
      {% endif %}

      {% if table.page.has_previous or table.page.has_next %}
        <li>{% blocktrans %}Page {{ num_page }} of {{ total_page }}{% endblocktrans %}</li>
      {% endif %}

      {% if table.page.has_next %}
        {% block pagination.next %}{{ block.super }}{% endblock pagination.next %}
      {% endif %}

{% comment %}
Block of action buttons

Behaviour is in static/js/actions.js
{% endcomment %}
      <li class="actions" style="display: none;">
        <span class="actions-buttons">
          <form method="post" class="actions-form">
            {% csrf_token %}
            <input type="hidden" name="selection"/>
            <input type="submit" name="delete" value="{% trans "Delete" %}"/>
          </form>
        </span>
        <span class="actions-selection">
          {% blocktrans %}Selected <span class="js-selected"></span> of <span class="js-total">{{ total }}</span> documents{% endblocktrans %}
          <span class="action-selection-modifiers">
            <button class="js-delete-selection">{% trans "Cancel selection" %}</button>
            <button class="js-select-everything">{% blocktrans %}Select all {{ total }} documents{% endblocktrans %}</button>
          </span>
        </span>
      </li>
      <li class="cardinality">
        <span>{% if num_doc != total_doc %}{{ num_doc }} de {{ total_doc }}{% else %}{{ total_doc }}{% endif %} {% if total_doc == 1 %}document{% else %}documents{% endif %}</span>
        / <a href="{% block csv.url %}{% endblock %}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}">Export CSV</a>
        / <a href="{% block ods.url %}{% endblock %}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}">Export ODS</a>
      </li>
    </ul>
  {% endwith %}
{% endblock pagination %}
