<commit_before>var React = require('react');
var Modal = require('react-bootstrap').Modal;
var Button = require('react-bootstrap').Button;
var OverlayMixin = require('react-bootstrap').OverlayMixin;
var SurveyActions = require('../actions/SurveyActions');
var ItemTypes = require('./ItemTypes');

// to get around the refs issues - https://github.com/react-bootstrap/react-bootstrap/issues/223
var BaseModal = React.createClass({
    propTypes: {
        parentID: React.PropTypes.string
    },
    componentDidMount() {
        var textInput = this.refs.qtext.getDOMNode();
        textInput.focus();
    },
    handleClose() {
        SurveyActions.toggleModal(ItemTypes.QUESTION);
    },
    handleSubmit() {
        var qtext = this.refs.qtext.getDOMNode().value;
        var ordering = this.refs.ordering.getDOMNode().checked;
        var freetext = this.refs.freetext.getDOMNode().checked;
        var exclusive = this.refs.exclusive.getDOMNode().checked;
        SurveyActions.questionDropped({
            parentID: this.props.parentID,
            qtext: qtext,
            ordering: ordering,
            freetext: freetext,
            exclusive: exclusive
        });
        this.handleClose();
    },
    render() {
        return <Modal title='Add Question'
            bsStyle='primary'
            backdrop={true}
            animation={true}
            container={null}
            onRequestHide={this.handleClose}>
            <div className='modal-body'>
                <div className="form-group">
                    <label htmlFor="qtext">Question Text</label>
                    <input type="text" placeholder="What is value of 4 + 5?" className="form-control" id="qtext" ref="qtext" />
                </div>
                <h5>Configuration</h5>
                <div className="checkbox">
                    <label><input type="checkbox" ref="ordering" /> Preserve ordering of the options</label>
                </div>
                <div className="checkbox">
                    <label> <input type="checkbox" ref="exclusive" /> Present options as radio-buttons (default is checkbox)</label>
                </div>
                <div className="checkbox">
                    <label> <input type="checkbox" ref="freetext"/> Allow free text entry</label>
                </div>
            </div>
            <div className='modal-footer'>
                <Button onClick={this.handleClose}>Cancel</Button>
                <Button bsStyle='primary' onClick={this.handleSubmit}>Confirm</Button>
            </div><commit_msg>Question modals does submit on Enter key press<commit_after>var React = require('react');
var Modal = require('react-bootstrap').Modal;
var Button = require('react-bootstrap').Button;
var OverlayMixin = require('react-bootstrap').OverlayMixin;
var SurveyActions = require('../actions/SurveyActions');
var ItemTypes = require('./ItemTypes');

// to get around the refs issues - https://github.com/react-bootstrap/react-bootstrap/issues/223
var BaseModal = React.createClass({
    getInitialState() {
        return { qtext: "" }
    },
    propTypes: {
        parentID: React.PropTypes.string
    },
    componentDidMount() {
        var textInput = this.refs.qtext.getDOMNode();
        textInput.focus();
    },
    handleClose() {
        SurveyActions.toggleModal(ItemTypes.QUESTION);
    },
    handleInput(e) {
        // submit on enter key press
        if (e.key === "Enter") {
            this.handleSubmit();
        } else {
            this.setState({qtext: this.refs.qtext.getDOMNode().value});
        }
    },
    handleSubmit() {
        var qtext = this.refs.qtext.getDOMNode().value;
        var ordering = this.refs.ordering.getDOMNode().checked;
        var freetext = this.refs.freetext.getDOMNode().checked;
        var exclusive = this.refs.exclusive.getDOMNode().checked;
        SurveyActions.questionDropped({
            parentID: this.props.parentID,
            qtext: qtext,
            ordering: ordering,
            freetext: freetext,
            exclusive: exclusive
        });
        this.handleClose();
    },
    render() {
        return <Modal title='Add Question'
            bsStyle='primary'
            backdrop={true}
            animation={true}
            container={null}
            onRequestHide={this.handleClose}>
            <div className='modal-body'>
                <div className="form-group">
                    <label htmlFor="qtext">Question Text</label>
                    <input type="text" placeholder="What is value of 4 + 5?" 
                        className="form-control" id="qtext" ref="qtext" onKeyPress={this.handleInput} />
                </div>
                <h5>Configuration</h5>
                <div className="checkbox">
                    <label><input type="checkbox" ref="ordering" /> Preserve ordering of the options</label>
                </div>
                <div className="checkbox">
                    <label> <input type="checkbox" ref="exclusive" /> Present options as radio-buttons (default is checkbox)</label>
                </div>
                <div className="checkbox">
                    <label> <input type="checkbox" ref="freetext"/> Allow free text entry</label>
                </div>
            </div>
            <div className='modal-footer'>
                <Button onClick={this.handleClose}>Cancel</Button>
                <Button bsStyle='primary' onClick={this.handleSubmit}>Confirm</Button>
            </div>
{'fraction_non_alphanumeric': 0.13059294288832302, 'fraction_numerical': 0.0025463805020007274, 'mean_word_length': 2.0669269380925823, 'pattern_counts': {'":': 0, '<': 65, '<?xml version=': 0, '>': 65, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6515013', 'n_tokens_mistral': 1473, 'n_tokens_neox': 1416, 'n_words': 299}