{% extends "base.html" %}

{% block title %}
{% if wg %}
Edit info on {{ wg.acronym }}
{% else %}
Create WG
{% endif %}
{% endblock %}

{% block morecss %}
form.edit-info #id_name {
  width: 396px;
}

form.edit-info #id_list_email {
  width: 396px;
}

form.edit-info #id_list_subscribe {
  width: 396px;
}

form.edit-info #id_list_archive {
  width: 396px;
}

form.edit-info #id_urls {
  width: 400px;
}

form.edit-info #id_comments {
  width: 400px;
}

{% endblock %}

{% block pagehead %}
<link rel="stylesheet" type="text/css" href="/css/token-input.css"></link>
{% endblock %}

{% block content %}
{% load ietf_filters %}
<h1>{% if wg %}
Edit info on {{ wg.acronym }}
{% else %}
Create WG
{% endif %}
</h1>

<form class="edit-info" action="" method="POST">
  <table>
    {% for field in form.visible_fields %}
    <tr>
      <th>{{ field.label_tag }}:</th>
      <td>{{ field }}
      {% ifequal field.name "ad" %}
      {% if user|in_group:"Area_Director" %}
      <label><input type="checkbox" name="ad" value="{{ login.pk }}" /> Assign to me</label>
      {% endif %}
      {% endifequal %}      
      {% if field.help_text %}<div class="help">{{ field.help_text }}</div>{% endif %}
      {{ field.errors }}
      </td>
    </tr>
    {% endfor %}
    <tr>
      <td></td>
      <td class="actions">
	{% if wg %}
          <a href="{% url wg_view name=wg.acronym %}">Back</a>
          <input type="submit" value="Save"/>
        {% else %}
          <input type="submit" value="Create"/>
	{% endif %}
      </td>
    </tr>
  </table>
</form>
{% endblock %}

{% block scripts %}
$(document).ready(function () {
    var chairs = eval($("#id_chairs").val()),
        secretaries = eval($("#id_secretaries").val()),
        techadv = eval($("#id_techadv").val());
    $("#id_chairs").tokenInput("/wgcharter/searchPerson/", { hintText: "",
                                                            preventDuplicates: true, 
                                                            prePopulate: chairs });
    $("#id_secretaries").tokenInput("/wgcharter/searchPerson/", { hintText: "",
                                                                 preventDuplicates: true,
                                                                 prePopulate: secretaries });
    $("#id_techadv").tokenInput("/wgcharter/searchPerson/", { hintText: "",
                                                             preventDuplicates: true,
                                                             prePopulate: techadv });
    $("#id_name").focus();
});
{% endblock %}

{% block content_end %}
<script type="text/javascript" src="/js/lib/jquery.tokeninput.js"></script>
{% endblock %}
