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

<h2 class="first-heading">
    {% trans 'Children' %}
</h2>

{% ifportalhasperm manage_portal %}
    <form action="{% url 'lfc_update_portal_children' %}"
          method="post">

        {% if children %}
            <table class="lfs-manage-table" width="100%">
                <tr>
                    <th width="1%">
                        <input type="checkbox"
                               class="select-all"
                               value="child" />
                    </th>
                    <th width="10%">
                        {% trans 'Position' %}
                    </th>
                    <th width="20%">
                        {% trans 'Title' %}
                    </th>
                    <th width="20%">
                        {% trans 'State' %}
                    </th>
                    <th width="20%">
                        {% trans 'Type' %}
                    </th>
                    <th class="right last small">
                        {% trans 'Manage' %}
                    </th>
                </tr>
                {% for child in children %}
                    <tr>
                        <td>
                            <input type="hidden"
                                   name="obj_id-{{ child.id }}" />
                            <input type="checkbox"
                                   class="select-child"
                                   name="delete-{{ child.id }}"
                                   style="float:left" />
                        </td>
                        <td>
                            <input type="text"
                                   class="position"
                                   name="position-{{ child.id }}"
                                   value="{{ child.position }}" />
                        </td>
                        <td>
                            <a href="{% url 'lfc_manage_object' child.id %}">
                                {{ child.title }}
                            </a>
                        </td>
                        <td>
                            {% trans child.get_state.name %}
                        </td>
                        <td>
                            {% trans child.get_content_type %}
                        </td>
                        <td class="right last">
                            {% if not forloop.first %}
                                <a class="up ajax-link"
                                   href="{% url 'lfc_move_portal_child' child.id %}?direction=0"></a>
                            {% endif %}
                            {% if not forloop.last %}
                                <a class="down ajax-link"
                                   title='{% trans "Move Down" %}'
                                   href="{% url 'lfc_move_portal_child' child.id %}?direction=1"></a>
                            {% else %}
                                <span class="blank"></span>
                            {% endif %}
                            <a class="edit"
                               href="{% url 'lfc_manage_object' child.id %}"></a>
                            <a class="view"
                               href="{{ child.get_absolute_url }}"></a>
                        </td>
                    </tr>
                {% endfor %}
            </table>
            <div class="manage-form-buttons">
                <input class="ajax-submit"
                       type="submit" name="update" value="{% trans 'Update' %}" />
                <input class="ajax-submit"
                       type="submit" name="delete" value="{% trans 'Delete' %}" />
                <input class="ajax-submit"
                       type="submit" name="copy" value="{% trans 'Copy' %}" />
                <input class="ajax-submit"
                       type="submit" name="cut" value="{% trans 'Cut' %}" />

                {% if display_paste %}
                    <input class="ajax-submit"
                           type="submit" name="paste" value="{% trans 'Paste' %}" />
                {% endif %}
            </div>

        {% else %}
            <div>{% trans 'There are no children' %}</div>

            {% if display_paste %}
                <div class="manage-form-buttons">
                    <input class="ajax-submit"
                           type="submit" name="paste" value="{% trans 'Paste' %}" />
                </div>
            {% endif %}
        {% endif %}
    </form>
{% else %}
    {% if children %}
        <table class="lfs-manage-table">
            <tr>
                <th class="middle">
                    {% trans 'Title' %}
                </th>
                <th class="middle">
                    {% trans 'State' %}
                </th>
                <th class="middle">
                    {% trans 'Type' %}
                </th>
                <th class="small right-padding">
                    {% trans 'Manage' %}
                </th>
            </tr>
            {% for child in children %}
                <tr>
                    <td>
                        <a href="{% url 'lfc_manage_object' child.id %}">
                            <a href="{% url 'lfc_manage_object' child.id %}">
                                {{ child.title }}
                            </a>
                        </a>
                    </td>
                    <td>
                        {{ child.get_state.name }}
                    </td>
                    <td>
                        {{ child.get_content_type }}
                    </td>
                    <td class="right last">
                        <a class="edit"
                           href="{% url 'lfc_manage_object' child.id %}"></a>
                        <a class="view"
                           href="{{ child.get_absolute_url }}"></a>
                    </td>
                </tr>
            {% endfor %}
        </table>
    {% else %}
        <div>{% trans 'There are no children' %}</div>
    {% endif %}
{% endifportalhasperm %}
