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 11import Component from '@ember/component' ;
22import { computed } from '@ember/object' ;
3+ import { kebabCase } from 'lodash-es' ;
34
45export default class extends Component {
56 @
computed ( '[email protected] ' , 'sortDir' ) 67 get sortIcon ( ) {
78 if ( this . sorts && this . sorts [ 0 ] && this . sorts [ 0 ] . valuePath === this . column . valuePath ) {
8- this . set ( 'sortDirection' , this . sorts [ 0 ] . isAscending ? 'ASC' : 'DES' ) ;
99 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
1111 return 'caret up' ;
1212 } else {
1313 return 'caret down' ;
@@ -21,15 +21,18 @@ export default class extends Component {
2121 super . didInsertElement ( ...arguments ) ;
2222 if ( this . sorts && this . sorts [ 0 ] && this . sorts [ 0 ] . valuePath === this . column . valuePath ) {
2323 this . setProperties ( {
24- sortBy : this . sorts [ 0 ] . valuePath ,
24+ sortBy : kebabCase ( this . sorts [ 0 ] . valuePath ) , // Ensures field names are server compatible with sort
2525 sortDir : this . sorts [ 0 ] . isAscending ? 'ASC' : 'DSC'
2626 } ) ;
2727
2828 } 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+ }
3336 }
3437 }
3538}
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ export default class extends Controller {
88 search = null ;
99 sort_dir = null ;
1010 sort_by = null ;
11-
11+ sorts = [ ] ;
1212 @computed ( )
1313 get columns ( ) {
1414 return [
@@ -29,9 +29,11 @@ export default class extends Controller {
2929 }
3030 } ,
3131 {
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'
3537
3638 } ,
3739 {
You can’t perform that action at this time.
0 commit comments