{% extends "admin/base.html" %}

{% load i18n %}

{% block title %}{% trans "New Automate" %}{% endblock %}

{% block breadcrumb %}
    <div class="col-sm-12 pl-0">
      <a href="{% url 'admin:automates' %}">{% trans "Automates" %}</a>
      /
      {{ title }}
    </div><!-- /.col -->
{% endblock %}

{% block content %}
    <div class="col-lg-12 col-md-12">
        <div class="p-1 p-md-3">
          <!-- form error messages -->
            {% if form.errors %}
              <ul class='form-errors text-danger list-unstyled'>
                {% for field in form %}
                    {% for error in field.errors %}
                      <li><i class="fa fa-exclamation-triangle m-2"></i>{{ error|escape }}</li>
                    {% endfor %}
                {% endfor %}
                {% for error in form.non_field_errors %}
                    <li>{{ error|escape }}</li>
                {% endfor %}
              </ul>
            {% endif %}
            <!-- form error messages -->
            <form id="changeform" class="group" method="POST" action="{{ action_url }}">
              {% csrf_token %}
              {% for field in form %}
                {% if field.name != 'tags' %}
                    <div class="form-group">
                        {{ field.errors }}
                        {{ field.label_tag }}
                        {{ field }}
                        {% if field.help_text %}
                          <small class="form-text text-muted">{{ field.help_text|safe }}</small>
                        {% endif %}
                    </div>
                {% else %}
                  <div class="form-group">
                    <label for="id_name">{% trans "Tags" %}:</label>
                    <div class="tags-container automate-tags-container d-flex">
                    </div>
                    <small class="form-text text-muted">
                      {% trans "These tags will be assigned to matched document." %}
                    </small>
                  </div>
                {% endif %}
              {% endfor %}
            </form>
        </div>
    </div>
    <input name="automate_id" type="hidden" value="{{form.instance.id|default_if_none:''}}" />
{% endblock %}


{% block widgetsbar %}
<div class="card">
  <div class="card-body">
    <ul class="collection">
      <li class="collection-item d-flex flex-row-reverse mt-3">
          <button form="changeform" class="btn btn-primary btn-flat mx-1 btn-block" type="submit">
            <i class="fa fa-check"></i>
            {% trans "Submit" %}
          </button>
      </li>
      <li class="collection-item d-flex flex-row-reverse mt-3">
        <a class="btn btn-flat btn-block btn-light" href="{% url 'admin:automates' %}">{% trans "Cancel" %}</a>
      </li>
    </ul>
  </div>
</div>
{% endblock %}