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