{# Project list item #}
{# Expects to have custom_cols and list_parent set #}
{% load rules %}
{% load projectroles_tags %}
{% load projectroles_common_tags %}

{% has_perm 'projectroles.view_project' request.user p as can_view_project %}
{% get_project_list_indent p list_parent as project_indent %}
{% if request.user.is_superuser %}
  {% get_remote_icon p request as remote_icon %}
{% endif %}

<tr class="sodar-pr-project-list-item"
    id="sodar-pr-project-list-item-{{ p.sodar_uuid }}"
    data-title="{{ p.title }}"
    data-full-title="{{ p.full_title }}"
    data-starred="{% if p in starred_projects %}1{% else %}0{% endif %}">
  <td>
    <div class="sodar-overflow-container">
      <span class="sodar-pr-project-indent"
            style="padding-left: {{ project_indent }}px;"></span>
      <i class="iconify"
         data-icon="mdi:{% if p.type == 'CATEGORY' %}rhombus-split{% else %}cube{% endif %}"></i>
      <span class="sodar-pr-project-title
                   {% if p.type == 'CATEGORY' %}text-underline{% endif %}
                   {% if not can_view_project %}text-muted{% endif %}">
        {% if can_view_project %}
          <a class="sodar-pr-project-link"
             href="{% url 'projectroles:detail' project=p.sodar_uuid %}">{{ p.title }}</a>
        {% else %}
          {{ p.title }}
        {% endif %}
        {% if request.user.is_superuser and remote_icon %}
          {{ remote_icon | safe }}
        {% endif %}
        {% if p.type == 'PROJECT' and p.public_guest_access %}
          <span class="sodar-pr-project-public"
                title="Public guest access"
                data-toggle="tooltip" data-placement="top">
            <i class="iconify text-info mx-1" data-icon="mdi:earth"></i>
          </span>
        {% endif %}
        {% if p in starred_projects %}
          <i class="iconify text-warning sodar-tag-starred" data-icon="mdi:star"></i>
        {% endif %}
      </span>
    </div>
  </td>
  {% for col in project_custom_cols %}
    {% if col.active %}
      {% if p.type == 'PROJECT' %}
        <td class="sodar-pr-project-list-custom text-{{ col.align }}"
            {% if col.width %} style="width: {{ col.width }}px !important"{% endif %}>
          {% get_project_column_value col p as col_val %}
          {{ col_val | safe }}
        </td>
      {% else %}
        <td></td>
      {% endif %}
    {% endif %}
  {% endfor %}
  <td>
    {% get_user_role_html p request.user as user_role_html %}
    {{ user_role_html | safe }}
  </td>
</tr>
