{% 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>
{{ item.unit.position }}
{% if item.unit.readonly %}<span class="badge">{% trans "Read only" %}</span>{% endif %}
</td>
<td colspan="2">
<a href="{% url 'translate' project=object.component.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" title="{% trans "Open in full editor" %}">{% icon "pencil.svg" %}</a>
{% if item.unit.context %}
<div class="pull-right flip zen-context">
<label>{% trans "Context:" %}</label>
{{ item.unit.context }}
</div>
{% endif %}
{% get_location_links user.profile item.unit %}
</td>
</tr>


{% if item.unit.comment %}
<tr id="row-comment-{{ item.unit.checksum }}">
<td></td>
<td colspan="2" class="translatetext">
    <label>{% trans "Comment" %}</label>
    {% format_translation item.unit.comment item.unit.translation.component.project.source_language %}
</td>
</tr>
{% endif %}


<tr id="row-source-{{ item.unit.checksum }}">
<td>
{% if user.profile.zen_mode == user.profile.ZEN_HORIZONTAL %}
{% loading_icon item.unit.checksum %}
<span id="status-{{ item.unit.checksum }}">{% get_state_flags item.unit %}</span>
{% 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">
<label>
    {{ unit.translation.language }}
    {% perm 'unit.edit' unit as user_can_edit_secondary %}
    {% if user_can_edit_secondary %}
    <a title="{% trans "Edit string" %}"href="{{ unit.get_absolute_url }}" class="btn btn-link btn-xs">{% icon "pencil.svg" %}</a>
    {% endif %}
</label>
{% format_translation unit.target unit.translation.language unit.translation.plural %}
</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.project.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">
<label>
    {% trans "Source" %}
    {% perm 'unit.edit' item.unit.source_info as user_can_edit_template %}
    <a title="{% trans "Edit source string" %}"href="{{ item.unit.source_info.get_absolute_url }}" class="btn btn-link btn-xs">{% icon "pencil.svg" %}</a>
</label>
{% format_translation item.unit.source item.unit.translation.component.project.source_language search_match=search_query num_plurals=item.unit.translation.plural.number unit=item.unit %}
</div>
{% endif %}

</td>

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


<tr id="row-edit-{{ item.unit.checksum }}">
<td>
{% loading_icon item.unit.checksum %}
<span id="status-{{ item.unit.checksum }}">{% get_state_flags item.unit %}</span>
</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 %}
