<commit_before>{% import _self as that %}

{% form_theme form _self %}

{% trans_default_domain 'admin' %}

{% macro config_link(type, current_type) %}
    {% set title = ('configuration.action.edit.heading.' ~ type)|trans %}

    {% if type == current_type %}
        <span>{{ title }}</span>
    {% else %}
        <a href="{{ path('darvin_admin_configuration', {'type': type}) }}">{{ title }}</a>
    {% endif %}
{% endmacro %}

{% macro form_row_start(row) %}

    {% set expanded_cookie = 'darvin_admin_config' %}
    {% set expanded        = row.vars.id in app.request.cookies.get(expanded_cookie)|split(',') %}

    <div class="main_options_item_container"{% if row.vars.hidden|default %} style="display: none;"{% endif %}>
        <div class="main_options_item{% if expanded %} is-open{% endif %}">
            <div class="heading">
                <div class="name">{{ form_label(row) }}</div>
                <div class="btn_toggle{% if expanded %} is-open{% endif %}"
                     data-text-open="{% trans %}configuration.action.edit.toggle.collapse{% endtrans %}"
                     data-text-close="{% trans %}configuration.action.edit.toggle.expand{% endtrans %}"
                     data-cookie="{{ expanded_cookie }}"
                     data-id="{{ row.vars.id }}">{{ ('configuration.action.edit.toggle.' ~ (expanded ? 'collapse' : 'expand'))|trans }}</div>
            </div>
            <div class="content"{% if expanded %} style="display: block;"{% endif %}>
{% endmacro %}

{% macro form_row_end() %}
            </div>
        </div>
    </div>
{% endmacro %}

{% macro form_row(row) %}

    {% import _self as that %}

    {{ that.form_row_start(row) }}
    {% if row.children is not empty %}
        {% for child in row.children if
            child.vars.compound
            and 'hidden' != child.vars.block_prefixes[1]|default
            and ('collection' != child.vars.block_prefixes[1]|default or not child.vars.allow_add)
        %}
            {% if 'darvin_admin_translatable' == child.vars.block_prefixes[1]|default %}
                {% form_theme child '@DarvinAdmin/fields.html.twig' %}
                {{ form_row(child) }}
            {% else %}
                {{ that.form_row(child) }}
            {% endif %}
        {% endfor %}
    {% endif %}
    {% if not row.rendered %}
        <div class="content_type-table">
            {% for child in row %}
                {% if 'hidden' == child.vars.block_prefixes[1]|default %}
                    {{ form_widget(child) }}
                {% else %}
                    <div class="item">
                        {% if not child.vars.compound or ('collection' == child.vars.block_prefixes[1]|default and child.vars.allow_add) %}
                            <div class="name">{{ form_label(child) }}</div>
                        {% endif %}
                        <div class="val">

                            {% set attr = {} %}

                            {% if 'collection' == child.vars.block_prefixes[1]|default %}

                                {% set attr = attr|merge({
                                    'class':             'js-collection',
                                    'data-allow-add':    +child.vars.allow_add,
                                    'data-allow-delete': +child.vars.allow_delete,
                                    'data-name':         child.vars.name,
                                }) %}

                                {% if child.vars.allow_add %}

                                    {% set attr = attr|merge({'data-index': child.children is not empty ? max(child.children|keys) + 1 : 0}) %}

                                {% endif %}
                            {% endif %}
                            {% if 'darvin_admin_ace_editor' == child.vars.block_prefixes[3]|default %}
                                {% form_theme child '@DarvinAdmin/fields.html.twig' %}
                                {{ form_widget(child, {'attr': attr, 'style': {'position': 'relative'}}) }}
                            {% else %}

                                {% set attr = attr|merge({
                                    'class': (attr.class|default ~ ' ' ~ child.vars.block_prefixes[1]|default)|trim,
                                }) %}

                                {{ form_widget(child, {'attr': attr}) }}
                            {% endif %}
                        </div>
                        {{ form_errors(child) }}
                    </div>
                {% endif %}
            {% endfor %}
        </div>
    {% endif %}
    {{ that.form_row_end() }}
{% endmacro %}

{% block form_label %}
    {% if form.parent %}
        {% if label is not same as(false) -%}
            {% set is_ckeditor = 'ckeditor' == block_prefixes[3]|default %}
            {% if not is_ckeditor %}
                {% set label_attr = label_attr|merge({'class': (label_attr.class|default ~ ' name')|trim}) %}
            {% endif %}
            {% if not compound -%}
                {% set label_attr = label_attr|merge({'for': id}) %}
            {%- endif -%}
            {% if required -%}
                {% set label_attr = label_attr|merge({'class': (label_attr.class|default('') ~ ' required')|trim}) %}
            {%- endif -%}
            {% if label is empty -%}
                {%- if label_format is not empty -%}
                    {% set label = label_format|replace({
                    '%name%': name,
                    '%id%': id,
                    }) %}
                {%- else -%}
                    {% set label = name|humanize %}
                {%- endif -%}
            {%- endif -%}
            {%- if 'collection' == form.parent.vars.block_prefixes[1]|default and form.parent.vars.allow_add -%}
                <label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>
            {%- endif -%}
            {{ translation_domain is same as(false) ? label : label|trans({}, translation_domain) }}{% if not is_ckeditor %}:{% endif %}
            {%- if 'collection' == form.parent.vars.block_prefixes[1]|default and form.parent.vars.allow_add -%}
                </label>
            {%- endif -%}
        {%- endif -%}
    {% endif %}
{% endblock %}

{{ form_start(form) }}
{% if is_granted('ROLE_SUPERADMIN') %}
    {{ that.config_link('common', current_type) }}
    &nbsp;|&nbsp;
    {{ that.config_link('security', current_type) }}
{% endif %}

{% block submit %}
    <div class="post_item_btn">
        <button type="submit" class="submit_edit">{% trans %}configuration.action.edit.submit{% endtrans %}</button>
    </div>
{% endblock %}

<div class="main_options_container">
    <div class="main_options_block">

        {% set first_common_config   = true %}
        {% set first_security_config = true %}

        {% for row in form if 'hidden' != row.vars.block_prefixes[1]|default %}
            {% if not darvin_admin_is_security_configuration_form(row) %}
                {% if first_common_config %}
                    <p class="heading">{% trans %}configuration.action.edit.heading.common{% endtrans %}</p>

                    {% set first_common_config = false %}

                {% endif %}
                {% if row.children is not empty %}
                    {{ that.form_row(row) }}
                {% else %}
                    {{ form_widget(row, {'attr': {'style': 'display: none;'}}) }}
                {% endif %}
            {% else %}
                {% if first_security_config %}
                    {% if not loop.first %}
                        </div><div class="main_options_block">
                    {% endif %}
                    <p class="heading">{% trans %}configuration.action.edit.heading.security{% endtrans %}</p>

                    {% set first_security_config = false %}

                {% endif %}

                {% set row = row.permissions.children[row.permissions.children|keys[0]] %}

                {{ that.form_row_start(row) }}
                <div class="content_type-list">
                    {% for user in row.userPermissionsSet.children %}
                        <div class="item">
                            <div class="value">
                                <input type="text" value="{{ form_label(user) }}">
                            </div>
                            <div class="btn_container js-permissions">
                                {% for permission in user.permissions %}
                                    <button type="button"
                                            class="js-permission {{ permission.vars.data ? 'btn_default' : 'btn_show_view' }}"
                                            data-checkbox="{{ permission.vars.id }}"
                                            data-class-checked="btn_default"
                                            data-class-unchecked="btn_show_view">
                                        {{ form_label(permission) }}
                                    </button>
                                    {{ form_widget(permission) }}
                                {% endfor %}
                            </div>
                        </div>
                    {% endfor %}
                </div>
                {{ form_widget(row, {'attr': {'style': 'display: none;'}}) }}
                {{ that.form_row_end() }}
            {% endif %}
        {% endfor %}
    </div>
</div>

{{ block('submit') }}

{{ form_end(form) }}
<commit_msg>Extract configuration edit partial template.<commit_after>{% import _self as that %}

{% form_theme form _self %}

{% trans_default_domain 'admin' %}

{% macro config_link(type, current_type) %}
    {% set title = ('configuration.action.edit.heading.' ~ type)|trans %}

    {% if type == current_type %}
        <span>{{ title }}</span>
    {% else %}
        <a href="{{ path('darvin_admin_configuration', {'type': type}) }}">{{ title }}</a>
    {% endif %}
{% endmacro %}

{% macro form_row_start(row) %}

    {% set expanded_cookie = 'darvin_admin_config' %}
    {% set expanded        = row.vars.id in app.request.cookies.get(expanded_cookie)|split(',') %}

    <div class="main_options_item_container"{% if row.vars.hidden|default %} style="display: none;"{% endif %}>
        <div class="main_options_item{% if expanded %} is-open{% endif %}">
            <div class="heading">
                <div class="name">{{ form_label(row) }}</div>
                <div class="btn_toggle{% if expanded %} is-open{% endif %}"
                     data-text-open="{% trans %}configuration.action.edit.toggle.collapse{% endtrans %}"
                     data-text-close="{% trans %}configuration.action.edit.toggle.expand{% endtrans %}"
                     data-cookie="{{ expanded_cookie }}"
                     data-id="{{ row.vars.id }}">{{ ('configuration.action.edit.toggle.' ~ (expanded ? 'collapse' : 'expand'))|trans }}</div>
            </div>
            <div class="content"{% if expanded %} style="display: block;"{% endif %}>
{% endmacro %}

{% macro form_row_end() %}
            </div>
        </div>
    </div>
{% endmacro %}

{% macro form_row(row) %}

    {% import _self as that %}

    {{ that.form_row_start(row) }}
    {% if row.children is not empty %}
        {% for child in row.children if
            child.vars.compound
            and 'hidden' != child.vars.block_prefixes[1]|default
            and ('collection' != child.vars.block_prefixes[1]|default or not child.vars.allow_add)
        %}
            {% if 'darvin_admin_translatable' == child.vars.block_prefixes[1]|default %}
                {% form_theme child '@DarvinAdmin/fields.html.twig' %}
                {{ form_row(child) }}
            {% else %}
                {{ that.form_row(child) }}
            {% endif %}
        {% endfor %}
    {% endif %}
    {% if not row.rendered %}
        <div class="content_type-table">
            {% for child in row %}
                {% if 'hidden' == child.vars.block_prefixes[1]|default %}
                    {{ form_widget(child) }}
                {% else %}
                    <div class="item">
                        {% if not child.vars.compound or ('collection' == child.vars.block_prefixes[1]|default and child.vars.allow_add) %}
                            <div class="name">{{ form_label(child) }}</div>
                        {% endif %}
                        <div class="val">

                            {% set attr = {} %}

                            {% if 'collection' == child.vars.block_prefixes[1]|default %}

                                {% set attr = attr|merge({
                                    'class':             'js-collection',
                                    'data-allow-add':    +child.vars.allow_add,
                                    'data-allow-delete': +child.vars.allow_delete,
                                    'data-name':         child.vars.name,
                                }) %}

                                {% if child.vars.allow_add %}

                                    {% set attr = attr|merge({'data-index': child.children is not empty ? max(child.children|keys) + 1 : 0}) %}

                                {% endif %}
                            {% endif %}
                            {% if 'darvin_admin_ace_editor' == child.vars.block_prefixes[3]|default %}
                                {% form_theme child '@DarvinAdmin/fields.html.twig' %}
                                {{ form_widget(child, {'attr': attr, 'style': {'position': 'relative'}}) }}
                            {% else %}

                                {% set attr = attr|merge({
                                    'class': (attr.class|default ~ ' ' ~ child.vars.block_prefixes[1]|default)|trim,
                                }) %}

                                {{ form_widget(child, {'attr': attr}) }}
                            {% endif %}
                        </div>
                        {{ form_errors(child) }}
                    </div>
                {% endif %}
            {% endfor %}
        </div>
    {% endif %}
    {{ that.form_row_end() }}
{% endmacro %}

{% block form_label %}
    {% if form.parent %}
        {% if label is not same as(false) -%}
            {% set is_ckeditor = 'ckeditor' == block_prefixes[3]|default %}
            {% if not is_ckeditor %}
                {% set label_attr = label_attr|merge({'class': (label_attr.class|default ~ ' name')|trim}) %}
            {% endif %}
            {% if not compound -%}
                {% set label_attr = label_attr|merge({'for': id}) %}
            {%- endif -%}
            {% if required -%}
                {% set label_attr = label_attr|merge({'class': (label_attr.class|default('') ~ ' required')|trim}) %}
            {%- endif -%}
            {% if label is empty -%}
                {%- if label_format is not empty -%}
                    {% set label = label_format|replace({
                    '%name%': name,
                    '%id%': id,
                    }) %}
                {%- else -%}
                    {% set label = name|humanize %}
                {%- endif -%}
            {%- endif -%}
            {%- if 'collection' == form.parent.vars.block_prefixes[1]|default and form.parent.vars.allow_add -%}
                <label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>
            {%- endif -%}
            {{ translation_domain is same as(false) ? label : label|trans({}, translation_domain) }}{% if not is_ckeditor %}:{% endif %}
            {%- if 'collection' == form.parent.vars.block_prefixes[1]|default and form.parent.vars.allow_add -%}
                </label>
            {%- endif -%}
        {%- endif -%}
    {% endif %}
{% endblock %}

{{ form_start(form) }}

{% if is_granted('ROLE_SUPERADMIN') %}
    {{ that.config_link('common', current_type) }}
    &nbsp;|&nbsp;
    {{ that.config_link('security', current_type) }}
{% endif %}

{% block submit %}
    <div class="post_item_btn">
        <button type="submit" class="submit_edit">{% trans %}configuration.action.edit.submit{% endtrans %}</button>
    </div>
{% endblock %}

<div class="main_options_container">
    <div class="main_options_block">

        {% set first_common_config   = true %}
        {% set first_security_config = true %}

        {% for row in form if 'hidden' != row.vars.block_prefixes[1]|default %}
            {% if not darvin_admin_is_security_configuration_form(row) %}
                {% if first_common_config %}
                    <p class="heading">{% trans %}configuration.action.edit.heading.common{% endtrans %}</p>

                    {% set first_common_config = false %}

                {% endif %}
                {% if row.children is not empty %}
                    {{ that.form_row(row) }}
                {% else %}
                    {{ form_widget(row, {'attr': {'style': 'display: none;'}}) }}
                {% endif %}
            {% else %}
                {% if first_security_config %}
                    {% if not loop.first %}
                        </div><div class="main_options_block">
                    {% endif %}
                    <p class="heading">{% trans %}configuration.action.edit.heading.security{% endtrans %}</p>

                    {% set first_security_config = false %}

                {% endif %}

                {% set row = row.permissions.children[row.permissions.children|keys[0]] %}

                {{ that.form_row_start(row) }}
                <div class="content_type-list">
                    {% for user in row.userPermissionsSet.children %}
                        <div class="item">
                            <div class="value">
                                <input type="text" value="{{ form_label(user) }}">
                            </div>
                            <div class="btn_container js-permissions">
                                {% for permission in user.permissions %}
                                    <button type="button"
                                            class="js-permission {{ permission.vars.data ? 'btn_default' : 'btn_show_view' }}"
                                            data-checkbox="{{ permission.vars.id }}"
                                            data-class-checked="btn_default"
                                            data-class-unchecked="btn_show_view">
                                        {{ form_label(permission) }}
                                    </button>
                                    {{ form_widget(permission) }}
                                {% endfor %}
                            </div>
                        </div>
                    {% endfor %}
                </div>
                {{ form_widget(row, {'attr': {'style': 'display: none;'}}) }}
                {{ that.form_row_end() }}
            {% endif %}
        {% endfor %}
    </div>
</div>

{{ block('submit') }}

{{ form_end(form) }}

{'fraction_non_alphanumeric': 0.1540443883454297, 'fraction_numerical': 0.001577784790154623, 'mean_word_length': 1.403007708833565, 'pattern_counts': {'":': 0, '<': 105, '<?xml version=': 0, '>': 105, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 58, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6335947', 'n_tokens_mistral': 5584, 'n_tokens_neox': 4872, 'n_words': 946}