{% extends "layouts/content.html" %}
{% load static %}

{% block styles %}
<link rel="stylesheet" type="text/css" href="{% static "lava_results_app/css/query.css" %}"/>
{% endblock %}

{% block content %}
{% if form.instance.id %}
<h1>Edit query &ldquo;{{ form.instance.name }}&rdquo;…</h1>
{% elif is_copy %}
<h1>Copy query &ldquo;{{ query_name }}&rdquo;…</h1>
{% else %}
<h1>Add new query…</h1>
{% endif %}

{% block content_form %}
<form action="" method="post">{% csrf_token %}

  {% if form.errors %}
  <div class="errors">
    <div>
      {{ form.non_field_errors }}
      <ul>
	{% for field in form %}
	{% if field.errors %}
        <li>{{ field.label }}: {{ field.errors|striptags }}</li>
        {% endif %}
	{% endfor %}
      </ul>
    </div>
  </div>
  {% endif %}

<div class="form-field">
  {{ form.name.label_tag }}
  {{ form.name }}
  {{ form.owner }}
</div>
<div class="form-field">
{{ form.content_type.label_tag }}
{% if form.content_type.value %}
{{ form.content_type.as_hidden }}
{{ form.instance.content_type.name }}
{% else %}
{{ form.content_type }}
{% endif %}
</div>
<div class="form-field">
  {{ form.is_live.label_tag }}
  {{ form.is_live }}
  &nbsp;&nbsp;
  <button type="button" class="btn btn-info btn-xs" data-toggle="tooltip" data-placement="right" title="Query will display latest results always. Keep in mind that live queries take a lot more time to load and can also affect the system performance as each time someone go to query result page the results are updated.">?</button>
</div>
<div class="form-field">
  {{ form.limit.label_tag }}
  {{ form.limit }}
</div>
<div class="form-field">
  {{ form.description.label_tag }}
  {{ form.description }}
</div>

<div class="submit-button">
<input type="submit" value="Save" />
</div>
</form>

{% endblock content_form %}

{% endblock %}
