{# Needs some keys in context. See AJAX view "RmsTableCardView" #}
{% load analysis_tags %}
{% load icon_tags %}

<div class="card search-result-card">
    <div class="card-header">
      {% if analyses_available %}
      <div class="btn-group btn-group-sm float-right">
        {% if not analyses_unready %}
          <button class="btn btn-primary btn-sm" href="#" data-toggle="modal"
             data-target="#statusesModal-{{ card_id }}">Tasks</button>
        {% endif %}
        <div class="btn-group btn-group-sm float-right dropdown">
          <a href="{% url 'analysis:function-detail' function.pk %}" class="btn btn-default float-right open-btn">
                    {% fa5_icon 'folder-open' 'far' %} Open
          </a>
          <button type="button" class="btn btn-default" data-toggle="dropdown"
                  aria-haspopup="true" aria-expanded="false">
            <i class="fa fa-chevron-down"></i>
          </button>
          <div class="dropdown-menu dropdown-menu-right">
            {% if analyses_success %}
            <a class="dropdown-item" href="{% url 'analysis:download' analyses_success|analyses_results_ids_list_str 'roughness parameters' 'txt' %}">Download TXT</a>
            <a class="dropdown-item" href="{% url 'analysis:download' analyses_success|analyses_results_ids_list_str 'roughness parameters' 'xlsx' %}">Download XLSX</a>
            {% endif %}

          </div>
        </div>
      </div>
      {% endif %}
      <h5>{{ title }}</h5>
    </div>
    <div class="card-body">
      {% if analyses_failure %}
      <ul class="nav nav-tabs">
        <li class="nav-item" style="list-style-type: none;">
          <a class="nav-link active" data-toggle="tab" href="#table-tab-{{ card_id }}">Table</a>
        </li>
        <li class="nav-item" style="list-style-type: none;">
          <a class="nav-link" data-toggle="tab" href="#warnings-tab-{{ card_id }}">Warnings</a>
        </li>
      </ul>
      {% endif %}

      <div class="tab-content">
        <div class="tab-pane fade show active" id="table-tab-{{ card_id }}" role="tabpanel">
          {% include 'analysis/analyses_alerts.html' %}
          {% if not analyses_unready and analyses_success %}
            {% include 'topobank_statistics/roughnessparameters_card_datatables.html' %}
          {% endif %}
        </div>
        {% include 'analysis/analyses_warnings_tab_pane.html' %}
      </div>
    </div>
</div>

{% include 'analysis/task_info_modal.html' %}


