{% load i18n %}

{% if parent_for_portlets %}
    <form class="portlets-form"
          action="{% url lfs_update_portlets object_type_id, object.id %}"
          method="post"
          style="padding-bottom:25px">
        <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">{% trans slot.name %}</label>
            </div>
        {% endfor %}

        <div class="buttons">
            <input type="submit"
                   class="button ajax-save-button"
                   value="{% trans 'Save blocked parent slots' %}" />
        </div>
    </form>
{% endif %}

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

    {% if slot.portlets %}

        <table class="lfs-manage-table">
            <tr>
                <th class="small">
                    {% trans 'Type' %}
                </th>
                <th class="middle">
                    {% trans 'Title' %}
                </th>
                <th class="tiny right-padding">
                    {% trans 'Manage' %}
                </th>
            </tr>
            {% for portlet in slot.portlets %}
                <tr>
                    <td>
                        {% trans portlet.type %}
                    </td>
                    <td>
                        {{ portlet.title }}
                    </td>
                    <td class="right-padding management">
                        <a class="delete-link"
                           dialog_message='{% trans "Do you really want to delete this portlet?" %}'
                           href="{% url lfs_delete_portlet portlet.pa_id %}">{% trans 'Delete' %}
                        </a> |
                        <a class="portlet-edit-button"
                           href="{% url lfs_edit_portlet portlet.pa_id %}">{% trans 'Edit' %}
                        </a>
                    </td>
                </tr>
            {% endfor %}
        </table>
    {% else %}
        <p class="no-portlets">{% trans 'There are no portlets assigned' %}</p>
    {% endif %}
{% endfor %}

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

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

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