{% extends "docbow/base_user.html" %}
{% load i18n %}
{% load render_table from django_tables2 %}

{% block extra_scripts %}
{{ block.super }}
<link rel="stylesheet" href="{{ STATIC_URL }}django_tables2/themes/paleblue/css/screen.css" />
{{ filter_form.media.css }}

{% endblock %}

{% block main-column %}
{% block box_title %}
<h3>{% trans "Documents" %}</h3>
{% endblock %}

<div id="mailbox-table">
  <form method="get" action=".">
    {% if filter_form.non_field_errors %}
      <p>{{ filter_form.non_field_errors }}</p>
    {% endif %}
    {% if filter_form.sort %}{{ filter_form.sort }}{% endif %}
    {% if filter_form.page %}{{ filter_form.page }}{% endif %}
    <p id="filter-inputs">
      Messages du {{ filter_form.not_before }} au {{ filter_form.not_after }}
      {{ filter_form.not_before.errors }}
      {{ filter_form.not_after.errors }}
      {% trans "containing" %}
      {{ filter_form.search_terms }}
      <input type="submit" name="submit" value="Filtrer"/>
      <input type="submit" name="clear" value="Effacer les filtres"/>
      {% if show_trash %}<span class="action"><a href="{{trash_url}}">{% trans "Trash" %}</a>{% endif %}
    </p>
  </form>
  {% block mailbox.table %}
    {% render_table table "docbow/mailbox_table.html" %}
  {% endblock %}
</div>
{% endblock %}

{% block endscripts %}
{{ filter_form.media.js }}
<script>
  $('#mailbox-table').delegate('.tooltip', 'click', function (e) {
      var $this = $(this);
      var $p = $this.find('p');
      $('.tooltip p').not($p).hide();
      $this.find('p').toggle();
      e.stopPropagation();
  });
  $('#mailbox-table').delegate('.js-mailbox-row', 'click',
    function () {
      var id = $(this).data('id');
      var href = "{% block mailbox.url %}{% endblock %}".replace('99999999', id);
      document.location.href = href;
    });
</script>
<script src="{{ STATIC_URL }}js/refresh.js"></script>
<script src="{{ STATIC_URL }}js/actions.js"></script>
{% endblock %}
