<!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
{% block sw_users_permissions_additional_permissions %}
<sw-card
    class="sw-users-permissions-additional-permissions"
    position-identifier="sw-users-permissions-additional-permissions"
    :title="$tc('sw-users-permissions.roles.additional-permissions.title')"
>
    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
    {% block sw_users_permissions_additional_permissions_additional_privileges %}
    <template
        v-for="privilege in additionalPermissions"
        :key="`head-${privilege.key}`"
    >
        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
        {% block sw_users_permissions_additional_permissions_additional_privileges_headline %}
        <h4
            :class="'sw-users-permissions-additional-permissions_' + privilege.key"
        >
            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
            {% block sw_users_permissions_additional_permissions_additional_privileges_headline_content %}
            <strong>
                {{ $tc('sw-privileges.additional_permissions.' + privilege.key + '.label') }}
            </strong>
            {% endblock %}
        </h4>
        {% endblock %}

        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
        {% block sw_users_permissions_additional_permissions_additional_privileges_switches %}
        <div
            class="sw-users-permissions-additional-permissions__switches"
        >
            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
            {% block sw_users_permissions_additional_permissions_additional_privileges_switches_content %}
            <template
                v-for="(value, roleName) in privilege.roles"
                :key="roleName"
            >
                <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                {% block sw_users_permissions_additional_permissions_additional_privileges_switches_content_switch %}
                <sw-switch-field
                    :disabled="disabled"
                    :class="'sw_users_permissions_additional_permissions_' + privilege.key + '_' + roleName"
                    :value="isPrivilegeSelected(privilege.key + '.' + roleName)"
                    :label="$tc('sw-privileges.additional_permissions.' + privilege.key + '.' + roleName)"
                    :bordered="true"
                    @update:value="onSelectPrivilege(privilege.key + '.' + roleName, $event)"
                />
                {% endblock %}
            </template>
            {% endblock %}
        </div>
        {% endblock %}
    </template>
    {% endblock %}

    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
    {% block sw_users_permissions_additional_permissions_app_privileges %}
    <template
        v-for="privilege in appPermissions"
        :key="privilege.key"
    >
        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
        {% block sw_users_permissions_additional_permissions_app_privileges_headline %}
        <h4
            class="sw-users-permissions-additional-permissions-app"
        >
            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
            {% block sw_users_permissions_additional_permissions_app_privileges_headline_content %}
            <strong>
                {{ $tc('sw-privileges.additional_permissions.app.label') }}
            </strong>
            {% endblock %}
        </h4>
        {% endblock %}

        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
        {% block sw_users_permissions_additional_permissions_app_privileges_switches %}
        <div
            class="sw-users-permissions-additional-permissions__switches"
        >
            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
            {% block sw_users_permissions_additional_permissions_app_privileges_switches_content %}
            <template
                v-for="(key, roleName) in privilege.roles"
                :key="roleName"
            >
                <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                {% block sw_users_permissions_additional_permissions_app_privileges_switches_content_switch %}
                <sw-switch-field
                    v-if="roleName === 'all'"
                    :disabled="disabled"
                    class="sw_users_permissions_additional_permissions_app_all"
                    :value="isPrivilegeSelected('app.' + roleName)"
                    :label="$tc('sw-privileges.additional_permissions.app.all')"
                    :bordered="true"
                    @update:value="changeAllAppPermissionsForKey('app.' + roleName, $event)"
                />

                <sw-switch-field
                    v-else
                    v-tooltip="{
                        message: $tc('sw-privileges.additional_permissions.app.disabledCheckboxMessage'),
                        disabled: !isPrivilegeSelected('app.all') || disabled,
                        showOnDisabledElements: false
                    }"
                    :disabled="isPrivilegeSelected('app.all') || disabled"
                    :class="'sw_users_permissions_additional_permissions_app_' + roleName"
                    :value="isPrivilegeSelected('app.' + roleName)"
                    :label="roleName"
                    :bordered="true"
                    @update:value="onSelectPrivilege('app.' + roleName, $event)"
                />
                {% endblock %}
            </template>
            {% endblock %}
        </div>
        {% endblock %}
    </template>
    {% endblock %}
</sw-card>
{% endblock %}
