{% extends "ui/base-devices.html" %}

{% load url from future %}
{% load icons %}

{% block sidebar %}
<div class="well">
    <p><strong>Devices being edited:</strong></p>
    <ul class="unstyled">
    {% for d in devices %}
        <li><a href="{% url 'search' 'info' d.id %}">{{ d|device_icon }}&nbsp;{{ d.name }}</a></li>
    {% endfor %}
    </ul>
</div>
{% endblock %}

{% block contentarea %}
<p><strong>Hint:</strong> use checkboxes next to labels to mark fields that you want to change.</p>
<p>Fields highlighted in yellow mean different values between devices.</p>
<form class="form form-horizontal bulk-edit-form" method="POST">
    {% csrf_token %}
    <div class="well">
        {% for d in devices %}
        <input type="hidden" name="select" value="{{ d.id }}">
        {% endfor %}
        {% for f in form.visible_fields %}
        {% if f.name != 'save_comment' %}
        <div class="control-group {{ f.css_classes }}
            {% if f.errors %}error{% endif %}
            {% if f.name in different_fields %}warning{% endif %}
        ">
            <label class="control-label checkbox-inline">
                {{ f.label }}
                <input
                    type="checkbox"
                    name="edit"
                    value="{{ f.name }}"
                    style="margin-top: -2px"
                    {% if f.name in edit_fields %}
                    checked='checked'
                    {% endif %}
                >
            </label>
            <div class="controls">
                {{ f }}
                {% for e in f.errors %}
                    <span class="help-block">{{ e }}</span>
                {% empty %}
                    {%  if f.help_text %}
                        <span class="help-block">{{ f.help_text }}</span>
                    {%  endif %}
                {% endfor %}
            </div>

        </div>
        {% endif %}
        {% endfor %}
    </div>
    <div class="control-group {% if form.save_comment.errors %}error{% endif %}">
        <div class="input-append" style="white-space:nowrap">
            {{ form.save_comment }}
            <button class="btn btn-primary" type="submit" name="save">
                {% icon 'fugue-tick' %}&nbsp;Save
            </button>
        </div>
        {% for e in form.save_comment.errors %}
            <div class="help-block error-text">{{ e }}</div>
        {% empty %}
            <div class="help-block">{{ form.save_comment.help_text }}</div>
        {% endfor %}
    </div>
</form>
{% endblock %}
