{% extends base_template %}
{% load debusine %}
{% 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 items %}
        <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 items %}
                    <tr>
                        <td>{{ item.category }}</td>
                        <td>
                            {% if item.artifact %}
                                <a href="{{ item.artifact.get_absolute_url }}">{{ item.name }}</a>
                            {% elif item.collection %}
                                <a href="{{ item.collection.get_absolute_url }}">{{ item.name }}</a>
                            {% else %}
                                <a href="{{ item.get_absolute_url }}">{{ item.name }}</a>
                            {% endif %}
                        </td>
                        <td>{{ item.created_at|date:"Y-m-d H:i" }}</td>
                        <td>
                            <div class="btn-group btn-group-sm"
                                 role="group"
                                 aria-label="Item shortcuts">
                                {% ui_shortcuts item as shortcuts %}
                                {% for shortcut in shortcuts %}
                                    {% widget shortcut %}
                                {% endfor %}
                            </div>
                        </td>
                    </tr>
                {% endfor %}
            </tbody>
        </table>
    {% else %}
        <p>No results.</p>
    {% endif %}
    {% include "web/_pagination.html" %}
{% endblock %}
