Last active
February 13, 2019 12:35
-
-
Save felipeands/b0285df812fcf63f2199acc21970bc27 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Options extends React.Component { | |
constructor(props) { | |
super(props); | |
} | |
updateAlternative(e, key) { | |
this.props.questions[key].text = e.target.value; | |
} | |
dragulaDecorator(componentBackingInstance) { | |
if (componentBackingInstance) { | |
let dragEl = reactDragula([componentBackingInstance]); | |
dragEl.on('drop', (el, target, source, sibling) => { | |
console.log('source', source); | |
this.reorderItems(source); | |
}); | |
} | |
} | |
reorderItems(source) { | |
console.log('reorder'); | |
} | |
render() { | |
return( | |
<div className="container" ref={(e) => this.dragulaDecorator(e)}> | |
{this.props.questions.map((question, key) => | |
<div key={question.id} className="option"> | |
<hr /> | |
<div className="form-group row"> | |
<label className="col-sm-3 col-form-label">Opção</label> | |
<div className="col-sm-9"> | |
<input type="text" name="question[]" className="form-control" defaultValue={question.text} onChange={(e) => this.updateAlternative(e, key)} /> | |
<input type="hidden" name="question_order[]" defaultValue={question.order} /> | |
</div> | |
</div> | |
<GoToChatbotMessage question={question} messages={this.props.messages} /> | |
</div> | |
)} | |
</div> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment