{#
/**
 * @file
 * Template for list of forums and containers.
 */
#}

<table id="forum-{{ forum_id }}" class="table">
  <thead>
  <tr>
    <th>{{ 'Forum'|t }}</th>
    <th>{{ 'Topics'|t }}</th>
    <th>{{ 'Posts'|t }}</th>
    <th>{{ 'Last post'|t }}</th>
  </tr>
  </thead>
  <tbody>
  {% for child_id, forum in forums %}
    <tr id="forum-list-{{ child_id }}" class="{{ forum.zebra }}">
      <td {% if forum.is_container == true -%}
        colspan="4" class="container"
      {%- else -%}
        class="forum-list__forum pt-4 pb-2"
        {%- endif -%}>
        {#
          Enclose the contents of this cell with X divs, where X is the
          depth this forum resides at. This will allow us to use CSS
          left-margin for indenting.
        #}
        {% if forum.depth > 0 %}{% for i in 1..forum.depth %}<div class="indented">{% endfor %}{% endif %}
          <div class="forum__icon forum-status-{{ forum.icon_class }}" title="{{ forum.icon_title }}">
            <span class="visually-hidden">{{ forum.icon_title }}</span>
          </div>
          <div class="d-flex align-items-center">
            <h4 class="forum__name mr-2 mb-0"><a href="{{ forum.link }}">{{ forum.label }}</a></h4>
            {% if forum.new_topics == true %}
              <a href="{{ forum.new_url }}" class="badge badge-primary">{{ forum.new_text }}</a>
            {% endif %}
          </div>
          {% if forum.description.value %}
            <div class="forum__description text-muted mt-1">{{ forum.description.value }}</div>
          {% endif %}
        {% if forum.depth > 0 %}{% for i in 1..forum.depth %}</div>{% endfor %}{% endif %}
      </td>
      {% if forum.is_container == false %}
        <td class="forum__topics pt-4 pb-2">
          {{ forum.num_topics }}
        </td>
        <td class="forum__posts pt-4 pb-2">{{ forum.num_posts }}</td>
        <td class="forum__last-reply pt-4 pb-2">{{ forum.last_reply }}</td>
      {% endif %}
    </tr>
  {% endfor %}
  </tbody>
</table>
