Commit 5c607b029954c3bbab94ea4db3a08e27246ea33a
1 parent
c42d4eeace
Exists in
master
add a little ux touch to document editor
Showing
1 changed file
with
1 additions
and
0 deletions
Show diff stats
imports/ui/components/DocumentEditor.js
1 | /* eslint-disable max-len, no-return-assign */ | 1 | /* eslint-disable max-len, no-return-assign */ |
2 | 2 | ||
3 | import React from 'react'; | 3 | import React from 'react'; |
4 | import { FormGroup, ControlLabel, FormControl, Button } from 'react-bootstrap'; | 4 | import { FormGroup, ControlLabel, FormControl, Button } from 'react-bootstrap'; |
5 | import documentEditor from '../../modules/document-editor.js'; | 5 | import documentEditor from '../../modules/document-editor.js'; |
6 | 6 | ||
7 | export default class DocumentEditor extends React.Component { | 7 | export default class DocumentEditor extends React.Component { |
8 | componentDidMount() { | 8 | componentDidMount() { |
9 | documentEditor({ component: this }); | 9 | documentEditor({ component: this }); |
10 | setTimeout(() => { document.querySelector('[name="title"]').focus(); }, 0); | ||
10 | } | 11 | } |
11 | 12 | ||
12 | render() { | 13 | render() { |
13 | const { doc } = this.props; | 14 | const { doc } = this.props; |
14 | return (<form | 15 | return (<form |
15 | ref={ form => this.form = form } | 16 | ref={ form => this.form = form } |
16 | onSubmit={ event => event.preventDefault() } | 17 | onSubmit={ event => event.preventDefault() } |
17 | > | 18 | > |
18 | <FormGroup> | 19 | <FormGroup> |
19 | <ControlLabel>Title</ControlLabel> | 20 | <ControlLabel>Title</ControlLabel> |
20 | <FormControl | 21 | <FormControl |
21 | type="text" | 22 | type="text" |
22 | name="title" | 23 | name="title" |
23 | defaultValue={ doc && doc.title } | 24 | defaultValue={ doc && doc.title } |
24 | placeholder="Oh, The Places You'll Go!" | 25 | placeholder="Oh, The Places You'll Go!" |
25 | /> | 26 | /> |
26 | </FormGroup> | 27 | </FormGroup> |
27 | <FormGroup> | 28 | <FormGroup> |
28 | <ControlLabel>Body</ControlLabel> | 29 | <ControlLabel>Body</ControlLabel> |
29 | <FormControl | 30 | <FormControl |
30 | componentClass="textarea" | 31 | componentClass="textarea" |
31 | name="body" | 32 | name="body" |
32 | defaultValue={ doc && doc.body } | 33 | defaultValue={ doc && doc.body } |
33 | placeholder="Congratulations! Today is your day. You're off to Great Places! You're off and away!" | 34 | placeholder="Congratulations! Today is your day. You're off to Great Places! You're off and away!" |
34 | /> | 35 | /> |
35 | </FormGroup> | 36 | </FormGroup> |
36 | <Button type="submit" bsStyle="success"> | 37 | <Button type="submit" bsStyle="success"> |
37 | { doc && doc._id ? 'Save Changes' : 'Add Document' } | 38 | { doc && doc._id ? 'Save Changes' : 'Add Document' } |
38 | </Button> | 39 | </Button> |
39 | </form>); | 40 | </form>); |
40 | } | 41 | } |
41 | } | 42 | } |
42 | 43 | ||
43 | DocumentEditor.propTypes = { | 44 | DocumentEditor.propTypes = { |
44 | doc: React.PropTypes.object, | 45 | doc: React.PropTypes.object, |
45 | }; | 46 | }; |
46 | 47 |