{% extends "admin/base_app.html" %}
{% load core i18n assets %}

{% block breadcrumbs %}
{{ block.super }}<li>{% trans "Projects" %}</li>
{% endblock %}

{% block app_init %}
{% assets 'js_fs_app' %}
<script type="text/javascript" src="{{ ASSET_URL }}"></script>
{% endassets %}
<script type="text/javascript">
$(function() {
  PTL.fs.init();
});
</script>
{% endblock %}

{% block title %}{% trans "Projects" %} | {{ block.super }}{% endblock %}

{% block content %}
{% block section_body %}
<div id="content">
  <div id="pootle-fs-project-admin" class="settings-container">
    <div class="hd">
      <h2>{% blocktrans with project_code=project.code %}Filesystem configuration: {{ project_code }}{% endblocktrans %}</h2>
      <h3 class="warning">
        {% blocktrans trimmed %}
        Pootle FS is still experimental, we’d love you to use it, but it does
        require a level of expertise in localisation, Python and Pootle in case
        anything goes wrong.
        {% endblocktrans %}
      </h3>
    </div>
    <div class="config-content">
      <div class="config-content-panel">
	<h3>{% trans "Backend configuration" %}</h3>
	<form method="POST" class="pootle-fs-config-form">
	  {% csrf_token %}
	  {{ form.as_p }}
	  <div class="hide js-fs-preselect-choices">
	    {% for fs_preset in fs_choices %}
	    <dt>{{ fs_preset.0 }}</dt>
	    <dd>{{ fs_preset.2 }}</dd>
	    {% endfor %}
	  </div>
	  <div class="centered">
	    <input type="submit" class="btn" value="{% trans 'Update filesystem configuration' %}" />
	  </div>
	  <p>
	    {% trans "Translation path mapping should be of the format:" %}
	    <blockquote class="centered">
	      <code>
		`/path/to/translation/files/&lt;language_code&gt;/&lt;dir_path&gt;/&lt;filename&gt;.&lt;ext&gt;`
	      </code>
	    </blockquote>
	  </p>
	  <p>
	    {% blocktrans trimmed %}
	    Only `&lt;language_code&gt;` is required, although it must end with
	    `.&lt;ext&gt;`
	    {% endblocktrans %}
	  </p>
	  <p>
	    {% blocktrans trimmed %}
	    If you are using the localfs backend the translation path mapping will
	    be combined with the path specified in backend URL
	    {% endblocktrans %}
	  </p>
	  <p>
	    {% blocktrans trimmed %}
	    For other backends the translation path mapping will be relative to the
	    root of the repository.
	    {% endblocktrans %}
	  </p>
	</form>
      </div>
    </div>
    <div class="config-content">
      <div class="config-content-panel">
	<h3>{% trans "Language mapping configuration" %}</h3>

	<form method="post" action___="{{ lang_mapping_formset_action }}">
	  {% csrf_token %}
	  {{ lang_mapping_formset.management_form }}
	  {% for error in lang_mapping_formset.non_form_errors %}
	  <div class="msg-error padded-top padded-bottom">{{ error }}</div>
	  {% endfor %}
	  <table>
	    <tr>
	      <th class="aligned-right">{% trans "Remove" %}</th>
	      <th>{% trans "Pootle code" %}</th>
	      <th>{% trans "Filesystem code" %}</th>
	    </tr>
	    {% for form in lang_mapping_formset %}
	    <tr>
	      <td class="aligned-right padded-half-right">{% if form.initial %}{{ form.remove }}{% else %}{% trans 'Add' %}{% endif %}</td>
	      <td>{{ form.pootle_code }} {{ form.pootle_code.errors }}</td>
	      <td>{{ form.fs_code }}</td>
	    </tr>
	    {% endfor %}
	    <tr>
	      <td colspan="3" class="centered">
		<input type="submit" class="btn" value="{% trans 'Update' %}" />
	      </td>
	    </tr>
	  </table>
	</form>
      </div>
    </div>
  </div>
</div>
{% endblock %}
{% endblock %}
