{% extends "community/_base.html" %}

{% from "macros/box.html" import m_box_content, m_box_menu %}
{% from "macros/recent.html" import m_recent_items with context %}
{% from "macros/user.html" import m_user_avatar as m_user %}

{% from "documents/_macros.html" import m_docs_table, m_breadcrumbs2 with context %}

{% block content %}
  {% call m_box_content(title=_('Folder descendants')) %}
    <div style="margin: 5px 0;">
      <i class="fa fa-folder-open-o fa-large"></i>
      {{ m_breadcrumbs2(breadcrumbs) }}
    </div>

    <hr>

    {%- if folder.description %}
      <p>{{ folder.description }}</p>
      <p>&nbsp;</p>
    {%- endif %}

    <ul style="list-style: none; padding-left: 0;">
      {% for level, type, obj in descendants %}
        <li style="margin-left: {{ level*1.5 }}em; padding-top: 3px; padding-bottom: 3px;">
          <a href="{{ url_for(obj) }}">
            <img src="{{ get_icon(obj) }}" style="height: 16px; width: 16px;" alt="">
            {% if type == 'F' %}
              <b>{{ obj['name'] }}</b>
            {% else %}
              {{ obj['name'] }}
            {% endif %}
          </a>
          <small>
            {{ obj['created_at'] |datetimeformat(format='short') }}
            {%- set owner = owners.get(obj['owner']) %}
            {%- if owner %}
              {{ _('Owner') }}: {{ m_user(owner) }}
            {%- endif %}
          </small>

        </li>
      {% endfor %}
    </ul>

  {% endcall %}
{% endblock %}

{% block sidebar %}
  {%- set content_actions = actions.for_category('documents:content') %}
  {%- if content_actions %}
    {% call m_box_menu() %}
      <ul class="nav nav-list">
        {%- for action in content_actions %}
          <li>{{ action.render() }}</li>
        {%- endfor %}
      </ul>
    {% endcall %}
  {%- endif %}
{% endblock %}


{% block modals %}
  {% include "documents/_modals_folder.html" %}
{% endblock %}
