{% extends "translation_projects/terminology/base.html" %}

{% load i18n assets render_pager store_tags terminology_tags locale %}

{% get_current_language as LANGUAGE_CODE %}

{% block css %}
{{ block.super }}
{% assets "css_editor" %}
<link rel="stylesheet" type="text/css" href="{{ ASSET_URL }}" />
{% endassets %}
{% endblock css %}

{% block scripts_extra %}
{% assets "js_admin" %}
<script type="text/javascript" src="{{ ASSET_URL }}"></script>
{% endassets %}
{% endblock scripts_extra %}

{% block content %}
{% if formset %}
<div class="settings-container centered">
  <p class="message"><a href="{% url 'pootle-terminology-extract' language.code project.code %}">{% trans "You can regenerate the glossary from scratch." %}</a></p>

  <div class="pagination-control">
  {{ objects|render_pager }}
  </div>

  <div class="translate-form">
    <form action="" method="post">
      {% csrf_token %}
      {{ formset.management_form }}
      <table cellpadding="0" cellspacing="0" class="translate-table" dir="{% locale_dir %}">
        <thead>
          <tr lang="{{ LANGUAGE_CODE }}">
            <th colspan="1" rowspan="1" class="translate-table-title translate-original">{% trans "Term" %}</th>
            <th colspan="1" rowspan="1" class="translate-table-title translate-translation">{% trans "Translation" %}</th>
            <th colspan="1" rowspan="1" class="translate-table-title translate-edit">{% trans "Delete" %}</th>
          </tr>
        </thead>
        {% for form in formset.forms %}
        <tr class="item">
          {% render_term_edit form %}
          <td class="DELETE">
            {% for hidden_field in form.hidden_fields %}
              {{ hidden_field }}
            {% endfor %}
           {{ form.DELETE }}
          </td>
        </tr>
        {% endfor %}
      </table>
      <p class="buttons">
        <input type="submit" class="btn" name="submit" value="{% trans 'Save Changes' %}" />
      </p>
    </form>
  </div>

  <div class="pagination-control">
  {{ objects|render_pager }}
  </div>
</div>
{% else %}
<div class="form message" lang="{{ LANGUAGE_CODE }}">
  <h2>{% trans "Glossary is Empty" %}</h2>
  <p><a href="{% url 'pootle-terminology-extract' language.code project.code %}">{% trans "Generate Glossary" %}</a></p>
</div>
{% endif %}
{% endblock %}
