Display number of welcome notification on listings page
[MAILPOET-1562]
This commit is contained in:
@ -193,10 +193,24 @@ const NewsletterListWelcome = createReactClass({ // eslint-disable-line react/pr
|
||||
},
|
||||
|
||||
renderStatus: function renderStatus(newsletter) {
|
||||
const totalSent = (parseInt(newsletter.total_sent, 10)) ?
|
||||
MailPoet.I18n.t('sentToXSubscribers')
|
||||
.replace('%$1d', newsletter.total_sent.toLocaleString()) :
|
||||
MailPoet.I18n.t('notSentYet');
|
||||
let totalSentMessage = MailPoet.I18n.t('notSentYet');
|
||||
const totalSent = (parseInt(newsletter.total_sent, 10));
|
||||
if (totalSent === 1) {
|
||||
totalSentMessage = MailPoet.I18n.t('sentToXSubscribers');
|
||||
}
|
||||
if (totalSent > 1) {
|
||||
totalSentMessage = MailPoet.I18n.t('sentToXSubscribersPlural')
|
||||
.replace('%$1d', newsletter.total_sent.toLocaleString());
|
||||
}
|
||||
let totalScheduledMessage = '';
|
||||
const totalScheduled = (parseInt(newsletter.total_scheduled, 10));
|
||||
if (totalScheduled === 1) {
|
||||
totalScheduledMessage = MailPoet.I18n.t('scheduledToXSubscribers');
|
||||
}
|
||||
if (totalScheduled > 1) {
|
||||
totalScheduledMessage = MailPoet.I18n.t('scheduledToXSubscribersPlural')
|
||||
.replace('%$1d', newsletter.total_sent.toLocaleString());
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
@ -210,7 +224,11 @@ const NewsletterListWelcome = createReactClass({ // eslint-disable-line react/pr
|
||||
<option value="draft">{ MailPoet.I18n.t('inactive') }</option>
|
||||
</select>
|
||||
</p>
|
||||
<p>{ totalSent }</p>
|
||||
<p>
|
||||
{ totalSentMessage }
|
||||
{ totalScheduledMessage !== '' ? <br /> : '' }
|
||||
{ totalScheduledMessage }
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
|
@ -394,6 +394,7 @@ class Newsletters extends APIEndpoint {
|
||||
$newsletter
|
||||
->withOptions()
|
||||
->withTotalSent()
|
||||
->withScheduledToBeSent()
|
||||
->withStatistics();
|
||||
} else if($newsletter->type === Newsletter::TYPE_NOTIFICATION) {
|
||||
$newsletter
|
||||
|
@ -514,6 +514,13 @@ class Newsletter extends Model {
|
||||
return $this;
|
||||
}
|
||||
|
||||
function withScheduledToBeSent() {
|
||||
$this->total_scheduled = (int)SendingQueue::findTaskByNewsletterId($this->id)
|
||||
->where('tasks.status', SendingQueue::STATUS_SCHEDULED)
|
||||
->count();
|
||||
return $this;
|
||||
}
|
||||
|
||||
function withStatistics() {
|
||||
$statistics = $this->getStatistics();
|
||||
$this->statistics = $statistics;
|
||||
|
@ -100,7 +100,10 @@
|
||||
'active': __('Active'),
|
||||
'inactive': __('Not Active'),
|
||||
'newsletterQueueCompleted': __('Sent to %$1d of %$2d'),
|
||||
'sentToXSubscribers': __('Sent to %$1d subscribers'),
|
||||
'sentToXSubscribers': _x('Sent to 1 subscriber', 'inform the number of emails already sent'),
|
||||
'sentToXSubscribersPlural': _x('Sent to %$1d subscribers', 'inform the number of emails already sent; always plural'),
|
||||
'scheduledToXSubscribers': _x('1 scheduled to be sent', 'inform the number of emails planned to be sent'),
|
||||
'scheduledToXSubscribersPlural': _x('%$1d scheduled to be sent', 'inform the number of emails planned to be sent; always plural'),
|
||||
'resume': __('Resume'),
|
||||
'pause': __('Pause'),
|
||||
'paused': __('Paused'),
|
||||
|
Reference in New Issue
Block a user