File tree Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change
1
+ import React , { Component , PropTypes } from 'react'
2
+ import { observer } from 'mobx-react'
3
+
4
+ @observer
5
+ export default class InputCheckboxes extends Component {
6
+ constructor ( props ) {
7
+ super ( props )
8
+ this . onChange = this . onChange . bind ( this )
9
+ }
10
+
11
+ onChange ( event ) {
12
+ this . props . onChange ( this . props . name , event . target . value )
13
+ }
14
+
15
+ render ( ) {
16
+ const { items, name, checkedItems} = this . props
17
+ return (
18
+ < div className = "form-group" >
19
+ < b > { name } </ b >
20
+ {
21
+ items . map ( ( item ) => {
22
+ return (
23
+ < div className = "checkbox" key = { `${ name } -${ item } ` } >
24
+ < label htmlFor = { `${ name } -${ item } ` } >
25
+ < input type = "checkbox" name = { `${ name } ` } value = { item } id = { `${ name } -${ item } ` }
26
+ checked = { checkedItems . indexOf ( item ) > - 1 }
27
+ onChange = { this . onChange } /> { item }
28
+ </ label >
29
+ </ div >
30
+ )
31
+ } )
32
+ }
33
+ </ div >
34
+ )
35
+ }
36
+ }
37
+
38
+ InputCheckboxes . propTypes = {
39
+ onChange : PropTypes . func . isRequired ,
40
+ name : PropTypes . string . isRequired
41
+ }
Original file line number Diff line number Diff line change 1
1
import asForm from './asForm'
2
2
import InputCheckbox from './InputCheckbox'
3
+ import InputCheckboxes from './InputCheckboxes'
3
4
import InputField from './InputField'
4
5
import InputRadio from './InputRadio'
5
6
6
7
export {
7
8
asForm ,
8
9
InputCheckbox ,
10
+ InputCheckboxes ,
9
11
InputField ,
10
12
InputRadio
11
13
}
You can’t perform that action at this time.
0 commit comments