mirror of
https://github.com/strapi/strapi.git
synced 2025-08-09 09:14:49 +00:00
Merge pull request #14588 from wusuopu/fix-edit-json-field
This commit is contained in:
commit
70d7bbcb53
@ -12,14 +12,14 @@ const formatContentTypeData = (data, ct, composSchema) => {
|
||||
const compoUid = getOtherInfos(schema, [current, 'component']);
|
||||
const isRepeatable = getOtherInfos(schema, [current, 'repeatable']);
|
||||
|
||||
if (!value) {
|
||||
acc[current] = value;
|
||||
if (type === 'json' && value !== undefined) {
|
||||
acc[current] = JSON.stringify(value, null, 2);
|
||||
|
||||
return acc;
|
||||
}
|
||||
|
||||
if (type === 'json') {
|
||||
acc[current] = JSON.stringify(value, null, 2);
|
||||
if (!value) {
|
||||
acc[current] = value;
|
||||
|
||||
return acc;
|
||||
}
|
||||
|
@ -87,6 +87,7 @@ describe('STRAPI_HELPER_PLUGIN | utils | formatContentTypeData', () => {
|
||||
dz: { type: 'dynamiczone', components: ['compos.sub-compo'] },
|
||||
jsonString: { type: 'json' },
|
||||
jsonObject: { type: 'json' },
|
||||
jsonBool: { type: 'json' },
|
||||
},
|
||||
};
|
||||
|
||||
@ -119,6 +120,7 @@ describe('STRAPI_HELPER_PLUGIN | utils | formatContentTypeData', () => {
|
||||
],
|
||||
jsonString: 'hello',
|
||||
jsonObject: { hello: true },
|
||||
jsonBool: false,
|
||||
};
|
||||
|
||||
const expected = {
|
||||
@ -136,6 +138,7 @@ describe('STRAPI_HELPER_PLUGIN | utils | formatContentTypeData', () => {
|
||||
],
|
||||
jsonString: '"hello"',
|
||||
jsonObject: '{\n "hello": true\n}',
|
||||
jsonBool: 'false',
|
||||
};
|
||||
|
||||
expect(formatContentTypeData(data, contentType, components)).toEqual(expected);
|
||||
|
Loading…
x
Reference in New Issue
Block a user