{% extends 'base_for_backbone.html' %}
{% load staticfiles %}
{% load seahub_tags avatar_tags group_avatar_tags i18n %}

{% block sub_title %}{{group.group_name}} - {% endblock %}

{% block main_panel %}
<form id="mods-enable-form" method="post" action="{% url 'group_toggle_modules' group.id %}" class="hide">{% csrf_token%}
  <h3>{% trans "Enable Modules"%}</h3>
  <ul>
    {% for mod in mods_available %}
    {% if mod == 'group wiki' %}
    <li>
      <label class="checkbox-label">
        <span class="checkbox {% if mod in mods_enabled %}checkbox-checked{% endif %}"><input type="checkbox" name="group_wiki" class="checkbox-orig" {%if mod in mods_enabled%}checked{% endif%} /></span>
        <span class="checkbox-option">{% trans "Wiki" %}</span>
      </label>
    </li>
    {% endif %}
    {% endfor %}
  </ul>
  <input type="submit" value="{% trans "Submit"%}" class="submit" />
</form>
{% endblock %}

{% block left_panel %}
<div class="side-tabnav">
  <div class="hd w100 ovhd">
    <h3 class="fleft">
      {% grp_avatar group.props.id 32 %} <span title="{{ group.group_name }}" class="grp-name ellipsis vam">{{ group.group_name }}</span>
    </h3>
    {% if is_staff %}
    <img id="enable-mods" class="fright" title="{% trans "Enable Modules" %}" src="{{MEDIA_URL}}img/setting.png" alt="" style="margin:8px 0 0 5px;" />
    {% endif %}
    {% if group.is_pub %}<img src="{{MEDIA_URL}}img/grp_public.png" alt="" title="{% trans "This group is public." %}" class="fright" style="margin:8px 0 0 5px;" />{% endif %}
  </div>
  <ul class="side-tabnav-tabs">
    <li class="tab tab-cur"><a href="{% url 'group_info' group.id %}" class="lib">{% trans "Libraries" %}</a></li>

    <li class="tab {% block cur_discuss %}{% endblock%}"><a href="{% url 'group_discuss' group.id %}" class="msgs">{% trans "Discussion" %}</a></li>

    {% for mod in mods_enabled %}
    {% if mod == 'group wiki' %}
    <li class="tab {% block cur_wiki %}{%endblock%}"><a href="{% url 'group_wiki' group.id %}" class="wiki">{% trans "Wiki" %}</a></li>
    {% endif %}
    {% endfor %}

    {% if enable_pubfile and group.is_pub %}
    <li class="tab {% block cur_pubfile %}{%endblock%}"><a href="{% url 'group_pubfiles' group.id %}" class="files">{% trans "Files" %}</a></li>
    {% endif %}

    {% if group.view_perm != 'pub' %}
    <li class="tab {% block cur_members %}{%endblock%}"><a href="{% url 'group_members' group.id %}" class="members">{% trans "Members" %}</a></li>
    {% endif %}

    {% if is_staff %}
    <li class="tab {% block cur_admin %}{%endblock%}"><a href="{% url 'group_manage' group.id %}" class="admin">{% trans "Admin" %}</a></li>
    {% endif %}
  </ul>
</div>
{% endblock %}

{% block right_panel %}
<div id="tabs" class="tab-tabs">
    <div class="hd ovhd">
        <ul class="tab-tabs-nav fleft">
            <li class="tab"><a href="{% url 'group_info' group.id %}" class="a">{% trans "Libraries" %}</a></li>
        </ul>
        {% if user.permissions.can_add_repo %}
        <button id="repo-create" class="fright"><img src="{{ MEDIA_URL }}img/add.png" alt="" class="add vam" /><span class="vam">{% trans "New Library" %}</span></button>
        {% endif %}
    </div>

    <div id="grp-repos">
        <table style="display:none">
            <thead>
                <tr>
                    <th width="4%"><!--icon--></th>
                    <th width="38%">{% trans "Name" %} <span class="by-name icon-caret-up cspt"></span></th>
                    <th width="10%"><!--op--></th>
                    <th width="14%">{% trans "Size" %}</th>
                    <th width="18%">{% trans "Last Update" %} <span class="by-time icon-caret-down cspt"></span></th>
                    <th width="16%">{% trans "Shared By" %}</th>
                </tr>
            </thead>
            <tbody></tbody>
        </table>

        <div class="empty-tips" style="margin-bottom:150px; display:none;">
            <h2 class="alc">{% trans "No library is sharing to this group" %}</h2>
            <p>{% blocktrans %}You can share libraries by clicking the "New Library" button above or the "Share" icon on your libraries list.{% endblocktrans %}</p>
            <p>{% trans "Libraries shared as writable can be downloaded and synced by other group members. Read only libraries can only be downloaded, updates by others will not be uploaded." %}</p>
        </div>
    </div>

    <img class="loading-tip" src="{{MEDIA_URL}}img/loading-icon.gif" alt="{% trans 'Loading...' %}" />
</div>

{% include "js/dir-view.html" %}

{% endblock %}

{% block extra_script %}
{% include "js/lib-op-popups.html" %}
<script>
 app["pageOptions"] = {
     site_root: "{{ SITE_ROOT }}",
     groupId: {{ group.id }},
     groupReposUrl: "{% url "api2-grouprepos" group.id %}",
     groupChangesUrl: "{% url "api2-group-changes" group.id %}",
     isGroupStaff: (function() {
         if ("{{ is_staff }}" == "True")
             return true;
         return false;
     })(),
     csrfToken: "{{csrf_token}}",
     repo_password_min_length: {{ repo_password_min_length }}
 };
</script>
{% if debug %}
<script data-main="{% static "scripts/group.js" %}" src="{% static "scripts/lib/require.js" %}"></script>
{% else %}
<script data-main="{% static "scripts/dist/group.js" %}" src="{% static "scripts/lib/require.js" %}"></script>
{% endif %}

{% endblock %}
