<!-- -*-jinja2-*- -->
{% extends "base.html" %}
{% block app_content %}
  <script>
    $( function() {
    $("#tabs").tabs({ active: {{ npr.index(activetab) }} });
    } );
  </script>
    <h2>Search Results</h1>
    <br>

    {% if thing == "no_hits" %}
      <h3>No hits for query</h3>
    {% endif %}
    {% if thing == "terms" %}
      {% if paging %}
	{{ paging[entdisplay].pagination.info }}
	{{ paging[entdisplay].pagination.links }}
      {% endif %}
      <table class="table table-striped">
	<tr>
	  <th>Value</th><th>Definition</th><th>Origin</th><th>Origin ID</th><th>Score</th>
	</tr>
	{% for item in ents[paging[entdisplay].first:paging[entdisplay].last] %}
	  <tr>
	    <td><a href={{ url_for('main.entities', entities="terms", id=item.ent["nanoid"])}}> {{item.ent["value"]}}</a></td>
	    <td>
	      {% if item.ent["origin_definition"] %}
		{{item.ent["origin_definition"]}}
	      {% else %}
		<i>none</i>
	      {% endif %}
	    </td>
	    <td>{{item.ent["origin_name"]}}</td>
	    <td>
	      {% if item.ent["origin_id"] %}
		{{item.ent["origin_id"]}}
	      {% else %}
		<i>none</i>
	      {% endif %}
	    </td>
	    <td>{{item.score}}</td>
	  </tr>
	{% endfor %}
	</table>
      {% if paging %}
	{{paging[entdisplay].pagination.links}}
      {% endif %}
    {% endif %}
    {% if thing == "models" %}
      <div id="tabs">
        <ul class="nav nav-pills">
          <li class="nav-item">
            <a class="nav-link"
               href="#nodes">Nodes ({{ents.nodes | length}})</a>
          </li>
          <li class="nav-item">
            <a class="nav-link "
               href="#properties">Properties ({{ents.properties | length}})</a>
          </li>
          <li class="nav-item">
            <a class="nav-link "
               href="#relationships">Relationships ({{ents.relationships | length}})</a>
          </li>
        </ul>
        {% for entype in ('nodes', 'properties', 'relationships') %}
          <div id={{entype}} >
            {% if paging %}
	      {{ paging[entype].pagination.info }} 
	      {{ paging[entype].pagination.links }} 
            {% endif %} 
  	    <h3>{{entype | title }})</h3>
	    <table class="table table-striped">
	      <tr>
	        <th>Handle</th><th>Description</th><th>Model</th><th>Score</th>
	      </tr>
	      {# {% for item in ents[entype][paging[entype].first:paging[entype].last] %} #}
              {% for item in ents[entype] %}
	        <tr>
	          <td><a href={{ url_for('main.entities',entities=entype, id=item.ent["nanoid"])}}>{{item.ent["handle"]}}</a></td>
	          <td>
		    {% if item.ent["desc"] %}
		      {{item.ent["desc"]}}
		    {% else %}
		      <i>none</i>
		    {% endif %}
	          </td>
	          <td>{{item.ent["model"]}}</td>
	          <td>{{item.score}}</td>
	        </tr>
	      {% endfor %}
	    </table>
            {# {% if paging %} #}
	    {#   {{ paging[entype].pagination.links }} #}
            {# {% endif %} #}
          </div>
        {% endfor %}
      </div>
    {% endif %}
    

{% endblock %}
