Fix eslint6 func-names

[MAILPOET-1140]
This commit is contained in:
Pavel Dohnal
2018-03-15 11:55:03 +00:00
parent 9e685efd41
commit d3250030ba
35 changed files with 283 additions and 286 deletions

View File

@ -31,7 +31,6 @@
"react/jsx-boolean-value": 0,
"react/jsx-no-bind": 0,
"react/no-array-index-key": 0,
"func-names": 0,
"object-shorthand": 0,
"space-unary-ops": 0,
"space-infix-ops": 0,

View File

@ -5,11 +5,11 @@ define([
React
) => {
const FormFieldCheckbox = React.createClass({
onValueChange: function (e) {
onValueChange: function onValueChange(e) {
e.target.value = this.checkbox.checked ? '1' : '0';
return this.props.onValueChange(e);
},
render: function () {
render: function render() {
if (this.props.field.values === undefined) {
return false;
}

View File

@ -21,7 +21,7 @@ define([
jQuery
) => {
const FormField = React.createClass({
renderField: function (data, inline = false) {
renderField: function renderField(data, inline = false) {
let description = false;
if (data.field.description) {
description = (
@ -89,7 +89,7 @@ define([
</div>
);
},
render: function () {
render: function render() {
let field = false;
if (this.props.field.fields !== undefined) {

View File

@ -5,7 +5,7 @@ define([
React
) => {
const FormFieldRadio = React.createClass({
render: function () {
render: function render() {
if (this.props.field.values === undefined) {
return false;
}

View File

@ -10,21 +10,21 @@ define([
jQuery
) => {
const Selection = React.createClass({
allowMultipleValues: function () {
allowMultipleValues: function allowMultipleValues() {
return (this.props.field.multiple === true);
},
isSelect2Initialized: function () {
isSelect2Initialized: function isSelect2Initialized() {
return (jQuery(`#${this.select.id}`).hasClass('select2-hidden-accessible') === true);
},
isSelect2Component: function () {
isSelect2Component: function isSelect2Component() {
return this.allowMultipleValues() || this.props.field.forceSelect2;
},
componentDidMount: function () {
componentDidMount: function componentDidMount() {
if (this.isSelect2Component()) {
this.setupSelect2();
}
},
componentDidUpdate: function (prevProps) {
componentDidUpdate: function componentDidUpdate(prevProps) {
if ((this.props.item !== undefined && prevProps.item !== undefined)
&& (this.props.item.id !== prevProps.item.id)
) {
@ -40,26 +40,26 @@ define([
this.resetSelect2();
}
},
componentWillUnmount: function () {
componentWillUnmount: function componentWillUnmount() {
if (this.isSelect2Component()) {
this.destroySelect2();
}
},
getFieldId: function (data) {
getFieldId: function getFieldId(data) {
const props = data || this.props;
return props.field.id || props.field.name;
},
resetSelect2: function () {
resetSelect2: function resetSelect2() {
this.destroySelect2();
this.setupSelect2();
},
destroySelect2: function () {
destroySelect2: function destroySelect2() {
if (this.isSelect2Initialized()) {
jQuery(`#${this.select.id}`).select2('destroy');
this.cleanupAfterSelect2();
}
},
cleanupAfterSelect2: function () {
cleanupAfterSelect2: function cleanupAfterSelect2() {
// remove DOM elements created by Select2 that are not tracked by React
jQuery(`#${this.select.id}`)
.find('option:not(.default)')
@ -70,7 +70,7 @@ define([
.off('select2:unselecting')
.off('select2:opening');
},
setupSelect2: function () {
setupSelect2: function setupSelect2() {
if (this.isSelect2Initialized()) {
return;
}
@ -81,7 +81,7 @@ define([
id: '', // the value of the option
text: this.props.field.placeholder,
},
templateResult: function (item) {
templateResult: function templateResult(item) {
if (item.element && item.element.selected) {
return null;
} else if (item.title) {
@ -98,7 +98,7 @@ define([
url: window.ajaxurl,
type: 'POST',
dataType: 'json',
data: function (params) {
data: function data(params) {
return {
action: 'mailpoet',
api_version: window.mailpoet_api_version,
@ -111,7 +111,7 @@ define([
),
};
},
processResults: function (response) {
processResults: function processResults(response) {
return {
results: response.data.map(item => (
{ id: item.id || item.value, text: item.name || item.text }
@ -142,7 +142,7 @@ define([
select2.on('change', this.handleChange);
},
getSelectedValues: function () {
getSelectedValues: function getSelectedValues() {
if (this.props.field.selected !== undefined) {
return this.props.field.selected(this.props.item);
} else if (this.props.item !== undefined && this.props.field.name !== undefined) {
@ -156,7 +156,7 @@ define([
}
return null;
},
getItems: function () {
getItems: function getItems() {
let items;
if (typeof (window[`mailpoet_${this.props.field.endpoint}`]) !== 'undefined') {
items = window[`mailpoet_${this.props.field.endpoint}`];
@ -172,7 +172,7 @@ define([
return items;
},
handleChange: function (e) {
handleChange: function handleChange(e) {
let value;
if (this.props.onValueChange !== undefined) {
if (this.props.field.multiple) {
@ -190,19 +190,19 @@ define([
});
}
},
getLabel: function (item) {
getLabel: function getLabel(item) {
if (this.props.field.getLabel !== undefined) {
return this.props.field.getLabel(item, this.props.item);
}
return item.name;
},
getSearchLabel: function (item) {
getSearchLabel: function getSearchLabel(item) {
if (this.props.field.getSearchLabel !== undefined) {
return this.props.field.getSearchLabel(item, this.props.item);
}
return null;
},
getValue: function (item) {
getValue: function getValue(item) {
if (this.props.field.getValue !== undefined) {
return this.props.field.getValue(item, this.props.item);
}
@ -211,13 +211,13 @@ define([
// When it's impossible to represent the desired value in DOM,
// this function may be used to transform the placeholder value into
// desired value.
transformChangedValue: function (value) {
transformChangedValue: function transformChangedValue(value) {
if (typeof this.props.field.transformChangedValue === 'function') {
return this.props.field.transformChangedValue.call(this, value);
}
return value;
},
insertEmptyOption: function () {
insertEmptyOption: function insertEmptyOption() {
// https://select2.org/placeholders
// For single selects only, in order for the placeholder value to appear,
// we must have a blank <option> as the first option in the <select> control.
@ -225,7 +225,7 @@ define([
if (this.props.field.placeholder) return (<option className="default" />);
return undefined;
},
render: function () {
render: function render() {
const items = this.getItems(this.props.field);
const selectedValues = this.getSelectedValues();
const options = items.map((item, index) => {

View File

@ -5,7 +5,7 @@ define([
React
) => {
const FormFieldTextarea = React.createClass({
render: function () {
render: function render() {
return (
<textarea
type="text"

View File

@ -19,25 +19,25 @@ define(
contextTypes: {
router: React.PropTypes.object.isRequired,
},
getDefaultProps: function () {
getDefaultProps: function getDefaultProps() {
return {
params: {},
};
},
getInitialState: function () {
getInitialState: function getInitialState() {
return {
loading: false,
errors: [],
item: {},
};
},
getValues: function () {
getValues: function getValues() {
return this.props.item ? this.props.item : this.state.item;
},
getErrors: function () {
getErrors: function getErrors() {
return this.props.errors ? this.props.errors : this.state.errors;
},
componentDidMount: function () {
componentDidMount: function componentDidMount() {
if (this.isMounted()) {
if (this.props.params.id !== undefined) {
this.loadItem(this.props.params.id);
@ -50,7 +50,7 @@ define(
}
}
},
componentWillReceiveProps: function (props) {
componentWillReceiveProps: function componentWillReceiveProps(props) {
if (props.params.id === undefined) {
setImmediate(() => {
this.setState({
@ -63,7 +63,7 @@ define(
}
}
},
loadItem: function (id) {
loadItem: function loadItem(id) {
this.setState({ loading: true });
MailPoet.Ajax.post({
@ -85,12 +85,12 @@ define(
this.setState({
loading: false,
item: {},
}, function () {
}, function failSetStateCallback() {
this.context.router.push('/new');
});
});
},
handleSubmit: function (e) {
handleSubmit: function handleSubmit(e) {
e.preventDefault();
// handle validation
@ -143,7 +143,7 @@ define(
}
});
},
handleValueChange: function (e) {
handleValueChange: function handleValueChange(e) {
if (this.props.onChange) {
return this.props.onChange(e);
}
@ -157,7 +157,7 @@ define(
});
return true;
},
render: function () {
render: function render() {
let errors;
if (this.getErrors() !== undefined) {
errors = this.getErrors().map((error, index) => (

View File

@ -85,7 +85,7 @@ const itemActions = [
{
name: 'edit',
label: MailPoet.I18n.t('edit'),
link: function (item) {
link: function link(item) {
return (
<a href={`admin.php?page=mailpoet-form-editor&id=${item.id}`}>{MailPoet.I18n.t('edit')}</a>
);
@ -94,7 +94,7 @@ const itemActions = [
{
name: 'duplicate',
label: MailPoet.I18n.t('duplicate'),
onClick: function (item, refresh) {
onClick: function onClick(item, refresh) {
return MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'forms',

View File

@ -7,13 +7,13 @@ define([
MailPoet
) => {
const ListingBulkActions = React.createClass({
getInitialState: function () {
getInitialState: function getInitialState() {
return {
action: false,
extra: false,
};
},
handleChangeAction: function (e) {
handleChangeAction: function handleChangeAction(e) {
this.setState({
action: e.target.value,
extra: false,
@ -28,7 +28,7 @@ define([
}
});
},
handleApplyAction: function (e) {
handleApplyAction: function handleApplyAction(e) {
e.preventDefault();
const action = this.getSelectedAction();
@ -47,7 +47,7 @@ define([
data.action = this.state.action;
let onSuccess = function () {};
let onSuccess = () => {};
if (action.onSuccess !== undefined) {
onSuccess = action.onSuccess;
}
@ -64,7 +64,7 @@ define([
extra: false,
});
},
getSelectedAction: function () {
getSelectedAction: function getSelectedAction() {
const selectedAction = this.action.value;
if (selectedAction.length > 0) {
const action = this.props.bulk_actions.filter(act => (act.name === selectedAction));
@ -75,7 +75,7 @@ define([
}
return null;
},
render: function () {
render: function render() {
if (this.props.bulk_actions.length === 0) {
return null;
}

View File

@ -9,7 +9,7 @@ define([
MailPoet
) => {
const ListingFilters = React.createClass({
handleFilterAction: function () {
handleFilterAction: function handleFilterAction() {
const filters = {};
this.getAvailableFilters().forEach((filter, i) => {
filters[this[`filter-${i}`].name] = this[`filter-${i}`].value;
@ -19,10 +19,10 @@ define([
}
return this.props.onSelectFilter(filters);
},
handleEmptyTrash: function () {
handleEmptyTrash: function handleEmptyTrash() {
return this.props.onEmptyTrash();
},
getAvailableFilters: function () {
getAvailableFilters: function getAvailableFilters() {
const filters = this.props.filters;
return Object.keys(filters).filter(filter => !(
filters[filter].length === 0
@ -32,7 +32,7 @@ define([
)
));
},
componentDidUpdate: function () {
componentDidUpdate: function componentDidUpdate() {
const selectedFilters = this.props.filter;
this.getAvailableFilters().forEach(
(filter, i) => {
@ -44,7 +44,7 @@ define([
}
);
},
render: function () {
render: function render() {
const filters = this.props.filters;
const availableFilters = this.getAvailableFilters()
.map((filter, i) => (

View File

@ -1,9 +1,9 @@
define(['react', 'classnames'], (React, classNames) => {
const ListingGroups = React.createClass({
handleSelect: function (group) {
handleSelect: function handleSelect(group) {
return this.props.onSelectGroup(group);
},
render: function () {
render: function render() {
const groups = this.props.groups.map((group, index) => {
if (group.name === 'trash' && group.count === 0) {
return false;

View File

@ -3,12 +3,12 @@ import React from 'react';
import classNames from 'classnames';
const ListingHeader = React.createClass({
handleSelectItems: function () {
handleSelectItems: function handleSelectItems() {
return this.props.onSelectItems(
this.toggle.checked
);
},
render: function () {
render: function render() {
const columns = this.props.columns.map((column, index) => {
const renderColumn = column;
renderColumn.is_primary = (index === 0);
@ -57,12 +57,12 @@ const ListingHeader = React.createClass({
});
const ListingColumn = React.createClass({
handleSort: function () {
handleSort: function handleSort() {
const sortBy = this.props.column.name;
const sortOrder = (this.props.column.sorted === 'asc') ? 'desc' : 'asc';
this.props.onSort(sortBy, sortOrder);
},
render: function () {
render: function render() {
const classes = classNames(
'manage-column',
{ 'column-primary': this.props.column.is_primary },

View File

@ -12,12 +12,12 @@ import ListingGroups from 'listing/groups.jsx';
import ListingFilters from 'listing/filters.jsx';
const ListingItem = React.createClass({
getInitialState: function () {
getInitialState: function getInitialState() {
return {
expanded: false,
};
},
handleSelectItem: function (e) {
handleSelectItem: function handleSelectItem(e) {
this.props.onSelectItem(
parseInt(e.target.value, 10),
e.target.checked
@ -25,19 +25,19 @@ const ListingItem = React.createClass({
return !e.target.checked;
},
handleRestoreItem: function (id) {
handleRestoreItem: function handleRestoreItem(id) {
this.props.onRestoreItem(id);
},
handleTrashItem: function (id) {
handleTrashItem: function handleTrashItem(id) {
this.props.onTrashItem(id);
},
handleDeleteItem: function (id) {
handleDeleteItem: function handleDeleteItem(id) {
this.props.onDeleteItem(id);
},
handleToggleItem: function () {
handleToggleItem: function handleToggleItem() {
this.setState({ expanded: !this.state.expanded });
},
render: function () {
render: function render() {
let checkbox = false;
if (this.props.is_selectable === true) {
@ -203,7 +203,7 @@ const ListingItem = React.createClass({
const ListingItems = React.createClass({
render: function () {
render: function render() {
if (this.props.items.length === 0) {
let message;
if (this.props.loading === true) {
@ -301,7 +301,7 @@ const Listing = React.createClass({
contextTypes: {
router: React.PropTypes.object.isRequired,
},
getInitialState: function () {
getInitialState: function getInitialState() {
return {
loading: false,
search: '',
@ -320,12 +320,12 @@ const Listing = React.createClass({
meta: {},
};
},
getParam: function (param) {
getParam: function getParam(param) {
const regex = /(.*)\[(.*)\]/;
const matches = regex.exec(param);
return [matches[1], matches[2]];
},
initWithParams: function (params) {
initWithParams: function initWithParams(params) {
const state = this.getInitialState();
// check for url params
if (params.splat) {
@ -366,7 +366,7 @@ const Listing = React.createClass({
this.getItems();
});
},
getParams: function () {
getParams: function getParams() {
// get all route parameters (without the "splat")
const params = _.omit(this.props.params, 'splat');
// TODO:
@ -377,7 +377,7 @@ const Listing = React.createClass({
}
return params;
},
setParams: function () {
setParams: function setParams() {
if (this.props.location) {
const params = Object.keys(this.state)
.filter(key => (
@ -414,7 +414,7 @@ const Listing = React.createClass({
}
}
},
getUrlWithParams: function (params) {
getUrlWithParams: function getUrlWithParams(params) {
let baseUrl = (this.props.base_url !== undefined)
? this.props.base_url
: null;
@ -425,7 +425,7 @@ const Listing = React.createClass({
}
return `/${params}`;
},
setBaseUrlParams: function (baseUrl) {
setBaseUrlParams: function setBaseUrlParams(baseUrl) {
let ret = baseUrl;
if (ret.indexOf(':') !== -1) {
const params = this.getParams();
@ -438,7 +438,7 @@ const Listing = React.createClass({
return ret;
},
componentDidMount: function () {
componentDidMount: function componentDidMount() {
if (this.isMounted()) {
const params = this.props.params || {};
this.initWithParams(params);
@ -450,11 +450,11 @@ const Listing = React.createClass({
}
}
},
componentWillReceiveProps: function (nextProps) {
componentWillReceiveProps: function componentWillReceiveProps(nextProps) {
const params = nextProps.params || {};
this.initWithParams(params);
},
getItems: function () {
getItems: function getItems() {
if (this.isMounted()) {
this.setState({ loading: true });
@ -505,7 +505,7 @@ const Listing = React.createClass({
});
}
},
handleRestoreItem: function (id) {
handleRestoreItem: function handleRestoreItem(id) {
this.setState({
loading: true,
page: 1,
@ -533,7 +533,7 @@ const Listing = React.createClass({
);
});
},
handleTrashItem: function (id) {
handleTrashItem: function handleTrashItem(id) {
this.setState({
loading: true,
page: 1,
@ -561,7 +561,7 @@ const Listing = React.createClass({
);
});
},
handleDeleteItem: function (id) {
handleDeleteItem: function handleDeleteItem(id) {
this.setState({
loading: true,
page: 1,
@ -589,7 +589,7 @@ const Listing = React.createClass({
);
});
},
handleEmptyTrash: function () {
handleEmptyTrash: function handleEmptyTrash() {
return this.handleBulkAction('all', {
action: 'delete',
group: 'trash',
@ -609,7 +609,7 @@ const Listing = React.createClass({
);
});
},
handleBulkAction: function (selectedIds, params) {
handleBulkAction: function handleBulkAction(selectedIds, params) {
if (
this.state.selection === false
&& this.state.selected_ids.length === 0
@ -649,7 +649,7 @@ const Listing = React.createClass({
}
});
},
handleSearch: function (search) {
handleSearch: function handleSearch(search) {
this.setState({
search: search,
page: 1,
@ -659,7 +659,7 @@ const Listing = React.createClass({
this.setParams();
});
},
handleSort: function (sortBy, sortOrder = 'asc') {
handleSort: function handleSort(sortBy, sortOrder = 'asc') {
this.setState({
sort_by: sortBy,
sort_order: (sortOrder === 'asc') ? 'asc' : 'desc',
@ -667,7 +667,7 @@ const Listing = React.createClass({
this.setParams();
});
},
handleSelectItem: function (id, isChecked) {
handleSelectItem: function handleSelectItem(id, isChecked) {
let selectedIds = this.state.selected_ids;
let selection = false;
@ -688,7 +688,7 @@ const Listing = React.createClass({
selected_ids: selectedIds,
});
},
handleSelectItems: function (isChecked) {
handleSelectItems: function handleSelectItems(isChecked) {
if (isChecked === false) {
this.clearSelection();
} else {
@ -700,7 +700,7 @@ const Listing = React.createClass({
});
}
},
handleSelectAll: function () {
handleSelectAll: function handleSelectAll() {
if (this.state.selection === 'all') {
this.clearSelection();
} else {
@ -710,13 +710,13 @@ const Listing = React.createClass({
});
}
},
clearSelection: function () {
clearSelection: function clearSelection() {
this.setState({
selection: false,
selected_ids: [],
});
},
handleFilter: function (filters) {
handleFilter: function handleFilter(filters) {
this.setState({
filter: filters,
page: 1,
@ -724,7 +724,7 @@ const Listing = React.createClass({
this.setParams();
});
},
handleGroup: function (group) {
handleGroup: function handleGroup(group) {
// reset search
jQuery('#search_input').val('');
@ -737,7 +737,7 @@ const Listing = React.createClass({
this.setParams();
});
},
handleSetPage: function (page) {
handleSetPage: function handleSetPage(page) {
this.setState({
page: page,
selection: false,
@ -746,14 +746,14 @@ const Listing = React.createClass({
this.setParams();
});
},
handleRenderItem: function (item, actions) {
handleRenderItem: function handleRenderItem(item, actions) {
const render = this.props.onRenderItem(item, actions, this.state.meta);
return render.props.children;
},
handleRefreshItems: function () {
handleRefreshItems: function handleRefreshItems() {
this.getItems();
},
render: function () {
render: function render() {
const items = this.state.items;
const sortBy = this.state.sort_by;
const sortOrder = this.state.sort_order;

View File

@ -8,54 +8,54 @@ define([
MailPoet
) => {
const ListingPages = React.createClass({
getInitialState: function () {
getInitialState: function getInitialState() {
return {
page: null,
};
},
setPage: function (page) {
setPage: function setPage(page) {
this.setState({
page: null,
}, () => {
this.props.onSetPage(this.constrainPage(page));
});
},
setFirstPage: function () {
setFirstPage: function setFirstPage() {
this.setPage(1);
},
setLastPage: function () {
setLastPage: function setLastPage() {
this.setPage(this.getLastPage());
},
setPreviousPage: function () {
setPreviousPage: function setPreviousPage() {
this.setPage(this.constrainPage(
parseInt(this.props.page, 10) - 1)
);
},
setNextPage: function () {
setNextPage: function setNextPage() {
this.setPage(this.constrainPage(
parseInt(this.props.page, 10) + 1)
);
},
constrainPage: function (page) {
constrainPage: function constrainPage(page) {
return Math.min(Math.max(1, Math.abs(Number(page))), this.getLastPage());
},
handleSetManualPage: function (e) {
handleSetManualPage: function handleSetManualPage(e) {
if (e.which === 13) {
this.setPage(this.state.page);
}
},
handleChangeManualPage: function (e) {
handleChangeManualPage: function handleChangeManualPage(e) {
this.setState({
page: e.target.value,
});
},
handleBlurManualPage: function (e) {
handleBlurManualPage: function handleBlurManualPage(e) {
this.setPage(e.target.value);
},
getLastPage: function () {
getLastPage: function getLastPage() {
return Math.ceil(this.props.count / this.props.limit);
},
render: function () {
render: function render() {
if (this.props.count === 0) {
return false;
}

View File

@ -6,16 +6,16 @@ define([
React
) => {
const ListingSearch = React.createClass({
handleSearch: function (e) {
handleSearch: function handleSearch(e) {
e.preventDefault();
this.props.onSearch(
this.search.value.trim()
);
},
componentWillReceiveProps: function (nextProps) {
componentWillReceiveProps: function componentWillReceiveProps(nextProps) {
this.search.value = nextProps.search;
},
render: function () {
render: function render() {
if (this.props.search === false) {
return false;
}

View File

@ -14,7 +14,7 @@ define(
const Link = Router.Link;
const Breadcrumb = React.createClass({
getInitialState: function () {
getInitialState: function getInitialState() {
const steps = this.props.steps || [
{
name: 'type',
@ -39,7 +39,7 @@ define(
steps: steps,
};
},
render: function () {
render: function render() {
const steps = this.state.steps.map((step, index) => {
const stepClasses = classNames(
{ mailpoet_current: (this.props.step === step.name) }

View File

@ -10,7 +10,7 @@ import Hooks from 'wp-js-hooks';
import StatsBadge from 'newsletters/badges/stats.jsx';
const QueueMixin = {
pauseSending: function (newsletter) {
pauseSending: function pauseSending(newsletter) {
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'sendingQueue',
@ -30,7 +30,7 @@ const QueueMixin = {
}
});
},
resumeSending: function (newsletter) {
resumeSending: function resumeSending(newsletter) {
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'sendingQueue',
@ -50,7 +50,7 @@ const QueueMixin = {
}
});
},
renderQueueStatus: function (newsletter, mailerLog) {
renderQueueStatus: function renderQueueStatus(newsletter, mailerLog) {
if (!newsletter.queue) {
return (
<span>{MailPoet.I18n.t('notSentYet')}</span>
@ -142,15 +142,15 @@ const QueueMixin = {
},
};
const trackStatsCTAClicked = function () {
function trackStatsCTAClicked() {
MailPoet.trackEvent(
'User has clicked a CTA to view detailed stats',
{ 'MailPoet Free version': window.mailpoet_version }
);
};
}
const StatisticsMixin = {
renderStatistics: function (newsletter, isSent, currentTime) {
renderStatistics: function renderStatistics(newsletter, isSent, currentTime) {
let sent = isSent;
if (sent === undefined) {
// condition for standard and post notification listings
@ -324,20 +324,20 @@ const StatisticsMixin = {
</div>
);
},
addStatsCTAAction: function (actions) {
addStatsCTAAction: function addStatsCTAAction(actions) {
if (window.mailpoet_premium_active) {
return actions;
}
actions.unshift({
name: 'stats',
link: function () {
link: function link() {
return (
<a href={'admin.php?page=mailpoet-premium'} onClick={trackStatsCTAClicked}>
{MailPoet.I18n.t('statsListingActionTitle')}
</a>
);
},
display: function (newsletter) {
display: function display(newsletter) {
// welcome emails provide explicit total_sent value
const countProcessed = newsletter.queue && newsletter.queue.count_processed;
return Number(newsletter.total_sent || countProcessed) > 0;
@ -345,7 +345,7 @@ const StatisticsMixin = {
});
return actions;
},
addStatsCTALink: function (params) {
addStatsCTALink: function addStatsCTALink(params) {
if (window.mailpoet_premium_active) {
return params;
}
@ -358,7 +358,7 @@ const StatisticsMixin = {
};
const MailerMixin = {
checkMailerStatus: function (state) {
checkMailerStatus: function checkMailerStatus(state) {
if (state.meta.mta_log.error && state.meta.mta_log.status === 'paused') {
MailPoet.Notice.error(
'',

View File

@ -102,7 +102,7 @@ const bulkActions = [
const newsletterActions = [
{
name: 'view',
link: function (newsletter) {
link: function link(newsletter) {
return (
<a href={newsletter.preview_url} target="_blank">
{MailPoet.I18n.t('preview')}
@ -112,7 +112,7 @@ const newsletterActions = [
},
{
name: 'edit',
link: function (newsletter) {
link: function link(newsletter) {
return (
<a href={`?page=mailpoet-newsletter-editor&id=${newsletter.id}`}>
{MailPoet.I18n.t('edit')}
@ -123,7 +123,7 @@ const newsletterActions = [
{
name: 'duplicate',
label: MailPoet.I18n.t('duplicate'),
onClick: function (newsletter, refresh) {
onClick: function onClick(newsletter, refresh) {
return MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'newsletters',
@ -155,7 +155,7 @@ const newsletterActions = [
const NewsletterListNotification = React.createClass({
mixins: [MailerMixin],
updateStatus: function (e) {
updateStatus: function updateStatus(e) {
// make the event persist so that we can still override the selected value
// in the ajax callback
e.persist();
@ -181,7 +181,7 @@ const NewsletterListNotification = React.createClass({
e.target.value = response.status;
});
},
renderStatus: function (newsletter) {
renderStatus: function renderStatus(newsletter) {
return (
<select
data-id={newsletter.id}
@ -193,7 +193,7 @@ const NewsletterListNotification = React.createClass({
</select>
);
},
renderSettings: function (newsletter) {
renderSettings: function renderSettings(newsletter) {
let sendingFrequency;
// get list of segments' name
@ -261,7 +261,7 @@ const NewsletterListNotification = React.createClass({
</span>
);
},
renderHistoryLink: function (newsletter) {
renderHistoryLink: function renderHistoryLink(newsletter) {
const childrenCount = Number((newsletter.children_count));
if (childrenCount === 0) {
return (
@ -274,7 +274,7 @@ const NewsletterListNotification = React.createClass({
>{ MailPoet.I18n.t('viewHistory') }</Link>
);
},
renderItem: function (newsletter, actions) {
renderItem: function renderItem(newsletter, actions) {
const rowClasses = classNames(
'manage-column',
'column-primary',
@ -307,7 +307,7 @@ const NewsletterListNotification = React.createClass({
</div>
);
},
render: function () {
render: function render() {
return (
<div>
<h1 className="title">

View File

@ -42,7 +42,7 @@ const columns = [
let newsletterActions = [
{
name: 'view',
link: function (newsletter) {
link: function link(newsletter) {
return (
<a href={newsletter.preview_url} target="_blank">
{MailPoet.I18n.t('preview')}
@ -57,7 +57,7 @@ newsletterActions = Hooks.applyFilters('mailpoet_newsletters_listings_notificati
const NewsletterListNotificationHistory = React.createClass({
mixins: [QueueMixin, StatisticsMixin, MailerMixin],
renderItem: function (newsletter, actions, meta) {
renderItem: function renderItem(newsletter, actions, meta) {
const rowClasses = classNames(
'manage-column',
'column-primary',
@ -94,7 +94,7 @@ const NewsletterListNotificationHistory = React.createClass({
</div>
);
},
render: function () {
render: function render() {
return (
<div>
<h1 className="title">

View File

@ -122,7 +122,7 @@ const confirmEdit = (newsletter) => {
let newsletterActions = [
{
name: 'view',
link: function (newsletter) {
link: function link(newsletter) {
return (
<a href={newsletter.preview_url} target="_blank">
{MailPoet.I18n.t('preview')}
@ -138,7 +138,7 @@ let newsletterActions = [
{
name: 'duplicate',
label: MailPoet.I18n.t('duplicate'),
onClick: function (newsletter, refresh) {
onClick: function onClick(newsletter, refresh) {
return MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'newsletters',
@ -173,7 +173,7 @@ newsletterActions = Hooks.applyFilters('mailpoet_newsletters_listings_standard_a
const NewsletterListStandard = React.createClass({
mixins: [QueueMixin, StatisticsMixin, MailerMixin],
renderItem: function (newsletter, actions, meta) {
renderItem: function renderItem(newsletter, actions, meta) {
const rowClasses = classNames(
'manage-column',
'column-primary',
@ -211,7 +211,7 @@ const NewsletterListStandard = React.createClass({
</div>
);
},
render: function () {
render: function render() {
return (
<div>
<h1 className="title">

View File

@ -101,7 +101,7 @@ const bulkActions = [
let newsletterActions = [
{
name: 'view',
link: function (newsletter) {
link: function link(newsletter) {
return (
<a href={newsletter.preview_url} target="_blank">
{MailPoet.I18n.t('preview')}
@ -111,7 +111,7 @@ let newsletterActions = [
},
{
name: 'edit',
link: function (newsletter) {
link: function link(newsletter) {
return (
<a href={`?page=mailpoet-newsletter-editor&id=${newsletter.id}`}>
{MailPoet.I18n.t('edit')}
@ -129,7 +129,7 @@ newsletterActions = Hooks.applyFilters('mailpoet_newsletters_listings_welcome_no
const NewsletterListWelcome = React.createClass({
mixins: [StatisticsMixin, MailerMixin],
updateStatus: function (e) {
updateStatus: function updateStatus(e) {
// make the event persist so that we can still override the selected value
// in the ajax callback
e.persist();
@ -155,7 +155,7 @@ const NewsletterListWelcome = React.createClass({
e.target.value = response.status;
});
},
renderStatus: function (newsletter) {
renderStatus: function renderStatus(newsletter) {
const totalSent = (
MailPoet.I18n.t('sentToXSubscribers')
.replace('%$1d', newsletter.total_sent.toLocaleString())
@ -177,7 +177,7 @@ const NewsletterListWelcome = React.createClass({
</div>
);
},
renderSettings: function (newsletter) {
renderSettings: function renderSettings(newsletter) {
let sendingEvent;
let sendingDelay;
let segment;
@ -254,7 +254,7 @@ const NewsletterListWelcome = React.createClass({
</span>
);
},
renderItem: function (newsletter, actions) {
renderItem: function renderItem(newsletter, actions) {
const rowClasses = classNames(
'manage-column',
'column-primary',
@ -292,7 +292,7 @@ const NewsletterListWelcome = React.createClass({
</div>
);
},
render: function () {
render: function render() {
return (
<div>
<h1 className="title">

View File

@ -31,41 +31,41 @@ define(
contextTypes: {
router: React.PropTypes.object.isRequired,
},
getInitialState: function () {
getInitialState: function getInitialState() {
return {
fields: [],
item: {},
loading: false,
};
},
getFieldsByNewsletter: function (newsletter) {
getFieldsByNewsletter: function getFieldsByNewsletter(newsletter) {
const type = this.getSubtype(newsletter);
return type.getFields(newsletter);
},
getSendButtonOptions: function () {
getSendButtonOptions: function getSendButtonOptions() {
const type = this.getSubtype(this.state.item);
return type.getSendButtonOptions(this.state.item);
},
getSubtype: function (newsletter) {
getSubtype: function getSubtype(newsletter) {
switch (newsletter.type) {
case 'notification': return NotificationNewsletterFields;
case 'welcome': return WelcomeNewsletterFields;
default: return StandardNewsletterFields;
}
},
isValid: function () {
isValid: function isValid() {
return jQuery('#mailpoet_newsletter').parsley().isValid();
},
componentDidMount: function () {
componentDidMount: function componentDidMount() {
if (this.isMounted()) {
this.loadItem(this.props.params.id);
}
jQuery('#mailpoet_newsletter').parsley();
},
componentWillReceiveProps: function (props) {
componentWillReceiveProps: function componentWillReceiveProps(props) {
this.loadItem(props.params.id);
},
loadItem: function (id) {
loadItem: function loadItem(id) {
this.setState({ loading: true });
MailPoet.Ajax.post({
@ -90,9 +90,9 @@ define(
});
});
},
saveTemplate: function (response, done) {
saveTemplate: function saveTemplate(response, done) {
Thumbnail.fromUrl(response.meta.preview_url)
.then(function (thumbnail) {
.then(function saveTemplateAjax(thumbnail) {
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'newsletterTemplates',
@ -109,7 +109,7 @@ define(
})
.catch(err => this.showError({ errors: [err] }));
},
handleSend: function (e) {
handleSend: function handleSend(e) {
e.preventDefault();
if (!this.isValid()) {
@ -211,7 +211,7 @@ define(
}
return false;
},
handleResume: function (e) {
handleResume: function handleResume(e) {
e.preventDefault();
if (!this.isValid()) {
jQuery('#mailpoet_newsletter').parsley().validate();
@ -247,7 +247,7 @@ define(
}
return false;
},
handleSave: function (e) {
handleSave: function handleSave(e) {
e.preventDefault();
this.saveNewsletter(e).done(() => {
@ -258,7 +258,7 @@ define(
this.context.router.push(`/${this.state.item.type || ''}`);
}).fail(this.showError);
},
handleRedirectToDesign: function (e) {
handleRedirectToDesign: function handleRedirectToDesign(e) {
e.preventDefault();
const redirectTo = e.target.href;
@ -270,7 +270,7 @@ define(
window.location = redirectTo;
}).fail(this.showError);
},
saveNewsletter: function () {
saveNewsletter: function saveNewsletter() {
const data = this.state.item;
data.queue = undefined;
this.setState({ loading: true });
@ -302,7 +302,7 @@ define(
);
}
},
handleFormChange: function (e) {
handleFormChange: function handleFormChange(e) {
const item = this.state.item;
const field = e.target.name;
@ -313,7 +313,7 @@ define(
});
return true;
},
render: function () {
render: function render() {
const isPaused = this.state.item.status === 'sending'
&& this.state.item.queue
&& this.state.item.queue.status === 'paused';

View File

@ -38,13 +38,13 @@ define(
api_version: window.mailpoet_api_version,
endpoint: 'segments',
multiple: true,
filter: function (segment) {
filter: function filter(segment) {
return !segment.deleted_at;
},
getLabel: function (segment) {
getLabel: function getLabel(segment) {
return `${segment.name} (${parseInt(segment.subscribers, 10).toLocaleString()})`;
},
transformChangedValue: function (segmentIds) {
transformChangedValue: function transformChangedValue(segmentIds) {
const allSegments = this.getItems();
return _.map(segmentIds, id => _.find(allSegments, segment => segment.id === id));
},
@ -103,10 +103,10 @@ define(
fields = Hooks.applyFilters('mailpoet_newsletters_3rd_step_fields', fields);
return {
getFields: function () {
getFields: function getFields() {
return fields;
},
getSendButtonOptions: function () {
getSendButtonOptions: function getSendButtonOptions() {
return {
value: MailPoet.I18n.t('activate'),
};

View File

@ -84,7 +84,7 @@ define(
};
const DateText = React.createClass({
onChange: function (event) {
onChange: function onChange(event) {
const changeEvent = event;
// Swap display format to storage format
const displayDate = changeEvent.target.value;
@ -93,19 +93,19 @@ define(
changeEvent.target.value = storageDate;
this.props.onChange(changeEvent);
},
componentDidMount: function () {
componentDidMount: function componentDidMount() {
const $element = jQuery(this.dateInput);
const that = this;
if ($element.datepicker) {
// Override jQuery UI datepicker Date parsing and formatting
jQuery.datepicker.parseDate = function (format, value) {
jQuery.datepicker.parseDate = function parseDate(format, value) {
// Transform string format to Date object
return MailPoet.Date.toDate(value, {
parseFormat: dateDisplayFormat,
format: format,
});
};
jQuery.datepicker.formatDate = function (format, value) {
jQuery.datepicker.formatDate = function formatDate(format, value) {
// Transform Date object to string format
const newValue = MailPoet.Date.format(value, {
format: format,
@ -116,7 +116,7 @@ define(
$element.datepicker(_.extend({
dateFormat: this.props.displayFormat,
isRTL: false,
onSelect: function (value) {
onSelect: function onSelect(value) {
that.onChange({
target: {
name: that.getFieldName(),
@ -129,27 +129,27 @@ define(
this.datepickerInitialized = true;
}
},
componentWillUnmount: function () {
componentWillUnmount: function componentWillUnmount() {
if (this.datepickerInitialized) {
jQuery(this.dateInput).datepicker('destroy');
}
},
getFieldName: function () {
getFieldName: function getFieldName() {
return this.props.name || 'date';
},
getDisplayDate: function (date) {
getDisplayDate: function getDisplayDate(date) {
return MailPoet.Date.format(date, {
parseFormat: this.props.storageFormat,
format: this.props.displayFormat,
});
},
getStorageDate: function (date) {
getStorageDate: function getStorageDate(date) {
return MailPoet.Date.format(date, {
parseFormat: this.props.displayFormat,
format: this.props.storageFormat,
});
},
render: function () {
render: function render() {
return (
<input
type="text"
@ -167,7 +167,7 @@ define(
});
const TimeSelect = React.createClass({
render: function () {
render: function render() {
const options = Object.keys(timeOfDayItems).map(
(value, index) => (
<option
@ -195,13 +195,13 @@ define(
const DateTime = React.createClass({
DATE_TIME_SEPARATOR: ' ',
getInitialState: function () {
getInitialState: function getInitialState() {
return this.buildStateFromProps(this.props);
},
componentWillReceiveProps: function (nextProps) {
componentWillReceiveProps: function componentWillReceiveProps(nextProps) {
this.setState(this.buildStateFromProps(nextProps));
},
buildStateFromProps: function (props) {
buildStateFromProps: function buildStateFromProps(props) {
const value = props.value || defaultDateTime;
const [date, time] = value.split(this.DATE_TIME_SEPARATOR);
return {
@ -209,15 +209,13 @@ define(
time: time,
};
},
handleChange: function (event) {
handleChange: function handleChange(event) {
const newState = {};
newState[event.target.name] = event.target.value;
this.setState(newState, function () {
this.propagateChange();
});
this.setState(newState, this.propagateChange);
},
propagateChange: function () {
propagateChange: function propagateChange() {
if (this.props.onChange) {
this.props.onChange({
target: {
@ -227,10 +225,10 @@ define(
});
}
},
getDateTime: function () {
getDateTime: function getDateTime() {
return [this.state.date, this.state.time].join(this.DATE_TIME_SEPARATOR);
},
render: function () {
render: function render() {
return (
<span>
<DateText
@ -255,7 +253,7 @@ define(
});
const StandardScheduling = React.createClass({
getCurrentValue: function () {
getCurrentValue: function getCurrentValue() {
return _.defaults(
this.props.item[this.props.field.name] || {},
{
@ -264,7 +262,7 @@ define(
}
);
},
handleValueChange: function (event) {
handleValueChange: function handleValueChange(event) {
const oldValue = this.getCurrentValue();
const newValue = {};
newValue[event.target.name] = event.target.value;
@ -276,22 +274,22 @@ define(
},
});
},
handleCheckboxChange: function (event) {
handleCheckboxChange: function handleCheckboxChange(event) {
const changeEvent = event;
changeEvent.target.value = this.isScheduledInput.checked ? '1' : '0';
return this.handleValueChange(changeEvent);
},
isScheduled: function () {
isScheduled: function isScheduled() {
return this.getCurrentValue().isScheduled === '1';
},
getDateValidation: function () {
getDateValidation: function getDateValidation() {
return {
'data-parsley-required': true,
'data-parsley-required-message': MailPoet.I18n.t('noScheduledDateError'),
'data-parsley-errors-container': '#mailpoet_scheduling',
};
},
render: function () {
render: function render() {
let schedulingOptions;
if (this.isScheduled()) {
@ -350,13 +348,13 @@ define(
api_version: window.mailpoet_api_version,
endpoint: 'segments',
multiple: true,
filter: function (segment) {
filter: function filter(segment) {
return !segment.deleted_at;
},
getLabel: function (segment) {
getLabel: function getLabel(segment) {
return `${segment.name} (${parseInt(segment.subscribers, 10).toLocaleString()})`;
},
transformChangedValue: function (segmentIds) {
transformChangedValue: function transformChangedValue(segmentIds) {
const allSegments = this.getItems();
return _.map(segmentIds, id => _.find(allSegments, segment => segment.id === id));
},
@ -421,10 +419,10 @@ define(
fields = Hooks.applyFilters('mailpoet_newsletters_3rd_step_fields', fields);
return {
getFields: function () {
getFields: function getFields() {
return fields;
},
getSendButtonOptions: function (newsletter) {
getSendButtonOptions: function getSendButtonOptions(newsletter) {
const newsletterOptions = newsletter || {};
const isScheduled = (

View File

@ -76,10 +76,10 @@ define(
fields = Hooks.applyFilters('mailpoet_newsletters_3rd_step_fields', fields);
return {
getFields: function () {
getFields: function getFields() {
return fields;
},
getSendButtonOptions: function () {
getSendButtonOptions: function getSendButtonOptions() {
return {
value: MailPoet.I18n.t('activate'),
};

View File

@ -19,7 +19,7 @@ define(
contextTypes: {
router: React.PropTypes.object.isRequired,
},
setupNewsletter: function (type) {
setupNewsletter: function setupNewsletter(type) {
if (type !== undefined) {
this.context.router.push(`/new/${type}`);
MailPoet.trackEvent('Emails > Type selected', {
@ -28,7 +28,7 @@ define(
});
}
},
createNewsletter: function (type) {
createNewsletter: function createNewsletter(type) {
MailPoet.trackEvent('Emails > Type selected', {
'MailPoet Free version': window.mailpoet_version,
'Email type': type,
@ -52,7 +52,7 @@ define(
}
});
},
getAutomaticEmails: function () {
getAutomaticEmails: function getAutomaticEmails() {
if (!window.mailpoet_automatic_emails) return [];
return _.map(window.mailpoet_automatic_emails, (automaticEmail) => {
@ -73,13 +73,13 @@ define(
return email;
});
},
render: function () {
render: function render() {
const defaultTypes = [
{
slug: 'standard',
title: MailPoet.I18n.t('regularNewsletterTypeTitle'),
description: MailPoet.I18n.t('regularNewsletterTypeDescription'),
action: function () {
action: function action() {
return (
<a
className="button button-primary"
@ -97,7 +97,7 @@ define(
slug: 'welcome',
title: MailPoet.I18n.t('welcomeNewsletterTypeTitle'),
description: MailPoet.I18n.t('welcomeNewsletterTypeDescription'),
action: (function () {
action: (function action() {
return (
<div>
<a href="?page=mailpoet-premium" target="_blank">
@ -111,7 +111,7 @@ define(
slug: 'notification',
title: MailPoet.I18n.t('postNotificationNewsletterTypeTitle'),
description: MailPoet.I18n.t('postNotificationNewsletterTypeDescription'),
action: function () {
action: function action() {
return (
<a
className="button button-primary"

View File

@ -25,7 +25,7 @@ define(
contextTypes: {
router: React.PropTypes.object.isRequired,
},
getInitialState: function () {
getInitialState: function getInitialState() {
return {
options: {
intervalType: 'daily',
@ -36,12 +36,12 @@ define(
},
};
},
handleValueChange: function (event) {
handleValueChange: function handleValueChange(event) {
const state = this.state;
state[event.target.name] = event.target.value;
this.setState(state);
},
handleNext: function () {
handleNext: function handleNext() {
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'newsletters',
@ -61,10 +61,10 @@ define(
}
});
},
showTemplateSelection: function (newsletterId) {
showTemplateSelection: function showTemplateSelection(newsletterId) {
this.context.router.push(`/template/${newsletterId}`);
},
render: function () {
render: function render() {
return (
<div>
<h1>{MailPoet.I18n.t('postNotificationNewsletterTypeTitle')}</h1>

View File

@ -35,10 +35,10 @@ const nthWeekDayField = {
};
const NotificationScheduling = React.createClass({
getCurrentValue: function () {
getCurrentValue: function getCurrentValue() {
return (this.props.item[this.props.field.name] || {});
},
handleValueChange: function (name, value) {
handleValueChange: function handleValueChange(name, value) {
const oldValue = this.getCurrentValue();
const newValue = {};
@ -51,37 +51,37 @@ const NotificationScheduling = React.createClass({
},
});
},
handleIntervalChange: function (event) {
handleIntervalChange: function handleIntervalChange(event) {
return this.handleValueChange(
'intervalType',
event.target.value
);
},
handleTimeOfDayChange: function (event) {
handleTimeOfDayChange: function handleTimeOfDayChange(event) {
return this.handleValueChange(
'timeOfDay',
event.target.value
);
},
handleWeekDayChange: function (event) {
handleWeekDayChange: function handleWeekDayChange(event) {
return this.handleValueChange(
'weekDay',
event.target.value
);
},
handleMonthDayChange: function (event) {
handleMonthDayChange: function handleMonthDayChange(event) {
return this.handleValueChange(
'monthDay',
event.target.value
);
},
handleNthWeekDayChange: function (event) {
handleNthWeekDayChange: function handleNthWeekDayChange(event) {
return this.handleValueChange(
'nthWeekDay',
event.target.value
);
},
render: function () {
render: function render() {
const value = this.getCurrentValue();
let timeOfDaySelection;
let weekDaySelection;

View File

@ -15,10 +15,10 @@ define(
contextTypes: {
router: React.PropTypes.object.isRequired,
},
showTemplateSelection: function (newsletterId) {
showTemplateSelection: function showTemplateSelection(newsletterId) {
this.context.router.push(`/template/${newsletterId}`);
},
componentDidMount: function () {
componentDidMount: function componentDidMount() {
// No options for this type, create a newsletter upon mounting
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
@ -38,7 +38,7 @@ define(
}
});
},
render: function () {
render: function render() {
return (
<div>
<h1>{MailPoet.I18n.t('regularNewsletterTypeTitle')}</h1>

View File

@ -51,10 +51,10 @@ const WelcomeScheduling = React.createClass({
contextTypes: {
router: React.PropTypes.object.isRequired,
},
getCurrentValue: function () {
getCurrentValue: function getCurrentValue() {
return (this.props.item[this.props.field.name] || {});
},
handleValueChange: function (name, value) {
handleValueChange: function handleValueChange(name, value) {
const oldValue = this.getCurrentValue();
const newValue = {};
@ -67,37 +67,37 @@ const WelcomeScheduling = React.createClass({
},
});
},
handleEventChange: function (event) {
handleEventChange: function handleEventChange(event) {
return this.handleValueChange(
'event',
event.target.value
);
},
handleSegmentChange: function (event) {
handleSegmentChange: function handleSegmentChange(event) {
return this.handleValueChange(
'segment',
event.target.value
);
},
handleRoleChange: function (event) {
handleRoleChange: function handleRoleChange(event) {
return this.handleValueChange(
'role',
event.target.value
);
},
handleAfterTimeNumberChange: function (event) {
handleAfterTimeNumberChange: function handleAfterTimeNumberChange(event) {
return this.handleValueChange(
'afterTimeNumber',
event.target.value
);
},
handleAfterTimeTypeChange: function (event) {
handleAfterTimeTypeChange: function handleAfterTimeTypeChange(event) {
return this.handleValueChange(
'afterTimeType',
event.target.value
);
},
handleNext: function () {
handleNext: function handleNext() {
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'newsletters',
@ -117,10 +117,10 @@ const WelcomeScheduling = React.createClass({
}
});
},
showTemplateSelection: function (newsletterId) {
showTemplateSelection: function showTemplateSelection(newsletterId) {
this.context.router.push(`/template/${newsletterId}`);
},
render: function () {
render: function render() {
const value = this.getCurrentValue();
let roleSegmentSelection;
let timeNumber;

View File

@ -17,7 +17,7 @@ define(
contextTypes: {
router: React.PropTypes.object.isRequired,
},
setupNewsletter: function (type) {
setupNewsletter: function setupNewsletter(type) {
if (type !== undefined) {
this.context.router.push(`/new/${type}`);
MailPoet.trackEvent('Emails > Type selected', {
@ -26,7 +26,7 @@ define(
});
}
},
createNewsletter: function (type) {
createNewsletter: function createNewsletter(type) {
MailPoet.trackEvent('Emails > Type selected', {
'MailPoet Free version': window.mailpoet_version,
'Email type': type,
@ -50,7 +50,7 @@ define(
}
});
},
render: function () {
render: function render() {
const types = [
{
id: 'woocommerce',

View File

@ -26,10 +26,10 @@ define(
];
const messages = {
onUpdate: function () {
onUpdate: function onUpdate() {
MailPoet.Notice.success(MailPoet.I18n.t('segmentUpdated'));
},
onCreate: function () {
onCreate: function onCreate() {
MailPoet.Notice.success(MailPoet.I18n.t('segmentAdded'));
MailPoet.trackEvent('Lists > Add new', {
'MailPoet Free version': window.mailpoet_version,
@ -40,7 +40,7 @@ define(
const Link = Router.Link;
const SegmentForm = React.createClass({
render: function () {
render: function render() {
return (
<div>
<h1 className="title">

View File

@ -97,12 +97,12 @@ const bulkActions = [
const itemActions = [
{
name: 'edit',
link: function (item) {
link: function link(item) {
return (
<Link to={`/edit/${item.id}`}>{MailPoet.I18n.t('edit')}</Link>
);
},
display: function (segment) {
display: function display(segment) {
return (segment.type !== 'wp_users');
},
},
@ -127,13 +127,13 @@ const itemActions = [
{ scroll: true }
);
}),
display: function (segment) {
display: function display(segment) {
return (segment.type !== 'wp_users');
},
},
{
name: 'read_more',
link: function () {
link: function link() {
return (
<a
href="http://docs.mailpoet.com/article/133-the-wordpress-users-list"
@ -141,14 +141,14 @@ const itemActions = [
>{MailPoet.I18n.t('readMore')}</a>
);
},
display: function (segment) {
display: function display(segment) {
return (segment.type === 'wp_users');
},
},
{
name: 'synchronize_segment',
label: MailPoet.I18n.t('forceSync'),
onClick: function (item, refresh) {
onClick: function onClick(item, refresh) {
MailPoet.Modal.loading(true);
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
@ -170,13 +170,13 @@ const itemActions = [
}
});
},
display: function (segment) {
display: function display(segment) {
return (segment.type === 'wp_users');
},
},
{
name: 'view_subscribers',
link: function (item) {
link: function link(item) {
return (
<a href={item.subscribers_url}>{MailPoet.I18n.t('viewSubscribers')}</a>
);
@ -184,14 +184,14 @@ const itemActions = [
},
{
name: 'trash',
display: function (segment) {
display: function display(segment) {
return (segment.type !== 'wp_users');
},
},
];
const SegmentList = React.createClass({
renderItem: function (segment, actions) {
renderItem: function renderItem(segment, actions) {
const rowClasses = classNames(
'manage-column',
'column-primary',
@ -248,7 +248,7 @@ const SegmentList = React.createClass({
</div>
);
},
render: function () {
render: function render() {
return (
<div>
<h1 className="title">

View File

@ -18,7 +18,7 @@ define(
name: 'email',
label: MailPoet.I18n.t('email'),
type: 'text',
disabled: function (subscriber) {
disabled: function disabled(subscriber) {
return Number(subscriber.wp_user_id > 0);
},
},
@ -26,7 +26,7 @@ define(
name: 'first_name',
label: MailPoet.I18n.t('firstname'),
type: 'text',
disabled: function (subscriber) {
disabled: function disabled(subscriber) {
return Number(subscriber.wp_user_id > 0);
},
},
@ -34,7 +34,7 @@ define(
name: 'last_name',
label: MailPoet.I18n.t('lastname'),
type: 'text',
disabled: function (subscriber) {
disabled: function disabled(subscriber) {
return Number(subscriber.wp_user_id > 0);
},
},
@ -48,7 +48,7 @@ define(
unsubscribed: MailPoet.I18n.t('unsubscribed'),
bounced: MailPoet.I18n.t('bounced'),
},
filter: function (subscriber, value) {
filter: function filter(subscriber, value) {
if (Number(subscriber.wp_user_id) > 0 && value === 'unconfirmed') {
return false;
}
@ -64,7 +64,7 @@ define(
api_version: window.mailpoet_api_version,
endpoint: 'segments',
multiple: true,
selected: function (subscriber) {
selected: function selected(subscriber) {
if (Array.isArray(subscriber.subscriptions) === false) {
return null;
}
@ -73,13 +73,13 @@ define(
.filter(subscription => subscription.status === 'subscribed')
.map(subscription => subscription.segment_id);
},
filter: function (segment) {
filter: function filter(segment) {
return (!segment.deleted_at && segment.type === 'default');
},
getLabel: function (segment) {
getLabel: function getLabel(segment) {
return `${segment.name} (${segment.subscribers})`;
},
getSearchLabel: function (segment, subscriber) {
getSearchLabel: function getSearchLabel(segment, subscriber) {
let label = '';
if (subscriber.subscriptions !== undefined) {
@ -142,10 +142,10 @@ define(
});
const messages = {
onUpdate: function () {
onUpdate: function onUpdate() {
MailPoet.Notice.success(MailPoet.I18n.t('subscriberUpdated'));
},
onCreate: function () {
onCreate: function onCreate() {
MailPoet.Notice.success(MailPoet.I18n.t('subscriberAdded'));
MailPoet.trackEvent('Subscribers > Add new', {
'MailPoet Free version': window.mailpoet_version,
@ -153,7 +153,7 @@ define(
},
};
const beforeFormContent = function (subscriber) {
function beforeFormContent(subscriber) {
if (Number(subscriber.wp_user_id) > 0) {
return (
<p className="description">
@ -172,9 +172,9 @@ define(
);
}
return undefined;
};
}
const afterFormContent = function () {
function afterFormContent() {
return (
<p className="description">
<strong>
@ -182,12 +182,12 @@ define(
</strong> { MailPoet.I18n.t('customFieldsTip') }
</p>
);
};
}
const Link = Router.Link;
const SubscriberForm = React.createClass({
render: function () {
render: function render() {
return (
<div>
<h1 className="title">

View File

@ -104,12 +104,12 @@ const bulkActions = [
{
name: 'moveToList',
label: MailPoet.I18n.t('moveToList'),
onSelect: function () {
onSelect: function onSelect() {
const field = {
id: 'move_to_segment',
api_version: window.mailpoet_api_version,
endpoint: 'segments',
filter: function (segment) {
filter: function filter(segment) {
return !!(
!segment.deleted_at && segment.type === 'default'
);
@ -120,12 +120,12 @@ const bulkActions = [
<Selection field={field} />
);
},
getData: function () {
getData: function getData() {
return {
segment_id: Number(jQuery('#move_to_segment').val()),
};
},
onSuccess: function (response) {
onSuccess: function onSuccess(response) {
MailPoet.Notice.success(
MailPoet.I18n.t('multipleSubscribersMovedToList')
.replace('%$1d', (Number(response.meta.count)).toLocaleString())
@ -136,12 +136,12 @@ const bulkActions = [
{
name: 'addToList',
label: MailPoet.I18n.t('addToList'),
onSelect: function () {
onSelect: function onSelect() {
const field = {
id: 'add_to_segment',
api_version: window.mailpoet_api_version,
endpoint: 'segments',
filter: function (segment) {
filter: function filter(segment) {
return !!(
!segment.deleted_at && segment.type === 'default'
);
@ -152,12 +152,12 @@ const bulkActions = [
<Selection field={field} />
);
},
getData: function () {
getData: function getData() {
return {
segment_id: Number(jQuery('#add_to_segment').val()),
};
},
onSuccess: function (response) {
onSuccess: function onSuccess(response) {
MailPoet.Notice.success(
MailPoet.I18n.t('multipleSubscribersAddedToList')
.replace('%$1d', (Number(response.meta.count)).toLocaleString())
@ -168,12 +168,12 @@ const bulkActions = [
{
name: 'removeFromList',
label: MailPoet.I18n.t('removeFromList'),
onSelect: function () {
onSelect: function onSelect() {
const field = {
id: 'remove_from_segment',
api_version: window.mailpoet_api_version,
endpoint: 'segments',
filter: function (segment) {
filter: function filter(segment) {
return !!(
segment.type === 'default'
);
@ -184,12 +184,12 @@ const bulkActions = [
<Selection field={field} />
);
},
getData: function () {
getData: function getData() {
return {
segment_id: Number(jQuery('#remove_from_segment').val()),
};
},
onSuccess: function (response) {
onSuccess: function onSuccess(response) {
MailPoet.Notice.success(
MailPoet.I18n.t('multipleSubscribersRemovedFromList')
.replace('%$1d', (Number(response.meta.count)).toLocaleString())
@ -200,7 +200,7 @@ const bulkActions = [
{
name: 'removeFromAllLists',
label: MailPoet.I18n.t('removeFromAllLists'),
onSuccess: function (response) {
onSuccess: function onSuccess(response) {
MailPoet.Notice.success(
MailPoet.I18n.t('multipleSubscribersRemovedFromAllLists')
.replace('%$1d', (Number(response.meta.count)).toLocaleString())
@ -210,7 +210,7 @@ const bulkActions = [
{
name: 'sendConfirmationEmail',
label: MailPoet.I18n.t('resendConfirmationEmail'),
onSuccess: function (response) {
onSuccess: function onSuccess(response) {
MailPoet.Notice.success(
MailPoet.I18n.t('multipleConfirmationEmailsSent')
.replace('%$1d', (Number(response.meta.count)).toLocaleString())
@ -228,7 +228,7 @@ const itemActions = [
{
name: 'edit',
label: MailPoet.I18n.t('edit'),
link: function (subscriber) {
link: function link(subscriber) {
return (
<Link to={`/edit/${subscriber.id}`}>{MailPoet.I18n.t('edit')}</Link>
);
@ -236,14 +236,14 @@ const itemActions = [
},
{
name: 'trash',
display: function (subscriber) {
display: function display(subscriber) {
return Number(subscriber.wp_user_id) === 0;
},
},
];
const SubscriberList = React.createClass({
getSegmentFromId: function (segmentId) {
getSegmentFromId: function getSegmentFromId(segmentId) {
let result = false;
window.mailpoet_segments.forEach((segment) => {
if (segment.id === segmentId) {
@ -252,7 +252,7 @@ const SubscriberList = React.createClass({
});
return result;
},
renderItem: function (subscriber, actions) {
renderItem: function renderItem(subscriber, actions) {
const rowClasses = classNames(
'manage-column',
'column-primary',
@ -334,7 +334,7 @@ const SubscriberList = React.createClass({
</div>
);
},
render: function () {
render: function render() {
return (
<div>
<h1 className="title">