{% extends "squad/group_settings/base.jinja2" %}

{% block settings %}
<h1>{{ _('Group members') }}</h1>

<h2>{{ _('Add a new member') }}</h2>
<form method="POST" class="form-inline">

  <p>
  <a href="#" data-toggle="modal" data-target="#permissions">
  <i class="fa fa-question-circle"></i> {{ _('Help on permissions') }}
  </a>
  </p>

  <!-- Modal -->
  <div class="modal fade" id="permissions" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
      <div class="modal-content">
        <div class="modal-header">
           <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
           <h4 class="modal-title">{{ _('Permissions by access level') }}</h4>
        </div>

        <div class="modal-body">
          {% include "squad/_permissions.jinja2" %}
        </div>
      </div>
    </div>
  </div> <!-- id="permissions" -->

  {{crispy(form, form_style='inline', field_class='inline')}}
  <input type='submit' class='btn btn-default' value='Add member'/>
</form>

<h2>{{ _('Existing members') }}</h2>
<ul class="list-group">
  {% for member in members %}
  <li class="list-group-item">
  {% with user=member.user %}

  {% if user != request.user %}
  <div class='group-member-actions pull-right'>
    <form method="post" class="inline form-inline">
    {{csrf_input}}
    <input type="hidden" name="_method" value="put"/>
    <input type="hidden" name="member_id" value='{{member.id}}'/>
    <div class="form-group">
    <select name="access" class="form-control">
    {% for key, value in access %}
    <option value="{{key}}" {% if key == member.access %}selected{% endif %}>{{value}}</option>
    {% endfor %}
    </select>
    </div>
    <input type='submit' class='btn btn-default' value='{{ _('Change') }}'/>
    </form>

    &nbsp;
    &nbsp;

    <form method="post" class="inline form-inline">
    {{csrf_input}}
    <input type="hidden" name="_method" value="delete"/>
    <input type="hidden" name="member_id" value='{{member.id}}'/>
    <input type="submit" class='btn btn-danger' value='{{ _('Remove') }}'/>
    </form>
  </div>
  {% endif %}

  <div class='group-member-details'>
    <strong>{{user.first_name}} {{user.last_name}}</strong>
    {{user.username}}
    <br/>
    <em>{{ _('Member since %s') % member.member_since }}</em>
  </div>


  {% endwith %}
  </li>

  {% endfor %}
</ul>


{% endblock %}
