Add operator field
[MAILPOET-3224]
This commit is contained in:
@@ -1,22 +1,57 @@
|
|||||||
import React from 'react';
|
import React, { useEffect } from 'react';
|
||||||
|
import { assign, compose, find } from 'lodash/fp';
|
||||||
|
|
||||||
|
import { Grid } from 'common/grid';
|
||||||
|
import MailPoet from 'mailpoet';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
EmailFormItem,
|
EmailFormItem,
|
||||||
OnFilterChange,
|
OnFilterChange, SelectOption,
|
||||||
} from '../types';
|
} from '../types';
|
||||||
|
import Select from '../../../common/form/react_select/react_select';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
onChange: OnFilterChange;
|
onChange: OnFilterChange;
|
||||||
item: EmailFormItem;
|
item: EmailFormItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const moreLessOptions = [
|
||||||
|
{
|
||||||
|
label: MailPoet.I18n.t('moreThan'),
|
||||||
|
value: 'more',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: MailPoet.I18n.t('lessThan'),
|
||||||
|
value: 'less',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
export const EmailOpensAbsoluteCountFields: React.FunctionComponent<Props> = ({
|
export const EmailOpensAbsoluteCountFields: React.FunctionComponent<Props> = ({
|
||||||
onChange,
|
onChange,
|
||||||
item,
|
item,
|
||||||
}) => (
|
}) => {
|
||||||
|
useEffect(() => {
|
||||||
|
if (item.operator === undefined) {
|
||||||
|
onChange(assign(item, { operator: 'more' }));
|
||||||
|
}
|
||||||
|
}, [onChange, item, item.operator]);
|
||||||
|
|
||||||
|
return (
|
||||||
<>
|
<>
|
||||||
|
<Grid.CenteredRow>
|
||||||
<div className="mailpoet-form-field">
|
<div className="mailpoet-form-field">
|
||||||
{item.name}
|
<div className="mailpoet-form-input mailpoet-form-select" data-automation-id="segment-email">
|
||||||
|
<Select
|
||||||
|
options={moreLessOptions}
|
||||||
|
value={find(['value', item.operator], moreLessOptions)}
|
||||||
|
onChange={(option: SelectOption): void => compose([
|
||||||
|
onChange,
|
||||||
|
assign(item),
|
||||||
|
])({ operator: option.value })}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
</Grid.CenteredRow>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
};
|
||||||
|
@@ -41,6 +41,7 @@ export interface EmailFormItem extends FormItem {
|
|||||||
action?: string;
|
action?: string;
|
||||||
newsletter_id?: string;
|
newsletter_id?: string;
|
||||||
link_id?: string;
|
link_id?: string;
|
||||||
|
operator?: string,
|
||||||
}
|
}
|
||||||
|
|
||||||
export type AnyFormItem = WordpressRoleFormItem | WooCommerceFormItem | EmailFormItem;
|
export type AnyFormItem = WordpressRoleFormItem | WooCommerceFormItem | EmailFormItem;
|
||||||
|
@@ -135,6 +135,8 @@
|
|||||||
'selectUserRolePlaceholder': __('Select user role'),
|
'selectUserRolePlaceholder': __('Select user role'),
|
||||||
'emailActionOpened': _x('opened', 'Dynamic segment creation: when newsletter was opened'),
|
'emailActionOpened': _x('opened', 'Dynamic segment creation: when newsletter was opened'),
|
||||||
'emailActionOpensAbsoluteCount': __('# of opens'),
|
'emailActionOpensAbsoluteCount': __('# of opens'),
|
||||||
|
'moreThan': __('more than'),
|
||||||
|
'lessThan': __('less than'),
|
||||||
'emailActionNotOpened': _x('not opened', 'Dynamic segment creation: when newsletter was not opened'),
|
'emailActionNotOpened': _x('not opened', 'Dynamic segment creation: when newsletter was not opened'),
|
||||||
'emailActionClicked': _x('clicked', 'Dynamic segment creation: when a newsletter link was clicked'),
|
'emailActionClicked': _x('clicked', 'Dynamic segment creation: when a newsletter link was clicked'),
|
||||||
'emailActionNotClicked': _x('not clicked', 'Dynamic segment creation: when a newsletter link was not clicked'),
|
'emailActionNotClicked': _x('not clicked', 'Dynamic segment creation: when a newsletter link was not clicked'),
|
||||||
|
Reference in New Issue
Block a user