{% extends '@ChillMain/CRUD/Admin/index.html.twig' %}

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

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


{% block admin_content %}
    {% embed '@ChillMain/CRUD/_index.html.twig' %}
        {% block table_entities_thead_tr %}
        {% endblock %}

        {% block table_entities_tbody %}
            {% if entities|length == 0 %}
                <p class="chill-no-data-statement">{{ 'docgen.Any template configured'|trans }}</p>
            {% else %}
                <div class="flex-table">
                    {% for entity in entities %}
                            <div class="item-bloc">
                                <div class="item-row">
                                    <div class="item-col" style="flex-basis:100%;">
                                        <h2>{{ entity.name|localize_translatable_string }} </h2>
                                        <p style="margin-left: 1rem;"><span class="badge bg-chill-gray">
                                            {% if entity.active %}
                                                {{ 'admin.active'|trans }}
                                            {% else %}
                                                {{ 'admin.not active'|trans }}
                                            {% endif %}
                                        </span></p>
                                    </div>
                                </div>
                                <div class="item-row">
                                    <p><span class="badge bg-chill-green-dark">{{ contextManager.getContextByKey(entity.context).name|trans }}</span></p>
                                </div>
{#                                <div class="item-row">#}
{#                                    <div class="item-col" style="flex-basis:100%;">#}
{##}
{#                                    </div>#}
{#                                </div>#}
                                <div class="item-row">
                                    <div class="item-col"></div>
                                    <ul class="record_actions item-col flex-shrink-1">
                                        <li>
                                            <form method="get" action="{{ path('chill_docgenerator_test_generate_redirect') }}">
                                                <input type="hidden" name="returnPath" value="{{ app.request.query.get('returnPath', app.request.uri)|e('html_attr') }}" />
                                                <input type="hidden" name="template" value="{{ entity.id|e('html_attr') }}" />
                                                <input type="hidden" name="entityClassName" value="{{ contextManager.getContextByKey(entity.context).entityClass|e('html_attr') }}" />
                                                <input type="text" name="entityId" placeholder="{{ 'docgen.entity_id_placeholder'|trans }}" required />

                                                <button type="submit" class="btn btn-mini btn-misc"><i class="fa fa-cog"></i>{{ 'docgen.test generate'|trans }}</button>
                                            </form>
                                        </li>
                                        <li>
                                            {{ entity.file|chill_document_button_group('Template file', true) }}
                                        </li>
                                        <li>
                                            <a href="{{ chill_path_add_return_path('chill_crud_docgen_template_edit', { 'id': entity.id }) }}" class="btn btn-edit" title="{{ 'Edit'|trans }}"></a>
                                        </li>
                                    </ul>
                                </div>
                            </div>
                    {% endfor %}
                </div>
            {% endif %}

        {% endblock %}

        {% block actions_before %}
            <li class='cancel'>
                <a href="{{ path('chill_main_admin_central') }}" class="btn btn-cancel">{{'Back to the admin'|trans}}</a>
            </li>
        {% endblock %}
    {% endembed %}
{% endblock %}
