{% extends "wagtailadmin/generic/edit.html" %}
{% load i18n %}

{% block titletag %}Translation request{% endblock %}

{% block content %}

    {% include "wagtailadmin/shared/header.html" with title="translation request" subtitle=translation_request.id icon=view.header_icon %}

    <div class="nice-padding">
        <h2>Basic information</h2>
        <dl>
            <dt>Source Locale:</dt>
            <dd>{{ translation_request.source_locale }}</dd>

            <dt>Target Locale:</dt>
            <dd>{{ translation_request.target_locale }}</dd>

            <dt>Requested by:</dt>
            <dd>{% firstof translation_request.created_by.get_full_name translation_request.created_by %}</dd>

            <dt>Requested at:</dt>
            <dd>{{ translation_request.created_at }}</dd>
        </dl>

        <h2>Actions</h2>

        {% for action_module in action_modules %}
            {{ action_module.render }}
        {% empty %}
            <p>No actions can be performed on this request</p>
        {% endfor %}

        <h2>Pages</h2>

        <table class="listing">
            <thead>
                <tr>
                    <th class="name">Title</th>
                    <th class="name">Status</th>
                    <th class="name">Actions</th>
                </tr>
            </thead>
            <tbody>
                {% for page in pages %}
                    <tr>
                        <td class="title" style="padding-left: {% widthratio page.depth 1 10 %}px;">
                            {{ page.source_page.get_admin_display_title }}
                        </td>
                        <td>
                            {% if page.is_completed %}
                                Completed
                            {% elif page.get_translation %}
                                Modified
                            {% else %}
                                New
                            {% endif %}
                        </td>
                        <td>
                            <ul class="actions">
                                {% if page.get_translation %}
                                    <li style="visibility: visible !important">
                                        <a href="{% url 'wagtailadmin_pages:edit' page.get_translation.id %}" class="button button-small button-secondary">{% trans "Edit" %}</a>
                                    </li>
                                    {% if not page.is_completed and page.previous_request %}
                                        <li style="visibility: visible !important">
                                            <a href="{% url 'wagtailadmin_pages:revisions_compare' page.source_page.id page.previous_request.source_revision_id page.source_revision_id %}" class="button button-small button-secondary">{% trans "View changes" %}</a>
                                        </li>
                                    {% endif %}
                                {% else %}
                                     {% if not page.parent or page.parent.get_translation %}
                                        <li style="visibility: visible !important">
                                            <a href="{% url view.copy_for_translation_url_name translation_request.id page.id %}" class="button button-small button-secondary">{% trans "Copy for translation" %}</a>
                                        </li>
                                    {% endif %}
                                {% endif %}
                            </ul>
                        </td>
                    </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
{% endblock %}
