@@ -43,6 +43,14 @@ var SchedulingCheck = React.createClass({
43
43
}
44
44
} ;
45
45
} ,
46
+
47
+ updateTableState : function ( state ) {
48
+ /*this.state.tableState = {
49
+ greyed: state.greyed,
50
+ sort: state.sort
51
+ };*/
52
+ this . state . tableState = state ;
53
+ } ,
46
54
47
55
handleClick : function ( ) {
48
56
if ( this . state . open ) {
@@ -96,7 +104,7 @@ var SchedulingCheck = React.createClass({
96
104
var data = JSON . parse ( this . state . data ) ; // Might not work on old browsers
97
105
var table ;
98
106
if ( data . headings . length == 0 ) {
99
- table = < SelectTable rows = { data . body } header = { false } saveState = { this . state . tableState } /> ;
107
+ table = < SelectTable rows = { data . body } header = { false } saveState = { this . state . tableState } updateTableState = { this . updateTableState } /> ;
100
108
} else {
101
109
var columns = [ ] ;
102
110
for ( i = 0 ; i < data . headings . length ; i ++ ) {
@@ -106,7 +114,7 @@ var SchedulingCheck = React.createClass({
106
114
columns [ i ] = { key : String ( i ) , label : " " } ;
107
115
}
108
116
}
109
- table = < SelectTable rows = { data . body } columns = { columns } header = { true } saveState = { this . state . tableState } /> ;
117
+ table = < SelectTable rows = { data . body } columns = { columns } header = { true } saveState = { this . state . tableState } updateTableState = { this . updateTableState } /> ;
110
118
}
111
119
body = < div >
112
120
< div className = "placeholder" >
@@ -149,19 +157,21 @@ var SelectTable = React.createClass({
149
157
150
158
propTypes : {
151
159
rows : React . PropTypes . array . isRequired ,
152
- savestate : React . PropTypes . shape ( {
160
+ saveState : React . PropTypes . shape ( {
153
161
greyed : React . PropTypes . object . isRequired ,
154
162
sort : React . PropTypes . any . isRequired
155
163
} ) . isRequired ,
156
164
header : React . PropTypes . bool . isRequired ,
157
- columns : React . PropTypes . object
165
+ columns : React . PropTypes . array ,
166
+ updateTableState : React . PropTypes . func . isRequired
158
167
} ,
159
168
160
169
getInitialState : function ( ) {
161
170
// We will store the sorted column and whether each row is greyed out
162
- return { sort : this . props . saveState . sort , greyed : this . props . saveState . greyed } ;
171
+ return { sort : this . props . saveState . sort , greyed : this . props . saveState . greyed } ;
163
172
} ,
164
173
render : function ( ) {
174
+ this . props . updateTableState ( this . state ) ;
165
175
var me = this ,
166
176
// clone the rows
167
177
items = this . props . rows . slice ( )
@@ -204,13 +214,13 @@ var SelectTable = React.createClass({
204
214
} ,
205
215
206
216
onClickHeader : function ( e , column ) {
207
- this . props . saveState . sort = column ;
208
217
this . setState ( { sort : column } ) ;
209
218
} ,
210
219
211
- onClickRow : function ( e , item ) {
212
- this . state . greyed [ item ] = ! this . state . greyed [ item ] ;
213
- this . props . saveState . greyed [ item ] = this . state . greyed [ item ] ;
214
- this . setState ( ) ; // so that it actually updates
220
+ onClickRow : function ( e , item ) {
221
+ // kind of kludgy but I can't figure out how to do this more nicely
222
+ newgreyed = jQuery . extend ( { } , this . state . greyed ) ;
223
+ newgreyed [ item ] = ! newgreyed [ item ] ;
224
+ this . setState ( { greyed : newgreyed } ) ;
215
225
}
216
226
} ) ;
0 commit comments