{% extends '@ChillMain/layout.html.twig' %}

{% block title -%}
    {{ 'Workflow'|trans }}
{%- endblock %}

{% block js %}
    {{ parent() }}
    {{ encore_entry_script_tags('mod_pickentity_type') }}
    {{ encore_entry_script_tags('mod_entity_workflow_subscribe') }}
    {{ encore_entry_script_tags('page_workflow_show') }}
    {{ encore_entry_script_tags('mod_document_action_buttons_group') }}
    {{ encore_entry_script_tags('mod_workflow_attachment') }}
{% endblock %}

{% block css %}
    {{ parent() }}
    {{ encore_entry_link_tags('mod_pickentity_type') }}
    {{ encore_entry_link_tags('mod_entity_workflow_subscribe') }}
    {{ encore_entry_link_tags('page_workflow_show') }}
    {{ encore_entry_link_tags('mod_document_action_buttons_group') }}
    {{ encore_entry_link_tags('mod_workflow_attachment') }}
{% endblock %}

{% import '@ChillMain/Workflow/macro_breadcrumb.html.twig' as macro %}

{% block content %}
<div class="col-10 workflow">
    <h1 class="mb-5">{{ block('title') }}</h1>

    {#  handler_template:
        - src/Bundle/ChillPersonBundle/Resources/views/Workflow/_evaluation.html.twig
        - src/Bundle/ChillPersonBundle/Resources/views/Workflow/_accompanying_period_work.html.twig
        - src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/_workflow.html.twig
    #}
    <section class="step my-4">
        <div class="mb-5">
            <h2>{{ handler.entityTitle(entity_workflow) }}</h2>

            {{ macro.breadcrumb(entity_workflow) }}
            {% if entity_workflow.isOnHoldAtCurrentStep %}
                <span class="badge bg-success rounded-pill" title="{{ 'workflow.On hold'|trans|escape('html_attr') }}">{{ 'workflow.On hold'|trans }}</span>
            {% endif %}
        </div>

        {% include handler_template with handler_template_data|merge({'display_action': true }) %}

        {% if is_granted('CHILL_MAIN_WORKFLOW_DELETE', entity_workflow) %}
            <ul class="record_actions">
                <li>
                    <a class="btn btn-delete"
                       href="{{ chill_path_add_return_path('chill_main_workflow_delete', {'id': entity_workflow.id}) }}"
                    >
                        {{ 'workflow.Delete workflow'|trans }}
                    </a>
                </li>
            </ul>
        {% endif %}
    </section>

    {% if signatures|length > 0 %}
    <section class="step my-4">{% include '@ChillMain/Workflow/_signature.html.twig' %}</section>
    {% endif %}

    <section class="step my-4">{% include '@ChillMain/Workflow/_attachment.html.twig' %}</section>

    <section class="step my-4">{% include '@ChillMain/Workflow/_follow.html.twig' %}</section>
    {% if entity_workflow.currentStep.sends|length > 0 %}
        <section class="step my-4">
            <h2>{{ 'workflow.external_views.title'|trans({'numberOfSends': entity_workflow.currentStep.sends|length }) }}</h2>
            {% include '@ChillMain/Workflow/_send_views_list.html.twig' with {'sends': entity_workflow.currentStep.sends} %}
        </section>
    {% else %}
        <section class="step my-4">{% include '@ChillMain/Workflow/_decision.html.twig' %}</section>
    {% endif %}
    {# <section class="step my-4">{% include '@ChillMain/Workflow/_comment.html.twig' %}</section> #}
    <section class="step my-4">{% include '@ChillMain/Workflow/_history.html.twig' %}</section>


</div>
{% endblock %}
