{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig"  %}

{% set activeRouteKey = '' %}

{% import "@ChillDocStore/Macro/macro.html.twig" as m %}
{% import "@ChillDocStore/Macro/macro_mimeicon.html.twig" as mm %}

{% block title %}
	{# {{ 'Detail of document of %name%'|trans({ '%name%': accompanyingCourse|chill_entity_render_string } ) }} #}
    {{ 'Document %title%' | trans({ '%title%': document.title }) }}
{% endblock %}

{% block css %}
    {{ parent() }}
    {{ encore_entry_link_tags('mod_async_upload') }}
    {{ encore_entry_link_tags('mod_entity_workflow_pick') }}
    {{ encore_entry_link_tags('mod_document_action_buttons_group') }}
{% endblock %}

{% block content %}
<div class="document-show">
    <h1>{{ block('title') }}</h1>

    {{ mm.mimeIcon(document.object.type) }}

    <dl class="chill_view_data mt-4">
        <dt>{{ 'Title'|trans }}</dt>
        <dd>{{ document.title }}</dd>

        {% if document.category is not null %}
            <dt>{{ 'Category'|trans }}</dt>
            <dd>{{ document.category.name|localize_translatable_string }}</dd>
        {% endif %}

        <dt>{{ 'Description' | trans }}</dt>
        <dd>
            {% if document.description is empty %}
                <span class="chill-no-data-statement">{{ 'Any description'|trans }}</span>
            {% else %}
                <blockquote class="chill-user-quote">
                    {{ document.description|chill_markdown_to_html }}
                </blockquote>
            {% endif %}
        </dd>
    </dl>

    <ul class="record_actions sticky-form-buttons">
        <li class="cancel">
            <a href="{{ chill_return_path_or('chill_docstore_generic-doc_by-period_index', {'id': accompanyingCourse.id}) }}" class="btn btn-cancel">
                {{ 'Back to the list' | trans }}
            </a>
        </li>
        {% if is_granted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_DELETE', document) %}
            <li class="delete">
                <a href="{{ chill_return_path_or('chill_docstore_accompanying_course_document_delete', {'course': accompanyingCourse.id, 'id': document.id}) }}" class="btn btn-delete"></a>
            </li>
        {% endif %}
        {% if is_granted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_UPDATE', document) %}
            <li>
                <a href="{{ path('accompanying_course_document_edit', {'id': document.id, 'course': accompanyingCourse.id}) }}"
                   class="btn btn-edit" title="{{ 'Edit attributes' | trans }}"></a>
            </li>
        {% endif %}
        <li>
            {{ document.object|chill_document_button_group(document.title) }}
        </li>
        {% set workflows_frame = chill_entity_workflow_list('Chill\\DocStoreBundle\\Entity\\AccompanyingCourseDocument', document.id) %}
        {% if workflows_frame is not empty %}
            <li>
                {{ workflows_frame|raw }}
            </li>
        {% endif %}
    </ul>
</div>
{% endblock %}

{% block block_post_menu %}
    <div class="post-menu pt-4"></div>
{% endblock %}

{% block js %}
    {{ parent() }}
    {{ encore_entry_script_tags('mod_async_upload') }}
    {{ encore_entry_script_tags('mod_entity_workflow_pick') }}
    {{ encore_entry_script_tags('mod_document_action_buttons_group') }}
{% endblock %}
