{% extends "base.html" %}
{% load static %}

{% block title %}Workshop {{ workshop.name }}{% endblock %}

{% block header_bar %}
    <a href="{% url "workshop-list" %}"><img class="icon" src="{% static "inventory/img/back.svg" %}"></a>
    {{ workshop.name }}
    <span class="small">{{ workshop.description}}</span>
{% endblock %}

{% block header_icons %}
    {% if user.is_staff %}
        <li>
            <a href="{% url "admin:inventory_workshop_change" object_id=workshop.pk %}"><img class="icon" src="{% static "inventory/img/edit.svg" %}"></a>
        </li>
        {% include 'inventory/set_index.html' with item=workshop is_index=is_index %}
    {% endif %}
{% endblock %}

{% block content %}
    <h3>Areas</h3>

    <table class="list">
        <tbody>
        {% for area in workshop.area_related.all %}
            <tr>
                <td>
                    <a href="{% url 'area-detail' area.id %}" title="{{ area.description }}">{{ area.name }}</a>
                </td>
                <td>
                {% if user.is_staff %}
                    <a class="edit" href="{% url "admin:inventory_area_change" object_id=area.pk %}"><img class="icon" src="{% static 'inventory/img/edit.svg' %}"></a>
                {% endif %}
                </td>
            </tr>
        {% empty %}
            <tr><td>No areas defined</td></tr>
        {% endfor %}
        </tbody>
    </table>

    {% if user.is_staff %}
        <p><a href="{% url "admin:inventory_area_add" %}?container={{ workshop.id }}&index=0">Create new area...</a></p>
    {% endif %}

    {% if workshop.show_boxes %}
        <h3>Containers</h3>
        <table class="list">
            <tbody>
            {% for box in workshop.box_related.all %}
                <tr>
                    <td>
                        <a href="{% url 'box-detail' box.id %}" title="{{ box.description }}">{{ box.name }}</a>
                    </td>
                    <td>
                    {% if user.is_staff %}
                        <a class="edit" href="{% url "admin:inventory_box_change" object_id=box.pk %}"><img class="icon" src="{% static 'inventory/img/edit.svg' %}"></a>
                    {% endif %}
                    </td>
                </tr>
            {% empty %}
                <tr><td>No containers defined</td></tr>
            {% endfor %}
            </tbody>
        </table>
    
        {% if user.is_staff %}
            <p><a href="{% url "admin:inventory_box_add" %}?container={{ workshop.id }}&index=0">Create new container...</a></p>
        {% endif %}
    {% endif %}
{% endblock %}