{% load filesfolders_tags %}

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

<tr>
  {# Icon & name column #}
  <td>
    {% if item|get_class == 'Folder' %}
      <i class="iconify" data-icon="mdi:folder"></i>
    {% elif item|get_class == 'HyperLink' %}
      <i class="iconify" data-icon="mdi:link"></i>
    {% elif item|get_class == 'File' %}
      <i class="iconify" data-icon="{% get_file_icon item %}"></i>
    {% endif %}
  </td>
  {# Name/link column #}
  <td>
    {% if item.flag %}
      {% get_flag_classes item.flag as flag_classes %}
    {% endif %}
    {% if item|get_class == 'Folder' %}
      <a href="{% url 'filesfolders:list' folder=item.sodar_uuid %}"
         class="{{ flag_classes }}">
        {{ item.name|force_wrap:24|safe }}
      </a>
    {% elif item|get_class == 'HyperLink' %}
      <a href="{{ item.url }}" target="_blank"class="{{ flag_classes }}">
        {{ item.name|force_wrap:24|safe }}
      </a>
    {% elif item|get_class == 'File' %}
      <a href="{% url 'filesfolders:file_serve' file=item.sodar_uuid file_name=item.name %}"
         class="{{ flag_classes }}">
        {{ item.name|force_wrap:24|safe }}
      </a>
      {% if allow_public_links and item.public_url and can_share_link %}
        <a href="{% url 'filesfolders:file_public_link' file=item.sodar_uuid %}"
           class="sodar-ff-link-public"
           id="sodar-ff-link-public-{{ item.sodar_uuid }}"
           title="Public Link"
           data-toggle="tooltip" data-placement="top">
          <i class="iconify" data-icon="mdi:link-variant"></i>
        </a>
      {% endif %}
    {% endif %}
    {% if item.flag %}
      {% get_flag item.flag as item_flag %}
      {{ item_flag|safe }}
    {% endif %}
  </td>
  {# File size column (only for files) #}
  <td class="text-right">
    {% if item|get_class == 'File' %}
      {{ item.file.file.size|filesizeformat }}
    {% endif %}
  </td>
  {# Description column #}
  <td>{{ item.description }}</td>
  {# Owner column #}
  <td>{% get_user_html item.owner as user_html %}{{ user_html|safe }}</td>
  {# Date column #}
  <td>{{ item.date_modified|date:'Y-m-d H:i' }}</td>
  {% if not details_card_mode %}
  {# Action button column #}
    <td class="sodar-ff-item-dropdown">
      {% if can_update_all or item.owner == request.user and can_update_own %}
        {% if item|get_class == 'Folder' %}
          {% include 'filesfolders/_folder_dropdown.html' with item_uuid=item.uuid %}
        {% elif item|get_class == 'HyperLink' %}
          {% include 'filesfolders/_hyperlink_dropdown.html' with link=item %}
        {% elif item|get_class == 'File' %}
          {% include 'filesfolders/_file_dropdown.html' with file=file %}
        {% endif %}
      {% endif %}
    </td>
    {# Checkbox column #}
    <td>
      {% if can_update_all or item.owner == request.user and can_update_own %}
        <input class="sodar-checkbox sodar-ff-checkbox-item" type="checkbox"
               id="sodar-ff-checkbox-{{ item|get_class }}-{{ item.sodar_uuid }}"
               name="batch_item_{{ item|get_class }}_{{ item.sodar_uuid }}" value="1" />
      {% endif %}
    </td>
  {% endif %}
</tr>
