settings column done for welcome emails + WordPress capitalization fix

This commit is contained in:
Jonathan Labreuille
2016-06-14 19:41:17 +02:00
parent ee6e261c42
commit d6a68dd4d0
9 changed files with 84 additions and 38 deletions

View File

@ -84,7 +84,7 @@ position: relative
body
overflow-x: auto
/* Hide the "Details" section of Wordpress Media manager */
/* Hide the "Details" section of WordPress Media manager */
.media-sidebar
display: none
@ -98,7 +98,7 @@ body
.attachments-browser .uploader-inline
right: 0
/* Remove max width from date selector in Wordpress Media Manager */
/* Remove max width from date selector in WordPress Media Manager */
#media-attachment-date-filters
max-width: calc(100% - 12px)

View File

@ -10,6 +10,8 @@ import jQuery from 'jquery'
import MailPoet from 'mailpoet'
import _ from 'underscore'
const mailpoet_roles = window.mailpoet_roles || {};
const messages = {
onTrash(response) {
const count = ~~response;
@ -74,7 +76,8 @@ var columns = [
},
{
name: 'statistics',
label: MailPoet.I18n.t('statistics')
label: MailPoet.I18n.t('statistics'),
display: mailpoet_tracking_enabled
},
{
name: 'updated_at',
@ -187,12 +190,20 @@ const NewsletterListWelcome = React.createClass({
);
},
renderSettings: function(newsletter) {
let settings;
let sendingEvent;
let sendingDelay;
// set sending event
switch (newsletter.options.event) {
case 'user':
// WP User
settings = MailPoet.I18n.t('onWordpressUserRegistration');
if (newsletter.options.role === 'mailpoet_all') {
sendingEvent = MailPoet.I18n.t('welcomeEventWPUserAnyRole');
} else {
sendingEvent = MailPoet.I18n.t('welcomeEventWPUserWithRole').replace(
'%$1s', mailpoet_roles[newsletter.options.role]
);
}
break;
case 'segment':
@ -201,33 +212,57 @@ const NewsletterListWelcome = React.createClass({
return (~~(segment.id) === ~~(newsletter.options.segment));
});
settings = MailPoet.I18n.t('onSubscriptionToList') + ' ' +segment.name;
sendingEvent = MailPoet.I18n.t('welcomeEventSegment').replace(
'%$1s', segment.name
);
break;
}
// set sending delay
if (newsletter.options.afterTimeType !== 'immediate') {
switch (newsletter.options.afterTimeType) {
case 'hours':
sendingDelay = MailPoet.I18n.t('sendingDelayHours').replace(
'%$1d', newsletter.options.afterTimeNumber
);
break;
case 'days':
sendingDelay = MailPoet.I18n.t('sendingDelayDays').replace(
'%$1d', newsletter.options.afterTimeNumber
);
break;
case 'weeks':
sendingDelay = MailPoet.I18n.t('sendingDelayWeeks').replace(
'%$1d', newsletter.options.afterTimeNumber
);
break;
}
sendingEvent += ' [' + sendingDelay + ']';
}
return (
<span>
{ settings }
{ sendingEvent }.
</span>
);
},
renderStatistics: function(newsletter) {
if(!newsletter.statistics || !newsletter.queue || newsletter.queue.count_processed == 0 || newsletter.queue.status === 'scheduled') {
return (
<span>
{MailPoet.I18n.t('notSentYet')}
</span>
);
if (mailpoet_tracking_enabled === false) {
return;
}
var percentage_clicked = Math.round(
(newsletter.statistics.clicked * 100) / (newsletter.queue.count_processed)
if(newsletter.statistics && newsletter.queue && newsletter.queue.status !== 'scheduled') {
const total_sent = ~~(newsletter.queue.count_processed);
const percentage_clicked = Math.round(
(~~(newsletter.statistics.clicked) * 100) / total_sent
);
var percentage_opened = Math.round(
(newsletter.statistics.opened * 100) / (newsletter.queue.count_processed)
const percentage_opened = Math.round(
(~~(newsletter.statistics.opened) * 100) / total_sent
);
var percentage_unsubscribed = Math.round(
(newsletter.statistics.unsubscribed * 100) / (newsletter.queue.count_processed)
const percentage_unsubscribed = Math.round(
(~~(newsletter.statistics.unsubscribed) * 100) / total_sent
);
return (
@ -235,6 +270,11 @@ const NewsletterListWelcome = React.createClass({
{ percentage_opened }%, { percentage_clicked }%, { percentage_unsubscribed }%
</span>
);
} else {
return (
<span>{MailPoet.I18n.t('notSentYet')}</span>
);
}
},
renderItem: function(newsletter, actions) {
var rowClasses = classNames(

View File

@ -25,7 +25,7 @@ define(
name: 'event',
values: {
'segment': MailPoet.I18n.t('onSubscriptionToList'),
'user': MailPoet.I18n.t('onWordpressUserRegistration'),
'user': MailPoet.I18n.t('onWPUserRegistration'),
}
};

View File

@ -21,7 +21,7 @@ class ShortcodesHelper {
'shortcode' => 'subscriber:email',
),
array(
'text' => __('Wordpress User Display Name'),
'text' => __('WordPress User Display Name'),
'shortcode' => 'subscriber:displayname | default:member',
),
array(

View File

@ -263,10 +263,6 @@ class Newsletters {
->withOptions()
->withTotalSent()
->withStatistics();
$options = $newsletter->options()->findArray();
$newsletter->options = Helpers::arrayColumn($options, 'value', 'name');
} else if($newsletter->type === Newsletter::TYPE_NOTIFICATION) {
$newsletter
->withSegments()

View File

@ -40,7 +40,7 @@ class DateTime {
/**
* Generates a list of time strings within an interval,
* formatted and mapped from DEFAULT_TIME_FORMAT to Wordpress time strings.
* formatted and mapped from DEFAULT_TIME_FORMAT to WordPress time strings.
*/
function getTimeInterval(
$start_time='00:00:00',

View File

@ -29,7 +29,8 @@ class WordPress extends \Codeception\Module
namespace MailPoet\WP;
function get_option($key) {
if ($callback = \Helper\Wordpress::getInterceptor('get_option'))
if($callback = \Helper\WordPress::getInterceptor('get_option')) {
return $callback($key);
}
return \get_option($key);
}

View File

@ -77,6 +77,6 @@ class DateTimeTest extends MailPoetTest {
}
function _afterStep() {
Wordpress::releaseAllFunctions();
WordPress::releaseAllFunctions();
}
}

View File

@ -137,7 +137,7 @@
'selectEventToSendWelcomeEmail': __('Select an event to send this welcome email'),
'onSubscriptionToList': __('When someone subscribes to the list...'),
'onWordpressUserRegistration': __('When a new WordPress user is added to your site...'),
'onWPUserRegistration': __('When a new WordPress user is added to your site...'),
'delayImmediately': __('immediately'),
'delayHoursAfter': __('hour(s) after'),
'delayDaysAfter': __('day(s) after'),
@ -214,6 +214,15 @@
'welcomeEmailActivated': __('Your welcome email is now active.'),
'welcomeEmailActivationFailed': __('Your welcome email could not be activated, check its settings.'),
'postNotificationActivated': __('Your post notification is now active.'),
'postNotificationActivationFailed': __('Your post notification could not be activated, check its settings.')
'postNotificationActivationFailed': __('Your post notification could not be activated, check its settings.'),
'welcomeEventSegment': __('This newsletter is sent when someone subscribes to the list "%$1s"'),
'welcomeEventWPUserAnyRole': __('This newsletter is sent when a new WordPress user is added to your site'),
'welcomeEventWPUserWithRole': __('This newsletter is sent when a new WordPress user with the role "%$1s" is added to your site'),
'sendingDelayHours': __('%$1d hour(s) later'),
'sendingDelayDays': __('%$1d day(s) later'),
'sendingDelayWeeks': __('%$1d week(s) later')
}) %>
<% endblock %>