fix segments loaded on subscribers page + removed counts for bulk actions' segments
This commit is contained in:
@@ -73,7 +73,7 @@ define(
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
filter: function(segment) {
|
filter: function(segment) {
|
||||||
return !!(!segment.deleted_at);
|
return !!(!segment.deleted_at && segment.type === 'default');
|
||||||
},
|
},
|
||||||
getSearchLabel: function(segment, subscriber) {
|
getSearchLabel: function(segment, subscriber) {
|
||||||
let label = '';
|
let label = '';
|
||||||
|
@@ -106,11 +106,6 @@ const bulk_actions = [
|
|||||||
return !!(
|
return !!(
|
||||||
!segment.deleted_at && segment.type === 'default'
|
!segment.deleted_at && segment.type === 'default'
|
||||||
);
|
);
|
||||||
},
|
|
||||||
getLabel: function (segment) {
|
|
||||||
return (segment.subscribers > 0) ?
|
|
||||||
segment.name + ' (' + parseInt(segment.subscribers).toLocaleString() + ')' :
|
|
||||||
segment.name;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -142,11 +137,6 @@ const bulk_actions = [
|
|||||||
return !!(
|
return !!(
|
||||||
!segment.deleted_at && segment.type === 'default'
|
!segment.deleted_at && segment.type === 'default'
|
||||||
);
|
);
|
||||||
},
|
|
||||||
getLabel: function (segment) {
|
|
||||||
return (segment.subscribers > 0) ?
|
|
||||||
segment.name + ' (' + parseInt(segment.subscribers).toLocaleString() + ')' :
|
|
||||||
segment.name;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -178,11 +168,6 @@ const bulk_actions = [
|
|||||||
return !!(
|
return !!(
|
||||||
segment.type === 'default'
|
segment.type === 'default'
|
||||||
);
|
);
|
||||||
},
|
|
||||||
getLabel: function (segment) {
|
|
||||||
return (segment.subscribers > 0) ?
|
|
||||||
segment.name + ' (' + parseInt(segment.subscribers).toLocaleString() + ')' :
|
|
||||||
segment.name;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -234,14 +219,17 @@ const item_actions = [
|
|||||||
{
|
{
|
||||||
name: 'edit',
|
name: 'edit',
|
||||||
label: MailPoet.I18n.t('edit'),
|
label: MailPoet.I18n.t('edit'),
|
||||||
link: function(item) {
|
link: function(subscriber) {
|
||||||
return (
|
return (
|
||||||
<Link to={ `/edit/${item.id}` }>{MailPoet.I18n.t('edit')}</Link>
|
<Link to={ `/edit/${subscriber.id}` }>{MailPoet.I18n.t('edit')}</Link>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'trash'
|
name: 'trash',
|
||||||
|
display: function(subscriber) {
|
||||||
|
return !!(~~subscriber.wp_user_id === 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -280,15 +268,11 @@ const SubscriberList = React.createClass({
|
|||||||
}
|
}
|
||||||
|
|
||||||
let segments = false;
|
let segments = false;
|
||||||
let subscribed_segments = [];
|
|
||||||
|
|
||||||
// WordPress Users
|
|
||||||
if (~~(subscriber.wp_user_id) > 0) {
|
|
||||||
subscribed_segments.push(MailPoet.I18n.t('WPUsersSegment'));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Subscriptions
|
// Subscriptions
|
||||||
if (subscriber.subscriptions.length > 0) {
|
if (subscriber.subscriptions.length > 0) {
|
||||||
|
let subscribed_segments = [];
|
||||||
|
|
||||||
subscriber.subscriptions.map((subscription) => {
|
subscriber.subscriptions.map((subscription) => {
|
||||||
const segment = this.getSegmentFromId(subscription.segment_id);
|
const segment = this.getSegmentFromId(subscription.segment_id);
|
||||||
if(segment === false) return;
|
if(segment === false) return;
|
||||||
@@ -296,13 +280,14 @@ const SubscriberList = React.createClass({
|
|||||||
subscribed_segments.push(segment.name);
|
subscribed_segments.push(segment.name);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
segments = (
|
||||||
|
<span>
|
||||||
|
{ subscribed_segments.join(', ') }
|
||||||
|
</span>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
segments = (
|
|
||||||
<span>
|
|
||||||
{ subscribed_segments.join(', ') }
|
|
||||||
</span>
|
|
||||||
);
|
|
||||||
|
|
||||||
let avatar = false;
|
let avatar = false;
|
||||||
if(subscriber.avatar_url) {
|
if(subscriber.avatar_url) {
|
||||||
|
@@ -355,7 +355,7 @@ class Menu {
|
|||||||
$data = array();
|
$data = array();
|
||||||
|
|
||||||
$data['items_per_page'] = $this->getLimitPerPage('subscribers');
|
$data['items_per_page'] = $this->getLimitPerPage('subscribers');
|
||||||
$data['segments'] = Segment::getSegmentsWithSubscriberCount();
|
$data['segments'] = Segment::findArray();
|
||||||
|
|
||||||
$data['custom_fields'] = array_map(function($field) {
|
$data['custom_fields'] = array_map(function($field) {
|
||||||
$field['params'] = unserialize($field['params']);
|
$field['params'] = unserialize($field['params']);
|
||||||
@@ -484,7 +484,7 @@ class Menu {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getLimitPerPage($model = null) {
|
private function getLimitPerPage($model = null) {
|
||||||
if($model === null) {
|
if($model === null) {
|
||||||
return Listing\Handler::DEFAULT_LIMIT_PER_PAGE;
|
return Listing\Handler::DEFAULT_LIMIT_PER_PAGE;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user