@@ -39,7 +39,7 @@ var SchedulingCheck = React.createClass({
39
39
timestamp : "never" ,
40
40
tableState : {
41
41
greyed : { } ,
42
- sort : false ,
42
+ sort : - 1 ,
43
43
reverse : false
44
44
}
45
45
} ;
@@ -48,6 +48,18 @@ var SchedulingCheck = React.createClass({
48
48
updateTableState : function ( state ) {
49
49
this . state . tableState = state ;
50
50
} ,
51
+
52
+ resetTable : function ( ) {
53
+ this . setState ( {
54
+ tableState : {
55
+ greyed : { } ,
56
+ sort : - 1 ,
57
+ reverse : false
58
+ } ,
59
+ open : false
60
+ } ) ;
61
+
62
+ } ,
51
63
52
64
handleClick : function ( ) {
53
65
if ( this . state . open ) {
@@ -125,6 +137,7 @@ var SchedulingCheck = React.createClass({
125
137
< div className = "scheduling-check-title" >
126
138
< span onClick = { this . handleClick } > { this . props . title } </ span >
127
139
< RefreshButton onClick = { this . loadData } />
140
+ < ResetButton onClick = { this . resetTable } />
128
141
</ div >
129
142
< div className = "scheduling-check-body" >
130
143
{ body }
@@ -148,6 +161,20 @@ var RefreshButton = React.createClass({
148
161
} ,
149
162
} ) ;
150
163
164
+ /**
165
+ * Calls its onClick prop to reset table greying/sorting
166
+ */
167
+ var ResetButton = React . createClass ( {
168
+ propTypes : {
169
+ onClick : React . PropTypes . func . isRequired ,
170
+ } ,
171
+
172
+ render : function ( ) {
173
+ return < button onClick = { this . props . onClick } className = "reset-button" >
174
+ Reset
175
+ </ button > ;
176
+ } ,
177
+ } ) ;
151
178
152
179
// Modified from react-json-table example code.
153
180
var SelectTable = React . createClass ( {
@@ -174,9 +201,7 @@ var SelectTable = React.createClass({
174
201
// clone the rows
175
202
items = this . props . rows . slice ( ) ;
176
203
177
- items = _ . sortBy ( items , function ( item ) {
178
- return item [ me . state . sort ] ;
179
- } ) ;
204
+ items = _ . sortBy ( items , me . state . sort ) ;
180
205
181
206
if ( this . state . reverse ) items . reverse ( ) ;
182
207
0 commit comments