{% from "./macros/case.html" import show_case %}
{% from "./macros/conditions.html" import show_conditions %}
{% from "./macros/verification.html" import show_verification %}

{% macro show_scenario(item) %}
  <li class="accordion-item status-{{ item.status }}" data-accordion-item>
    <a href="#" class="accordion-title">
      <span class="badge status-{{ item.status }}">{{ item.status }}</span>
      {{ item.label }}
    </a>
    <div class="accordion-content" data-tab-content>
      {% if not item.message and not item.conditions.children and not item.cases and not item.subscenarios %}
        No message.
      {% else %}
        {% if item.message %}
          <pre>{{ item.message }}</pre>
        {% endif %}

        <ul class="accordion" data-accordion data-multi-expand="true" data-allow-all-closed="true">

          {{ show_conditions(item.conditions) }}

          <li class="accordion-item status-{{ item.cases.status }}" data-accordion-item>
            <a href="#" class="accordion-title">
              <span class="badge status-{{ item.cases.status }}">{{ item.cases.status }}</span>
              Cases
            </a>

            <div class="accordion-content" data-tab-content>
              {% if item.cases %}
                <ul class="accordion" data-accordion data-multi-expand="true" data-allow-all-closed="true">
                  {% for case in item.cases.items %}
                    {{ show_case(case) }}
                  {% endfor %}
                </ul>
              {% else %}
                No message.
              {% endif %}
            </div>
          </li>

          <li class="accordion-item status-{{ item.subscenarios.status }}" data-accordion-item>
            <a href="#" class="accordion-title">
              <span class="badge status-{{ item.subscenarios.status }}">{{ item.subscenarios.status }}</span>
              Subscenarios
            </a>

            <div class="accordion-content" data-tab-content>
              {% if item.subscenarios %}
                <ul class="accordion" data-accordion data-multi-expand="true" data-allow-all-closed="true">
                  {% for subscenario in item.subscenarios.items %}
                    {{ show_scenario(subscenario) }}
                  {% endfor %}
                </ul>
              {% else %}
                No message.
              {% endif %}
            </div>
          </li>

        </ul>
      {% endif %}
    </div>
  </li>
{% endmacro %}
