{% extends "base.html" %}
{% load i18n %}
{% load translations %}
{% load permissions %}
{% load crispy_forms_tags %}

{% block breadcrumbs %}
<li><a href="{{ object.get_absolute_url }}">{{ object }}</a></li>

<a class="pull-right flip" href="{{ object.get_widgets_url }}">
<img src="{% url 'widget-image' project=object.slug widget='svg' color='badge' extension='svg' %}" />
</a>
{% endblock %}

{% block content %}

{% whiteboard_messages project=object %}

{% include "watch-dropdown.html" with project=object %}

{% perm 'meta:vcs.status' object as user_can_see_repository_status %}
{% perm 'vcs.commit' object as user_can_commit_translation %}
{% perm 'project.permissions' object as user_can_manage_acl %}
{% perm 'project.edit' object as user_can_edit_project %}
{% perm 'reports.view' object as user_can_view_reports %}
{% perm 'component.edit' object as user_can_edit_component %}

{% include "snippets/project-nav.html" %}

<div class="tab-content">
<div class="tab-pane active" id="components">


{% include "snippets/list-objects.html" with objects=components name_source="name" label=_("Component") %}

{% if user_can_edit_project %}
  <a class="btn btn-primary project-add-component" href="{% url 'create-component' %}?project={{ object.pk }}">{% trans "Add new translation component" %}</a>
{% endif %}

{% with components as page_obj %}
{% include "paginator.html" %}
{% endwith %}

</div>

<div class="tab-pane" id="information">

<table class="table table-striped">
{% include "project_info.html" %}
{% if licenses %}
<tr>
<th>{% trans "Translation license" %}</th>
<td colspan="2">{{ licenses }}</td>
</tr>
{% endif %}
{% include "project_stats.html" %}
</table>

</div>
<div class="tab-pane" id="languages">

{% include "snippets/list-objects.html" with objects=language_stats name_source="language" label=_("Language") project=object global_base=object.stats %}

</div>

<div class="tab-pane" id="history">
{% include "last-changes-content.html" %}
<a class="btn btn-primary" href="{% url 'changes' %}?{{ last_changes_url }}">{% trans "Browse all project changes" %}</a>
</div>

{% include "activity-tab.html" %}

<div class="tab-pane" id="search">

<form action="{% url 'search' project=object.slug %}" method="GET" data-persist="search-project">
{% include "snippets/search-form.html" %}
</form>

</div>

{% if replace_form %}
<div class="tab-pane" id="replace">
<form action="{% url 'replace' project=object.slug %}" method="post" enctype="multipart/form-data">
<div class="panel panel-default">
<div class="panel-heading"><h4 class="panel-title">{% trans "Search and replace" %}</h4></div>
<div class="panel-body">
<p>{% trans "You can substitute all instances of a string. The search is a simple substring case sensitive search." %}</p>
{% csrf_token %}
{{ replace_form|crispy }}
</div>
<div class="panel-footer">
<input type="submit" value="{% trans "Replace" %}" class="btn btn-primary" />
</div>
</div>
</form>
</div>
{% endif %}

{% if bulk_state_form %}
<div class="tab-pane" id="bulk-state">
<form action="{% url 'state-change' project=object.slug %}" method="post" enctype="multipart/form-data">
<div class="panel panel-default">
<div class="panel-heading"><h4 class="panel-title">{% trans "Bulk status change" %}</h4></div>
<div class="panel-body">
<p>{% trans "You can change the state of all strings matching given type at once." %}</p>
{% csrf_token %}
{{ bulk_state_form|crispy }}
</div>
<div class="panel-footer">
<input type="submit" value="{% trans "Apply" %}" class="btn btn-primary" />
</div>
</div>
</form>
</div>
{% endif %}


{% if whiteboard_form %}
<div class="tab-pane" id="whiteboard">
<form action="{% url 'whiteboard_project' project=object.slug %}" method="post">
<div class="panel panel-default">
<div class="panel-heading"><h4 class="panel-title">{% trans "Add a project message" %}</h4></div>
<div class="panel-body">
{% csrf_token %}
{{ whiteboard_form|crispy }}
<p class="help-block">{% trans "The message is shown for all translations within the project, until its given expiry, or permanently until it is deleted." %}</p>
</div>
<div class="panel-footer">
<input type="submit" value="{% trans "Add" %}" class="btn btn-primary" />
</div>
</form>

</div>
</div>
{% endif %}

{% if delete_form %}
{% include "trans/delete-form.html" %}
{% endif %}

{% if rename_form %}
<div class="tab-pane" id="rename">

<form method="post" action="{% url 'rename' project=object.slug %}">
<div class="panel panel-default">
<div class="panel-heading"><h4 class="panel-title">{% trans "Rename project" %}</h4></div>
<div class="panel-body">
<div class="form-group">
<p>{% trans "Renaming the project will change all URLs, users will have to update bookmarks or references in cloned repositories!" %}</p>
</div>
{% crispy rename_form %}
</div>
<div class="panel-footer">
<input type="submit" class="btn btn-warning" value="{% trans "Rename" %}">
</div>
</div>
</form>

</div>
{% endif %}

{% if user_can_see_repository_status %}
<div class="tab-pane" id="repository">
<p>{% trans "Loading…" %}</p>
</div>
{% endif %}

{% if user.is_authenticated %}
<div class="tab-pane" id="reports">
{% if not user_can_view_reports %}
{% trans "You don't have permission to view reports for all users, only your contributions will be listed." as msg %}
{% show_message "warning" msg %}
{% endif %}
<div class="row">
<div class="col-lg-6">
<form action="{% url 'credits' project=object.slug %}" method="post" enctype="multipart/form-data">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
{% documentation_icon 'devel/reporting' 'credits' right=True %}
{% trans "Credits" %}
</h4>
</div>
<div class="panel-body">
<p>{% trans "Lists all translators contributing to this project in a given time period. Useful for inclusion in documentation or the app itself, to thank translators and generate feedback to them." %}</p>
{% crispy reports_form %}
</div>
<div class="panel-footer">
<input type="submit" value="{% trans "Generate" %}" class="btn btn-primary" />
</div>
</div>
</form>
</div>
<div class="col-lg-6">
<form action="{% url 'counts' project=object.slug %}" method="post" enctype="multipart/form-data">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
{% documentation_icon 'devel/reporting' 'stats' right=True %}
{% trans "Contributor stats" %}
</h4>
</div>
<div class="panel-body">
<p>{% trans "Reports the number of strings and words translated by each translator." %}</p>
{% crispy reports_form %}
</div>
<div class="panel-footer">
<input type="submit" value="{% trans "Generate" %}" class="btn btn-primary" />
</div>
</div>
</form>
</div>
</div>
</div>
{% endif %}

</div>

{% endblock %}
