mirror of
https://github.com/strapi/strapi.git
synced 2025-09-23 07:22:51 +00:00
don't clean creator fields because they are not sended to backend
This commit is contained in:
parent
41844c2867
commit
3ec34be1ab
@ -236,17 +236,14 @@ const reducer = (state, action) =>
|
|||||||
|
|
||||||
const findAllRelationsAndReplaceWithEmptyArray = findAllAndReplace(
|
const findAllRelationsAndReplaceWithEmptyArray = findAllAndReplace(
|
||||||
components,
|
components,
|
||||||
(value) => {
|
|
||||||
return value.type === 'relation';
|
|
||||||
},
|
|
||||||
(value, { path }) => {
|
(value, { path }) => {
|
||||||
const relationFieldName = path[path.length - 1];
|
// We don't replace creator fields because we already return them without need to populate them separately
|
||||||
|
const isCreatorField =
|
||||||
// When editing, we don't want to fetch the relations with creator fields because we already have it
|
path[path.length - 1] === 'createdBy' || path[path.length - 1] === 'updatedBy';
|
||||||
if (value && (relationFieldName === 'createdBy' || relationFieldName === 'updatedBy')) {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return value.type === 'relation' && !isCreatorField;
|
||||||
|
},
|
||||||
|
(_, { path }) => {
|
||||||
if (state.modifiedData?.id === data.id && get(state.modifiedData, path)) {
|
if (state.modifiedData?.id === data.id && get(state.modifiedData, path)) {
|
||||||
return get(state.modifiedData, path);
|
return get(state.modifiedData, path);
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,11 @@ const cleanData = ({ browserState, serverState }, currentSchema, componentsSchem
|
|||||||
*/
|
*/
|
||||||
const recursiveCleanData = (browserState, serverState, schema, pathToParent) => {
|
const recursiveCleanData = (browserState, serverState, schema, pathToParent) => {
|
||||||
return Object.keys(browserState).reduce((acc, current) => {
|
return Object.keys(browserState).reduce((acc, current) => {
|
||||||
|
// Creator attributes can be safely ignored because they are handle on the backend
|
||||||
|
if (current === 'createdBy' || current === 'updatedBy') {
|
||||||
|
return acc;
|
||||||
|
}
|
||||||
|
|
||||||
const path = pathToParent ? `${pathToParent}.${current}` : current;
|
const path = pathToParent ? `${pathToParent}.${current}` : current;
|
||||||
const attrType = getType(schema, current);
|
const attrType = getType(schema, current);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user