improve task list

This commit is contained in:
2018-04-20 21:55:56 +02:00
parent 9dfa39ff07
commit 196fc2c38f
4 changed files with 250 additions and 91 deletions

View File

@@ -21,85 +21,70 @@
{% block title %}{{ 'Task list'|trans }}{% endblock %}
{% macro thead() %}
<thead>
<tr>
<th>{{ 'Title'|trans }}</th>
<th>{{ 'Task type'|trans }}</th>
<th>{{ 'Task status'|trans }}</th>
<th>{{ 'Task start date'|trans }}</th>
<th>{{ 'Task warning date'|trans }}</th>
<th>{{ 'Task end date'|trans }}</th>
</tr>
</thead>
{% endmacro %}
{% macro row(task) %}
<tr>
<td>{{ task.title }}</td>
<td>{{ task.type }}</td>
<td>todo</td>
<td>{{ task.startDate|localizeddate('medium', 'none') }}</td>
<td>{{ task.warningDate|localizeddate('medium', 'none') }}</td>
<td>{{ task.endDate|localizeddate('medium', 'none') }}</td>
</tr>
{% endmacro %}
{% macro date_status(title, tasks, count, paginator) %}
{% if tasks|length > 0 %}
<h2>{{ title|trans }}</h2>
<table>
<thead>
<tr>
<th>{{ 'Title'|trans }}</th>
<th>{{ 'Task type'|trans }}</th>
<th>{{ 'Task status'|trans }}</th>
<th>{{ 'Task start date'|trans }}</th>
<th>{{ 'Task warning date'|trans }}</th>
<th>{{ 'Task end date'|trans }}</th>
</tr>
</thead>
<tbody>
{% for task in tasks %}
<tr>
<td>{{ task.title }}</td>
<td>{{ task.type }}</td>
<td>todo</td>
<td>{% if task.startDate is not null %}{{ task.startDate|localizeddate('medium', 'none') }}{% endif %}</td>
<td>{% if task.warningDate is not null %}{{ task.warningDate|localizeddate('medium', 'none') }}{% endif %}</td>
<td>{% if task.endDate is not null %}{{ task.endDate|localizeddate('medium', 'none') }}{% endif %}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% if tasks|length > paginator.getTotalItems %}
{{ chill_pagination(paginator) }}
{% endif %}
{% endif %}
{% endmacro %}
{% import _self as helper %}
{# filter tasks #}
{% set ended_tasks = [] %}
{% for task in single_tasks if (task.endDate|date("U") > 'now'|date("U")) %}
{% set ended_tasks = ended_tasks|merge([ task ]) %}
{% endfor %}
{% set warning_tasks = [] %}
{% for task in single_tasks if (task.warningDate|date('U') > 'now'|date("U") and task not in ended_tasks) %}
{% set warning_tasks = warning_tasks|merge([ task ]) %}
{% endfor %}
{% set rest_tasks = [] %}
{% for task in single_tasks if (task not in ended_tasks and task not in warning_tasks) %}
{% set rest_tasks = rest_tasks|merge([ task ]) %}
{% endfor %}
{% block personcontent %}
<h1>{{ 'Task list'|trans }}</h1>
{% if ended_tasks|length > 0 %}
<h2>{{ 'Task with expired deadline'|trans }}</h2>
<table>
{{ helper.thead() }}
<tbody>
{% for task in ended_tasks %}
{{ helper.row(task) }}
{% endfor %}
</tbody>
</table>
{% if single_task_ended_tasks is defined %}
{{ helper.date_status('Tasks with expired deadline', single_task_ended_tasks, single_task_ended_count, single_task_ended_paginator) }}
{% endif %}
{% if warning_tasks|length > 0 %}
<h2>{{ 'Task with warning'|trans }}</h2>
<table>
{{ helper.thead() }}
<tbody>
{% for task in warning_tasks %}
{{ helper.row(task) }}
{% endfor %}
</tbody>
</table>
{% if single_task_warning_tasks is defined %}
{{ helper.date_status('Tasks with warning deadline reached', single_task_warning_tasks, single_task_warning_count, single_task_warning_paginator) }}
{% endif %}
{% if rest_tasks|length > 0 %}
<h2>{{ 'Task '|trans }}</h2>
<table>
{{ helper.thead() }}
<tbody>
{% for task in rest_tasks %}
{{ helper.row(task) }}
{% endfor %}
</tbody>
</table>
{% if single_task_current_tasks is defined %}
{{ helper.date_status('Current tasks', single_task_current_tasks, single_task_current_count, single_task_current_paginator) }}
{% endif %}
{% if single_task_not_started_tasks is defined %}
{{ helper.date_status('Tasks not started', single_task_not_started_tasks, single_task_not_started_count, single_task_not_started_paginator) }}
{% endif %}