{% extends "layout_maps.html" %}

{% block title %}
<title>Add collaborator | Contextualise</title>
{% endblock %}

{% block content %}
<h1>{{ topic_map.name }}
    <small class="text-muted">Add collaborator</small>
</h1>
<hr />
<form action="{{ url_for('map.add_collaborator', map_identifier=topic_map.identifier) }}" autocomplete="off"
    enctype="multipart/form-data" method="post" role="form">
    <input name="_csrf_token" type="hidden" value="{{ csrf_token() }}">
    <div class="form-group">
        <label for="collaborator-email"><strong>Email address</strong></label>
        <input class="form-control" id="collaborator-email" name="collaborator-email"
            placeholder="Email address of user" required autofocus type="text" value="{{ collaborator_email }}">
        {% if error|bitwise_and(1) == 1 %}
        <small class="text-danger">
            A Contextualise user with this user name does not exist. Please provide a different user name.
        </small>
        {% endif %}
        {% if error|bitwise_and(2) == 2 %}
        <small class="text-danger">
            You cannot share a topic map for collaboration purposes with yourself. Please provide a different user name.
        </small>
        {% endif %}
    </div>
    <div class="form-group">
        <label for="collaboration-mode"><strong>Collaboration mode</strong></label>
        <select class="form-control" id="collaboration-mode" name="collaboration-mode">
            <option value="view" {% if collaboration_mode=='view' %} selected="selected" {% endif %}>Can view</option>
            <option value="comment" {% if collaboration_mode=='comment' %} selected="selected" {% endif %}>Can comment
            </option>
            <option value="edit" {% if collaboration_mode=='edit' %} selected="selected" {% endif %}>Can edit</option>
        </select>
    </div>
    <br />
    <a class="btn btn-secondary" href="{{ url_for('map.collaborators', map_identifier=topic_map.identifier) }}"
        role="button">Cancel</a>
    <button class="btn btn-success" type="submit">Add collaborator</button>
</form>
<br />
{% endblock %}