{% extends "layout.html" %}

{% block content %}
<div class="content itemlist">
  <div class="stream">
    <div class="header">
      <h1>{% if tray.editor %}Рабочая папка пользователя {% else %}Папка {% endif %}{{ tray.title }}</h1>
    </div>
    <div class="stream-items">
      <div class="table">
        <div class="line"></div>
        <table class="container init-block"style="width: 100%"
               data-block-name="tray" 
               data-delete-url="{{ url_for("delete_from_tray") }}"><tbody><tr><td>
          <table class="items">
            <thead>
              <th>ID</th>
              <th>Тип</th>
              <th>Название</th>
              <th>Отправитель</th>
              <th>Комментарий</th>
              <th>Дата отправки</th>
            </thead>
            <tbody>
            {% if not items %}
              <td colspan="5">{% if tray.editor %}Рабочая папка{% else %}Папка{% endif %} пуста</td>
            {% endif %}
            {% for url, stream_title, stream, obj, item in items %}
              <tr class="item {{ loop.cycle('odd', 'even') }}
                         {%- if item.public is defined -%}
                           {%- if item.public %} published{% else %} unpublished{% endif -%}
                           {%- endif %}">
                <td class="field_id"><a href="{{ url }}">
                  {{- item.id -}}
                </a></td>
                <td class="field_id"><a href="{{ url }}">
                  {{- stream_title -}}
                </a></td>
                <td><a href="{{ url }}">
                    {%- if item.title is defined %}
                      {{- item.title -}}
                    {%- else -%}
                      {{- item -}}
                    {%- endif -%}
                </a></td>
                <td><a href="{{ url }}">
                    {% if obj.sender %}{{- obj.sender.name or obj.sender.login -}}{% endif %}
                </a></td>
                <td><a href="{{ url }}">
                  {{- obj.comment -}}
                </a></td>
                <td style="white-space: nowrap"><a href="{{ url }}">
                  {%- if obj.created_dt -%}
                    {{- obj.created_dt.strftime('%d.%m.%Y %H:%M') -}}
                  {%- endif -%}
                </a></td>
                <td><a class="tray__remove" data-id="{{ obj.id }}"></a></td>
              </tr>
            {% endfor %}
            </tbody>
          </table>
        </td></tr></tbody></table>
      </div>
    </div>
  </div>
</div>
{% endblock %}
