{% extends "common/_modal_form.html" %}
{% load i18n humanize %}
{% load url from future %} {# fix for django 1.4.9 on CentOS #}
{% block form_action %}
    {% url 'horizon:murano:catalog:add' app_id environment_id do_redirect drop_wm_form %}
{% endblock %}
{% block form_id %}form_{{ app_id }}{% endblock %}
{% block modal_id %}modal_{{ app_id }}{% endblock %}
{% block modal-header %}{% trans "Add Application to " %}&ldquo;{{ environment_name }}&rdquo;{% endblock %}

{% block modal-body %}
<div class="left">
{{ wizard.management_form }}
{% if wizard.form.forms %}
    {{ wizard.form.management_form }}
    {% for form in wizard.form.forms %}
        {{ form }}
    {% endfor %}
{% else %}
    <fieldset>
    {% with form=wizard.form %}
        {% include "horizon/common/_form_fields.html" %}
    {% endwith %}
    </fieldset>
{% endif %}
<p>{% blocktrans %} {{ extended_description }} {% endblocktrans %}</p>
</div>
<div class="right">
    <h3> {% blocktrans %} {{ service_name }} Application{% endblocktrans %} </h3>
    {% for title, description in field_descriptions %}
        <p>
        {% if title %}
            <strong>{% blocktrans %}{{ title }}:{% endblocktrans %}</strong>
        {% endif %}
        {% blocktrans with description|linebreaksbr as desc %}{{ desc }}{% endblocktrans %}
        </p>
    {% endfor %}
</div>
{% endblock %}

{% block modal-footer %}
    <script type="text/javascript">
        $(function() {
            {# Make element ids unique per-wizard to avoid interference #}
            {# upon pressing 'Back' button while creating one application #}
            {# from another #}
            var btn_id = '#{{ prefix }}_btn', val_id = '#{{ prefix }}_val';
            $(btn_id).click(function() {
                $(val_id).val('{{ wizard.steps.prev }}')
            });
        });
    </script>
    {{ wizard.form.media }}

    <input type="hidden" name="wizard_goto_step" id="{{ prefix }}_val"/>
    <input type="hidden" name="do_redirect" value="{{ do_redirect }}"/>
    <input type="hidden" name="drop_wm_form" value="{{ drop_wm_form }}"/>
    {% if wizard.steps.next %}
        {% trans "Next" as next %}
    {% else %}
        {% trans "Create" as next %}
    {% endif %}
	{% if wizard.steps.index > 0 %}
        <input type="submit" class="btn btn-primary pull-right" value="{{ next }}"/>
        <button name="wizard_goto_step" type="submit" class="btn btn-small"
                id="{{ prefix }}_btn">{% trans "Back" %}</button>
    {% else %}
        <button name="wizard_goto_step" type="submit" class="btn btn-small">
            {{ next }}</button>
	{% endif %}
{% endblock %}
