diff --git a/assets/js/src/listing/listing.jsx b/assets/js/src/listing/listing.jsx
index 524203bca9..0dac115b94 100644
--- a/assets/js/src/listing/listing.jsx
+++ b/assets/js/src/listing/listing.jsx
@@ -540,6 +540,7 @@ define(
var data = params || {};
data.listing = {
+ tab: (this.props.tab) ? this.props.tab : '',
offset: 0,
limit: 0,
filter: this.state.filter,
diff --git a/assets/js/src/newsletters/list.jsx b/assets/js/src/newsletters/list.jsx
index e545d13bb2..45927cb86a 100644
--- a/assets/js/src/newsletters/list.jsx
+++ b/assets/js/src/newsletters/list.jsx
@@ -250,13 +250,6 @@ define(
return segment.name
}).join(', ');
- var statistics_column =
- (!mailpoet_settings.tracking || !mailpoet_settings.tracking.enabled) ?
- false :
-
@@ -271,7 +264,9 @@ define(
|
{ segments }
|
- { statistics_column }
+
+ { this.renderStatistics(newsletter) }
+ |
{ MailPoet.Date.format(newsletter.created_at) }
|
@@ -282,15 +277,24 @@ define(
);
},
render: function() {
- if (!mailpoet_settings.tracking || !mailpoet_settings.tracking.enabled) {
- columns = _.without(columns, _.findWhere(columns, {name: 'statistics'}));
- }
return (
{MailPoet.I18n.t('pageTitle')} {MailPoet.I18n.t('new')}
+
+
+ { MailPoet.I18n.t('tabStandardTitle') }
+
+
+ { MailPoet.I18n.t('tabWelcomeTitle') }
+
+
+ { MailPoet.I18n.t('tabNotificationTitle') }
+
+
+
+ {/* New newsletters */}
-
-
-
+
+
+
+ {/* Form: template selection */}
-
+ {/* Listing: tabs */}
+
+
+
+ {/* Listing: filtering */}
+ {/* Form: sending options */}
+
diff --git a/lib/Listing/Handler.php b/lib/Listing/Handler.php
index aac2842e62..948a4ee3e5 100644
--- a/lib/Listing/Handler.php
+++ b/lib/Listing/Handler.php
@@ -66,10 +66,21 @@ class Handler {
}
function getSelection() {
- if(!empty($this->data['selection'])) {
- $this->model->whereIn($this->table_name.'.id', $this->data['selection']);
+ if(method_exists($this->model_class, 'listingQuery')) {
+ $custom_query = call_user_func_array(
+ array($this->model_class, 'listingQuery'),
+ array($this->data)
+ );
+ if(!empty($this->data['selection'])) {
+ $custom_query->whereIn($this->table_name.'.id', $this->data['selection']);
+ }
+ return $custom_query;
+ } else {
+ if(!empty($this->data['selection'])) {
+ $this->model->whereIn($this->table_name.'.id', $this->data['selection']);
+ }
+ return $this->model;
}
- return $this->model;
}
function getSelectionIds() {
@@ -101,6 +112,8 @@ class Handler {
array($this->data)
);
+ $count = $custom_query->count();
+
$items = $custom_query
->offset($this->data['offset'])
->limit($this->data['limit'])
@@ -108,19 +121,19 @@ class Handler {
$this->table_name.'.'.$this->data['sort_by']
)
->findMany();
- $count = $custom_query->count();
+
} else {
$this->setFilter();
$this->setGroup();
$this->setSearch();
$this->setOrder();
+ $count = $this->model->count();
+
$items = $this->model
->offset($this->data['offset'])
->limit($this->data['limit'])
->findMany();
-
- $count = $this->model->count();
}
diff --git a/lib/Models/Newsletter.php b/lib/Models/Newsletter.php
index c1569e2945..a6c32da012 100644
--- a/lib/Models/Newsletter.php
+++ b/lib/Models/Newsletter.php
@@ -162,13 +162,13 @@ class Newsletter extends Model {
return $filters;
}
- static function filterBy($orm, $filters = null) {
- if(!empty($filters)) {
- foreach($filters as $key => $value) {
+ static function filterBy($orm, $data = array()) {
+ if(!empty($data['filter'])) {
+ foreach($data['filter'] as $key => $value) {
if($key === 'segment') {
$segment = Segment::findOne($value);
if($segment !== false) {
- $orm = $segment->newsletters();
+ $orm = $segment->newsletters()->where('type', $data['tab']);
}
}
}
@@ -215,7 +215,7 @@ class Newsletter extends Model {
static function listingQuery($data = array()) {
return self::where('type', $data['tab'])
- ->filter('filterBy', $data['filter'])
+ ->filter('filterBy', $data)
->filter('groupBy', $data['group'])
->filter('search', $data['search']);
}
diff --git a/views/newsletters.html b/views/newsletters.html
index 8896bb75b6..531235e0c6 100644
--- a/views/newsletters.html
+++ b/views/newsletters.html
@@ -20,6 +20,11 @@
<% block translations %>
<%= localize({
'pageTitle': __('Newsletters'),
+
+ 'tabStandardTitle': __('Newsletters'),
+ 'tabWelcomeTitle': __('Welcome emails'),
+ 'tabNotificationTitle': __('Post notifications'),
+
'searchLabel': __('Search'),
'loadingItems': __('Loading newsletters...'),
'noItemsFound': __('No newsletters found.'),