{% extends 'core/page.html' %}
{% load i18n %}
{% load static %}
{% load compress %}
{% load core_tags %}
{% load accounts_tags %}
{% load projects_tags %}

{% block head %}
    {% compress css %}
    <link rel="stylesheet" href="{% static 'projects/css/projects.scss' %}" type="text/x-scss" />
    {% endcompress %}
{% endblock %}

{% block sidebar %}
    <h2>{% trans 'Search projects' %}</h2>

    <form method="GET">
        <input type="text" class="form-control" id="search" name="title" placeholder="{% trans 'Search project title' %}"
               value="{{request.GET.title }}" />
    </form>

    <h2>{% trans 'Options' %}</h2>

    <ul class="list-unstyled">
        <li>
            <a href="{% url 'projects' %}">{% trans 'Back to my projects' %}</a>
        </li>
    </ul>

{% endblock %}

{% block page %}
    <h1>{% blocktrans trimmed with site=request.site %}All projects on {{ site }}{% endblocktrans %}</h1>

    <table class="table projects-table">
        <thead>
            <tr>
                <th style="width: 50%;">{% trans 'Name' %}</th>
                <th style="width: 20%;">{% trans 'Created' %}</th>
                <th style="width: 20%;">{% trans 'Last changed' %}</th>
                <th style="width: 10%;"></th>
            </tr>
        </thead>
        <tbody>
            {% for project in projects %}
            <tr>
                <td>
                    <a class=""href="{% url 'project' project.pk %}">
                    {% for ancestor in project.get_ancestors %}{{ ancestor }} / {% endfor %}
                    <strong>{{ project.title }}</strong>
                    </a>
                </td>
                <td>
                    {{ project.created }}
                </td>
                <td>
                    {{ project.last_changed }}
                </td>
                <td class="text-right">
                    <a href="{% url 'project_update' project.pk %}?next={% url 'site_projects' %}" class="fa fa-pencil"></a>
                    <a href="{% url 'project_delete' project.pk %}?next={% url 'site_projects' %}" class="fa fa-trash"></a>
                </td>
            </tr>
            {% endfor %}
        </tbody>
    </table>

    {% include 'projects/projects_pagination.html' %}
{% endblock %}
