- Fix unmounting select2 component

- Fix subjects of welcome and notification newsletters
- Remove debugging statements
This commit is contained in:
Tautvidas Sipavičius
2016-04-07 15:44:14 +03:00
parent ad5441487b
commit 0c008325c4
5 changed files with 10 additions and 12 deletions

View File

@ -30,6 +30,9 @@ function(
.trigger('change');
}
},
componentWillUnmount: function() {
jQuery('#'+this.refs.select.id).select2('destroy');
},
setupSelect2: function() {
if(
!this.props.field.multiple

View File

@ -49,7 +49,6 @@ define(
} else {
this.loadItem(props.params.id);
}
console.log('Receiving props', arguments);
},
loadItem: function(id) {
this.setState({ loading: true });

View File

@ -59,7 +59,7 @@ define(
endpoint: 'newsletters',
action: 'get',
data: id
}).done(function(response) {
}).done((response) => {
if(response === false) {
this.setState({
loading: false,
@ -74,7 +74,7 @@ define(
fields: this.getFieldsByNewsletter(response),
});
}
}.bind(this));
});
},
getFieldsByNewsletter: function(newsletter) {
switch(newsletter.type) {
@ -150,22 +150,16 @@ define(
});
},
handleFormChange: function(e) {
console.log('Form change', e);
var item = this.state.item,
field = e.target.name;
item[field] = e.target.value;
console.log('State before change', this.state);
this.setState({
item: item
});
console.log('State after change', this.state);
return true;
},
handleFormSubmit: function() {
console.log('Handling form submit', arguments);
},
getParams: function() {
return {};
},

View File

@ -48,7 +48,8 @@ define(
endpoint: 'newsletters',
action: 'create',
data: _.extend({}, this.state, {
type: 'notification'
type: 'notification',
subject: MailPoet.I18n.t('draftNewsletterTitle'),
}),
}).done(function(response) {
if(response.result && response.newsletter.id) {

View File

@ -48,7 +48,8 @@ define(
endpoint: 'newsletters',
action: 'create',
data: _.extend({}, this.state, {
type: 'welcome'
type: 'welcome',
subject: MailPoet.I18n.t('draftNewsletterTitle'),
}),
}).done(function(response) {
if(response.result && response.newsletter.id) {