File tree Expand file tree Collapse file tree 1 file changed +14
-15
lines changed Expand file tree Collapse file tree 1 file changed +14
-15
lines changed Original file line number Diff line number Diff line change @@ -120,23 +120,22 @@ <h3 id="title"></h3>
120
120
} else if ( idx == - sort_idx ) {
121
121
th . setAttribute ( "data-sorted-by" , "asc" ) ;
122
122
}
123
- th . addEventListener ( "click" , ( ) => {
124
- let sortedBy = th . attributes [ "data-sorted-by" ] ;
125
- if ( sortedBy && sortedBy . value == "desc" ) {
126
- state . sort_idx = - idx ;
127
- } else if ( sortedBy && sortedBy . value == "asc" ) {
128
- state . sort_idx = idx ;
123
+ let sortedBy = th . attributes [ "data-sorted-by" ] ;
124
+ let clickState = Object . assign ( { } , state ) ;
125
+ if ( sortedBy && sortedBy . value == "desc" ) {
126
+ clickState . sort_idx = - idx ;
127
+ } else if ( sortedBy && sortedBy . value == "asc" ) {
128
+ clickState . sort_idx = idx ;
129
+ } else {
130
+ // start with descending
131
+ if ( th . attributes [ "data-default-sort-dir" ] . value == "1" ) {
132
+ clickState . sort_idx = idx ;
129
133
} else {
130
- // start with descending
131
- if ( th . attributes [ "data-default-sort-dir" ] . value == "1" ) {
132
- state . sort_idx = idx ;
133
- } else {
134
- state . sort_idx = - idx ;
135
- }
134
+ clickState . sort_idx = - idx ;
136
135
}
137
- console . log ( state ) ;
138
- window . location . search = query_string_for_state ( state ) ;
139
- } ) ;
136
+ }
137
+ let inner = th . innerHTML ;
138
+ th . innerHTML = `<a href=" ${ query_string_for_state ( clickState ) } "> ${ inner } </a>` ;
140
139
}
141
140
let table = document . getElementById ( "primary-table" ) ;
142
141
let idx = 0 ;
You can’t perform that action at this time.
0 commit comments