{% extends "orgapy/layout/skeleton.html" %}
{% load static %}

{% block title %}Tasks{% endblock title %}

{% block column_main %}
<div class="card">
    <h1 class="card-header">Tasks</h1>
    <div class="card-actions">
        <form id="createTaskForm" action="{% url 'orgapy:tasks' %}" method="post">{% csrf_token %}<input type="hidden" name="title"><button tabindex="3"><i class="ri-add-line"></i> Create</button></form>
    </div>
</div>
<div class="card">
    {% for task in tasks %}
    <div class="line task" task-id="{{ task.id }}" task-title="{{ task.title }}" task-start="{{ task.start_date | date:"Y-m-d" }}" task-due="{{ task.due_date | date:"Y-m-d"  }}" task-mode="{{ task.recurring_mode }}" task-period="{{ task.recurring_period }}">
        {% if task.completed %}
        <span class="label label-success"><i class="ri-checkbox-circle-line"></i> {{ task.date_completion | date }}</span>
        {% elif task.due_date %}
        <span class="label {% if task.overdue %}label-red{% endif %}"><i class="ri-calendar-schedule-line"></i> {{ task.due_date | date }}</span>
        {% endif %}
        {% if task.recurring_mode != 'ON' %}<i class="ri-refresh-line" title="{{task.get_recurring_mode_display}}, {{ task.recurring_period }}"></i>{% endif %}
        <a class="link-hidden" href="{{ task.get_absolute_url }}">{{ task.title }}</a>
    </div>
    {% endfor %}
    {% include 'orgapy/partials/pagination.html' %}
</div>
<script type="text/javascript">bindCreateForm(createTaskForm, "task")</script>
{% endblock column_main %}
