File tree Expand file tree Collapse file tree 2 files changed +16
-11
lines changed Expand file tree Collapse file tree 2 files changed +16
-11
lines changed Original file line number Diff line number Diff line change 1
1
import Component from '@ember/component' ;
2
2
import { computed } from '@ember/object' ;
3
+ import { kebabCase } from 'lodash-es' ;
3
4
4
5
export default class extends Component {
5
6
@
computed ( '[email protected] ' , 'sortDir' )
6
7
get sortIcon ( ) {
7
8
if ( this . sorts && this . sorts [ 0 ] && this . sorts [ 0 ] . valuePath === this . column . valuePath ) {
8
- this . set ( 'sortDirection' , this . sorts [ 0 ] . isAscending ? 'ASC' : 'DES' ) ;
9
9
if ( this . sorts [ 0 ] . isAscending ) {
10
- // support got sort up, sort down to come with next release of semantic-ui-ember
10
+ // support for sort up, sort down to come with next release of semantic-ui-ember
11
11
return 'caret up' ;
12
12
} else {
13
13
return 'caret down' ;
@@ -21,15 +21,18 @@ export default class extends Component {
21
21
super . didInsertElement ( ...arguments ) ;
22
22
if ( this . sorts && this . sorts [ 0 ] && this . sorts [ 0 ] . valuePath === this . column . valuePath ) {
23
23
this . setProperties ( {
24
- sortBy : this . sorts [ 0 ] . valuePath ,
24
+ sortBy : kebabCase ( this . sorts [ 0 ] . valuePath ) , // Ensures field names are server compatible with sort
25
25
sortDir : this . sorts [ 0 ] . isAscending ? 'ASC' : 'DSC'
26
26
} ) ;
27
27
28
28
} else {
29
- this . setProperties ( {
30
- sortBy : null ,
31
- sortDir : null
32
- } ) ;
29
+ // avoid resetting the query params, when sorts is uninitialised
30
+ if ( this . sorts && ! this . sorts [ 0 ] ) {
31
+ this . setProperties ( {
32
+ sortBy : null ,
33
+ sortDir : null
34
+ } ) ;
35
+ }
33
36
}
34
37
}
35
38
}
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ export default class extends Controller {
8
8
search = null ;
9
9
sort_dir = null ;
10
10
sort_by = null ;
11
-
11
+ sorts = [ ] ;
12
12
@computed ( )
13
13
get columns ( ) {
14
14
return [
@@ -29,9 +29,11 @@ export default class extends Controller {
29
29
}
30
30
} ,
31
31
{
32
- name : 'Date' ,
33
- valuePath : 'startsAt' ,
34
- cellComponent : 'ui-table/cell/cell-event-date'
32
+ name : 'Date' ,
33
+ valuePath : 'startsAt' ,
34
+ isSortable : true ,
35
+ headerComponent : 'tables/headers/sort' ,
36
+ cellComponent : 'ui-table/cell/cell-event-date'
35
37
36
38
} ,
37
39
{
You can’t perform that action at this time.
0 commit comments