feat(14.2.1-05): hydrate ML create/GET/save through TranslatedExact

Form schema meta lists enabled locales, Show/save expand mltext maps
without D-11 fallback, and the SPA seeds and adopt-merges every locale.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Jakub Zych
2026-10-06 15:37:00 +02:00
parent ed81f2a0c1
commit 0f8d13738d
11 changed files with 309 additions and 34 deletions

View File

@@ -13,7 +13,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 { FORM_ASSETS, FORM_LOCALE, FORM_PATCH, FORM_SESSION, FORM_VALUES, createUploadGate } from '../components/form/formContext'
import { FORM_ASSETS, FORM_ENABLED_LOCALES, FORM_LOCALE, FORM_PATCH, FORM_SESSION, FORM_VALUES, createUploadGate } from '../components/form/formContext'
import { RELATION_MANAGER, needsRecord } from '../components/form/registry'
import {
DEFAULT_TAB,
@@ -22,8 +22,10 @@ import {
fieldErrors,
focusField,
initialValues,
mergeMLValue,
panelDomId,
presetValue,
schemaEnabledLocales,
snapshot,
tabDomId,
tabOf,
@@ -168,9 +170,16 @@ const dirty = computed(
function adopt(record: RecordEnvelope | undefined): void {
if (record) {
// A record response never carries a password, so every password field
// is empty again after a save (UI-SPEC S7).
values.value = { ...record.data }
const locales = schemaEnabledLocales(schema.value?.meta)
const next: AdminRecord = { ...record.data }
for (const field of fields.value) {
if (field.type === 'password') {
next[field.name] = ''
} else if (field.type === 'mltext' || field.type === 'mlmarkdown') {
next[field.name] = mergeMLValue(record.data[field.name], locales)
}
}
values.value = next
labels.value = record.meta.labels ?? {}
}
saved.value = snapshot(editablePayload(fields.value, values.value, mode))
@@ -193,7 +202,7 @@ async function load(): Promise<void> {
assetsReady = loadControllerAssets(controllerId, schema.value.assets)
}
if (schema.value && mode === 'create') {
values.value = initialValues(fields.value)
values.value = initialValues(fields.value, schemaEnabledLocales(schema.value.meta))
}
adopt(recordResult?.data)
activeTab.value = tabs.value[0]?.key ?? DEFAULT_TAB
@@ -229,6 +238,7 @@ function update(name: string, value: unknown): void {
provide(FORM_VALUES, computed(() => values.value))
provide(FORM_PATCH, update)
provide(FORM_LOCALE, computed(() => schema.value?.meta.locale || currentLocale.value))
provide(FORM_ENABLED_LOCALES, computed(() => schemaEnabledLocales(schema.value?.meta)))
provide(FORM_ASSETS, () => assetsReady)
provide(FORM_SESSION, {
key: sessionKey,