{% import "helper.twig" as helper %}
{% import "label_system/dropdown_macro.html.twig" as dropdown %}

{{ helper.breadcrumb_entity_link(entity) }}

<div class="accordion mb-4" id="listAccordion">
    <div class="accordion-item">
        <div class="accordion-header">
            <button class="accordion-button collapsed py-2" data-bs-toggle="collapse" data-bs-target="#entityInfo">
                {% if entity.masterPictureAttachment is not null and attachment_manager.isFileExisting(entity.masterPictureAttachment) %}
                    <img class="hoverpic ms-0 me-1 d-inline" {{ stimulus_controller('elements/hoverpic') }} data-thumbnail="{{ entity_url(entity.masterPictureAttachment, 'file_view') }}" src="{{ attachment_thumbnail(entity.masterPictureAttachment, 'thumbnail_sm') }}">
                {% else %}
                    {{ helper.entity_icon(entity, "me-1") }}
                {% endif %}
                {{ header_label | trans }}:&nbsp;<b>{{ entity.name }}</b>
            </button>
        </div>
        <div id="entityInfo" class="accordion-collapse collapse" data-bs-parent="#listAccordion">
            <div class="accordion-body">
                <div class="row">
                    <div class="col-sm-2">
                        <div class="nav flex-column nav-pills" id="v-pills-tab" role="tablist" aria-orientation="vertical">
                            <a class="nav-link active" id="v-pills-home-tab" data-bs-toggle="pill" href="#v-pills-home" role="tab" aria-controls="v-pills-home" aria-selected="true">
                                <i class="fas fa-info-circle fa-fw"></i>
                                {% trans %}entity.info.common.tab{% endtrans %}
                            </a>
                            <a class="nav-link" id="v-pills-statistics-tab" data-bs-toggle="pill" href="#v-pills-statistics" role="tab" aria-controls="v-pills-profile" aria-selected="false">
                                <i class="fas fa-chart-pie fa-fw"></i>
                                {% trans %}entity.info.statistics.tab{% endtrans %}
                            </a>
                            {% if entity.attachments is not empty %}
                                <a class="nav-link" id="v-pills-attachments-tab" data-bs-toggle="pill" href="#v-pills-attachments" role="tab" aria-controls="v-pills-attachments" aria-selected="false">
                                    <i class="fas fa-paperclip fa-fw"></i>
                                    {% trans %}entity.info.attachments.tab{% endtrans %}
                                </a>
                            {% endif %}
                            {% if entity.parameters is not empty %}
                                <a class="nav-link" id="v-pills-parameters-tab" data-bs-toggle="pill" href="#v-pills-parameters" role="tab" aria-controls="v-pills-parameters" aria-selected="false">
                                    <i class="fas fa-atlas fa-fw"></i>
                                    {% trans %}entity.info.parameters.tab{% endtrans %}
                                </a>
                            {% endif %}
                            {% if entity.comment is not empty %}
                                <a class="nav-link" id="v-pills-comment-tab" data-bs-toggle="pill" href="#v-pills-comment" role="tab">
                                    <i class="fas fa-comment-alt fa-fw"></i>
                                    {% trans %}comment.label{% endtrans %}
                                </a>
                            {% endif %}
                        </div>
                    </div>
                    <div class="col-sm-10">
                        <div class="tab-content" id="v-pills-tabContent">
                            <div class="tab-pane fade show active" id="v-pills-home" role="tabpanel" aria-labelledby="v-pills-home-tab">
                                <div class="row">
                                    <div class="col-sm-9 form-horizontal">
                                        <div class="form-group">
                                            <label class="col-sm-4">{% trans %}entity.info.name{% endtrans %}:</label>
                                            <span class="col-sm form-control-static">{{ entity.name }}</span>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-4">{% trans %}entity.info.parent{% endtrans %}:</label>
                                            <span class="col-sm form-control-static">
                                        {% if entity.parent %}
                                            {{ entity.parent.fullPath }}
                                        {% else  %}
                                            -
                                        {% endif %}
                                    </span>
                                        </div>
                                    </div>
                                    <div class="col-sm-3">
                                        {% block quick_links %}{% endblock %}

                                        <a class="btn btn-secondary w-100 mb-2" href="{{ entity_url(entity, 'edit') }}">
                                            <i class="fas fa-edit"></i> {% trans %}entity.edit.btn{% endtrans %}
                                        </a>
                                        <div class="">
                                        <span class="text-muted" title="{% trans %}lastModified{% endtrans %}">
                                            <i class="fas fa-history fa-fw"></i> {{ entity.lastModified | format_datetime("short") }}
                                        </span>
                                            <br>
                                            <span class="text-muted mt-1" title="{% trans %}createdAt{% endtrans %}">
                                            <i class="fas fa-calendar-plus fa-fw"></i> {{ entity.addedDate | format_datetime("short") }}
                                        </span>
                                        </div>

                                        {% if entity is instanceof("App\\Entity\\Parts\\StorageLocation") %}
                                            {{ dropdown.profile_dropdown('storelocation', entity.id, true, 'btn-secondary w-100 mt-2') }}
                                        {% endif %}

                                    </div>
                                </div>
                            </div>
                            <div class="tab-pane fade" id="v-pills-statistics" role="tabpanel" aria-labelledby="v-pills-statistics-tab">
                                <div class="form-horizontal">
                                    <div class="form-group">
                                        <label class="col-sm-4">{% trans %}entity.info.children_count{% endtrans %}:</label>
                                        <span class="col-sm form-control-static">{{ entity.children | length }}</span>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-4">{% trans %}entity.info.parts_count{% endtrans %}:</label>
                                        <span class="col-sm form-control-static">{{ repo.partsCount(entity) }}</span>
                                    </div>
                                </div>
                            </div>

                            {% if entity.attachments is not empty %}
                                <div class="tab-pane fade" id="v-pills-attachments" role="tabpanel" aria-labelledby="v-pills-attachments-tab">
                                    {% include "parts/info/_attachments_info.html.twig" with {"part": entity} %}
                                </div>
                            {% endif %}

                            {% if entity.parameters is not empty %}
                                <div class="tab-pane fade" id="v-pills-parameters" role="tabpanel" aria-labelledby="v-pills-parameters-tab">
                                    {% for name, parameters in entity.groupedParameters %}
                                        {% if name is not empty %}<h5 class="mt-1">{{ name }}</h5>{% endif %}
                                        {{ helper.parameters_table(parameters) }}
                                    {% endfor %}
                                </div>
                            {% endif %}

                            {% if entity.comment is not empty %}
                                <div class="tab-pane fade" id="v-pills-comment" role="tabpanel" aria-labelledby="home-tab">
                                    <div class="container-fluid mt-2 latex" data-controller="common--latex">
                                        {{ entity.comment|format_markdown }}
                                    </div>
                                </div>
                            {% endif %}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    {% if filterForm is defined %}
        {% include "parts/lists/_filter.html.twig" %}
    {% endif %}
</div>
