{% extends 'assets/base.html' %}
{% load bob icons i18n %}
{% load assets %}

{% block content %}
<div id="float_toolbar">
  <a id="fill_all_rows" href="#" title="Fill all rows">
    {% icon 'fugue-pencil--plus' %}
  </a>
</div>

<div class="row"><h3>{% trans 'Bulk edit' %}</h3></div>
<form method="POST" class="form form-inline" {% dependency_data formset.forms.0 %}>
  {% csrf_token %}
  {{ formset.management_form }}
  <div class="row overflow-x">
      <table class="table table-striped table-bordered table-condensed
        scrollable-table bulk-table"
      >
      <thead><tr>
        <th></th>
      {% for field in formset.forms.0.visible_fields %}
        <th>{{field.label}}</th>
      {% endfor %}

      </tr></thead>
      <tbody>{% for form in formset %}
        <tr>
          <td>
            {{ forloop.counter }}
          {% for hidden_field in form.hidden_fields %}
            {{ hidden_field }}
          {% endfor %}
          </td>

          {% for field in form.visible_fields %}
            {% if form.device_info.value  %}
              <td class="control-group{% if form.device_info.value and field.errors %} error{% endif %}">
                  {{ field }}
                  {% if field.errors %}
                    <span class="help-inline">{% for error in field.errors %}{{ error }} {% endfor %}</span>
                  {% endif %}
              </td>
            {% else %}
              <td class="control-group{% if "-support_period" in field.html_name %} small{% endif %}{% if field.errors %} error{% endif %}">
                {{ field }}
                {% if field.errors %}
                  <span class="help-inline">{% for error in field.errors %}{{ error }} {% endfor %}</span>
                {% endif %}
              </td>
            {% endif %}
          {% endfor %}
        </tr>
      {% endfor %}</tbody>
    </table>
  </div>
  <div class="row">
    <div class="form-actions">
      <button type="submit" class="btn btn-primary">Save</button>
      {% if mode == 'back_office' %}
        {% transition_button 'return-asset' %}
      {% endif %}
    </div>
  </div>
</form>
{% endblock %}
