{% trans_default_domain 'FOSCommentBundle' %}

{#

 This file is part of the FOSCommentBundle package.

 (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>

 This source file is subject to the MIT license that is bundled
 with this source code in the file LICENSE.

#}

{% set depth = depth|default(0) %}
{% set view = view|default('tree') %}

{% if depth == 0 %}
    {% if fos_comment_can_comment_thread(thread) %}
        {{ render(url('fos_comment_new_thread_comments', {"id": thread.id})) }}
    {% endif %}

    {% if fos_comment_can_edit_thread(thread) %}
        <div class="fos_comment_thread_commentable mt-4 mb-4 text-right">
            {% if thread.commentable %}
                <button data-url="{{ url('fos_comment_edit_thread_commentable', {'id': thread.id, 'value': not thread.commentable}) }}" class="fos_comment_thread_commentable_action btn btn-sm btn-danger">
                    <i class="fas fa-lock"></i> {{ (thread.commentable ? 'fos_comment_thread_close' : 'fos_comment_thread_open') | trans({}, 'FOSCommentBundle') }}
                </button>
            {% else %}
                <button data-url="{{ url('fos_comment_edit_thread_commentable', {'id': thread.id, 'value': not thread.commentable}) }}" class="fos_comment_thread_commentable_action btn btn-sm btn-success">
                    <i class="fas fa-lock-open"></i> {{ (thread.commentable ? 'fos_comment_thread_close' : 'fos_comment_thread_open') | trans({}, 'FOSCommentBundle') }}
                </button>
            {% endif %}
        </div>
    {% endif %}

    {% set count = thread.numComments %}
    <h4>{% transchoice count with {'%count%': count} from 'FOSCommentBundle' %}fos_comment_thread_comment_count{% endtranschoice %}</h4>
{% endif %}

{% for commentinfo in comments %}
    {% include '@FOSComment/Thread/comment.html.twig' with { 'children': commentinfo.children, 'comment': commentinfo.comment, 'depth': depth, 'view': view } %}
{% endfor %}
