Remove names from stored segment block values
[MAILPOET-2801]
This commit is contained in:
committed by
Veljko V
parent
76e6d4d296
commit
936a75c277
@@ -14,6 +14,11 @@ const SegmentSelectEdit = ({ attributes, setAttributes }) => {
|
||||
valueWithName.name = segment ? segment.name : '';
|
||||
return valueWithName;
|
||||
}), [attributes.values, segments]);
|
||||
const stripNamesFromValues = (values) => values.map((value) => {
|
||||
const valueWithoutName = { ...value };
|
||||
delete valueWithoutName.name;
|
||||
return valueWithoutName;
|
||||
});
|
||||
const renderValues = () => {
|
||||
if (attributes.values.length === 0) {
|
||||
return (<p className="mailpoet_error">{MailPoet.I18n.t('blockSegmentSelectNoLists')}</p>);
|
||||
@@ -38,12 +43,12 @@ const SegmentSelectEdit = ({ attributes, setAttributes }) => {
|
||||
label={attributes.label}
|
||||
onLabelChanged={(label) => (setAttributes({ label }))}
|
||||
segmentsAddedIntoSelection={valuesWithNames}
|
||||
setNewSelection={(selection) => setAttributes({ values: selection })}
|
||||
setNewSelection={(selection) => setAttributes({ values: stripNamesFromValues(selection) })}
|
||||
addSegmentIntoSelection={(newSegment) => setAttributes({
|
||||
values: [
|
||||
values: stripNamesFromValues([
|
||||
...attributes.values,
|
||||
newSegment,
|
||||
],
|
||||
]),
|
||||
})}
|
||||
/>
|
||||
<span className="mailpoet_segment_label">
|
||||
@@ -60,7 +65,6 @@ SegmentSelectEdit.propTypes = {
|
||||
className: PropTypes.string,
|
||||
values: PropTypes.arrayOf(PropTypes.shape({
|
||||
isChecked: PropTypes.boolean,
|
||||
name: PropTypes.string.isRequired,
|
||||
id: PropTypes.string.isRequired,
|
||||
})).isRequired,
|
||||
}).isRequired,
|
||||
|
@@ -279,7 +279,6 @@ export const blocksToFormBodyFactory = (colorDefinitions, fontSizeDefinitions, c
|
||||
values: block.attributes.values.map((segment) => ({
|
||||
id: segment.id,
|
||||
is_checked: segment.isChecked ? '1' : undefined,
|
||||
name: segment.name,
|
||||
})),
|
||||
},
|
||||
};
|
||||
|
@@ -323,7 +323,6 @@ export const formBodyToBlocksFactory = (
|
||||
) {
|
||||
mapped.attributes.values = item.params.values.map((value) => ({
|
||||
id: value.id,
|
||||
name: value.name,
|
||||
isChecked: value.is_checked === '1' ? true : undefined,
|
||||
}));
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user