{% extends "ui/base-devices.html" %}
{% load icons %}
{% load url from future %}

{% block content %}
<table class="table table-striped table-bordered details-components">
    <thead><tr>
        <th width="16"></th>
        <th>Label</th>
        <th>Model Group</th>
        <th>Model</th>
        <th>Serial Number</th>
        <th>Speed</th>
        <th>Size</th>
        <th>Count</th>
        {% if user.is_staff %}
        <th>Action</th>
        {% endif %}
    </tr></thead>
    <tbody>
        {% for item in components %}
        {% if not item.model.is_software %}
        <tr>
            <td><i class="fugue-icon {{ item.icon }}"></i></td>
            {%  if item.hrefinfo %}
                <td><a href="{{ item.hrefinfo }}" style="white-space:nowrap">
                        {{ item.label }}
                     </a>
                </td>
            {%  else %}
                <td>{{ item.label }}</td>
            {%  endif %}
            <td>
                {% if item.model.group %}
                    {% if item.group == 'dev' %}
                        <a href="{% url 'catalog' 'device' item.model.type item.model.group.id|default:''%}">
                            {{ item.model.group.name }}
                        </a>
                    {% else %}
                        <a href="{% url 'catalog' 'component' item.model.type  item.model.group.id|default:''%}">
                            {{ item.model.group.name }}
                        </a>
                    {% endif %}
                {% endif %}
            </td>
            <td>
                {% if item.model.group %}
                    {% if item.group == 'dev' %}
                        <a href="{% url 'search' 'component' '' %}?model={{ item.model.name }}">
                            {{ item.model.name }}
                        </a>
                    {% else %}
                        <a href="{% url 'search' 'component' '' %}?component={{ item.model }}">
                            {{ item.model }}
                        </a>
                    {% endif %}
                {% else %}
                    {% if item.model.type %}
                        <a href="{% url 'catalog' 'component' item.model.type %}">{{ item.model }}</a>
                    {% else %}
                        {{ item.model }}
                    {% endif %}
                {% endif %}
            </td>
            <td>{{ item.serial|default:'' }}</td>
            <td>{{ item.speed|default:'' }}</td>
            <td>{{ item.size|default:'' }}</td>
            <td>{{ item.count|default:'' }}</td>
            {% if user.is_staff %}
            <td>
                {% if item.href %}
                <a href="{{ item.href }}" style="white-space:nowrap">
                    {% icon 'fugue-toolbox--pencil' %} Edit
                </a>
                {% endif %}
            </td>
            {% endif %}
        </tr>
        {% endif %}
        {% endfor %}
    </tbody>
</table>

{% endblock content %}
