{% from "macros.html" import assignee_menu, badges, csrf_field, icon, swap, tile with context %}
{% if error %}{% endif %}
{% for c in project.columns %} {% set items = by_column[c.id] %}

{{ c.name }}

{{ items | length }} tasks {% if c.human_only_entry %}{{ icon("lock") }}Approval{% endif %} {% if c.requires_resolution %}{{ icon("doc") }}Resolution{% endif %}
{% if loop.first %}{% set empty = "Nothing in " ~ c.name ~ ". Plans from chat land here." %} {% elif c.requires_resolution and not c.is_done %}{% set empty = "Nothing waiting for your review." %} {% else %}{% set empty = "Nothing in " ~ c.name ~ "." %}{% endif %}
    {% for t in items %} {% if c.is_done %}
  1. {{ icon("done") }} {{ t.ref }} {{ t.title }}
  2. {% else %}
  3. {{ t.ref }} {% if t.needs_input %}Needs input{% endif %} {% if t.comment_count %}{{ icon("comment") }}{{ t.comment_count }} comment{{ 's' if t.comment_count > 1 }}{% endif %}

    {{ t.title }}

    {% set labels = t.labels | reject("equalto", "needs-input") | list %} {% if labels %}
    {% for l in labels %}{{ l }}{% endfor %}
    {% endif %} {% set open = t.blocked_by | rejectattr("satisfied") | list %} {% set review = t.blocked_by | selectattr("satisfied") | rejectattr("closed") | list %} {% set done = t.blocked_by | selectattr("closed") | list %} {% if open %}
    blocked by {{ open | map(attribute="ref") | join(", ") }}
    {% endif %} {% if review %}
    waiting on review of {{ review | map(attribute="ref") | join(", ") }}
    {% endif %} {% if done %}
    {{ icon("check") }}{{ done | map(attribute="ref") | join(", ") }} done{% if not t.blocked and not t.claimed_by %}, ready to start{% endif %}
    {% endif %} {% if t.claimed_by %}
    Working{{ t.claim_label }} · {{ t.claimed_at | ago }}{% if t.assignee is none or t.claimed_by.handle != t.assignee.handle %} · @{{ t.claimed_by.handle }}{% endif %}
    {% endif %} {{ assignee_menu(t, agents, "card") }}
  4. {% endif %} {% endfor %}
{% if c.is_done and items | length > 4 %} {% endif %}
{% if loop.first and not project.archived %}
{{ icon("plus") }} Add task
{{ csrf_field() }} {% if add_error %}{% endif %}
{% endif %}
{% endfor %}