mirror of
https://github.com/strapi/strapi.git
synced 2025-12-27 15:13:21 +00:00
Fix dz errors on change compo
This commit is contained in:
parent
e991f6ec7c
commit
fc1cbbd753
@ -288,6 +288,7 @@ const EditViewDataManagerProvider = ({
|
||||
type: 'MOVE_COMPONENT_DOWN',
|
||||
dynamicZoneName,
|
||||
currentIndex,
|
||||
shouldCheckErrors: shouldCheckDZErrors(dynamicZoneName),
|
||||
});
|
||||
};
|
||||
const moveComponentUp = (dynamicZoneName, currentIndex) => {
|
||||
@ -296,6 +297,7 @@ const EditViewDataManagerProvider = ({
|
||||
type: 'MOVE_COMPONENT_UP',
|
||||
dynamicZoneName,
|
||||
currentIndex,
|
||||
shouldCheckErrors: shouldCheckDZErrors(dynamicZoneName),
|
||||
});
|
||||
};
|
||||
const moveComponentField = (pathToComponent, dragIndex, hoverIndex) => {
|
||||
@ -323,19 +325,23 @@ const EditViewDataManagerProvider = ({
|
||||
});
|
||||
};
|
||||
|
||||
const removeComponentFromDynamicZone = (dynamicZoneName, index) => {
|
||||
emitEvent('removeComponentFromDynamicZone');
|
||||
|
||||
const shouldCheckDZErrors = dzName => {
|
||||
const doesDZHaveError = Object.keys(formErrors).some(
|
||||
key => key.split('.')[0] === dynamicZoneName
|
||||
key => key.split('.')[0] === dzName
|
||||
);
|
||||
const shouldCheckErrors = !isEmpty(formErrors) && doesDZHaveError;
|
||||
|
||||
return shouldCheckErrors;
|
||||
};
|
||||
|
||||
const removeComponentFromDynamicZone = (dynamicZoneName, index) => {
|
||||
emitEvent('removeComponentFromDynamicZone');
|
||||
|
||||
dispatch({
|
||||
type: 'REMOVE_COMPONENT_FROM_DYNAMIC_ZONE',
|
||||
dynamicZoneName,
|
||||
index,
|
||||
shouldCheckErrors,
|
||||
shouldCheckErrors: shouldCheckDZErrors(dynamicZoneName),
|
||||
});
|
||||
};
|
||||
const removeComponentFromField = (keys, componentUid) => {
|
||||
|
||||
@ -104,31 +104,47 @@ const reducer = (state, action) => {
|
||||
}
|
||||
);
|
||||
case 'MOVE_COMPONENT_UP':
|
||||
return state.updateIn(['modifiedData', action.dynamicZoneName], list => {
|
||||
return list
|
||||
.delete(action.currentIndex)
|
||||
.insert(
|
||||
action.currentIndex - 1,
|
||||
state.getIn([
|
||||
'modifiedData',
|
||||
action.dynamicZoneName,
|
||||
action.currentIndex,
|
||||
])
|
||||
);
|
||||
});
|
||||
return state
|
||||
.update('shouldCheckErrors', v => {
|
||||
if (action.shouldCheckErrors) {
|
||||
return !v;
|
||||
}
|
||||
|
||||
return v;
|
||||
})
|
||||
.updateIn(['modifiedData', action.dynamicZoneName], list => {
|
||||
return list
|
||||
.delete(action.currentIndex)
|
||||
.insert(
|
||||
action.currentIndex - 1,
|
||||
state.getIn([
|
||||
'modifiedData',
|
||||
action.dynamicZoneName,
|
||||
action.currentIndex,
|
||||
])
|
||||
);
|
||||
});
|
||||
case 'MOVE_COMPONENT_DOWN':
|
||||
return state.updateIn(['modifiedData', action.dynamicZoneName], list => {
|
||||
return list
|
||||
.delete(action.currentIndex)
|
||||
.insert(
|
||||
action.currentIndex + 1,
|
||||
state.getIn([
|
||||
'modifiedData',
|
||||
action.dynamicZoneName,
|
||||
action.currentIndex,
|
||||
])
|
||||
);
|
||||
});
|
||||
return state
|
||||
.update('shouldCheckErrors', v => {
|
||||
if (action.shouldCheckErrors) {
|
||||
return !v;
|
||||
}
|
||||
|
||||
return v;
|
||||
})
|
||||
.updateIn(['modifiedData', action.dynamicZoneName], list => {
|
||||
return list
|
||||
.delete(action.currentIndex)
|
||||
.insert(
|
||||
action.currentIndex + 1,
|
||||
state.getIn([
|
||||
'modifiedData',
|
||||
action.dynamicZoneName,
|
||||
action.currentIndex,
|
||||
])
|
||||
);
|
||||
});
|
||||
case 'MOVE_FIELD':
|
||||
return state.updateIn(['modifiedData', ...action.keys], list => {
|
||||
return list
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user