Register categories for custom fields
[MAILPOET-2453]
This commit is contained in:
committed by
Rostislav Wolný
parent
d069b0dab4
commit
289e65bc76
@@ -1,4 +1,5 @@
|
|||||||
import { registerBlockType, setCategories } from '@wordpress/blocks';
|
import { registerBlockType, setCategories } from '@wordpress/blocks';
|
||||||
|
import { select } from '@wordpress/data';
|
||||||
import MailPoet from 'mailpoet';
|
import MailPoet from 'mailpoet';
|
||||||
|
|
||||||
import * as divider from './divider/divider.jsx';
|
import * as divider from './divider/divider.jsx';
|
||||||
@@ -10,10 +11,16 @@ import * as segmentSelect from './segment_select/segment_select.jsx';
|
|||||||
import * as customHtml from './custom_html/custom_html.jsx';
|
import * as customHtml from './custom_html/custom_html.jsx';
|
||||||
|
|
||||||
export default () => {
|
export default () => {
|
||||||
setCategories([
|
const customFields = select('mailpoet-form-editor').getAllAvailableCustomFields()
|
||||||
|
|
||||||
|
const categories = [
|
||||||
{ slug: 'obligatory', title: '' }, // Blocks from this category are not in block insert popup
|
{ slug: 'obligatory', title: '' }, // Blocks from this category are not in block insert popup
|
||||||
{ slug: 'fields', title: MailPoet.I18n.t('fieldsBlocksCategory') },
|
];
|
||||||
]);
|
if (Array.isArray(customFields) && customFields.length) {
|
||||||
|
categories.push({ slug: 'custom-fields', title: MailPoet.I18n.t('customFieldsBlocksCategory') });
|
||||||
|
}
|
||||||
|
categories.push({ slug: 'fields', title: MailPoet.I18n.t('fieldsBlocksCategory') });
|
||||||
|
setCategories(categories);
|
||||||
|
|
||||||
registerBlockType(divider.name, divider.settings);
|
registerBlockType(divider.name, divider.settings);
|
||||||
registerBlockType(email.name, email.settings);
|
registerBlockType(email.name, email.settings);
|
||||||
|
@@ -20,6 +20,9 @@ export default {
|
|||||||
getAllAvailableSegments(state) {
|
getAllAvailableSegments(state) {
|
||||||
return state.segments;
|
return state.segments;
|
||||||
},
|
},
|
||||||
|
getAllAvailableCustomFields(state) {
|
||||||
|
return state.customFields;
|
||||||
|
},
|
||||||
getAllAvailablePages(state) {
|
getAllAvailablePages(state) {
|
||||||
return state.pages;
|
return state.pages;
|
||||||
},
|
},
|
||||||
|
@@ -23,6 +23,7 @@ export default () => {
|
|||||||
formErrors: validateForm(formData, formBlocks),
|
formErrors: validateForm(formData, formBlocks),
|
||||||
segments: window.mailpoet_form_segments,
|
segments: window.mailpoet_form_segments,
|
||||||
pages: window.mailpoet_form_pages,
|
pages: window.mailpoet_form_pages,
|
||||||
|
customFields: window.mailpoet_custom_fields,
|
||||||
isFormSaving: false,
|
isFormSaving: false,
|
||||||
notices: [],
|
notices: [],
|
||||||
sidebar: {
|
sidebar: {
|
||||||
|
@@ -42,6 +42,7 @@
|
|||||||
'settingsGoToPage': __('Go to Page'),
|
'settingsGoToPage': __('Go to Page'),
|
||||||
'settingsPleaseSelectList': __('Please select a list'),
|
'settingsPleaseSelectList': __('Please select a list'),
|
||||||
'fieldsBlocksCategory': __('Fields'),
|
'fieldsBlocksCategory': __('Fields'),
|
||||||
|
'customFieldsBlocksCategory': __('Custom Fields'),
|
||||||
'blockMandatory': __('Mandatory field'),
|
'blockMandatory': __('Mandatory field'),
|
||||||
'blockFirstName': __('First name'),
|
'blockFirstName': __('First name'),
|
||||||
'blockFirstNameDescription': __('Input field used to catch subscribers’ first names.'),
|
'blockFirstNameDescription': __('Input field used to catch subscribers’ first names.'),
|
||||||
|
Reference in New Issue
Block a user