{% extends "admin/base_site.html" %}
{% load i18n admin_urls admin_static admin_modify %}

{% block extrahead %}{{ block.super }}
<script type="text/javascript" src="{% url 'admin:jsi18n' %}"></script>

<link rel="stylesheet" type="text/css" media="all" href="{{ STATIC_URL }}/chatterbox/css/styles.css"/>
<script type="text/javascript" src="{{ STATIC_URL }}/chatterbox/js/vendor/require.js"></script>
<script type="text/javascript">

    requirejs.config({
        baseUrl: '{{ STATIC_URL }}/chatterbox/js',
    });

    require(['{{ STATIC_URL }}/chatterbox/js/common.js'], function (common) {
        require(['main']);
    });

    var service = {
        id: {{ original.collector.service.id|default:"null"}},
        key: "{{ original.collector.service.key }}",
        label: "{{ original.collector.service.label }}",
    }

    var collector = {
        "id": {{ original.collector.id|default:"null"}},
        "label": "{{ original.collector.label }}",
    }

    var keys = [
        {% for key in original.keys.all %}
        {
            "id": {{ key.id|default:"null" }},
            "label": "{{ key.service_username }}",
        },
        {% endfor %}
    ]

    var JOB_DATA = {
        "add": {{ add|stringformat:"s"|lower }},
        "change": {{ change|stringformat:"s"|lower }},
        "service": service,
        "collector": collector,
        "keys": keys,
        "data": {{ original.data_json|safe|default:"null" }}
    }

</script>

{{ media }}
{% endblock %}

{% block extrastyle %}{{ block.super }}<link rel="stylesheet" type="text/css" href="{% static "admin/css/forms.css" %}" />{% endblock %}

{% block coltype %}colM{% endblock %}

{% block bodyclass %}{{ block.super }} app-{{ opts.app_label }} model-{{ opts.model_name }} change-form{% endblock %}

{% if not is_popup %}
{% block breadcrumbs %}
<div class="breadcrumbs">
<a href="{% url 'admin:index' %}">{% trans 'Home' %}</a>
&rsaquo; <a href="{% url 'admin:app_list' app_label=opts.app_label %}">{{ opts.app_config.verbose_name }}</a>
&rsaquo; {% if has_change_permission %}<a href="{% url opts|admin_urlname:'changelist' %}">{{ opts.verbose_name_plural|capfirst }}</a>{% else %}{{ opts.verbose_name_plural|capfirst }}{% endif %}
&rsaquo; {% if add %}{% trans 'Add' %} {{ opts.verbose_name }}{% else %}{{ original|truncatewords:"18" }}{% endif %}
</div>
{% endblock %}
{% endif %}

{% block content %}<div id="content-main">

<form {% if has_file_field %}enctype="multipart/form-data" {% endif %}action="{{ form_url }}" method="post" id="{{ opts.model_name }}_form" novalidate>{% csrf_token %}
    <fieldset class="grp-module">
        <div id="chatterbox-main"></div>
    </fieldset>

{% if save_on_top %}{% block submit_buttons_top %}{% submit_row %}{% endblock %}{% endif %}
{% if errors %}
    <p class="errornote">
    {% if errors|length == 1 %}{% trans "Please correct the error below." %}{% else %}{% trans "Please correct the errors below." %}{% endif %}
    </p>
    {{ adminform.form.non_field_errors }}
{% endif %}
{% block submit_buttons_bottom %}{% submit_row %}{% endblock %}
</form></div>


{% endblock %}
