{% load filesfolders_tags %}
{# Projectroles dependency #}
{% load projectroles_common_tags %}

<tr class="sodar-ff-search-item" id="sodar-ff-search-item-{{ item.sodar_uuid }}">
  {# Name & link column #}
  <td>
    <div class="sodar-overflow-container">
      {% highlight_search_term item.name search_terms as item_display_name %}
      <a
        {% if item|get_class == 'HyperLink' %}
          href="{{ item.url }}" target="_blank"
        {% elif item|get_class == 'Folder' %}
          href="{% url 'filesfolders:list' folder=item.sodar_uuid %}"
        {% elif item|get_class == 'File' %}
          href="{% url 'filesfolders:file_serve' file=item.sodar_uuid file_name=item.name %}"
        {% endif %}
      >
        {% autoescape off %}{{ item_display_name }}{% endautoescape %}
      </a>
      {% if item|get_class == 'File' and allow_public_links and item.public_url and can_share_link %}
        <a href="{% url 'filesfolders:file_public_link' file=item.sodar_uuid %}"
           title="Public Link"
           id="sodar-ff-link-public-{{ item.sodar_uuid }}">
          <i class="iconify" data-icon="mdi:link-variant"></i>
        </a>
      {% endif %}
      {% if item.flag %}
        {% get_flag item.flag as item_flag %}
        {{ item_flag|safe }}
      {% endif %}
    </div>
  </td>
  {# Type column #}
  <td class="text-nowrap">
    {{ item|get_class }}
  </td>
  {# Project column #}
  <td>
    <div class="sodar-overflow-container">
      <a
        {% if item.folder %}
          href="{% url 'filesfolders:list' folder=item.folder.sodar_uuid %}"
        {% else %}
          href="{% url 'filesfolders:list' project=item.project.sodar_uuid %}"
        {% endif %}
      >
        {% autoescape off %}
          {# NOTE: No highlight here as project is not searched for here #}
          {{ item.project.title }}
        {% endautoescape %}
      </a>
    </div>
  </td>
  {# File size column (only for files) #}
  <td class="text-right text-nowrap">
    {% if item|get_class == 'File' %}
      {{ item.file.file.size|filesizeformat }}
    {% endif %}
  </td>
  {# Description column #}
  <td>
    <div class="sodar-overflow-container">
      {% autoescape off %}
        {% highlight_search_term item.description search_terms %}
      {% endautoescape %}
    </div>
  </td>
</tr>
