- Formats all numbers >1000 to use comma
- Removes subscriber count from segments if its === 0 Fixes #431
This commit is contained in:
@ -21,7 +21,7 @@ define(['react', 'classnames'], function(React, classNames) {
|
|||||||
href="javascript:;"
|
href="javascript:;"
|
||||||
className={classes}
|
className={classes}
|
||||||
onClick={this.handleSelect.bind(this, group.name)} >
|
onClick={this.handleSelect.bind(this, group.name)} >
|
||||||
{group.label} <span className="count">({ group.count })</span>
|
{group.label} <span className="count">({ group.count.toLocaleString() })</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
);
|
);
|
||||||
|
@ -148,7 +148,7 @@ define([
|
|||||||
className="current-page" />
|
className="current-page" />
|
||||||
{MailPoet.I18n.t('pageOutOf')}
|
{MailPoet.I18n.t('pageOutOf')}
|
||||||
<span className="total-pages">
|
<span className="total-pages">
|
||||||
{Math.ceil(this.props.count / this.props.limit)}
|
{Math.ceil(this.props.count / this.props.limit).toLocaleString()}
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
@ -167,7 +167,7 @@ define([
|
|||||||
return (
|
return (
|
||||||
<div className={ classes }>
|
<div className={ classes }>
|
||||||
<span className="displaying-num">{
|
<span className="displaying-num">{
|
||||||
MailPoet.I18n.t('numberOfItems').replace('%$1d', this.props.count)
|
MailPoet.I18n.t('numberOfItems').replace('%$1d', this.props.count.toLocaleString())
|
||||||
}</span>
|
}</span>
|
||||||
{ pagination }
|
{ pagination }
|
||||||
</div>
|
</div>
|
||||||
|
@ -165,7 +165,11 @@ const SegmentList = React.createClass({
|
|||||||
'manage-column',
|
'manage-column',
|
||||||
'column-primary',
|
'column-primary',
|
||||||
'has-row-actions'
|
'has-row-actions'
|
||||||
);
|
),
|
||||||
|
subscribed = segment.subscribers_count.subscribed || 0,
|
||||||
|
unconfirmed = segment.subscribers_count.unconfirmed || 0,
|
||||||
|
unsubscribed = segment.subscribers_count.unsubscribed || 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<td className={ rowClasses }>
|
<td className={ rowClasses }>
|
||||||
@ -178,13 +182,13 @@ const SegmentList = React.createClass({
|
|||||||
<abbr>{ segment.description }</abbr>
|
<abbr>{ segment.description }</abbr>
|
||||||
</td>
|
</td>
|
||||||
<td className="column-date" data-colname="Subscribed">
|
<td className="column-date" data-colname="Subscribed">
|
||||||
<abbr>{ segment.subscribers_count.subscribed || 0 }</abbr>
|
<abbr>{ parseInt(subscribed).toLocaleString() }</abbr>
|
||||||
</td>
|
</td>
|
||||||
<td className="column-date" data-colname="Unconfirmed">
|
<td className="column-date" data-colname="Unconfirmed">
|
||||||
<abbr>{ segment.subscribers_count.unconfirmed || 0 }</abbr>
|
<abbr>{ parseInt(unconfirmed).toLocaleString() }</abbr>
|
||||||
</td>
|
</td>
|
||||||
<td className="column-date" data-colname="Unsubscribed">
|
<td className="column-date" data-colname="Unsubscribed">
|
||||||
<abbr>{ segment.subscribers_count.unsubscribed || 0 }</abbr>
|
<abbr>{ parseInt(unsubscribed).toLocaleString() }</abbr>
|
||||||
</td>
|
</td>
|
||||||
<td className="column-date" data-colname="Created on">
|
<td className="column-date" data-colname="Created on">
|
||||||
<abbr>{ MailPoet.Date.full(segment.created_at) }</abbr>
|
<abbr>{ MailPoet.Date.full(segment.created_at) }</abbr>
|
||||||
|
@ -490,7 +490,7 @@ define(
|
|||||||
),
|
),
|
||||||
invalid: (subscribers.invalid.length)
|
invalid: (subscribers.invalid.length)
|
||||||
? MailPoet.I18n.t('importNoticeInvalid')
|
? MailPoet.I18n.t('importNoticeInvalid')
|
||||||
.replace('%1$s', '<strong>' + subscribers.invalid.length + '</strong>')
|
.replace('%1$s', '<strong>' + subscribers.invalid.length.toLocaleString() + '</strong>')
|
||||||
.replace('%2$s', subscribers.invalid.join(', '))
|
.replace('%2$s', subscribers.invalid.join(', '))
|
||||||
: null,
|
: null,
|
||||||
duplicate: (subscribers.duplicate.length)
|
duplicate: (subscribers.duplicate.length)
|
||||||
@ -533,13 +533,15 @@ define(
|
|||||||
data: segments,
|
data: segments,
|
||||||
width: '20em',
|
width: '20em',
|
||||||
templateResult: function (item) {
|
templateResult: function (item) {
|
||||||
|
item.subscriberCount = parseInt(item.subscriberCount);
|
||||||
return (item.subscriberCount > 0)
|
return (item.subscriberCount > 0)
|
||||||
? item.name + ' (' + item.subscriberCount + ')'
|
? item.name + ' (' + item.subscriberCount.toLocaleString() + ')'
|
||||||
: item.name;
|
: item.name;
|
||||||
},
|
},
|
||||||
templateSelection: function (item) {
|
templateSelection: function (item) {
|
||||||
|
item.subscriberCount = parseInt(item.subscriberCount);
|
||||||
return (item.subscriberCount > 0)
|
return (item.subscriberCount > 0)
|
||||||
? item.name + ' (' + item.subscriberCount + ')'
|
? item.name + ' (' + item.subscriberCount.toLocaleString() + ')'
|
||||||
: item.name;
|
: item.name;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -1140,12 +1142,12 @@ define(
|
|||||||
importResults = {
|
importResults = {
|
||||||
created: (importData.step2.created)
|
created: (importData.step2.created)
|
||||||
? MailPoet.I18n.t('subscribersCreated')
|
? MailPoet.I18n.t('subscribersCreated')
|
||||||
.replace('%1$s', '<strong>' + importData.step2.created + '</strong>')
|
.replace('%1$s', '<strong>' + importData.step2.created.toLocaleString() + '</strong>')
|
||||||
.replace('%2$s', '"' + importData.step2.segments.join('", "') + '"')
|
.replace('%2$s', '"' + importData.step2.segments.join('", "') + '"')
|
||||||
: false,
|
: false,
|
||||||
updated: (importData.step2.updated)
|
updated: (importData.step2.updated)
|
||||||
? MailPoet.I18n.t('subscribersUpdated')
|
? MailPoet.I18n.t('subscribersUpdated')
|
||||||
.replace('%1$s', '<strong>' + importData.step2.updated + '</strong>')
|
.replace('%1$s', '<strong>' + importData.step2.updated.toLocaleString() + '</strong>')
|
||||||
.replace('%2$s', '"' + importData.step2.segments.join('", "') + '"')
|
.replace('%2$s', '"' + importData.step2.segments.join('", "') + '"')
|
||||||
: false,
|
: false,
|
||||||
noaction: (!importData.step2.updated && !importData.step2.created)
|
noaction: (!importData.step2.updated && !importData.step2.created)
|
||||||
|
@ -108,7 +108,9 @@ const bulk_actions = [
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
getLabel: function (segment) {
|
getLabel: function (segment) {
|
||||||
return segment.name + ' (' + segment.subscribers + ')';
|
return (segment.subscribers > 0) ?
|
||||||
|
segment.name + ' (' + parseInt(segment.subscribers).toLocaleString() + ')' :
|
||||||
|
segment.name;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -142,7 +144,9 @@ const bulk_actions = [
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
getLabel: function (segment) {
|
getLabel: function (segment) {
|
||||||
return segment.name + ' (' + segment.subscribers + ')';
|
return (segment.subscribers > 0) ?
|
||||||
|
segment.name + ' (' + parseInt(segment.subscribers).toLocaleString() + ')' :
|
||||||
|
segment.name;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -176,7 +180,9 @@ const bulk_actions = [
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
getLabel: function (segment) {
|
getLabel: function (segment) {
|
||||||
return segment.name + ' (' + segment.subscribers + ')';
|
return (segment.subscribers > 0) ?
|
||||||
|
segment.name + ' (' + parseInt(segment.subscribers).toLocaleString() + ')' :
|
||||||
|
segment.name;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ class Subscriber extends Model {
|
|||||||
static function verifyToken($email, $token) {
|
static function verifyToken($email, $token) {
|
||||||
return (self::generateToken($email) === $token);
|
return (self::generateToken($email) === $token);
|
||||||
}
|
}
|
||||||
|
|
||||||
static function subscribe($subscriber_data = array(), $segment_ids = array()) {
|
static function subscribe($subscriber_data = array(), $segment_ids = array()) {
|
||||||
if(empty($subscriber_data) or empty($segment_ids)) {
|
if(empty($subscriber_data) or empty($segment_ids)) {
|
||||||
return false;
|
return false;
|
||||||
@ -192,11 +192,14 @@ class Subscriber extends Model {
|
|||||||
'label' => __('All segments'),
|
'label' => __('All segments'),
|
||||||
'value' => ''
|
'value' => ''
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$subscribers_without_segment = self::filter('withoutSegments')->count();
|
||||||
|
$subscribers_without_segment_label = sprintf(
|
||||||
|
__('Subscribers without a segment (%s)'),
|
||||||
|
number_format($subscribers_without_segment)
|
||||||
|
);
|
||||||
$segment_list[] = array(
|
$segment_list[] = array(
|
||||||
'label' => sprintf(
|
'label' => str_replace(' (0)', '', $subscribers_without_segment_label),
|
||||||
__('Subscribers without a segment (%d)'),
|
|
||||||
self::filter('withoutSegments')->count()
|
|
||||||
),
|
|
||||||
'value' => 'none'
|
'value' => 'none'
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -205,8 +208,9 @@ class Subscriber extends Model {
|
|||||||
->filter('groupBy', $group)
|
->filter('groupBy', $group)
|
||||||
->count();
|
->count();
|
||||||
|
|
||||||
|
$label = sprintf('%s (%s)', $segment->name, number_format($subscribers_count));
|
||||||
$segment_list[] = array(
|
$segment_list[] = array(
|
||||||
'label' => sprintf('%s (%d)', $segment->name, $subscribers_count),
|
'label' => str_replace(' (0)', '', $label),
|
||||||
'value' => $segment->id()
|
'value' => $segment->id()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user