Fix saving class name attributes for divider and custom html blocks
[MAILPOET-2746]
This commit is contained in:
committed by
Veljko V
parent
162b968f09
commit
e9c3049576
@@ -228,7 +228,9 @@ export const blocksToFormBodyFactory = (colorDefinitions, customFields = []) =>
|
|||||||
id: 'divider',
|
id: 'divider',
|
||||||
type: 'divider',
|
type: 'divider',
|
||||||
name: 'Divider',
|
name: 'Divider',
|
||||||
params: '',
|
params: {
|
||||||
|
class_name: block.attributes.className || null,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
case 'mailpoet-form/html':
|
case 'mailpoet-form/html':
|
||||||
return {
|
return {
|
||||||
@@ -239,6 +241,7 @@ export const blocksToFormBodyFactory = (colorDefinitions, customFields = []) =>
|
|||||||
params: {
|
params: {
|
||||||
text: block.attributes && block.attributes.content ? block.attributes.content : '',
|
text: block.attributes && block.attributes.content ? block.attributes.content : '',
|
||||||
nl2br: block.attributes && block.attributes.nl2br ? '1' : '0',
|
nl2br: block.attributes && block.attributes.nl2br ? '1' : '0',
|
||||||
|
class_name: block.attributes.className || null,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
default:
|
default:
|
||||||
|
@@ -176,7 +176,7 @@ describe('Blocks to Form Body', () => {
|
|||||||
expect(divider.id).to.be.equal('divider');
|
expect(divider.id).to.be.equal('divider');
|
||||||
expect(divider.name).to.be.equal('Divider');
|
expect(divider.name).to.be.equal('Divider');
|
||||||
expect(divider.type).to.be.equal('divider');
|
expect(divider.type).to.be.equal('divider');
|
||||||
expect(divider.params).to.be.equal('');
|
expect(divider.params).to.deep.equal({ class_name: null });
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Should map multiple dividers', () => {
|
it('Should map multiple dividers', () => {
|
||||||
@@ -447,6 +447,16 @@ describe('Blocks to Form Body', () => {
|
|||||||
const [mappedEmail] = formBlocksToBody([email]);
|
const [mappedEmail] = formBlocksToBody([email]);
|
||||||
expect(mappedEmail.params.class_name).to.be.equal('my-class-3');
|
expect(mappedEmail.params.class_name).to.be.equal('my-class-3');
|
||||||
|
|
||||||
|
const divider = { ...dividerBlock };
|
||||||
|
divider.attributes.className = 'my-class-4';
|
||||||
|
const [mappedDivider] = formBlocksToBody([divider]);
|
||||||
|
expect(mappedDivider.params.class_name).to.be.equal('my-class-4');
|
||||||
|
|
||||||
|
const html = { ...customHtmlBlock };
|
||||||
|
html.attributes.className = 'my-class-5';
|
||||||
|
const [mappedHtml] = formBlocksToBody([html]);
|
||||||
|
expect(mappedHtml.params.class_name).to.be.equal('my-class-5');
|
||||||
|
|
||||||
const customField = {
|
const customField = {
|
||||||
created_at: '2019-12-10T15:05:06+00:00',
|
created_at: '2019-12-10T15:05:06+00:00',
|
||||||
id: 1,
|
id: 1,
|
||||||
|
Reference in New Issue
Block a user