refactoring the code
This commit is contained in:
@ -101,11 +101,6 @@ define([
|
||||
}
|
||||
return null;
|
||||
},
|
||||
isDisabled: function () {
|
||||
return this.props.item.status == 'sending'
|
||||
&& this.props.item.queue
|
||||
&& this.props.item.queue.status == 'paused';
|
||||
},
|
||||
loadCachedItems: function () {
|
||||
if(typeof(window['mailpoet_'+this.props.field.endpoint]) !== 'undefined') {
|
||||
let items = window['mailpoet_'+this.props.field.endpoint];
|
||||
@ -185,7 +180,7 @@ define([
|
||||
<select
|
||||
id={ this.props.field.id || this.props.field.name }
|
||||
ref="select"
|
||||
disabled={this.isDisabled()}
|
||||
disabled={this.props.field.disabled}
|
||||
data-placeholder={ this.props.field.placeholder }
|
||||
multiple={ this.props.field.multiple }
|
||||
defaultValue={ this.getSelectedValues() }
|
||||
|
@ -253,9 +253,12 @@ define(
|
||||
const isPaused = this.state.item.status == 'sending'
|
||||
&& this.state.item.queue
|
||||
&& this.state.item.queue.status == 'paused';
|
||||
// const fields = (!isPaused)
|
||||
// ? this.state.fields
|
||||
// : this.state.fields.filter(field => field.name != 'segments' && field.name != 'options');
|
||||
const fields = this.state.fields.map((field) => {
|
||||
if (field.name == 'segments' || field.name == 'options') {
|
||||
field.disabled = isPaused;
|
||||
}
|
||||
return field;
|
||||
});
|
||||
return (
|
||||
<div>
|
||||
<h1>{MailPoet.I18n.t('finalNewsletterStep')}</h1>
|
||||
@ -264,7 +267,7 @@ define(
|
||||
|
||||
<Form
|
||||
id="mailpoet_newsletter"
|
||||
fields={ this.state.fields }
|
||||
fields={ fields }
|
||||
item={ this.state.item }
|
||||
loading={ this.state.loading }
|
||||
onChange={this.handleFormChange}
|
||||
|
@ -286,11 +286,6 @@ define(
|
||||
'data-parsley-errors-container': '#mailpoet_scheduling',
|
||||
};
|
||||
},
|
||||
isDisabled: function () {
|
||||
return this.props.item.status == 'sending'
|
||||
&& this.props.item.queue
|
||||
&& this.props.item.queue.status == 'paused';
|
||||
},
|
||||
render: function () {
|
||||
let schedulingOptions;
|
||||
|
||||
@ -301,7 +296,7 @@ define(
|
||||
name="scheduledAt"
|
||||
value={this._getCurrentValue().scheduledAt}
|
||||
onChange={this.handleValueChange}
|
||||
disabled={this.isDisabled()}
|
||||
disabled={this.props.field.disabled}
|
||||
dateValidation={this.getDateValidation()} />
|
||||
|
||||
<span>
|
||||
@ -310,7 +305,6 @@ define(
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<input
|
||||
@ -318,7 +312,7 @@ define(
|
||||
type="checkbox"
|
||||
value="1"
|
||||
checked={this.isScheduled()}
|
||||
disabled={this.isDisabled()}
|
||||
disabled={this.props.field.disabled}
|
||||
name="isScheduled"
|
||||
onChange={this.handleCheckboxChange} />
|
||||
|
||||
|
Reference in New Issue
Block a user