diff options
| author | Georgios Andreadis <G.Andreadis@student.tudelft.nl> | 2017-10-04 23:23:09 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-10-04 23:23:09 +0200 |
| commit | fcaaae65d34003874c76e0c01134dedf94248e09 (patch) | |
| tree | 2aae1422168651e832a1904623f6f5b100fc17ec /src/components/modals/TextInputModal.js | |
| parent | 0a62dfb55c5700013d42a589b930c7448e5bff71 (diff) | |
| parent | 606d1de0be09f3597165248f65d54e158a13860c (diff) | |
Merge pull request #42 from atlarge-research/auto-reformat
Standardize code format
Diffstat (limited to 'src/components/modals/TextInputModal.js')
| -rw-r--r-- | src/components/modals/TextInputModal.js | 83 |
1 files changed, 45 insertions, 38 deletions
diff --git a/src/components/modals/TextInputModal.js b/src/components/modals/TextInputModal.js index 132df9fe..cc16f8e1 100644 --- a/src/components/modals/TextInputModal.js +++ b/src/components/modals/TextInputModal.js @@ -3,49 +3,56 @@ import React from "react"; import Modal from "./Modal"; class TextInputModal extends React.Component { - static propTypes = { - title: PropTypes.string.isRequired, - label: PropTypes.string.isRequired, - show: PropTypes.bool.isRequired, - callback: PropTypes.func.isRequired, - initialValue: PropTypes.string, - }; + static propTypes = { + title: PropTypes.string.isRequired, + label: PropTypes.string.isRequired, + show: PropTypes.bool.isRequired, + callback: PropTypes.func.isRequired, + initialValue: PropTypes.string + }; - componentDidUpdate() { - if (this.props.initialValue) { - this.textInput.value = this.props.initialValue; - } + componentDidUpdate() { + if (this.props.initialValue) { + this.textInput.value = this.props.initialValue; } + } - onSubmit() { - this.props.callback(this.textInput.value); - this.textInput.value = ""; - } + onSubmit() { + this.props.callback(this.textInput.value); + this.textInput.value = ""; + } - onCancel() { - this.props.callback(undefined); - this.textInput.value = ""; - } + onCancel() { + this.props.callback(undefined); + this.textInput.value = ""; + } - render() { - return ( - <Modal title={this.props.title} - show={this.props.show} - onSubmit={this.onSubmit.bind(this)} - onCancel={this.onCancel.bind(this)}> - <form onSubmit={e => { - e.preventDefault(); - this.onSubmit(); - }}> - <div className="form-group"> - <label className="form-control-label">{this.props.label}</label> - <input type="text" className="form-control" - ref={textInput => this.textInput = textInput}/> - </div> - </form> - </Modal> - ); - } + render() { + return ( + <Modal + title={this.props.title} + show={this.props.show} + onSubmit={this.onSubmit.bind(this)} + onCancel={this.onCancel.bind(this)} + > + <form + onSubmit={e => { + e.preventDefault(); + this.onSubmit(); + }} + > + <div className="form-group"> + <label className="form-control-label">{this.props.label}</label> + <input + type="text" + className="form-control" + ref={textInput => (this.textInput = textInput)} + /> + </div> + </form> + </Modal> + ); + } } export default TextInputModal; |
