Skip to content

Commit

Permalink
Fix default values in the campaign dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
knadh committed Nov 26, 2018
1 parent a4e8291 commit 0577367
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions frontend/my/src/Campaign.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,10 @@ class TheFormDef extends React.PureComponent {
})(<Input disabled={ this.props.formDisabled } placeholder="Company Name <email@company.com>" maxLength="200" />)}
</Form.Item>
<Form.Item {...formItemLayout} label="Lists" extra="Lists to subscribe to">
{getFieldDecorator("lists", { initialValue: subLists, rules: [{ required: true }] })(
{getFieldDecorator("lists", {
initialValue: subLists.length > 0 ? subLists : (this.props.data[cs.ModelLists].length === 1 ? [this.props.data[cs.ModelLists][0].id] : undefined),
rules: [{ required: true }]
})(
<Select disabled={ this.props.formDisabled } mode="multiple">
{[...this.props.data[cs.ModelLists]].map((v, i) =>
<Select.Option value={ v["id"] } key={ v["id"] }>{ v["name"] }</Select.Option>
Expand All @@ -317,9 +320,12 @@ class TheFormDef extends React.PureComponent {
)}
</Form.Item>
<Form.Item {...formItemLayout} label="Template" extra="Template">
{getFieldDecorator("template_id", { initialValue: record.template_id, rules: [{ required: true }] })(
{getFieldDecorator("template_id", {
initialValue: record.template_id ? record.template_id : (this.props.data[cs.ModelTemplates].length === 1 ? this.props.data[cs.ModelTemplates][0].id : undefined),
rules: [{ required: true }]
})(
<Select disabled={ this.props.formDisabled }>
{[...this.props.data[cs.ModelTemplates]].map((v, i) =>
{this.props.data[cs.ModelTemplates].map((v, i) =>
<Select.Option value={ v["id"] } key={ v["id"] }>{ v["name"] }</Select.Option>
)}
</Select>
Expand Down

0 comments on commit 0577367

Please sign in to comment.