{% load evelinks %}
{% load filters %}
{% load i18n %}

{% if not docs %}
    <div class="alert alert-warning text-center">{% translate "No Doctrines Found" %}</div>
{% else %}
    <table class="table table-striped table-hover" id="docTable">
        <thead>
            <tr>
                <th>{% translate "Name" %}</th>
                <th>{% translate "Categories" %}</th>
                <th>{% translate "Description" %}</th>
                <th>{% translate "Ships" %}</th>
            </tr>
        </thead>

        <tbody>
            {% for doc in docs %}
                <tr>
                    <td>
                        <a class="text-decoration-none" href="{% url 'fittings:view_doctrine' doc.pk %}">
                            <span class="d-block" style="min-width: 250px;">
                                <span class="me-2" style="height: 64px; width: 64px;">
                                    <img src="{{ doc.icon_url }}" class="rounded" height="64" width="64" alt="{{ doc.name }}">
                                </span>
                                <span>{{ doc.name }}</span>
                            </span>
                        </a>
                    </td>

                    <td>
                        {% for cat in doc.category.all %}
                            <span class="badge text-white" style="background-color: {{ cat.color }};">
                                <a href="{% url 'fittings:view_category' cat.pk %}" class="nostyle">{{ cat.name }}</a>
                            </span>
                        {% endfor %}
                    </td>

                    <td>
                        {{ doc.description|linebreaks|urlize }}
                    </td>

                    <td>
                        {% for fitting in doc_dict|get_item:doc.pk %}
                            <img
                                src="{{ fitting.ship_type_type_id|type_render_url:32 }}"
                                class="rounded"
                                data-bs-tooltip="aa-fittings"
                                title="{{ fitting.ship_type.name }}"
                                alt="{{ fitting.ship_type.name }}"
                            >
                        {% endfor %}
                    </td>
                </tr>
            {% endfor %}
        </tbody>
    </table>
{% endif %}
