{% load debusine %}
{% load artifacts %}
<table class="table table-sm table-hover table-striped"
       id="input-artifact-list">
    <colgroup>
        <col style="width: 13rem;">
        <col>
        <col>
        <col>
    </colgroup>
    <thead>
        <tr>
            <th>Label</th>
            <th>Category</th>
            <th>Name</th>
            <th>{# Actions #}</th>
        </tr>
    </thead>
    <tbody>
        {% for input_artifact in input_artifacts %}
            {% if input_artifact.artifacts %}
                {% for artifact in input_artifact.artifacts %}
                    <tr>
                        {% if forloop.first %}
                            <td rowspan="{{ input_artifact.artifacts|length }}">
                                <div class="d-flex">
                                    <span class="input-artifact-label flex-grow-1">{{ input_artifact.input_label }}</span>
                                    {% include "web/_lookup-modal.html" with lookup_display=input_artifact.lookup_display id_suffix=forloop.parentloop.counter label=input_artifact.input_label only %}
                                </div>
                            </td>
                        {% endif %}
                        {% include "web/_artifact-list-row.html" with artifact=artifact %}
                    </tr>
                {% endfor %}
            {% else %}
                {# No resolved artifacts (yet) #}
                <tr>
                    <td>
                        <div class="d-flex">
                            <span class="input-artifact-label flex-grow-1">{{ input_artifact.input_label }}</span>
                            {% include "web/_lookup-modal.html" with lookup_display=input_artifact.lookup_display id_suffix=forloop.counter label=input_artifact.input_label only %}
                        </div>
                    </td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
            {% endif %}
        {% endfor %}
    </tbody>
</table>
