{% import "helper.twig" as helper %}

<table class="table table-striped table-hover table-responsive-sm">
    <thead>
    <tr>
        <th></th>
        <th>{% trans %}attachment.name{% endtrans %}</th>
        <th>{% trans %}attachment.attachment_type{% endtrans %}</th>
        <th>{% trans %}attachment.file_name{% endtrans %}</th>
        <th>{% trans %}attachment.file_size{% endtrans %}</th>
        <th></th>
    </tr>
    </thead>

    <tbody>


    {% for attachment in part.attachments %}
        <tr>
            <td>
                {{ helper.attachment_icon(attachment, attachment_helper) }}
            </td>
            <td class="align-middle">{{ attachment.name }}</td>
            <td class="align-middle">{{ attachment.attachmentType.fullPath }}</td>
            <td class="align-middle">
                {% if attachment.external %}
                    <a href="{{ attachment.uRL }}" rel="noopener" target="_blank" class="link-external">{{ attachment.host }}</a>
                {% else %}
                    {{ attachment.filename }}
                {% endif %}
            </td>
            <td class="align-middle">
                {% if attachment.external %}
                    <i>{% trans %}attachment.external_file{% endtrans %}</i>
                {% elseif attachment_helper.fileExisting(attachment) %}
                    {{ attachment_helper.humanFileSize(attachment) }}
                {% else %}
                    <b class="text-danger">{% trans %}attachment.file_not_found{% endtrans %}</b>
                {% endif %}
            </td>

            <td><div class="btn-group" role="group" aria-label="">
                    <a {% if attachment_helper.fileExisting(attachment) %}href="{{ attachment|entityURL('file_view') }}"{% endif %} target="_blank"
                       class="btn btn-secondary {% if not attachment_helper.fileExisting(attachment)  %}disabled{% endif %}"
                       data-no-ajax title="{% trans %}attachment.view{% endtrans %}" rel="noopener">
                        <i class="fas fa-eye fa-fw"></i>
                    </a>
                    <a {% if attachment_helper.fileExisting(attachment)  %}href="{{ attachment|entityURL('file_download') }}"{% endif %} data-no-ajax
                       class="btn btn-secondary {% if not attachment_helper.fileExisting(attachment)  %}disabled{% endif %}"
                       title="{% trans %}attachment.download{% endtrans %}">
                        <i class="fas fa-download fa-fw"></i>
                    </a>

                    <div class="btn-group" role="group">
                        <button id="btnGroupDrop1" type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" data-boundary="window">
                        </button>
                        <div class="dropdown-menu" aria-labelledby="btnGroupDrop1">
                            <span class="text-muted dropdown-item-text" ><i class="fas fa-lightbulb fa-fw"></i> <b>ID:</b> {{ attachment.iD }}</span>
                            <span class="text-muted dropdown-item-text" ><i class="fas fa-calendar fa-fw"></i> <b>{% trans %}createdAt{% endtrans %}:</b> {{ attachment.addedDate | format_datetime("short")}}</span>
                            <span class="text-muted dropdown-item-text" ><i class="fas fa-history fa-fw"></i> <b>{% trans %}createdAt{% endtrans %}:</b> {{ attachment.addedDate | format_datetime("short")}}</span>
                            <div class="dropdown-divider"></div>
                            <a class="dropdown-item" href="#">{% trans %}attachment.edit{% endtrans %}</a>
                            <a class="dropdown-item" href="#">{% trans %}attachment.delete{% endtrans %}</a>
                        </div>
                    </div>
                </div></td>
        </tr>
    {% endfor %}

    </tbody>

</table>