Add groups to post notifications history
[MAILPOET-2192]
This commit is contained in:
@ -180,6 +180,7 @@ const NewsletterListNotificationHistory = (props) => (
|
|||||||
base_url="notification/history/:parent_id"
|
base_url="notification/history/:parent_id"
|
||||||
onRenderItem={renderItem}
|
onRenderItem={renderItem}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
|
messages={messages}
|
||||||
item_actions={newsletterActions}
|
item_actions={newsletterActions}
|
||||||
bulk_actions={bulkActions}
|
bulk_actions={bulkActions}
|
||||||
auto_refresh
|
auto_refresh
|
||||||
|
@ -823,19 +823,17 @@ class Newsletter extends Model {
|
|||||||
static function groups($data = []) {
|
static function groups($data = []) {
|
||||||
$type = isset($data['params']['type']) ? $data['params']['type'] : null;
|
$type = isset($data['params']['type']) ? $data['params']['type'] : null;
|
||||||
$group = (isset($data['params']['group'])) ? $data['params']['group'] : null;
|
$group = (isset($data['params']['group'])) ? $data['params']['group'] : null;
|
||||||
|
$parentId = (isset($data['params']['parent_id'])) ? $data['params']['parent_id'] : null;
|
||||||
|
|
||||||
// newsletter types without groups
|
$get_published_query = Newsletter::getPublished();
|
||||||
if (in_array($type, [
|
if (!is_null($parentId)) {
|
||||||
self::TYPE_NOTIFICATION_HISTORY,
|
$get_published_query->where('parent_id', $parentId);
|
||||||
])) {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$groups = [
|
$groups = [
|
||||||
[
|
[
|
||||||
'name' => 'all',
|
'name' => 'all',
|
||||||
'label' => WPFunctions::get()->__('All', 'mailpoet'),
|
'label' => WPFunctions::get()->__('All', 'mailpoet'),
|
||||||
'count' => Newsletter::getPublished()
|
'count' => $get_published_query
|
||||||
->filter('filterType', $type, $group)
|
->filter('filterType', $type, $group)
|
||||||
->count(),
|
->count(),
|
||||||
],
|
],
|
||||||
@ -879,6 +877,29 @@ class Newsletter extends Model {
|
|||||||
]);
|
]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case self::TYPE_NOTIFICATION_HISTORY:
|
||||||
|
$groups = array_merge($groups, [
|
||||||
|
[
|
||||||
|
'name' => self::STATUS_SENDING,
|
||||||
|
'label' => WPFunctions::get()->__('Sending', 'mailpoet'),
|
||||||
|
'count' => Newsletter::getPublished()
|
||||||
|
->where('parent_id', $parentId)
|
||||||
|
->filter('filterType', $type, $group)
|
||||||
|
->filter('filterStatus', self::STATUS_SENDING)
|
||||||
|
->count(),
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => self::STATUS_SENT,
|
||||||
|
'label' => WPFunctions::get()->__('Sent', 'mailpoet'),
|
||||||
|
'count' => Newsletter::getPublished()
|
||||||
|
->where('parent_id', $parentId)
|
||||||
|
->filter('filterType', $type, $group)
|
||||||
|
->filter('filterStatus', self::STATUS_SENT)
|
||||||
|
->count(),
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
break;
|
||||||
|
|
||||||
case self::TYPE_WELCOME:
|
case self::TYPE_WELCOME:
|
||||||
case self::TYPE_NOTIFICATION:
|
case self::TYPE_NOTIFICATION:
|
||||||
case self::TYPE_AUTOMATIC:
|
case self::TYPE_AUTOMATIC:
|
||||||
@ -903,10 +924,14 @@ class Newsletter extends Model {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$get_trashed_query = Newsletter::getTrashed();
|
||||||
|
if (!is_null($parentId)) {
|
||||||
|
$get_trashed_query->where('parent_id', $parentId);
|
||||||
|
}
|
||||||
$groups[] = [
|
$groups[] = [
|
||||||
'name' => 'trash',
|
'name' => 'trash',
|
||||||
'label' => WPFunctions::get()->__('Trash', 'mailpoet'),
|
'label' => WPFunctions::get()->__('Trash', 'mailpoet'),
|
||||||
'count' => Newsletter::getTrashed()
|
'count' => $get_trashed_query
|
||||||
->filter('filterType', $type, $group)
|
->filter('filterType', $type, $group)
|
||||||
->count(),
|
->count(),
|
||||||
];
|
];
|
||||||
|
Reference in New Issue
Block a user