@@ -28,22 +28,40 @@ let TreeChartChildEditor = React.createClass({
28
28
let that = this ;
29
29
return function ( e ) {
30
30
let update = { } ;
31
- update [ field ] = e . target . value ;
31
+ let value = e . target . value ;
32
+ if ( e . target . type === 'checkbox' ) {
33
+ value = e . target . checked ;
34
+ }
32
35
if ( validate ) {
33
- update [ field ] = validate ( e . target . value ) ;
36
+ value = validate ( value ) ;
34
37
}
38
+ update [ field ] = value ;
35
39
firebase . database ( ) . ref ( that . props . path ) . update ( update ) ;
36
40
}
37
41
} ,
38
42
render ( ) {
43
+ let progressEnabled = this . state . element . progress === 0 || this . state . element . progress > 0 ;
44
+ let progressBar = < div >
45
+ < input type = "range" onChange = { this . update ( 'progress' , parseInt ) } value = { this . state . element . progress } />
46
+ { this . state . element . progress }
47
+ </ div >
39
48
return < div ref = "root" className = "TreeChartChildEditor" >
40
49
< input type = "text" className = "TreeChartChildEditorTitle" value = { this . state . element . title } onChange = { this . update ( 'title' ) } />
41
50
< select className = "TreeChartChildEditorImportance" default = { this . state . element . importance } value = { this . state . element . importance } onChange = { this . update ( 'importance' , parseInt ) } >
42
51
{ [ 1 , 2 , 3 , 4 , 5 ] . map ( ( importance ) => { return < option key = { importance } value = { importance } > { importance } </ option > } ) }
43
52
</ select >
44
- < select className = "TreeChartChildEditorType" default = { this . state . element . type } value = { this . state . element . type } onChange = { this . update ( 'type' ) } >
53
+ < select
54
+ className = "TreeChartChildEditorType"
55
+ default = { this . state . element . type }
56
+ value = { this . state . element . type }
57
+ onChange = { this . update ( 'type' ) } >
45
58
{ types . map ( ( type ) => { return < option key = { type } value = { type } > { type } </ option > } ) }
46
59
</ select >
60
+ < input
61
+ type = "checkbox"
62
+ checked = { progressEnabled }
63
+ onChange = { this . update ( 'progress' , ( val ) => { return val ? 0 : null } ) } />
64
+ { progressEnabled ? progressBar : null }
47
65
</ div > ;
48
66
}
49
67
} ) ;
0 commit comments