feat(mail): one admin record per mail template with a locale switcher
Gap G-35-1 (supersedes D-05), tracer slice: - postcard: migration 202611130001_mail_template_base_code (base_code column and index); SyncIndex writes base_code; EnsureLocaleRows creates the <template>-<locale> rows of locales that ship no file; TemplateBase and Catalog.TemplateFor; send, preview and validation resolve a missing <template>-<locale> to the locale's customization, else the base's customization, else the base file. Names with their own file send as before. - cabana: mail locales are the translator's plus the TranslationWriter's enabled locales; sync ensures the locale rows and re-syncs when the locale set changes; record lookups admit fallback-locale rows; the record title is the base code; RecordMeta.LocaleVariants (RecordLocaleVariant) on the show and update responses. - admin: LocaleVariantSwitcher in the update form header, from meta.localeVariants, behind the unsaved-changes confirm. - tests: TestMailOverrideSmoke/locale_fallback, TestMailScreensSmoke/locales, LocaleVariantSwitcher.test.ts.
This commit is contained in:
@@ -22,6 +22,7 @@ import { mapWinterUrl } from '../app/winterUrl'
|
||||
import FormErrorBanner from '../components/form/FormErrorBanner.vue'
|
||||
import FormGrid from '../components/form/FormGrid.vue'
|
||||
import FormTabs from '../components/form/FormTabs.vue'
|
||||
import LocaleVariantSwitcher from '../components/form/LocaleVariantSwitcher.vue'
|
||||
import {
|
||||
DEPENDENT_CACHE,
|
||||
FORM_ASSETS,
|
||||
@@ -105,6 +106,8 @@ const recordTitle = ref('')
|
||||
const actions = ref<RecordAction[]>([])
|
||||
/** When false, Delete is hidden; absent means true (existing controllers). */
|
||||
const deletable = ref(true)
|
||||
/** The record's locale versions (meta.localeVariants); the switcher shows from two. */
|
||||
const localeVariants = ref<NonNullable<RecordMeta['localeVariants']>>([])
|
||||
const acting = ref(false)
|
||||
const partialReload = ref(0)
|
||||
const errors = ref<Record<string, string[]>>({})
|
||||
@@ -266,6 +269,9 @@ function adopt(record: RecordEnvelope | undefined): void {
|
||||
recordTitle.value = record.meta.title ?? ''
|
||||
actions.value = record.meta.actions ?? []
|
||||
deletable.value = record.meta.deletable !== false
|
||||
if (record.meta.localeVariants) {
|
||||
localeVariants.value = record.meta.localeVariants
|
||||
}
|
||||
}
|
||||
saved.value = snapshot(editablePayload(fields.value, values.value, mode, permissionLocks.value))
|
||||
}
|
||||
@@ -705,6 +711,12 @@ void load()
|
||||
<div class="flex min-w-0 flex-1 flex-col">
|
||||
<h1 class="truncate text-[24px] font-bold tracking-[-0.02em]">{{ loading ? '' : title }}</h1>
|
||||
<p v-if="subtitle" class="text-muted">{{ subtitle }}</p>
|
||||
<LocaleVariantSwitcher
|
||||
v-if="!loading && localeVariants.length > 1"
|
||||
class="mt-1.5"
|
||||
:variants="localeVariants"
|
||||
:control-id="`${ID_PREFIX}-locale-variant`"
|
||||
/>
|
||||
</div>
|
||||
<FormTabs v-if="tabs.length > 0" v-model="activeTab" :tabs="tabs" :id-prefix="ID_PREFIX" />
|
||||
</header>
|
||||
|
||||
Reference in New Issue
Block a user