{% extends "djblets_forms/admin/change_form_page.html" %}
{% load i18n pipeline static %}

{% block page_title %}
{%  blocktrans with name=form.integration.name %}Configure {{name}}{% endblocktrans %}
{% endblock %}

{% block form_title %}
{%  blocktrans with name=form.integration.name %}Configure {{name}}{% endblocktrans %}
{% endblock %}

{% block save_message %}
{%  trans "The integration settings have been saved." %}
{% endblock %}

{% block submit_row_buttons %}
{%  include "admin/submit_line.html" %}
{% endblock %}

{% block css %}
{{block.super}}
{%  stylesheet "djblets-forms" %}
{% endblock %}

{% block admin_scripts_post %}
{{block.super}}
{% include "js/underscore.html" %}
{%  javascript "djblets-gravy" %}
{%  javascript "djblets-forms" %}

<script>
    $('.deletelink').click(function(e) {
        e.preventDefault();
        e.stopPropagation();

        if (confirm(gettext("Are you sure you want to delete this configuration?"))) {
            $.ajax({
                type: 'DELETE',
                url: '.',
                success: function() {
                    window.location = "{{success_url|escapejs}}";
                },
                beforeSend: function(xhr) {
                    var csrfToken = $('input[name="csrfmiddlewaretoken"]')
                        .val();

                    if (csrfToken) {
                        xhr.setRequestHeader('X-CSRFToken', csrfToken);
                    }
                }
            });
        }
    });
</script>
{% endblock admin_scripts_post %}
