Register custom date blocks and add mappings
[MAILPOET-2453]
This commit is contained in:
committed by
Rostislav Wolný
parent
aef6832ca0
commit
080d5c84ac
@@ -11,6 +11,7 @@ import * as lastName from './last_name/last_name.jsx';
|
||||
import * as segmentSelect from './segment_select/segment_select.jsx';
|
||||
import * as html from './html/html.jsx';
|
||||
|
||||
import * as customDate from './custom_date/custom_date.jsx';
|
||||
import * as customText from './custom_text/custom_text.jsx';
|
||||
import * as customTextArea from './custom_textarea/custom_textarea.jsx';
|
||||
import * as customRadio from './custom_radio/custom_radio.jsx';
|
||||
@@ -19,6 +20,10 @@ import * as customSelect from './custom_select/custom_select.jsx';
|
||||
|
||||
const registerCustomFieldBlock = (customField) => {
|
||||
const namesMap = {
|
||||
date: {
|
||||
name: customDate.name,
|
||||
settings: customDate.getSettings(customField),
|
||||
},
|
||||
text: {
|
||||
name: customText.name,
|
||||
settings: customText.getSettings(customField),
|
||||
|
@@ -8,6 +8,9 @@ const mapCustomField = (block, customFields, mappedCommonProperties) => {
|
||||
id: block.attributes.customFieldId.toString(),
|
||||
name: customField.name,
|
||||
};
|
||||
if (block.name.startsWith('mailpoet-form/custom-date')) {
|
||||
mapped.type = 'date';
|
||||
}
|
||||
if (block.name.startsWith('mailpoet-form/custom-text')) {
|
||||
mapped.type = 'text';
|
||||
}
|
||||
@@ -29,6 +32,15 @@ const mapCustomField = (block, customFields, mappedCommonProperties) => {
|
||||
if (has(block.attributes, 'hideLabel') && block.attributes.hideLabel) {
|
||||
mapped.params.hide_label = '1';
|
||||
}
|
||||
if (has(block.attributes, 'defaultToday') && block.attributes.defaultToday) {
|
||||
mapped.params.is_default_today = '1';
|
||||
}
|
||||
if (has(block.attributes, 'dateType')) {
|
||||
mapped.params.date_type = block.attributes.dateType;
|
||||
}
|
||||
if (has(block.attributes, 'dateFormat')) {
|
||||
mapped.params.date_format = block.attributes.dateFormat;
|
||||
}
|
||||
if (has(block.attributes, 'values')) {
|
||||
mapped.params.values = block.attributes.values.map((value) => {
|
||||
const mappedValue = {
|
||||
|
@@ -11,6 +11,7 @@ const mapCustomField = (item, customFields, mappedCommonProperties) => {
|
||||
radio: 'mailpoet-form/custom-radio',
|
||||
checkbox: 'mailpoet-form/custom-checkbox',
|
||||
select: 'mailpoet-form/custom-select',
|
||||
date: 'mailpoet-form/custom-date',
|
||||
};
|
||||
const mapped = {
|
||||
...mappedCommonProperties,
|
||||
@@ -24,6 +25,15 @@ const mapCustomField = (item, customFields, mappedCommonProperties) => {
|
||||
if (has(item.params, 'hide_label')) {
|
||||
mapped.attributes.hideLabel = !!item.params.hide_label;
|
||||
}
|
||||
if (has(item.params, 'date_type')) {
|
||||
mapped.attributes.dateType = item.params.date_type;
|
||||
}
|
||||
if (has(item.params, 'date_format')) {
|
||||
mapped.attributes.dateFormat = item.params.date_format;
|
||||
}
|
||||
if (has(item.params, 'is_default_today')) {
|
||||
mapped.attributes.defaultToday = !!item.params.is_default_today;
|
||||
}
|
||||
if (has(item.params, 'values') && Array.isArray(item.params.values)) {
|
||||
mapped.attributes.values = item.params.values.map((value) => {
|
||||
const mappedValue = {
|
||||
|
Reference in New Issue
Block a user