feat(admin): render mltextarea fields per locale

- MLField.vue is the one locale-switching wrapper; MLTextField,
  MLMarkdownField and the new MLTextareaField are shells around it
- isMLFieldType replaces the inline ML type-name checks in formState,
  FormView and RelationChildModal
- register mltextarea as a group-labelled control; rebuild dist
This commit is contained in:
Jakub Zych
2026-10-06 21:36:04 +02:00
parent 3596df4ff5
commit a913eec50f
15 changed files with 275 additions and 162 deletions

View File

@@ -24,6 +24,7 @@ import {
fieldErrors,
focusField,
initialValues,
isMLFieldType,
mergeMLValue,
panelDomId,
presetUpdates,
@@ -177,7 +178,7 @@ function adopt(record: RecordEnvelope | undefined): void {
for (const field of fields.value) {
if (field.type === 'password') {
next[field.name] = ''
} else if (field.type === 'mltext' || field.type === 'mlmarkdown') {
} else if (isMLFieldType(field.type)) {
next[field.name] = mergeMLValue(record.data[field.name], locales)
}
}
@@ -221,7 +222,7 @@ async function load(): Promise<void> {
const edited = new Set<string>()
// The locales of each ML field the administrator edited by hand.
const editedLocales = new Map<string, Set<string>>()
// The locale every ML control shows (MLTextField broadcasts the choice).
// The locale every ML control shows (any ML control broadcasts the choice).
const mlLocale = ref('en')
function firstMLLocale(): string {
@@ -249,7 +250,7 @@ function update(name: string, value: unknown): void {
const next = { ...values.value, [name]: value }
edited.add(name)
const type = fields.value.find((field) => field.name === name)?.type
if (type === 'mltext' || type === 'mlmarkdown') {
if (isMLFieldType(type)) {
let locales = editedLocales.get(name)
if (!locales) {
locales = new Set<string>()