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) {
|
renderStatus: function renderStatus(newsletter) {
|
||||||
const totalSent = (parseInt(newsletter.total_sent, 10)) ?
|
let totalSentMessage = MailPoet.I18n.t('notSentYet');
|
||||||
MailPoet.I18n.t('sentToXSubscribers')
|
const totalSent = (parseInt(newsletter.total_sent, 10));
|
||||||
.replace('%$1d', newsletter.total_sent.toLocaleString()) :
|
if (totalSent === 1) {
|
||||||
MailPoet.I18n.t('notSentYet');
|
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 (
|
return (
|
||||||
<div>
|
<div>
|
||||||
@ -210,7 +224,11 @@ const NewsletterListWelcome = createReactClass({ // eslint-disable-line react/pr
|
|||||||
<option value="draft">{ MailPoet.I18n.t('inactive') }</option>
|
<option value="draft">{ MailPoet.I18n.t('inactive') }</option>
|
||||||
</select>
|
</select>
|
||||||
</p>
|
</p>
|
||||||
<p>{ totalSent }</p>
|
<p>
|
||||||
|
{ totalSentMessage }
|
||||||
|
{ totalScheduledMessage !== '' ? <br /> : '' }
|
||||||
|
{ totalScheduledMessage }
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -394,6 +394,7 @@ class Newsletters extends APIEndpoint {
|
|||||||
$newsletter
|
$newsletter
|
||||||
->withOptions()
|
->withOptions()
|
||||||
->withTotalSent()
|
->withTotalSent()
|
||||||
|
->withScheduledToBeSent()
|
||||||
->withStatistics();
|
->withStatistics();
|
||||||
} else if($newsletter->type === Newsletter::TYPE_NOTIFICATION) {
|
} else if($newsletter->type === Newsletter::TYPE_NOTIFICATION) {
|
||||||
$newsletter
|
$newsletter
|
||||||
|
@ -514,6 +514,13 @@ class Newsletter extends Model {
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function withScheduledToBeSent() {
|
||||||
|
$this->total_scheduled = (int)SendingQueue::findTaskByNewsletterId($this->id)
|
||||||
|
->where('tasks.status', SendingQueue::STATUS_SCHEDULED)
|
||||||
|
->count();
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
function withStatistics() {
|
function withStatistics() {
|
||||||
$statistics = $this->getStatistics();
|
$statistics = $this->getStatistics();
|
||||||
$this->statistics = $statistics;
|
$this->statistics = $statistics;
|
||||||
|
@ -100,7 +100,10 @@
|
|||||||
'active': __('Active'),
|
'active': __('Active'),
|
||||||
'inactive': __('Not Active'),
|
'inactive': __('Not Active'),
|
||||||
'newsletterQueueCompleted': __('Sent to %$1d of %$2d'),
|
'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'),
|
'resume': __('Resume'),
|
||||||
'pause': __('Pause'),
|
'pause': __('Pause'),
|
||||||
'paused': __('Paused'),
|
'paused': __('Paused'),
|
||||||
|
Reference in New Issue
Block a user