Add default values for form placement settings
[MAILPOET-2811]
This commit is contained in:
committed by
Veljko V
parent
5ee8dae154
commit
3276d32b60
@@ -20,11 +20,6 @@ const FixedBarSettings = () => {
|
|||||||
changeFormSettings(settings);
|
changeFormSettings(settings);
|
||||||
};
|
};
|
||||||
|
|
||||||
const fixedBarFormDelay = formSettings.fixedBarFormDelay === undefined
|
|
||||||
? 15
|
|
||||||
: formSettings.fixedBarFormDelay;
|
|
||||||
const fixedBarFormPosition = formSettings.fixedBarFormPosition === undefined ? 'top' : formSettings.fixedBarFormPosition;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<p>{MailPoet.I18n.t('placeFixedBarFormOnPagesDescription')}</p>
|
<p>{MailPoet.I18n.t('placeFixedBarFormOnPagesDescription')}</p>
|
||||||
@@ -41,7 +36,7 @@ const FixedBarSettings = () => {
|
|||||||
/>
|
/>
|
||||||
<SelectControl
|
<SelectControl
|
||||||
label={MailPoet.I18n.t('formPlacementDelay')}
|
label={MailPoet.I18n.t('formPlacementDelay')}
|
||||||
value={fixedBarFormDelay}
|
value={formSettings.fixedBarFormDelay}
|
||||||
onChange={partial(updateSettings, 'fixedBarFormDelay')}
|
onChange={partial(updateSettings, 'fixedBarFormDelay')}
|
||||||
options={delayValues.map((delayValue) => ({
|
options={delayValues.map((delayValue) => ({
|
||||||
value: delayValue,
|
value: delayValue,
|
||||||
@@ -50,7 +45,7 @@ const FixedBarSettings = () => {
|
|||||||
/>
|
/>
|
||||||
<RadioControl
|
<RadioControl
|
||||||
label={MailPoet.I18n.t('formPlacementPlacementPosition')}
|
label={MailPoet.I18n.t('formPlacementPlacementPosition')}
|
||||||
selected={fixedBarFormPosition}
|
selected={formSettings.fixedBarFormPosition}
|
||||||
options={[
|
options={[
|
||||||
{ label: MailPoet.I18n.t('formPlacementPlacementPositionTop'), value: 'top' },
|
{ label: MailPoet.I18n.t('formPlacementPlacementPositionTop'), value: 'top' },
|
||||||
{ label: MailPoet.I18n.t('formPlacementPlacementPositionBottom'), value: 'bottom' },
|
{ label: MailPoet.I18n.t('formPlacementPlacementPositionBottom'), value: 'bottom' },
|
||||||
|
@@ -20,9 +20,6 @@ const PopUpSettings = () => {
|
|||||||
settings[key] = value;
|
settings[key] = value;
|
||||||
changeFormSettings(settings);
|
changeFormSettings(settings);
|
||||||
};
|
};
|
||||||
const popupFormDelay = formSettings.popupFormDelay === undefined
|
|
||||||
? 15
|
|
||||||
: formSettings.popupFormDelay;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -40,7 +37,7 @@ const PopUpSettings = () => {
|
|||||||
/>
|
/>
|
||||||
<SelectControl
|
<SelectControl
|
||||||
label={MailPoet.I18n.t('formPlacementDelay')}
|
label={MailPoet.I18n.t('formPlacementDelay')}
|
||||||
value={popupFormDelay}
|
value={formSettings.popupFormDelay}
|
||||||
onChange={partial(updateSettings, 'popupFormDelay')}
|
onChange={partial(updateSettings, 'popupFormDelay')}
|
||||||
options={delayValues.map((delayValue) => ({
|
options={delayValues.map((delayValue) => ({
|
||||||
value: delayValue,
|
value: delayValue,
|
||||||
|
@@ -20,11 +20,6 @@ const SlideInSettings = () => {
|
|||||||
changeFormSettings(settings);
|
changeFormSettings(settings);
|
||||||
};
|
};
|
||||||
|
|
||||||
const slideInFormDelay = formSettings.slideInFormDelay === undefined
|
|
||||||
? 15
|
|
||||||
: formSettings.slideInFormDelay;
|
|
||||||
const slideInFormPosition = formSettings.slideInFormPosition === undefined ? 'right' : formSettings.slideInFormPosition;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<p>{MailPoet.I18n.t('placeSlideInFormOnPagesDescription')}</p>
|
<p>{MailPoet.I18n.t('placeSlideInFormOnPagesDescription')}</p>
|
||||||
@@ -41,7 +36,7 @@ const SlideInSettings = () => {
|
|||||||
/>
|
/>
|
||||||
<SelectControl
|
<SelectControl
|
||||||
label={MailPoet.I18n.t('formPlacementDelay')}
|
label={MailPoet.I18n.t('formPlacementDelay')}
|
||||||
value={slideInFormDelay}
|
value={formSettings.slideInFormDelay}
|
||||||
onChange={partial(updateSettings, 'slideInFormDelay')}
|
onChange={partial(updateSettings, 'slideInFormDelay')}
|
||||||
options={delayValues.map((delayValue) => ({
|
options={delayValues.map((delayValue) => ({
|
||||||
value: delayValue,
|
value: delayValue,
|
||||||
@@ -50,7 +45,7 @@ const SlideInSettings = () => {
|
|||||||
/>
|
/>
|
||||||
<RadioControl
|
<RadioControl
|
||||||
label={MailPoet.I18n.t('formPlacementPlacementPosition')}
|
label={MailPoet.I18n.t('formPlacementPlacementPosition')}
|
||||||
selected={slideInFormPosition}
|
selected={formSettings.slideInFormPosition}
|
||||||
options={[
|
options={[
|
||||||
{ label: MailPoet.I18n.t('formPlacementPlacementPositionLeft'), value: 'left' },
|
{ label: MailPoet.I18n.t('formPlacementPlacementPositionLeft'), value: 'left' },
|
||||||
{ label: MailPoet.I18n.t('formPlacementPlacementPositionRight'), value: 'right' },
|
{ label: MailPoet.I18n.t('formPlacementPlacementPositionRight'), value: 'right' },
|
||||||
|
@@ -2,37 +2,52 @@
|
|||||||
* Default values for various settings
|
* Default values for various settings
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export const belowPostStyles = {
|
export const belowPostForm = {
|
||||||
width: {
|
styles: {
|
||||||
unit: 'percent',
|
width: {
|
||||||
value: 100,
|
unit: 'percent',
|
||||||
|
value: 100,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const popupStyles = {
|
export const popupForm = {
|
||||||
width: {
|
styles: {
|
||||||
unit: 'pixel',
|
width: {
|
||||||
value: 560,
|
unit: 'pixel',
|
||||||
|
value: 560,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
formDelay: 15,
|
||||||
|
};
|
||||||
|
|
||||||
|
export const fixedBarForm = {
|
||||||
|
styles: {
|
||||||
|
width: {
|
||||||
|
unit: 'percent',
|
||||||
|
value: 100,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
position: 'top',
|
||||||
|
formDelay: 15,
|
||||||
|
};
|
||||||
|
|
||||||
|
export const otherForm = {
|
||||||
|
styles: {
|
||||||
|
width: {
|
||||||
|
unit: 'percent',
|
||||||
|
value: 100,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const fixedBarStyles = {
|
export const slideInForm = {
|
||||||
width: {
|
styles: {
|
||||||
unit: 'percent',
|
width: {
|
||||||
value: 100,
|
unit: 'pixel',
|
||||||
},
|
value: 560,
|
||||||
};
|
},
|
||||||
|
|
||||||
export const otherStyles = {
|
|
||||||
width: {
|
|
||||||
unit: 'percent',
|
|
||||||
value: 100,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
export const slideInStyles = {
|
|
||||||
width: {
|
|
||||||
unit: 'pixel',
|
|
||||||
value: 560,
|
|
||||||
},
|
},
|
||||||
|
position: 'right',
|
||||||
|
formDelay: 15,
|
||||||
};
|
};
|
||||||
|
@@ -10,15 +10,20 @@ export default function mapFormDataAfterLoading(data) {
|
|||||||
placeFormBellowAllPosts: data.settings.place_form_bellow_all_posts === '1',
|
placeFormBellowAllPosts: data.settings.place_form_bellow_all_posts === '1',
|
||||||
placePopupFormOnAllPages: data.settings.place_popup_form_on_all_pages === '1',
|
placePopupFormOnAllPages: data.settings.place_popup_form_on_all_pages === '1',
|
||||||
placePopupFormOnAllPosts: data.settings.place_popup_form_on_all_posts === '1',
|
placePopupFormOnAllPosts: data.settings.place_popup_form_on_all_posts === '1',
|
||||||
popupFormDelay: asNum(data.settings.popup_form_delay),
|
popupFormDelay: data.settings.popup_form_delay !== undefined
|
||||||
|
? asNum(data.settings.popup_form_delay) : defaults.popupForm.formDelay,
|
||||||
placeFixedBarFormOnAllPages: data.settings.place_fixed_bar_form_on_all_pages === '1',
|
placeFixedBarFormOnAllPages: data.settings.place_fixed_bar_form_on_all_pages === '1',
|
||||||
placeFixedBarFormOnAllPosts: data.settings.place_fixed_bar_form_on_all_posts === '1',
|
placeFixedBarFormOnAllPosts: data.settings.place_fixed_bar_form_on_all_posts === '1',
|
||||||
fixedBarFormDelay: asNum(data.settings.fixed_bar_form_delay),
|
fixedBarFormDelay: data.settings.fixed_bar_form_delay !== undefined
|
||||||
fixedBarFormPosition: data.settings.fixed_bar_form_position,
|
? asNum(data.settings.fixed_bar_form_delay)
|
||||||
|
: defaults.fixedBarForm.formDelay,
|
||||||
|
fixedBarFormPosition: data.settings.fixed_bar_form_position ?? defaults.fixedBarForm.position,
|
||||||
placeSlideInFormOnAllPages: data.settings.place_slide_in_form_on_all_pages === '1',
|
placeSlideInFormOnAllPages: data.settings.place_slide_in_form_on_all_pages === '1',
|
||||||
placeSlideInFormOnAllPosts: data.settings.place_slide_in_form_on_all_posts === '1',
|
placeSlideInFormOnAllPosts: data.settings.place_slide_in_form_on_all_posts === '1',
|
||||||
slideInFormDelay: asNum(data.settings.slide_in_form_delay),
|
slideInFormDelay: data.settings.slide_in_form_delay !== undefined
|
||||||
slideInFormPosition: data.settings.slide_in_form_position,
|
? asNum(data.settings.slide_in_form_delay)
|
||||||
|
: defaults.slideInForm.formDelay,
|
||||||
|
slideInFormPosition: data.settings.slide_in_form_position ?? defaults.slideInForm.position,
|
||||||
borderRadius: asNum(data.settings.border_radius),
|
borderRadius: asNum(data.settings.border_radius),
|
||||||
borderSize: asNum(data.settings.border_size),
|
borderSize: asNum(data.settings.border_size),
|
||||||
formPadding: data.settings.form_padding ? asNum(data.settings.form_padding) : 20,
|
formPadding: data.settings.form_padding ? asNum(data.settings.form_padding) : 20,
|
||||||
@@ -26,11 +31,11 @@ export default function mapFormDataAfterLoading(data) {
|
|||||||
borderColor: data.settings.border_color,
|
borderColor: data.settings.border_color,
|
||||||
backgroundImageUrl: data.settings.background_image_url,
|
backgroundImageUrl: data.settings.background_image_url,
|
||||||
backgroundImageDisplay: data.settings.background_image_display,
|
backgroundImageDisplay: data.settings.background_image_display,
|
||||||
belowPostStyles: { ...defaults.belowPostStyles, ...data.settings.below_post_styles },
|
belowPostStyles: { ...defaults.belowPostForm.styles, ...data.settings.below_post_styles },
|
||||||
slideInStyles: { ...defaults.slideInStyles, ...data.settings.slide_in_styles },
|
slideInStyles: { ...defaults.slideInForm.styles, ...data.settings.slide_in_styles },
|
||||||
fixedBarStyles: { ...defaults.fixedBarStyles, ...data.settings.fixed_bar_styles },
|
fixedBarStyles: { ...defaults.fixedBarForm.styles, ...data.settings.fixed_bar_styles },
|
||||||
popupStyles: { ...defaults.popupStyles, ...data.settings.popup_styles },
|
popupStyles: { ...defaults.popupForm.styles, ...data.settings.popup_styles },
|
||||||
otherStyles: { ...defaults.otherStyles, ...data.settings.other_styles },
|
otherStyles: { ...defaults.otherForm.styles, ...data.settings.other_styles },
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -85,6 +85,14 @@ describe('Form Data Load Mapper', () => {
|
|||||||
expect(map(data).settings).to.have.property('otherStyles').that.deep.eq({ width: { unit: 'percent', value: 100 } });
|
expect(map(data).settings).to.have.property('otherStyles').that.deep.eq({ width: { unit: 'percent', value: 100 } });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Sets default delays and positions', () => {
|
||||||
|
expect(map(data).settings).to.have.property('popupFormDelay').eq(15);
|
||||||
|
expect(map(data).settings).to.have.property('fixedBarFormDelay').eq(15);
|
||||||
|
expect(map(data).settings).to.have.property('slideInFormDelay').eq(15);
|
||||||
|
expect(map(data).settings).to.have.property('slideInFormPosition').eq('right');
|
||||||
|
expect(map(data).settings).to.have.property('fixedBarFormPosition').eq('top');
|
||||||
|
});
|
||||||
|
|
||||||
it('Keeps set placement styles', () => {
|
it('Keeps set placement styles', () => {
|
||||||
const mapData = {
|
const mapData = {
|
||||||
...data,
|
...data,
|
||||||
|
Reference in New Issue
Block a user