{% extends 'fleetfinder/base.html' %}

{% load i18n %}
{% load humanize %}
{% load static %}

{% block page_title %}{% translate "Edit Fleet" %}{% endblock %}

{% block fleetfinder_block %}
    <div class="panel panel-primary">
        <div class="panel-heading">
            <div class="panel-title">
                {% translate "Edit Fleet" %}
            </div>
        </div>

        <div class="panel-body">
            <div class="row">
                <div class="col-md-10 col-md-offset-1">
                    <form class="form-signin" role="form" action="{% url 'fleetfinder:save_fleet' %}" method="POST">
                        {% csrf_token %}

                        <input type="hidden" name="character_id" id="character_id" value="{{ character_id }}">
                        <input type="hidden" name="origin" id="origin" value="edit">

                        <div class="row">
                            <div class="col-sm-12">
                                <div class="form-group">
                                    <label for="name" class="control-label">{% translate "Fleet Name" %}</label>
                                    <input type="text" class="form-control" name="name" id="name" value="{{ fleet.name }}">
                                </div>
                            </div>
                        </div>

                        <div class="row">
                            <div class="col-sm-12">
                                <div class="form-group">
                                    <label for="groups" style="margin-bottom: 0;">{% translate "Select Groups" %}</label>

                                    <span class="help-block" style="margin-top: 0; margin-bottom: 0; font-size: 10pt; font-style: italic;">
                                        {% translate "Only selected groups will have access to the fleet. If no groups are selected the fleet will be available to all of the authed groups." %}
                                    </span>

                                    <select name="groups" id="groups" multiple>
                                        {% for group in auth_groups %}
                                            {% if group in fleet.groups.all %}
                                                <option value="{{ group.group_id }}" selected>{{ group }}</option>
                                            {% else %}
                                                <option value="{{ group.group_id }}">{{ group }}</option>
                                            {% endif %}
                                        {% endfor %}
                                    </select>
                                </div>
                            </div>
                        </div>

                        <div class="row">
                            <div class="col-sm-12">
                                <div class="form-group" >
                                    <label for="motd" class="control-label">{% translate "Fleet MOTD" %}</label>

                                    <div>
                                        <textarea class="form-control" name="motd" id="motd" rows="10">{{ fleet.motd }}</textarea>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <input type="checkbox" style="margin-right: 5px;" class="form-check-input" name="free_move" id="free_move"{% if fleet.is_free_move %} checked{% endif %}>
                        <label for="free_move" class="form-check-label">{% translate "Enable Free Move" %}</label>

                        <button class="btn btn-primary btn-block" type="submit">{% translate "Submit" %}</button>
                    </form>
                </div>
            </div>
        </div>
    </div>
{% endblock %}

{% block extra_css %}
    {% include 'fleetfinder/bundles/multi-select-css.html' %}
    {% include 'fleetfinder/bundles/slim-select-css.html' %}

    <link rel="stylesheet" href="{% static 'fleetfinder/css/fleetfinder.css' %}" type="text/css">
{% endblock %}

{% block extra_javascript %}
    {% include 'fleetfinder/bundles/slim-select-js.html' %}

    <script type="application/javascript">
        new SlimSelect({
            select: "#groups",
            hideSelectedOption: true
        });
    </script>
{% endblock %}

{% block extra_script %}

{% endblock %}
