Use underscore to unify naming

[MAILPOET-2639]
This commit is contained in:
Pavel Dohnal
2020-01-30 08:36:23 +01:00
committed by Jack Kitterhing
parent 1c1f0313f0
commit f001542b3e
6 changed files with 23 additions and 23 deletions

View File

@@ -3,8 +3,8 @@ export default function mapFormDataAfterLoading(data) {
...data, ...data,
settings: { settings: {
...data.settings, ...data.settings,
placeFormBellowAllPages: data.settings.placeFormBellowAllPages === '1', placeFormBellowAllPages: data.settings.place_form_bellow_all_pages === '1',
placeFormBellowAllPosts: data.settings.placeFormBellowAllPosts === '1', placeFormBellowAllPosts: data.settings.place_form_bellow_all_posts === '1',
}, },
}; };
} }

View File

@@ -3,8 +3,8 @@ export default function mapFormDataBeforeSaving(data) {
...data, ...data,
settings: { settings: {
...data.settings, ...data.settings,
placeFormBellowAllPages: data.settings.placeFormBellowAllPages === true ? '1' : '', place_form_bellow_all_pages: data.settings.placeFormBellowAllPages === true ? '1' : '',
placeFormBellowAllPosts: data.settings.placeFormBellowAllPosts === true ? '1' : '', place_form_bellow_all_posts: data.settings.placeFormBellowAllPosts === true ? '1' : '',
}, },
}; };
} }

View File

@@ -72,13 +72,13 @@ class DisplayFormInWPContent {
private function shouldDisplayFormBellowContent(FormEntity $form): bool { private function shouldDisplayFormBellowContent(FormEntity $form): bool {
$settings = $form->getSettings(); $settings = $form->getSettings();
if (!is_array($settings)) return false; if (!is_array($settings)) return false;
if (!isset($settings['placeFormBellowAllPosts'])) return false; if (!isset($settings['place_form_bellow_all_posts'])) return false;
if ( if (
($settings['placeFormBellowAllPosts'] === '1') ($settings['place_form_bellow_all_posts'] === '1')
&& $this->wp->isSingular('post') && $this->wp->isSingular('post')
) return true; ) return true;
if ( if (
($settings['placeFormBellowAllPages'] === '1') ($settings['place_form_bellow_all_pages'] === '1')
&& $this->wp->isPage() && $this->wp->isPage()
) return true; ) return true;
return false; return false;

View File

@@ -10,8 +10,8 @@ const data = {
success_message: 'Check your inbox or spam folder to confirm your subscription.', success_message: 'Check your inbox or spam folder to confirm your subscription.',
success_page: '5', success_page: '5',
segments_selected_by: 'admin', segments_selected_by: 'admin',
placeFormBellowAllPages: '1', place_form_bellow_all_pages: '1',
placeFormBellowAllPosts: '', place_form_bellow_all_posts: '',
}, },
styles: 'styles definition', styles: 'styles definition',
created_at: '2020-01-15 07:39:15', created_at: '2020-01-15 07:39:15',

View File

@@ -55,8 +55,8 @@ describe('Form Data Save Mapper', () => {
}); });
it('maps placement', () => { it('maps placement', () => {
expect(map(data).settings).to.have.property('placeFormBellowAllPages', '1'); expect(map(data).settings).to.have.property('place_form_bellow_all_pages', '1');
expect(map(data).settings).to.have.property('placeFormBellowAllPosts', ''); expect(map(data).settings).to.have.property('place_form_bellow_all_posts', '');
}); });
}); });
}); });

View File

@@ -34,8 +34,8 @@ class DisplayFormInWPContentTest extends \MailPoetUnitTest {
$form = new FormEntity('My Form'); $form = new FormEntity('My Form');
$form->setSettings([ $form->setSettings([
'segments' => ['3'], 'segments' => ['3'],
'placeFormBellowAllPages' => '', 'place_form_bellow_all_pages' => '',
'placeFormBellowAllPosts' => '1', 'place_form_bellow_all_posts' => '1',
]); ]);
$form->setBody([[ $form->setBody([[
'type' => 'submit', 'type' => 'submit',
@@ -57,8 +57,8 @@ class DisplayFormInWPContentTest extends \MailPoetUnitTest {
$form = new FormEntity('My Form'); $form = new FormEntity('My Form');
$form->setSettings([ $form->setSettings([
'segments' => ['3'], 'segments' => ['3'],
'placeFormBellowAllPages' => '', 'place_form_bellow_all_pages' => '',
'placeFormBellowAllPosts' => '', 'place_form_bellow_all_posts' => '',
]); ]);
$form->setBody([[ $form->setBody([[
'type' => 'submit', 'type' => 'submit',
@@ -78,8 +78,8 @@ class DisplayFormInWPContentTest extends \MailPoetUnitTest {
$form1 = new FormEntity('My Form'); $form1 = new FormEntity('My Form');
$form1->setSettings([ $form1->setSettings([
'segments' => ['3'], 'segments' => ['3'],
'placeFormBellowAllPages' => '', 'place_form_bellow_all_pages' => '',
'placeFormBellowAllPosts' => '1', 'place_form_bellow_all_posts' => '1',
]); ]);
$form1->setBody([[ $form1->setBody([[
'type' => 'submit', 'type' => 'submit',
@@ -90,8 +90,8 @@ class DisplayFormInWPContentTest extends \MailPoetUnitTest {
$form2 = new FormEntity('My Form'); $form2 = new FormEntity('My Form');
$form2->setSettings([ $form2->setSettings([
'segments' => ['3'], 'segments' => ['3'],
'placeFormBellowAllPages' => '', 'place_form_bellow_all_pages' => '',
'placeFormBellowAllPosts' => '1', 'place_form_bellow_all_posts' => '1',
]); ]);
$form2->setBody([[ $form2->setBody([[
'type' => 'submit', 'type' => 'submit',
@@ -121,8 +121,8 @@ class DisplayFormInWPContentTest extends \MailPoetUnitTest {
$form = new FormEntity('My Form'); $form = new FormEntity('My Form');
$form->setSettings([ $form->setSettings([
'segments' => ['3'], 'segments' => ['3'],
'placeFormBellowAllPages' => '', 'place_form_bellow_all_pages' => '',
'placeFormBellowAllPosts' => '1', 'place_form_bellow_all_posts' => '1',
]); ]);
$form->setBody([[ $form->setBody([[
'type' => 'submit', 'type' => 'submit',
@@ -145,8 +145,8 @@ class DisplayFormInWPContentTest extends \MailPoetUnitTest {
$form = new FormEntity('My Form'); $form = new FormEntity('My Form');
$form->setSettings([ $form->setSettings([
'segments' => ['3'], 'segments' => ['3'],
'placeFormBellowAllPages' => '1', 'place_form_bellow_all_pages' => '1',
'placeFormBellowAllPosts' => '', 'place_form_bellow_all_posts' => '',
]); ]);
$form->setBody([[ $form->setBody([[
'type' => 'submit', 'type' => 'submit',