mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
Fix the failing auto-creation of default languages in translation field setup (#22409)
Co-authored-by: Pascal Jufer <pascal-jufer@bluewin.ch>
This commit is contained in:
5
.changeset/curvy-houses-grin.md
Normal file
5
.changeset/curvy-houses-grin.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@directus/app': patch
|
||||
---
|
||||
|
||||
Fixed the failing auto-creating of default languages for translation fields when using an existing, custom language collection.
|
||||
@@ -38,7 +38,7 @@ export const useFieldDetailStore = defineStore({
|
||||
/** What field we're currently editing ("+"" for new) */
|
||||
editing: '+' as string,
|
||||
|
||||
/** Full field data with edits */
|
||||
/** Full field data with edits */
|
||||
field: {
|
||||
field: undefined,
|
||||
type: undefined,
|
||||
@@ -165,14 +165,9 @@ export const useFieldDetailStore = defineStore({
|
||||
alterations[localType].applyChanges(updates, state, { hasChanged, getCurrent });
|
||||
}
|
||||
|
||||
const { field: fieldUpdates, ...restUpdates } = updates;
|
||||
|
||||
mergeWith(state, restUpdates, (_, srcValue, key, object) => {
|
||||
if (Array.isArray(srcValue)) return srcValue;
|
||||
if (srcValue === undefined) object[key] = undefined;
|
||||
return;
|
||||
});
|
||||
const { field: fieldUpdates, items: itemUpdates, ...restUpdates } = updates;
|
||||
|
||||
// Handle `field` updates, shallow merge and mirror to `fieldUpdates`
|
||||
if (fieldUpdates) {
|
||||
const { schema: schemaUpdates, meta: metaUpdates, ...restFieldUpdates } = fieldUpdates;
|
||||
|
||||
@@ -189,6 +184,20 @@ export const useFieldDetailStore = defineStore({
|
||||
Object.assign((state.fieldUpdates.meta ??= {}), metaUpdates);
|
||||
}
|
||||
}
|
||||
|
||||
// Handle `item` updates, allowing full replacements
|
||||
if (itemUpdates) {
|
||||
state.items = itemUpdates as (typeof this.$state)['items'];
|
||||
}
|
||||
|
||||
// Handle remaining updates, deep merge
|
||||
mergeWith(state, restUpdates, (_, srcValue, key, object) => {
|
||||
// Override arrays instead of merging
|
||||
if (Array.isArray(srcValue)) return srcValue;
|
||||
// Allow properties to be resettable
|
||||
if (srcValue === undefined) object[key] = undefined;
|
||||
return;
|
||||
});
|
||||
});
|
||||
},
|
||||
async save() {
|
||||
|
||||
Reference in New Issue
Block a user