{% load i18n %}
{% load lfc_tags %}

{% if parent_for_portlets %}
    <form class="portlets-form"
          action="{% url lfc_update_portlets object_type_id, obj.id %}"
          method="post">
        <h2>{% trans 'Blocked parent slots' %}</h2>
        {% for slot in slots.items %}
            <div>
                <input type="checkbox"
                       name="block_slot"
                       value="{{ slot.id }}"
                       {% if slot.is_blocked %}checked="checked"{% endif %} />
                <label class="middle">{{ slot.name }}</label>
            </div>
        {% endfor %}

        <div class="middle">
            {% ifhasperm edit %}
                    <input type="submit"
                           class="ajax-save-button"
                           value="{% trans 'Save blocked parent slots' %}" />
            {% endifhasperm %}
        </div>

    </form>
{% endif %}

<h2 class="middle-heading">{% trans 'Slots' %}</h2>

{% for slot in slots.items %}
    <h3 {% if forloop.first %}class="first-heading"{% endif %}>
        {% trans 'Slot' %}: {{ slot.name }}
    </h3>

    {% if slot.portlets %}

        <table class="lfs-manage-table">
            <tr>
                <th width="100px">
                    {% trans 'Type' %}
                </th>
                <th width="200px">
                    {% trans 'Title' %}
                </th>
                <th>
                    {% trans 'Modify' %}
                </th>
            </tr>
            {% for portlet in slot.portlets %}
                <tr>
                    <td>
                        {{ portlet.type }}
                    </td>
                    <td>
                        {{ portlet.title }}
                    </td>
                    <td>
                        <a class="delete confirmation-link"
                           data="{% trans 'Delete?' %}"
                           href="{% url lfc_delete_portlet portlet.pa_id %}">{% trans 'Delete' %}</a>
                        </a> /
                        <a class="edit portlet-edit-button"
                           href="{% url lfc_edit_portlet portlet.pa_id %}">{% trans 'Edit' %}</a>
                        </a>
                    </td>
                </tr>
            {% endfor %}
        </table>
    {% else %}
        <p class="no-portlets">{% trans 'There are no portlets assigend' %}</p>
    {% endif %}
{% endfor %}


{% ifhasperm edit %}
    <h2 class="middle-heading">
        {% trans 'Add new portlet' %}
    </h2>

    <form class="portlet-add-form"
          action="{% url lfc_add_portlet object_type_id, obj.id %}"
          method="get">
        <select name="portlet_type">
            {% for portlet_type in portlet_types %}
                <option value="{{ portlet_type.type }}">
                    {{ portlet_type.name }}
                </option>
            {% endfor %}
        </select>

        <input class="portlet-add-button"
               type="submit"
               value="{% trans 'Add portlet' %}" />
    </form>
{% endifhasperm %}