{% extends "beam/base.html" %}
{% load i18n %}
{% load beam_tags %}


{% block extra_scripts %}{{ block.super }}{{ form.media.js }}{% for inline in inlines %}{{ inline.formset.media.js }}{% endfor %}{% endblock %}
{% block extra_styles %}{{ block.super }}{{ form.media.css }}{% for inline in inlines %}{{ inline.formset.media.css }}{% endfor %}{% endblock %}


{% block title %}
    {% if heading %}
        {{ heading }}
    {% else %}
        {% get_options component.model as options %}
        {% blocktrans with verbose_name=options.verbose_name %}Create {{ verbose_name }}{% endblocktrans %}
    {% endif %}
    | {{ block.super }}
{% endblock %}


{% block content %}
    <form method="post" class="beam-form" enctype="multipart/form-data" novalidate>
        {% block form %}
        {% csrf_token %}

        {% block main_container %}
        <main class="beam-main">
            {% block main %}

                {% block links_container %}
                    <div class="float-right beam-links">
                        {% block links %}
                            {% include "beam/partials/links.html" with links=viewset.links link_layout=component.link_layout %}
                        {% endblock %}
                    </div>
                {% endblock %}

                {% block heading_container %}
                    <h1>
                        {% block heading %}
                            {% if heading %}
                                {{ heading }}
                            {% else %}
                                {% get_options component.model as options %}
                                {% blocktrans with verbose_name=options.verbose_name %}Create {{ verbose_name }}{% endblocktrans %}
                            {% endif %}
                        {% endblock %}
                    </h1>
                {% endblock %}

                {% block form_buttons_top_container %}
                    <div class="beam-form__buttons-top clearfix">
                        <div class="btn-group float-right mb-2">
                            {% block form_buttons_top %}
                                <button type="submit" class="btn btn-primary">{% trans "Save" %}</button>
                            {% endblock %}
                        </div>
                    </div>
                {% endblock %}

                {% block form_errors_container %}
                    {% if form.non_field_errors %}
                        <div class="beam-form__errors alert alert-block alert-danger">
                            <ul class="mb-0">
                                {% block form_errors %}
                                    {{ form.non_field_errors|unordered_list }}
                                {% endblock %}
                            </ul>
                        </div>
                    {% endif %}
                {% endblock %}

                {% block details_container %}
                    <div class="card bg-light mb-4">
                        <div class="card-body">
                            <div class="card-text">
                                {% block details %}
                                    {% include "beam/partials/form_layout.html" with form=form fields=component.fields layout=component.layout %}
                                {% endblock %}
                            </div>
                        </div>
                    </div>
                {% endblock %}

            {% endblock %}
        </main>
        {% endblock %}

        {% block above_inlines %}{% endblock %}

        {% block inlines %}
            {% for inline in inlines %}
                {% block inline %}
                    {% include inline.form_template_name|default:"beam/partials/form_inline.html" %}
                {% endblock %}
            {% endfor %}
        {% endblock %}

        {% block below_inlines %}{% endblock %}

        {% block form_buttons_container %}
            <div class="beam-form__buttons clearfix">
                <div class="btn-group float-right mb-2">
                    {% block form_buttons %}
                        <button type="submit" class="btn btn-primary">{% trans "Save" %}</button>
                    {% endblock %}
                </div>
            </div>
        {% endblock %}

        {% endblock %}
    </form>
{% endblock %}
