{% extends "pub_base.html" %}
{% load seahub_tags avatar_tags i18n %}
{% load url from future %}

{% block extra_style %}
{% if has_file_search %}
<style type="text/css">
#search-org-user-form {
    margin-top:25px;
}
#search-org-user-form .input {
    width:188px;
    padding:2px 5px;
    background:#fafafa;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.075);
}
#search-org-user-form .input:focus {
    background:#fff;
}
</style>
{% endif %}
{% endblock %}

{% block cur_user %}tab-cur{% endblock %}

{% block left_panel %}{{block.super}}
{% if has_file_search %}
<form action="{% url "pubuser_search" %}" method="get" id="search-org-user-form">
    <input type="text" name="search" value="{{search}}" placeholder="{% trans "Find users..." %}" class="input" />
</form>
{% endif %}
{% endblock %}

{% block right_panel %}
<h3 class="hd">{% trans "Users" %}</h3>
{% if users %}
<ul class="user-list">
    {% for u in users %}
    {% with e=u.email id=u.email|id_or_email %}
    <li class="user ovhd">
    <a href="{% url 'user_profile' id %}" class="pic fleft">{% avatar e 48 %}</a>
    <div class="txt fright">
        <a class="name" href="{% url 'user_profile' id %}">{{ e|email2nickname }}</a>
        <p>{{ e }}</p>
        {% if u.can_be_contact %}
        <button class="add-to-contacts" data-email="{{e}}">{% trans "Add to Contacts" %}</button>
        {% endif %}
    </div>
    </li>
    {% endwith %}
    {% endfor %}
</ul>
<div id="paginator">
    {% if has_prev %}
    <a href="?page={{ current_page|add:"-1" }}">{% trans "Previous" %}</a>
    {% endif %}
    {% for pr in page_range %}
      {% if pr == current_page %}
      <span class="cur">{{ pr }}</span>
      {% else %}
      <a href="?page={{ pr }}" class="pg">{{ pr }}</a>
      {% endif %}
    {% endfor %}
    {% if has_next %}
    <a href="?page={{ current_page|add:"1" }}">{% trans "Next" %}</a>
    {% endif %}
</div>

{% else %}
<p>{% trans "None"%}</p>
{% endif %}

{% include 'snippets/add_to_contacts_form.html' %}
{% endblock %}

{% block extra_script %}
{% include 'snippets/add_to_contacts_js.html' %}
{% endblock %}
