{% extends "projector/project/detail.html" %}

{% load i18n %}
{% load pagination_tags %}
{% load sorting_tags %}

{% block col-single-extra %}

{% autosort filters.qs as task_list %}
{% autopaginate task_list %}

<div class="richtemplates-panel width-10 float-left">
    <h5>{% trans "Filters" %}</h5>
    <div class="richtemplates-panel-content">
        <form action="." method="get">
            <table class="filterform-table">
                {% for field in filters.form %}
                    {% include "richtemplates/forms/filter-field.html" %}
                {% endfor %}
            </table>
            <p>
                <input id="id_filter_task" type="submit" value="Search" />
            </p>
        </form>
    </div>
</div>

<div class="richtemplates-panel width-75 float-right">
    <h5>{% trans "Project's task list" %}</h5>
    <div class="richtemplates-panel-content">
    <h2>{% trans "Task List" %}</h2>
    <ul class="nav-inline">
        <li><a class="richbutton" href="{{ project.get_create_task_url }}">{% trans "Create new task" %}</a></li>
    </ul>
    {% if invalid_page %}
        <div class="messages">
            <p class="error">{% trans "There is no such page!" %}</p>
        </div>
    {% else %}
    <table class="datatable">
        <thead class="datatable-thead">
            <tr class="datatable-thead-subheader">
                <th>{% anchor id "Task" %}</th>
                <th>{% anchor summary "Summary" %}</th>
                <th>{% anchor milestone "Milestone" %}</th>
                <th>{% anchor created_at "Created at" %}</th>
                <th>{% anchor priority "Priority" %}</th>
                <th>{% anchor type "Type" %}</th>
                <th>{% anchor component "Component" %}</th>
                <th>{% anchor status "Status" %}</th>
                <th>{% anchor author "Reported by" %}</th>
                <th>{% anchor owner "Assigned to" %}</th>
            </tr>
        </thead>
        <tbody class="datatable-tbody">
            {% for task in task_list %}
            <tr class="{% cycle "odd" "even" %} hoverable">
                <td>{{ task.id }}</td>
                <td><a href="{{ task.get_absolute_url }}" class="block-link">{{ task.summary }}</a></td>
                <td><a href="{{ task.milestone.get_absolute_url }}" class="block-link">{{ task.milestone }}</a></td>
                <td>{{ task.created_at|date:"Y-m-d" }}</td>
                <td>{{ task.priority.name }}</td>
                <td>{{ task.type }}</td>
                <td><a href="{{ task.component.get_absolute_url }}" class="block-link">{{ task.component }}</a></td>
                <td>
                    <span class="{% if task.status.is_resolved %}task-closed{% else %}task-open{% endif %}">
                        {{ task.status }}
                    </span>
                </td>
                <td><a href="{% url projector_users_profile_detail task.author.username %}" 
                       class="block-link">{{ task.author }}</a>
                </td>
                <td>
                    {% if task.owner %}
                    <a href="{% url projector_users_profile_detail task.owner.username %}" 
                       class="block-link">{{ task.owner }}</a>
                    {% else %}
                    -
                    {% endif %}
                </td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
    {% paginate %}
    {% endif %}
</div>
</div>

{% endblock %}

