{% extends 'projectroles/project_base.html' %}

{% load rules %}

{% block title %}
  Confirm Folder Deletion
{% endblock title %}

{% block projectroles_extend %}

<div class="container-fluid sodar-subtitle-container">
  <h3>Confirm Folder Deletion</h3>
</div>

<div class="container-fluid sodar-page-container">
  {% if object.children.count > 0 or object.files.count > 0 or object.links.count > 0 %}
  <div class="alert alert-danger" role="alert">
    <strong>Error:</strong> Unable to delete a non-empty folder. Please delete
    files and subfolders and try again.
  </div>

  <div class="row">
    <div class="btn-group ml-auto">
      {% if object.folder %}
        <a role="button" class="btn btn-secondary"
            href="{% url 'filesfolders:list' folder=object.folder.sodar_uuid %}">
      {% else %}
        <a role="button" class="btn btn-secondary"
            href="{% url 'filesfolders:list' project=object.project.sodar_uuid %}">
      {% endif %}
        <i class="iconify" data-icon="mdi:arrow-left-circle"></i> Cancel
      </a>
    </div>
  </div>

  {% else %}
  <div class="alert alert-warning" role="alert">
    Do you really want to delete the folder "{{ object.name }}"
    from {{ object.project.title }}?
  </div>
  <form method="post">
    {% csrf_token %}
    <div class="row">
      <div class="btn-group ml-auto">
        {% if object.folder %}
          <a role="button" class="btn btn-secondary"
             href="{% url 'filesfolders:list' folder=object.folder.sodar_uuid %}">
        {% else %}
          <a role="button" class="btn btn-secondary"
             href="{% url 'filesfolders:list' project=object.project.sodar_uuid %}">
        {% endif %}
          <i class="iconify" data-icon="mdi:arrow-left-circle"></i> Cancel
        </a>
        <button type="submit" class="btn btn-danger">
          <i class="iconify" data-icon="mdi:close-thick"></i> Delete
        </button>
      </div>
    </div>
  </form>
  {% endif %}
</div>

{% endblock projectroles_extend %}
