{#
 * Copyright (C) 2014, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
 *
 * This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 *  License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
#}
{% extends "@ChillPerson/Person/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%': person|chill_entity_render_string } ) }}{% endblock %}

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

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

{% block content %}
    <h1>{{ 'Document %title%' | trans({ '%title%': document.title }) }}</h1>

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

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

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

        <dt>{{ 'Category'|trans }}</dt>
        <dd>{{ document.category.name|localize_translatable_string }}</dd>

        <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-person_index', {'id': person.id}) }}" class="btn btn-cancel">
                {{ 'Back to the list' | trans }}
            </a>
        </li>

        {% if is_granted('CHILL_PERSON_DOCUMENT_DELETE', document) %}
            <li class="delete">
                <a href="{{ chill_return_path_or('chill_docstore_person_document_delete', {'person': person.id, 'id': document.id}) }}" class="btn btn-delete"></a>
            </li>
        {% endif %}

        <li>
            {{ document.object|chill_document_button_group(document.title, is_granted('CHILL_PERSON_DOCUMENT_UPDATE', document)) }}
        </li>

        {% if is_granted('CHILL_PERSON_DOCUMENT_UPDATE', document) %}
            <li>
                <a href="{{ path('person_document_edit', {'id': document.id, 'person': person.id}) }}" class="btn btn-edit">
                    {{ 'Edit' | trans }}
                </a>
            </li>
        {% endif %}
{% endblock %}
