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

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

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

{% block content %}

{% whiteboard_messages subproject=object %}

{% can_see_repository_status user object.project as user_can_see_repository_status %}
{% can_commit_translation user object.project as user_can_commit_translation %}
{% can_manage_acl user object.project as user_can_manage_acl %}
{% can_view_reports user object.project as user_can_view_reports %}
{% can_add_translation user object.project as user_can_add_translation %}
{% can_edit_subproject user object.project as user_can_edit_subproject %}

{% include "show-lock.html" %}

<ul class="nav nav-pills">
  <li class="active"><a href="#translations" data-toggle="tab">{% trans "Translations" %}</a></li>
  <li><a href="#information" data-toggle="tab">{% trans "Information" %}</a></li>
  <li class="dropdown">
    <a class="dropdown-toggle" data-toggle="dropdown" href="#">
      {% trans "Insights" %} <span class="caret"></span>
    </a>
    <ul class="dropdown-menu">
      <li><a href="#history" data-toggle="tab">{% trans "History" %}</a></li>
      <li><a href="#activity" data-toggle="tab" data-load="activity" data-yearly="{% url 'yearly_activity' project=object.project.slug subproject=object.slug %}" data-monthly="{% url 'monthly_activity' project=object.project.slug subproject=object.slug %}">{% trans "Activity" %}</a></li>
      <li><a href="{% url 'export_stats' project=object.project.slug subproject=object.slug %}?format=csv">{% trans "Download statistics (CSV)" %}</a></li>
      <li><a href="{% url 'export_stats' project=object.project.slug subproject=object.slug %}?format=json">{% trans "Download statistics (JSON)" %}</a></li>
      {% if user_can_view_reports %}
      <li><a href="#reports" data-toggle="tab">{% trans "Translation reports" %}</a></li>
      {% endif %}
    </ul>
  </li>
  <li class="dropdown">
    <a class="dropdown-toggle" data-toggle="dropdown" href="#">
      {% trans "Tools" %} <span class="caret"></span>
    </a>
    <ul class="dropdown-menu">
      <li><a href="#search" data-toggle="tab">{% trans "Search" %}</a></li>
      {% if replace_form %}
      <li><a href="#replace" data-toggle="tab">{% trans "Search and replace" %}</a></li>
      {% endif %}
      <li><a href="{% url 'data_project' project=object.project.slug  %}">{% trans "Data exports" %}</a></li>
      <li><a href="{% url 'matrix' project=object.project.slug subproject=object.slug %}">{% trans "Matrix view" %}</a></li>
      <li><a href="{% url 'show_source' project=object.project.slug subproject=object.slug %}">{% trans "Source strings review" %}</a></li>
      {% if object.can_add_language and user_can_add_translation %}
      <li><a href="{% url "new-language" project=object.project.slug subproject=object.slug %}">{% trans "Start new translation" %}</a></li>
      {% endif %}
    </ul>
  </li>
  <li class="dropdown">
    <a class="dropdown-toggle" data-toggle="dropdown" href="#">
      {% trans "Manage" %} <span class="caret"></span>
    </a>
    <ul class="dropdown-menu">
      {% if user_can_commit_translation %}
      <li><a href="{{ object.get_commit_url }}" class="link-post">{% trans "Commit" %}</a></li>
      {% endif %}
      {% if user_can_see_repository_status %}
      <li><a href="#repository" data-toggle="tab" data-href="{% url 'git_status_subproject' project=object.project.slug subproject=object.slug %}">{% trans "Repository maintenance" %}</a></li>
      {% endif %}
      {% if user_can_commit_translation or user_can_see_repository_status %}
      <li role="separator" class="divider"></li>
      {% endif %}
      <li><a href="{% url 'screenshots' project=object.project.slug subproject=object.slug %}">{% trans "Manage screenshots" %}</a></li>
      {% if user_can_manage_acl %}
      <li><a href="{% url 'manage-access' project=object.project.slug %}">{% trans "Manage users" %}</a></li>
      {% endif %}
      {% if user_can_edit_subproject %}
      <li><a href="{% url 'addons' project=object.project.slug subproject=object.slug %}">{% trans "Addons" %}</a></li>
      <li><a href="{% url 'settings' project=object.project.slug subproject=object.slug %}">{% trans "Settings" %}</a></li>
      {% endif %}
    </ul>
  </li>
{% if enable_sharing %}
  <li class="dropdown">
    <a class="dropdown-toggle" data-toggle="dropdown" href="#">
      {% trans "Share" %} <span class="caret"></span>
    </a>
    <ul class="dropdown-menu">
{% with object.get_share_url as share_url and object.get_widgets_url as widgets_url %}
      <li><a href="https://www.facebook.com/sharer.php?u={{ share_url }}">{% trans "Share on Facebook!" %}</a></li>
      <li><a href="https://twitter.com/share?text={% blocktrans %}Translate {{ object }} using %23Weblate at {{ share_url }}!{% endblocktrans %}">{% trans "Tweet this translation!" %}</a></li>
      <li><a href="{% url 'engage' project=object.project.slug %}">{% trans "Engage page" %}</a></li>
      <li><a href="{{ widgets_url }}">{% trans "Status widgets" %}</a></li>
{% endwith %}
    </ul>
  </li>
{% endif %}
{% with object.project as project %}
{% include "watch-dropdown.html" %}
{% endwith %}
</ul>


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

{% include "list-translations.html" %}
<p>{% include "legend.html" %}</p>

{% if object.can_add_language and user_can_add_translation %}
<p>
<a class="btn btn-default" href="{% url "new-language" project=object.project.slug subproject=object.slug %}">{% trans "Start new translation" %}</a>
</p>
{% endif %}

</div>

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

<table class="table table-striped">
{% include "subproject_info.html" %}
{% include "project_stats.html" %}
</table>

</div>


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

<form action="{% url 'search' project=object.project.slug subproject=object.slug %}" method="GET" data-persist="search-component">
{{ search_form|crispy }}
<input type="submit" value="{% trans "Search" %}" class="btn btn-default" />
</form>

</div>

{% if replace_form %}
<div class="tab-pane" id="replace">
<form action="{% url 'replace' project=object.project.slug subproject=object.slug %}" method="post" enctype="multipart/form-data">
<div class="panel panel-primary">
<div class="panel-heading"><h4 class="panel-title">{% trans "Search and replace" %}</h4></div>
<div class="panel-body">
<p>{% trans "You can replace a string in all strings at once. 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 "Process" %}" class="btn btn-default" />
</div>
</div>
</form>

<form action="{% url 'state-change' project=object.project.slug subproject=object.slug %}" method="post" enctype="multipart/form-data">
<div class="panel panel-primary">
<div class="panel-heading"><h4 class="panel-title">{% trans "Mass state change" %}</h4></div>
<div class="panel-body">
<p>{% trans "You can change state of all strings matching given type at once." %}</p>
{% csrf_token %}
{{ mass_state_form|crispy }}
</div>
<div class="panel-footer">
<input type="submit" value="{% trans "Process" %}" class="btn btn-default" />
</div>
</div>
</form>
</div>
{% endif %}

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

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

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

{% if user_can_view_reports %}
<div class="tab-pane" id="reports">
<div class="row">
<div class="col-lg-6">
<form action="{% url 'credits' project=object.project.slug subproject=object.slug %}" method="post" enctype="multipart/form-data">
<div class="panel panel-primary">
<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 "Credits list all translators who have contributed to this component in a given time period. It can be useful for including in your documentation or application to thank translators." %}</p>
{% crispy reports_form %}
</div>
<div class="panel-footer">
<input type="submit" value="{% trans "Generate" %}" class="btn btn-default" />
</div>
</div>
</form>
</div>
<div class="col-lg-6">
<form action="{% url 'counts' project=object.project.slug subproject=object.slug %}" method="post" enctype="multipart/form-data">
<div class="panel panel-primary">
<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 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-default" />
</div>
</div>
</form>
</div>
</div>
</div>
{% endif %}

</div>



</div>

{% endblock %}
