mirror of
https://github.com/strapi/strapi.git
synced 2025-09-26 00:39:49 +00:00
Fix add compo to dz action
This commit is contained in:
parent
89568007f6
commit
16a6975af1
@ -81,8 +81,6 @@
|
||||
"dz": {
|
||||
"type": "dynamiczone",
|
||||
"components": [
|
||||
"default.closingperiod",
|
||||
"default.dish",
|
||||
"default.openingtimes",
|
||||
"default.restaurantservice"
|
||||
]
|
||||
|
@ -138,7 +138,7 @@ const MultipleMenuList = ({
|
||||
const handleChange = ({ target }) => {
|
||||
const dataTarget = {
|
||||
name,
|
||||
components: target.name,
|
||||
components: [target.name],
|
||||
shouldAddComponents: target.value,
|
||||
};
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { fromJS } from 'immutable';
|
||||
import { fromJS, List } from 'immutable';
|
||||
import pluralize from 'pluralize';
|
||||
import { snakeCase } from 'lodash';
|
||||
import makeUnique from '../../utils/makeUnique';
|
||||
@ -22,15 +22,17 @@ const reducer = (state, action) => {
|
||||
const { name, components, shouldAddComponents } = action;
|
||||
|
||||
return state.updateIn(['modifiedData', name], list => {
|
||||
let updatedList = list;
|
||||
|
||||
if (shouldAddComponents) {
|
||||
return makeUnique(list.concat(components));
|
||||
updatedList = list.concat(components);
|
||||
} else {
|
||||
return makeUnique(
|
||||
list.filter(comp => {
|
||||
updatedList = list.filter(comp => {
|
||||
return components.indexOf(comp) === -1;
|
||||
})
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
return List(makeUnique(updatedList.toJS()));
|
||||
});
|
||||
}
|
||||
case 'ON_CHANGE':
|
||||
|
Loading…
x
Reference in New Issue
Block a user