{% extends '@MauticCore/Default/content.html.twig' %}

{% block headerTitle pageTitle %}

{% block content %}
    {% set isModal = isModal|default(false) %}

    {% if not isModal %}
        {{ include('@DealFlow/Deal/_nav.html.twig') }}
    {% endif %}

    <style>
        .dealflow-settings-entry {
            background: var(--layer-02);
            border: 1px solid var(--border-subtle-01);
            border-radius: var(--border-radius-lg);
            overflow: visible;
        }

        .dealflow-settings-entry--modal {
            border: 0;
            border-radius: var(--border-radius-md);
        }

        {% if isModal %}
        #MauticSharedModal .modal-header {
            display: none;
        }

        #MauticSharedModal .modal-body {
            padding: 0;
        }
        {% endif %}

        .dealflow-settings-entry__body {
            padding: 24px 26px;
        }

        .dealflow-settings-entry__body--modal {
            padding-top: 20px;
        }

        .dealflow-settings-entry__card {
            background: var(--background);
            border: 1px solid var(--border-subtle-01);
            border-radius: var(--border-radius-md);
            overflow: visible;
        }

        .dealflow-settings-entry__card-head {
            background: var(--layer-01);
            border-top-left-radius: inherit;
            border-top-right-radius: inherit;
            border-bottom: 1px solid var(--border-subtle-01);
            padding: 16px 18px 14px;
        }

        .dealflow-settings-entry__card-title {
            color: var(--text-primary);
            font-size: 17px;
            font-weight: 700;
            margin: 0 0 4px;
        }

        .dealflow-settings-entry__card-copy {
            color: var(--text-secondary);
            font-size: 13px;
            margin: 0;
        }

        .dealflow-settings-entry__card-body {
            border-bottom-left-radius: inherit;
            border-bottom-right-radius: inherit;
            padding: 18px;
        }

        .dealflow-settings-entry__actions {
            border-top: 1px solid var(--border-subtle-01);
            display: flex;
            flex-wrap: wrap;
            gap: 10px;
            padding: 18px 26px 22px;
        }

        .dealflow-settings-entry .form-control,
        .dealflow-settings-entry .chosen-container-single .chosen-single,
        .dealflow-settings-entry .chosen-container-multi .chosen-choices {
            background: var(--background);
            border: 1px solid var(--border-subtle-01);
            border-radius: var(--border-radius-sm);
            box-shadow: none;
            color: var(--text-primary);
            min-height: 42px;
        }

        .dealflow-settings-entry .chosen-container {
            width: 100% !important;
        }

        .dealflow-settings-entry .chosen-container-active {
            z-index: 40;
        }

        .dealflow-settings-entry .chosen-drop {
            z-index: 45;
        }

        .dealflow-settings-entry .form-control:focus,
        .dealflow-settings-entry .chosen-container-active .chosen-single,
        .dealflow-settings-entry .chosen-container-active .chosen-choices {
            border-color: var(--link-primary);
            box-shadow: 0 0 0 1px var(--link-primary);
        }

        .dealflow-settings-entry .help-block {
            color: var(--text-secondary);
            font-size: 12px;
        }
    </style>

    {{ form_start(form, {'action': formAction|default(null)}) }}
    <div class="dealflow-settings-entry{{ isModal ? ' dealflow-settings-entry--modal' : '' }}">
        <div class="dealflow-settings-entry__body{{ isModal ? ' dealflow-settings-entry__body--modal' : '' }}">
            {% if form.vars.errors|length > 0 %}
                <div class="alert alert-danger">
                    {{ form_errors(form) }}
                </div>
            {% endif %}

            <section class="dealflow-settings-entry__card">
                <div class="dealflow-settings-entry__card-head">
                    <h3 class="dealflow-settings-entry__card-title">Pipeline settings</h3>
                    <p class="dealflow-settings-entry__card-copy">Name the pipeline clearly, then decide whether it should be active and the default for new deals.</p>
                </div>
                <div class="dealflow-settings-entry__card-body">
                    <div class="row">
                        <div class="col-md-12">{{ form_row(form.name) }}</div>
                    </div>
                    <div class="row">
                        <div class="col-md-6">{{ form_row(form.isDefault) }}</div>
                        <div class="col-md-6">{{ form_row(form.isPublished) }}</div>
                    </div>
                </div>
            </section>
        </div>

        <div class="dealflow-settings-entry__actions">
            <button class="btn btn-primary" type="submit">Save Pipeline</button>
            {% if isModal %}
                <button class="btn btn-secondary" type="button" data-dismiss="modal">Cancel</button>
            {% else %}
                <a class="btn btn-secondary" href="{{ cancelUrl }}" data-toggle="ajax">Cancel</a>
            {% endif %}
            {% if pipeline is defined and pipeline.getId() and not isModal %}
                <a class="btn btn-danger" href="{{ path('mautic_dealflow_pipeline_settings_delete', {'objectId': pipeline.getId()}) }}">Delete Pipeline</a>
            {% endif %}
        </div>
    </div>
    {{ form_end(form) }}
{% endblock %}
