<!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
{% block sw_settings_snippet_detail %}
<sw-page class="sw-settings-snippet-detail">

    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
    {% block sw_settings_snippet_detail_smart_bar %}
    <template #smart-bar-back>
        <router-link
            class="smart-bar__back-btn"
            :to="backPath"
            :style="{ 'color': moduleData.color }"
        >
            <sw-icon
                name="regular-chevron-left"
                small
            />
            <sw-icon
                v-if="moduleData && moduleData.icon"
                :name="moduleData.icon"
                small
            />
        </router-link>
    </template>
    {% endblock %}

    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
    {% block sw_settings_snippet_detail_header %}
    <template #smart-bar-header>
        <h2 v-if="translationKey">
            {{ translationKey }}
        </h2>
        <h2 v-else>
            {{ $tc('sw-settings-snippet.detail.textHeadline') }}
        </h2>
    </template>
    {% endblock %}

    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
    {% block sw_settings_snippet_detail_actions %}
    <template #smart-bar-actions>
        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
        {% block sw_settings_snippet_detail_actions_abort %}
        <sw-button
            :disabled="isLoading"
            :router-link="backPath"
        >
            {{ $tc('global.default.cancel') }}
        </sw-button>
        {% endblock %}

        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
        {% block sw_settings_snippet_detail_actions_save %}
        <sw-button-process
            v-tooltip="getNoPermissionsTooltip('snippet.editor')"
            class="sw-snippet-detail__save-action"
            :is-loading="isLoading"
            :process-success="isSaveSuccessful"
            :disabled="!acl.can('snippet.editor') || isLoading || !translationKey || !isSaveable"
            variant="primary"
            @update:process-success="saveFinish"
            @click.prevent="onSave"
        >
            {{ $tc('sw-settings-snippet.detail.buttonSave') }}
        </sw-button-process>
        {% endblock %}
    </template>
    {% endblock %}

    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
    {% block sw_settings_snippet_detail_content %}
    <template #content>
        <sw-card-view>
            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
            {% block sw_settings_snippet_set_detail_card %}
            <div class="sw-settings-snippet-set-detail-card">
                <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                {% block sw_settings_snippet_set_detail_card_information %}
                <sw-card
                    position-identifier="sw-settings-snippet-detail-information"
                    :title="$tc('sw-settings-snippet.detail.cardGeneralTitle')"
                    :is-loading="isLoading"
                >
                    <div class="snippet-general-card">
                        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                        {% block sw_settings_snippet_set_detail_card_information_key %}
                        <sw-text-field
                            v-model:value="translationKey"
                            v-tooltip.bottom="getNoPermissionsTooltip('snippet.editor')"
                            name="sw-field--translationKey"
                            :label="$tc('sw-settings-snippet.detail.labelName')"
                            :placeholder="$tc('sw-settings-snippet.detail.labelNamePlaceholder')"
                            :disabled="!(isCreate || isAddedSnippet)"
                            :error="invalidKeyError"
                            @update:value="onChange"
                        />
                        {% endblock %}
                    </div>
                </sw-card>
                {% endblock %}

                <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                {% block sw_settings_snippet_set_detail_card_snippets %}
                <sw-card
                    position-identifier="sw-settings-snippet-detail-snippets"
                    :title="$tc('sw-settings-snippet.detail.cardSnippetSetsTitle')"
                    :is-loading="isLoading || isLoadingSnippets"
                >
                    <div class="snippet-overview-card">
                        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                        {% block sw_settings_snippet_set_detail_card_snippets_fields %}
                        <sw-text-field
                            v-for="(snippet, index) in snippets"
                            :key="snippet.setId"
                            v-model:value="snippet.value"
                            v-tooltip.bottom="getNoPermissionsTooltip('snippet.editor')"
                            name="sw-field--snippet-value"
                            :class="`sw-settings-snippet-detail__translation-field--${index}`"
                            :disabled="!acl.can('snippet.editor') || isLoadingSnippets"
                            :label="$tc('sw-settings-snippet.detail.labelContent', 0, { name: sets.get(snippet.setId).name })"
                            :placeholder="snippet.origin || $tc('sw-settings-snippet.general.placeholderValue')"
                            @update:value="onChange"
                        />
                        {% endblock %}
                    </div>
                </sw-card>
                {% endblock %}
            </div>
            {% endblock %}
        </sw-card-view>
    </template>
    {% endblock %}
</sw-page>
{% endblock %}
