{% load translations %}
{% load i18n %}
{% load crispy_forms_tags %}
{% load permissions %}
{% load icons %}

{% for item in unitdata %}
<tbody class="zen-unit">


<tr id="row-status-{{ item.unit.checksum }}">
<td colspan="3">
{% if item.unit.context %}
  {{ item.unit.context }}
{% else %}
  {{ item.unit.position }}
{% endif %}
<a href="{% url 'translate' project=project.slug component=object.component.slug lang=object.language.code %}?{{ search_url }}&amp;offset={{ item.offset }}" class="btn btn-link btn-xs pull-right flip full-edit-link" title="{% trans "Open in full editor" %}">{% icon "pencil-mini.svg" %}</a>
{% get_location_links user.profile item.unit %}
</td>
</tr>


{% if item.unit.source_unit.explanation %}
<tr id="row-explanation-{{ item.unit.checksum }}">
<td class="unit-state-cell"></td>
<td colspan="2" class="translatetext">
    <label>{% trans "Explanation" %}</label>
    <div class="list-group">
        <div class="list-group-item">
            <div class="list-group-item-text">
                {{ item.unit.source_unit.explanation|markdown }}
            </div>
        </div>
    </div>
</td>
</tr>
{% endif %}


<tr id="row-source-{{ item.unit.checksum }}">
{% if user.profile.zen_mode == user.profile.ZEN_HORIZONTAL %}
<td id="status-{{ item.unit.checksum }}" class="unit-state-cell {% unit_state_class item.unit %}" title="{% unit_state_title item.unit %}">
{% else %}
<td>
{% endif %}
</td>
<td {% if user.profile.zen_mode != user.profile.ZEN_HORIZONTAL %}colspan="2"{% endif %} class="translatetext">

{% if item.secondary %}
{% for unit in item.secondary %}
<div class="form-group">
  <a href="{{ unit.get_absolute_url }}" class="language">{{ unit.translation.language }}</a>
  {% if user.profile.hide_source_secondary %}
    {% include "snippets/note-badge.html" with unit=item.unit %}
  {% endif %}
  {% format_translation unit.target unit.translation.language unit.translation.plural unit=unit %}
</div>
{% endfor %}
{% endif %}

{% if item.unit.previous_source and item.unit.fuzzy %}
<div class="form-group">
<label>{% trans "Source change" %}</label>
{% format_translation item.unit.source item.unit.translation.component.source_language diff=item.unit.previous_source num_plurals=item.unit.translation.plural.number %}
</div>
{% endif %}

{% if not user.profile.hide_source_secondary or not item.secondary %}
<div class="form-group">
  <a href="{{ item.unit.source_unit.get_absolute_url }}" class="language">{{ item.unit.translation.component.source_language }}</a>
  {% include "snippets/note-badge.html" with unit=item.unit %}
  {% format_translation item.unit.source item.unit.translation.component.source_language search_match=search_query num_plurals=item.unit.translation.plural.number unit=item.unit glossary=item.glossary %}
</div>
{% endif %}

</td>

{% if user.profile.zen_mode != user.profile.ZEN_HORIZONTAL %}
</tr>


<tr id="row-edit-{{ item.unit.checksum }}">
<td id="status-{{ item.unit.checksum }}" class="unit-state-cell {% unit_state_class item.unit %}" title="{% unit_state_title item.unit %}">
</td>
{% endif %}
<td {% if user.profile.zen_mode != user.profile.ZEN_HORIZONTAL %}colspan="2"{% endif %} class="translator">
{% crispy item.form %}
</td>
</tr>


</tbody>
{% endfor %}

{% if last_section %}
<tbody>
<tr><td colspan="3" id="last-section">
{% trans 'The translation has come to an end.' as msg %}
{% show_message 'info' msg %}
</td></tr>
</tbody>
{% endif %}
