{% load aa_forum_template_variables %}
{% load i18n %}
{% load static %}

<div class="aa-forum-topic-row {% if topic.is_locked %}aa-forum-topic-locked{% endif %} {% if topic.is_sticky %}aa-forum-topic-sticky{% endif %} row">
    <div class="aa-forum-topic">
        <div class="aa-forum-topic-image">
            <img src="{% static 'aa_forum/images/new_none.png' %}" alt="Topic">
        </div>

        <div class="aa-forum-topic-name">
            <p>
                <a href="{% url 'aa_forum:forum_topic' topic.board.category.slug topic.board.slug topic.slug %}">
                    {{ topic.subject }}
                </a>
                <br>
                <span class="small">
                    {% if topic.is_sticky %}
                        <span class="aa-forum-topic-status-icon aa-forum-topic-status-sticky">
                            <i class="fas fa-thumbtack" title="{% translate 'Topic is always on top' %}"></i>
                        </span>
                    {% endif %}

                    {% if topic.is_locked %}
                        <span class="aa-forum-topic-status-icon aa-forum-topic-status-locked">
                            <i class="fas fa-lock" title="{% translate 'Topic is locked' %}"></i>
                        </span>
                    {% endif %}

                    {% translate "Started by" %} {{ topic.user_started|main_character_name }}
                </span>
            </p>
        </div>

        <div class="aa-forum-topic-stats hidden-sm hidden-xs">
            <span class="small">
                {% if topic.num_posts > 0 %}
                    {% if topic.num_posts == 2 %}
                        1 {% translate "Reply" %}
                    {% else %}
                        {{ topic.num_posts|add:"-1" }} {% translate "Replies" %}
                    {% endif %}
                {% else %}
                    0 {% translate "Replies" %}
                {% endif %}
            </span>
        </div>

        <div class="aa-forum-topic-last-post hidden-xs">
            <span class="small">
                {% translate "Last post" %} {{ topic.time_modified|date }}, {{ topic.time_modified|time:"G:i:s" }}

                <a href="{% url 'aa_forum:forum_message_entry_point_in_topic' topic.last_message.pk %}" title="{% translate 'Go to last message' %}" style="margin-left: 0.5rem;">
                    <i class="fas fa-sign-in-alt"></i>
                </a>

                <br>
                by {{ topic.user_updated|main_character_name }}
            </span>
        </div>

        <div class="aa-forum-topic-actions hidden-xs">
            {% if perms.aa_forum.manage_forum %}
                <div class="text-right">
                    {% if topic.is_locked %}
                        <button class="btn btn-aa-forum-topic-moderation btn-xs" title="{% translate 'Unlock/Re-Open Topic' %}" data-toggle="modal" data-target="#topic-lock-state-change-{{ topic.pk }}">
                            <i class="fas fa-unlock"></i>
                        </button>
                    {% else %}
                        <button class="btn btn-aa-forum-topic-moderation btn-xs" title="{% translate 'Lock/Close Topic' %}" data-toggle="modal" data-target="#topic-lock-state-change-{{ topic.pk }}">
                            <i class="fas fa-lock"></i>
                        </button>
                    {% endif %}

                    <button class="btn btn-aa-forum-topic-moderation btn-xs" data-toggle="modal" data-target="#topic-sticky-state-change-{{ topic.pk }}">
                        <i class="fas fa-thumbtack"></i>
                    </button>

                    <button class="btn btn-aa-forum-topic-moderation btn-xs" title="{% translate 'Delete Topic' %}" data-toggle="modal" data-target="#delete-topic-{{ topic.pk }}">
                        <i class="far fa-trash-alt"></i>
                    </button>
                </div>

                {% include "aa_forum/modals/forum/board/topic-change-lock-state.html" %}
                {% include "aa_forum/modals/forum/board/topic-change-sticky-state.html" %}
                {% include "aa_forum/modals/forum/board/topic-delete.html" %}
            {% endif %}
        </div>
    </div>
</div>
