{% extends "tp_base_terminology.html" %}

{% load i18n assets render_pager baseurl 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='{{ "terminology_extract.html"|l }}'>{% 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="{% cycle 'even' 'odd' %}">
        {% 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="save" 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="{{ "terminology_extract.html"|l }}">{% trans "Generate Glossary" %}</a></p>
</div>
{% endif %}
{% endblock content %}
