-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.jsx
More file actions
92 lines (81 loc) · 3.4 KB
/
index.jsx
File metadata and controls
92 lines (81 loc) · 3.4 KB
1
2
3
4
5
6
7
8
9
10
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import React, { Component } from 'react';
import { Button, Input } from 'react-bootstrap';
import 'react-select/dist/react-select.css';
import Select from 'react-select';
import './index.css';
import { observer } from 'mobx-react';
@observer(['taskAdd', 'app'])
class TaskAddForm extends Component {
constructor(props) {
super(props);
this.state = { status: 'new', assignee: props.assignee, version: 'week1' };
}
add() {
const { getUserOptions } = this.props.app;
const { addTask } = this.props.taskAdd;
const title = this.refs.input.getValue();
const description = this.refs.description.getValue();
const { status, assignee, version } = this.state;
const assigneeUser = getUserOptions.find(user => user.value === assignee.value);
addTask({
title,
description,
status,
assignee: assignee.value,
version,
assigneeName: assigneeUser.label,
});
}
render() {
const { getStatusesOptions, getUserOptions } = this.props.app;
const { addVersion, versions } = this.props.taskAdd;
const allVersion = versions.map(version => ({ value: version.title, label: version.title }));
return (
<div>
<Input type='text' label='Title' ref='input' />
<div className='form-group task-add-from__status'>
<label className='control-label'>Status</label>
<Select
value={this.state.status}
onChange={(status) => this.setState({ status })}
searchable={false}
clearable={false}
placeholder='-'
options={getStatusesOptions}
/>
</div>
<div className='form-group task-add-from__user-select'>
<label className='control-label'>Assignee</label>
<Select
value={this.state.assignee}
onChange={assignee => this.setState({ assignee })}
placeholder='-'
options={getUserOptions}
/>
</div>
<div className='form-group'>
<label className='control-label'>Target Version</label>
<div className='input-group' >
<span className='form-control' style={{ padding: 0, border: 'none' }}>
<Select
value={this.state.version}
searchable={false}
clearable={false}
onChange={version => this.setState({ version: version.value })}
options={allVersion}
/>
</span>
<span className='input-group-btn'>
<Button onClick={addVersion}>
<i className='glyphicon glyphicon-plus'></i>
</Button>
</span>
</div>
</div>
<Input type='textarea' label='Description' ref='description' />
<Button onClick={() => this.add()}>add</Button>
</div>
);
}
}
export default TaskAddForm;