{% extends "modeltranslation/admin/admin.html" %}

{% load static from staticfiles %}
{% load thumbnail %}
{% load i18n %}

{% block custom-css %}
	{{ block.super }}
	<link rel="stylesheet" href="{% static 'css/modeltranslation/search.css' %}" />
{% endblock %}

{% block head_title %}
	Administrate translations
{% endblock %}

{% block breadcrumb_element %}
	{{ block.super }}
	&rsaquo;
	<a href="{% url 'modeltranslation:view_all_url' lang 'all' %}" class="first">Translations to {{language}}</a>
	{% if filter and filter != "all" %}
			&rsaquo;
			<a href="{% url 'modeltranslation:view_all_url' lang filter %}" class="first">
				{% if filter == "fuzzy" %}
					Incomplete
				{% elif filter == "completed" %}
					Complete
				{% endif %}
			</a>
	{% endif %}
	{% if search_query %}
		&rsaquo;
		<a href="{% url 'modeltranslation:view_all_url' lang filter %}?search={{search_query}}" class="first">Results</a>
	{% endif %}
{% endblock breadcrumb_element %}

{% block body %}

	<div id="body-content" class="span12">
		<div id="content-title" class="page-header">
			<h1>
				{%block title %}
					Administrate translations to {{language}}
				{% endblock %}
			</h1>
		</div>

		<div id="content" class="">
			{% block content %}
				{% include "modeltranslation/admin/search.html" %}
				<div id="tpvs_admin_list">
					<h2>List of existing texts:</h2>
					{% if translations|length > 0 %}
						<div id="translation_list" class="row-fluid">
							<table class="table table-hover table-striped">
								<tr>
									<th class="span2">Model</th>
									<th class="span3">Attribute</th>
									<th class="span5">Source text</th>
									<th class="span5">Translation</th>
									<th class="span1">Actions</th>
								</tr>
								{% for translation in translations %}
									{% cycle 'odd' 'even' as parity silent %}
									{% with verbose_field_name=translation.get_verbose_field_name source_text=translation.source_text translation_text=translation.translation %}
										<tr id="translation__{{translation.id}}" class="{{parity}} model-{{translation.model}}">
											<td class="span2">{{translation.source_model.meta__verbose_name.title}}</td>
											<td class="span3">{{verbose_field_name}}</td>
											<td class="span5">{{source_text|truncatewords:20}}</td>
											<td class="span5">{{translation_text|truncatewords:20}}</td>
											<td class="span1">
												<a title="Editar traducción" href="{% url 'modeltranslation:edit_url' translation.id %}"><span class="fa fa-flag icon"></span></a>
											</td>
										</tr>
									{% endwith %}
								{% endfor %}
							</table>
						</div>
					{% else %}
						<div class="alert alert-warning">There are no translations for this language</div>
					{% endif %}

				</div>
			{% endblock content %}
		</div>
	</div>
{% endblock %}
