Persist segments selection

[MAILPOET-2452]
This commit is contained in:
Pavel Dohnal
2019-12-09 14:36:12 +01:00
committed by Rostislav Wolný
parent be1e70bfb4
commit c3be5e99e4
4 changed files with 111 additions and 0 deletions

View File

@@ -50,6 +50,23 @@ export default (blocks) => {
static: '0',
name: 'Last name',
};
case 'mailpoet-form/segment-select':
return {
...mapped,
id: 'segments',
type: 'segment',
unique: '1',
static: '0',
name: 'List selection',
params: {
...mapped.params,
values: block.attributes.values.map((segment) => ({
id: segment.id,
is_checked: segment.isChecked ? '1' : undefined,
name: segment.name,
})),
},
};
case 'mailpoet-form/submit-button':
return {
...mapped,

View File

@@ -41,6 +41,24 @@ export default (data) => {
...mapped,
name: 'mailpoet-form/last-name-input',
};
case 'segments':
if (
item.params
&& Object.prototype.hasOwnProperty.call(item.params, 'values')
&& Array.isArray(item.params.values)
) {
mapped.attributes.values = item.params.values.map((value) => ({
id: value.id,
name: value.name,
isChecked: value.is_checked === '1' ? true : undefined,
}));
} else {
mapped.attributes.values = [];
}
return {
...mapped,
name: 'mailpoet-form/segment-select',
};
case 'submit':
return {
...mapped,