Listings
- fixed selection field JSX - fixed bulk actions (added filter function) - added getPublished/getTrashed static methods on Model - fixed step 3 of newsletter process - updated save/get methods of all listing-able models to conform with the new norm
This commit is contained in:
@@ -54,6 +54,11 @@ function(
|
||||
loadCachedItems: function() {
|
||||
if(typeof(window['mailpoet_'+this.props.field.endpoint]) !== 'undefined') {
|
||||
var items = window['mailpoet_'+this.props.field.endpoint];
|
||||
|
||||
if(this.props.field['filter'] !== undefined) {
|
||||
items = items.filter(this.props.field.filter);
|
||||
}
|
||||
|
||||
this.setState({
|
||||
items: items
|
||||
});
|
||||
@@ -76,7 +81,7 @@ function(
|
||||
return true;
|
||||
},
|
||||
render: function() {
|
||||
if(this.state.items.length === 0) {
|
||||
if((this.props.item !== undefined && this.props.item.id === undefined)) {
|
||||
return false;
|
||||
} else {
|
||||
var options = this.state.items.map(function(item, index) {
|
||||
|
@@ -88,7 +88,7 @@ define(
|
||||
}).done(function(response) {
|
||||
this.setState({ loading: false });
|
||||
|
||||
if(response === true) {
|
||||
if(response.result === true) {
|
||||
if(this.props.onSuccess !== undefined) {
|
||||
this.props.onSuccess()
|
||||
} else {
|
||||
@@ -101,10 +101,10 @@ define(
|
||||
this.props.messages['created']();
|
||||
}
|
||||
} else {
|
||||
if(response === false) {
|
||||
// unknown error occurred
|
||||
} else {
|
||||
this.setState({ errors: response });
|
||||
if(response.result === false) {
|
||||
if(response.errors.length > 0) {
|
||||
this.setState({ errors: response.errors });
|
||||
}
|
||||
}
|
||||
}
|
||||
}.bind(this));
|
||||
@@ -121,13 +121,15 @@ define(
|
||||
return true;
|
||||
},
|
||||
render: function() {
|
||||
var errors = this.state.errors.map(function(error, index) {
|
||||
return (
|
||||
<p key={ 'error-'+index } className="mailpoet_error">
|
||||
{ error }
|
||||
</p>
|
||||
);
|
||||
});
|
||||
if(this.state.errors !== undefined) {
|
||||
var errors = this.state.errors.map(function(error, index) {
|
||||
return (
|
||||
<p key={ 'error-'+index } className="mailpoet_error">
|
||||
{ error }
|
||||
</p>
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
var formClasses = classNames(
|
||||
'mailpoet_form',
|
||||
|
Reference in New Issue
Block a user