Renamed tab to type
- renamed getExtraParams to getParams - fixed issue with String.contains by replacing it with indexOf - removed useless break; statement
This commit is contained in:
@ -348,15 +348,15 @@ const Listing = React.createClass({
|
||||
this.getItems();
|
||||
}.bind(this));
|
||||
},
|
||||
getExtraParams: function() {
|
||||
getParams: function() {
|
||||
// get all route parameters (without the "splat")
|
||||
let extras = _.omit(this.props.params, 'splat');
|
||||
let params = _.omit(this.props.params, 'splat');
|
||||
// TO REFACTOR:
|
||||
// set the "tab" in the routes definition
|
||||
if (this.props.tab) {
|
||||
extras.tab = this.props.tab;
|
||||
// find a way to set the "type" in the routes definition
|
||||
if (this.props.type) {
|
||||
params.type = this.props.type;
|
||||
}
|
||||
return extras;
|
||||
return params;
|
||||
},
|
||||
setParams: function() {
|
||||
if (this.props.location) {
|
||||
@ -409,10 +409,10 @@ const Listing = React.createClass({
|
||||
}
|
||||
},
|
||||
setBaseUrlParams: function(base_url) {
|
||||
if (base_url.contains(':') === true) {
|
||||
const params = this.getExtraParams();
|
||||
if (base_url.indexOf(':') !== -1) {
|
||||
const params = this.getParams();
|
||||
Object.keys(params).map((key) => {
|
||||
if (base_url.contains(':'+key)) {
|
||||
if (base_url.indexOf(':'+key) !== -1) {
|
||||
base_url = base_url.replace(':'+key, params[key]);
|
||||
}
|
||||
});
|
||||
@ -446,7 +446,7 @@ const Listing = React.createClass({
|
||||
endpoint: this.props.endpoint,
|
||||
action: 'listing',
|
||||
data: {
|
||||
params: this.getExtraParams(),
|
||||
params: this.getParams(),
|
||||
offset: (this.state.page - 1) * this.state.limit,
|
||||
limit: this.state.limit,
|
||||
group: this.state.group,
|
||||
@ -561,7 +561,7 @@ const Listing = React.createClass({
|
||||
|
||||
var data = params || {};
|
||||
data.listing = {
|
||||
params: this.getExtraParams(),
|
||||
params: this.getParams(),
|
||||
offset: 0,
|
||||
limit: 0,
|
||||
filter: this.state.filter,
|
||||
|
@ -301,7 +301,7 @@ const NewsletterListNotification = React.createClass({
|
||||
location={ this.props.location }
|
||||
params={ this.props.params }
|
||||
endpoint="newsletters"
|
||||
tab="notification"
|
||||
type="notification"
|
||||
base_url="notification"
|
||||
onRenderItem={ this.renderItem }
|
||||
columns={ columns }
|
||||
|
@ -234,7 +234,7 @@ const NewsletterListNotificationHistory = React.createClass({
|
||||
location={ this.props.location }
|
||||
params={ this.props.params }
|
||||
endpoint="newsletters"
|
||||
tab="notification_history"
|
||||
type="notification_history"
|
||||
base_url="notification/history/:parent_id"
|
||||
onRenderItem={ this.renderItem }
|
||||
columns={columns}
|
||||
|
@ -321,7 +321,7 @@ const NewsletterListStandard = React.createClass({
|
||||
location={ this.props.location }
|
||||
params={ this.props.params }
|
||||
endpoint="newsletters"
|
||||
tab="standard"
|
||||
type="standard"
|
||||
base_url="standard"
|
||||
onRenderItem={this.renderItem}
|
||||
columns={columns}
|
||||
|
@ -343,7 +343,7 @@ const NewsletterListWelcome = React.createClass({
|
||||
location={ this.props.location }
|
||||
params={ this.props.params }
|
||||
endpoint="newsletters"
|
||||
tab="welcome"
|
||||
type="welcome"
|
||||
base_url="welcome"
|
||||
onRenderItem={ this.renderItem }
|
||||
columns={ columns }
|
||||
|
@ -219,8 +219,6 @@ class Newsletter extends Model {
|
||||
->where('queues.newsletter_id', $this->id)
|
||||
->where('queues.status', SendingQueue::STATUS_COMPLETED)
|
||||
->findOne();
|
||||
break;
|
||||
|
||||
default:
|
||||
if($this->queue === false) {
|
||||
return false;
|
||||
@ -259,7 +257,7 @@ class Newsletter extends Model {
|
||||
}
|
||||
|
||||
static function filters($data = array()) {
|
||||
$type = isset($data['params']['tab']) ? $data['params']['tab'] : null;
|
||||
$type = isset($data['params']['type']) ? $data['params']['type'] : null;
|
||||
|
||||
// newsletter types without filters
|
||||
if(in_array($type, array(
|
||||
@ -311,7 +309,7 @@ class Newsletter extends Model {
|
||||
}
|
||||
|
||||
// filter by type
|
||||
$type = isset($data['params']['tab']) ? $data['params']['tab'] : null;
|
||||
$type = isset($data['params']['type']) ? $data['params']['type'] : null;
|
||||
if($type !== null) {
|
||||
$orm->filter('filterType', $type);
|
||||
}
|
||||
@ -358,7 +356,7 @@ class Newsletter extends Model {
|
||||
}
|
||||
|
||||
static function groups($data = array()) {
|
||||
$type = isset($data['params']['tab']) ? $data['params']['tab'] : null;
|
||||
$type = isset($data['params']['type']) ? $data['params']['type'] : null;
|
||||
|
||||
// newsletter types without groups
|
||||
if(in_array($type, array(
|
||||
|
Reference in New Issue
Block a user