{% extends "web/_base.html" %}
{% block navbar_left %}
    {{ block.super }}
    {% include "web/_collection-menu.html" with collection=collection only %}
{% endblock %}
{% block title %}Search collection {{ collection.name }}@{{ collection.category }}{% endblock %}
{% block content %}
    <h1>Search {{ collection.name }}@{{ collection.category }} collection</h1>
    <form method="get" action=".">
        {{ form.as_p }}
        <button type="submit" class="btn btn-primary">Search</button>
    </form>
    {% if item_list %}
        <table class="table table-sm">
            <thead>
                <tr>
                    <th>
                        Category
                        {% include "web/_order.html" with name="category" order=order asc=asc only %}
                    </th>
                    <th>
                        Name
                        {% include "web/_order.html" with name="name" order=order asc=asc only %}
                    </th>
                    <th>
                        Created at
                        {% include "web/_order.html" with name="created_at" order=order asc=asc only %}
                    </th>
                    <th>Details</th>
                </tr>
            </thead>
            <tbody>
                {% for item in item_list %}
                    <tr>
                        <td>{{ item.category }}</td>
                        <td>
                            <a href="{% url 'artifacts:detail' artifact_id=item.artifact.id %}">{{ item.name }}</a>
                        </td>
                        <td>{{ item.created_at|date:"Y-m-d H:i" }}</td>
                        <td>
                            <a href="{{ item.get_absolute_url }}">
                                <i class="bi bi-arrow-right-square"></i>
                            </a>
                        </td>
                    </tr>
                {% endfor %}
            </tbody>
        </table>
    {% else %}
        <p>No results.</p>
    {% endif %}
    {% include "web/_pagination.html" %}
{% endblock %}
