Blame view

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