{# -*-jinja2-*- #}


{% macro render_nav(m, maintopics) %}

  <div class="nav">
    <div class="nav-item dropdown">
      <a class="nav-link dropdown-toggle" id="dropdownMenuLink1_{{m.firstmail}}"  data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" href="#">
	{% if m.is_answered() %}
	  IS answered
	{% else %}
	  ISNOT answered 
	{% endif %}
      </a>
      <div class="dropdown-menu" arialabelledby="dropdownMenuLink1_{{m.firstmail}}">
	<a class="btn" href="{{m.firstmail}}?key=answered&value={{(not m.is_answered())}}">
	  answered:{{(not m.is_answered())}}
	</a>
      </div>
    </div>

    <div class="dropdown nav-item">
      <a class="nav-link dropdown-toggle" id="dropdownMenuLink2_{{m.firstmail}}"  data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" href="#">
	{{m.maintopic}}
      </a>
      <div class="dropdown-menu" arialabelledby="dropdownMenuLink2_{{m.firstmail}}">
	{% for t in maintopics %}
	  <a class="dropdown-item" href="{{m.firstmail}}?key=maintopic&value={{t}}">{{t}}</a>
	{% endfor %}
      </div>
    </div>

    <div class="nav-item dropdown">
      <a class="nav-link dropdown-toggle" id="dropdownMenuLink3_{{m.firstmail}}"  data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" href="#"> {% if m.istrained %}
	IS trained
      {% else %}
	ISNOT trained 
      {% endif %}
      </a>
      <div class="dropdown-menu" arialabelledby="dropdownMenuLink3_{{m.firstmail}}">
	<a class="btn" href="{{m.firstmail}}?key=trained&value={{(not m.istrained)}}">TRAINED:{{(not m.istrained)}}</a> 
      </div>
    </div>

    <div class="nav-item dropdown">
      <a class="nav-link dropdown-toggle" id="dropdownMenuLink4_{{m.firstmail}}"  data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" href="#"> {{ m.lang }}
      </a>
      <div class="dropdown-menu" arialabelledby="dropdownMenuLink3_{{m.firstmail}}">
	{% for l in ["de", "en"] %}

	  <a class="btn" href="{{m.firstmail}}?key=lang&value={{l}}">{{(l)}}</a> 
	{% endfor %}

      </div>
    </div>			 
    
  </div>
{% endmacro %}

{% macro render_inline_thread(m, maintopics) %}

  <div class="card card-thread answ-{{m.is_answered()}} trained-{{m.istrained}}">
    <div class="" role="tab" id="heading{{m.firstmail}}">
      <b class="mb-0">
	<a data-toggle="collapse"
	   data-parent="#accordion"
	   href="#collapse{{m.firstmail}}"
	   aria-expanded="true" aria-controls="collapse1"
	   >
	   {% if m.istrained %} trained: {% endif %} {{m.tstr()}}
	</a>
      </b>
    </div>
    <div id="collapse{{m.firstmail}}"
	 class="collapse {{'show' if m.firstmail==opened}}"
	 role="tabpanel"
	 aria-labelledby="headingOne"
	 >
      <div class="card-block">
	{{render_nav(m,maintopics) }}
      </div>
      
      {% for (h,txt) in m.print_mail() %}
	<div> {{h}}</div>
	<div class="textbox"> {{ txt }}	</div>
      {% endfor %}
    </div>
  </div>
{% endmacro %}
