{% extends 'layout/page.html' %}

{% block head_title %}
  {% trans %}List of issues{% endtrans %}
{% endblock %}

{% block page_header %}
  {% trans %}List of issues{% endtrans %}
{% endblock %}

{% block content %}

  {% include 'layout/permission.html' %}

  {% if context.is_view_ok() %}
    {% set batch = request.batch() %}
    {% if batch %}
      <table class='table'>
        <tr class='info'>
		  {% if request.show.priority %}
          <td>{% trans %}Priority{% endtrans %}</td>
		  {% endif %}
		  {% if request.show.id %}
          <td>{% trans %}ID{% endtrans %}</td>
		  {% endif %}
		  {% if request.show.activity %}
          <td>{% trans %}Activity{% endtrans %}</td>
		  {% endif %}
		  {% if request.show.actor %}
          <td>{% trans %}Actor{% endtrans %}</td>
		  {% endif %}
		  {% if request.show.keyword %}
          <td>{% trans %}Keyword{% endtrans %}</td>
		  {% endif %}
		  {% if request.show.title %}
          <td>{% trans %}Title{% endtrans %}</td>
		  {% endif %}
		  {% if request.show.status %}
          <td>{% trans %}Status{% endtrans %}</td>
		  {% endif %}
		  {% if request.show.creator %}
          <td>{% trans %}Creator{% endtrans %}</td>
		  {% endif %}
		  {% if request.show.assignedto %}
          <td>{% trans %}Assigned To{% endtrans %}</td>
		  {% endif %}
        </tr>
        {% for issue in batch %}
          {% if request.group|length %}
            {% set group = [request.group[0][1], request.group[1][1]] if request.group|length >= 2 else [request.group[0][1]] %}
            {% if batch.propchanged(*group) %}
              <tr>
                <th class="text-center" colspan="{{ request.columns|length }}">
                  {%- for g in group -%}
                  {%- if issue[g] %} {% if g == 'id' %}{{ issue[g] }}{% else %}{{ issue[g].plain()|u }}{% endif %} {% else %} (no {{ g }} set) {% endif -%}
                  {%- endfor -%}
                </th>
              </tr>
            {% endif %}
          {% endif %}
          <tr>
		   {% if request.show.priority %}
           <td>{{ issue.priority.plain()|u }}</td>
		   {% endif %}
		   {% if request.show.id %}
           <td>{{ issue.id }}</td>
		   {% endif %}
		   {% if request.show.activity %}
           <td>{{ issue.activity.reldate()|u }}</td>
		   {% endif %}
		   {% if request.show.actor %}
           <td>{{ issue.actor.plain()|u }}</td>
		   {% endif %}
		   {% if request.show.keyword %}
           <td>{{ issue.keyword.plain()|u }}</td>
		   {% endif %}
		   {% if request.show.title %}
           <td>
            <a href='issue{{ issue.id }}'>{{ issue.title.plain(hyperlink=0)|u }}</a>
           </td>
		   {% endif %}
		   {% if request.show.status %}
           <td>{{ issue.status.plain()|u }}</td>
		   {% endif %}
		   {% if request.show.creator %}
           <td>{{ issue.creator.plain()|u }}</td>
		   {% endif %}
		   {% if request.show.assignedto %}
           <td>{{ issue.assignedto.plain()|u }}</td>
		   {% endif %}
          </tr>
        {% endfor %}
      </table>
      {% include 'layout/pagination.html' %}
      <div class="d-flex justify-content-end">
        <a class='btn btn-sm btn-secondary'
           href="{{ request.indexargs_url('issue', {'@action':'export_csv'}) }}">
          {% trans %}Download as CSV{% endtrans %}
        </a>
      </div>

      {% include 'layout/sort.html' %}

    {% else %}
      <p class='text-error'>{% trans %}There are no issues yet!{% endtrans %}</p>
    {% endif %}

  {% endif %}

{% endblock %}
