{% load i18n %}


{# <div id="parent-portlets"> #}
{#     {% if parent_slots %} #}
{#         <h2>{% trans 'Inherited portlets' %}</h2> #}
{#     {% endif %} #}
{#      #}
{#     {% for obj in parent_slots %} #}
{#         {% for slot in obj.items %} #}
{#             {% if slot.portlets %} #}
{#                 <h3 {% if forloop.first %}class="first-heading"{% endif %}> #}
{#                     {% trans 'Slot' %}: {{ slot.name }} #}
{#                 </h3> #}
{#  #}
{#                 <table class="lfs-manage-table"> #}
{#                     <tr> #}
{#                         <th> #}
{#                             {% trans 'Object' %} #}
{#                         </th> #}
{#                         <th> #}
{#                             {% trans 'Type' %} #}
{#                         </th> #}
{#                         <th> #}
{#                             {% trans 'Title' %} #}
{#                         </th> #}
{#                     </tr> #}
{#                     {% for portlet in slot.portlets %} #}
{#                         <tr> #}
{#                             <td> #}
{#                                 object #}
{#                             </td> #}
{#                             <td> #}
{#                                 {{ portlet.type }} #}
{#                             </td> #}
{#                             <td> #}
{#                                 {{ portlet.title }} #}
{#                             </td> #}
{#                         </tr> #}
{#                     {% endfor %} #}
{#                 </table> #}
{#             {% endif %} #}
{#         {% endfor %}         #}
{#     {% endfor %} #}
{# </div> #}

{% if parent_for_portlets %}
    <form class="portlets-form"
          action="{% url lfs_update_portlets object_type_id, object.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">
            <input type="submit"
                   class="ajax-save-button"
                   value="{% trans 'Save blocked parent slots' %}" />
        </div>           
    </form>
{% endif %}
        
<h2 class="heading-middle">{% 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="confirmation-link"
                           data="{% trans 'Delete?' %}"
                           href="{% url lfs_delete_portlet portlet.pa_id %}">{% trans 'Delete' %}</a>
                        </a> /
                        <a class="portlet-edit-button"
                           href="{% url lfs_edit_portlet portlet.pa_id %}">{% trans 'Edit' %}</a>
                        </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 }}">
                {{ portlet_type.name }}
            </option>
        {% endfor %}
    </select>

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