{% extends 'assets/add_assets.html' %}
{% load assets bob i18n history_tags %}

{% block form_title %}{% trans "Edit device" %}{% endblock %}

{% block additional_inputs %}
  {% for field in additional_info %}
    {% field_wrapper field %}
  {% endfor %}
{% endblock %}

{% block tabular_info %}
{% include 'assets/attachment_table.html' with attachment_parent=asset parent_name='asset'%}
  {% status_history asset %}
  {% transition_history asset %}
{% endblock %}

{% block parts %}
  <div>
    <h5>{% trans "Device parts" %}</h5>
    {% if parts %}
    <table class="table table-striped table-bordered details-history">
        <thead><tr>
            <th></th>
            <th>{% trans "Name" %}</th>
            <th>{% trans "Source device" %}</th>
            <th>{% trans "Author" %}</th>
        </tr></thead>
        <tbody>
        {% for part in parts%}
            <tr>
                <td><input type="checkbox" name="part_ids" value="{{ part.id }}"></td>
                <td><a href="{% url part_edit mode=mode asset_id=part.id %}">{{ part }}</a></td>
                <td><a href="{% if part.part_info.source_device %}{% url device_edit mode=mode asset_id=part.part_info.source_device.id %}{% endif %}">{{ part.part_info.source_device|default:'-'}}</a></td>
                <td>{{ part.user|default:'-'}}</td>
            </tr>
        {% endfor %}
        </tbody>
    </table>
    <div class="pull-left">
      <div class="pull-left">
      {% for field in part_form %}
          {{ field.label }}: {{ field }}
      {% endfor %}
      </div>
      <button class="btn btn-primary pull-left" name="move_parts" type="submit">{% trans "Move part" %}</button>
    </div>
    {% endif %}
    {% if not asset.has_parts %}
      {% spaceless %}
      <div class="pull-left">
        <a href="{% url device_split mode='dc' asset_id=asset.id %}" class="btn btn-danger">
          <i class="fugue-icon fugue-cutter"></i>&nbsp;{% trans "Split device" %}
        </a>
      </div>
      {% endspaceless %}
    {% endif %}
    <div class="pull-right">
      <a href="{% url add_part mode=mode  %}?device={{asset.id}}" class="btn btn-primary">{% trans "Add part" %}</a>
    </div>
  </div>
{% endblock %}
