Merge pull request #15 from payloadcms/fix/14/localized-groups

fix: localized groups
This commit is contained in:
Elliot DeNolf
2021-01-17 22:43:18 -05:00
committed by GitHub
2 changed files with 1 additions and 13 deletions

View File

@@ -81,7 +81,7 @@ const traverseFields = (args: Arguments): void => {
dataCopy[field.name] = JSON.parse(data[field.name] as string);
}
const hasLocalizedValue = (typeof data[field.name] === 'object' && data[field.name] !== null)
const hasLocalizedValue = (typeof data?.[field.name] === 'object' && data?.[field.name] !== null)
&& field.name
&& field.localized
&& locale !== 'all'

View File

@@ -73,18 +73,6 @@ export default function localizationPlugin(schema: any, options): void {
return value;
})
.set(function (value) {
// multiple locales are set as an object
if (value && typeof value === 'object' && !Array.isArray(value)) {
const { locales } = options;
locales.forEach((locale) => {
if (!value[locale]) {
return;
}
this.set(`${path}.${locale}`, value[locale]);
}, this);
return;
}
// embedded and sub-documents will use locale methods from the top level document
const owner = this.ownerDocument ? this.ownerDocument() : this;
const locale = owner.getLocale();