Solve the sortable but not sorted by column issue

This commit is contained in:
2018-02-02 15:37:02 -03:00
parent cd7d92443b
commit ec47493166
2 changed files with 18 additions and 6 deletions
@@ -5,9 +5,10 @@ export default Ember.Component.extend
layout: layout layout: layout
tagName: 'th' tagName: 'th'
classNames: ['sortable-table-header'] classNames: ['sortable-table-header']
classNameBindings: ['isSortedByKey:sorted', 'sortDirectionClass'] classNameBindings: ['isSortedByKey:sorted:not-sorted-by', 'sortDirectionClass']
filters: Ember.Object.create() filters: Ember.Object.create()
tScope: '' tScope: ''
defaultDirection: '' # asc or desc
direction: 'asc' direction: 'asc'
init: -> init: ->
@_super arguments... @_super arguments...
@@ -46,10 +47,9 @@ export default Ember.Component.extend
else else
@set 'filters.s', "#{key} asc" @set 'filters.s', "#{key} asc"
else else
default_direction = if key.match /date/ then 'desc' else 'asc' default_direction = @get('defaultDirection')
default_direction ||= if key.match /date|(_at$)/ then 'desc' else 'asc'
default_direction = 'asc' if default_direction is 'ascending'
default_direction = 'desc' if default_direction is 'descending'
@set 'filters.s', "#{key} #{default_direction}" @set 'filters.s', "#{key} #{default_direction}"
#debugger
#@get('afterburn')() # call action if given
@get('model')?.reload?() @get('model')?.reload?()
#@sendAction 'action'
#@get('filters.reload')() if typeof @get('filters.reload') is 'function'
@@ -1,4 +1,16 @@
// ransack componennt integration // ransack componennt integration
.ui.sortable.table thead th.sortable-table-header
&.not-sorted-by
&:after
display: inline-block
font-style: normal
content: '\f0dc'
font-family: Icons
opacity: 0.3
width: auto
height: 1em
margin: 0em 0em 0em 0.5em
table thead tr.table-filters-row, table.ui.table thead tr.table-filters-row table thead tr.table-filters-row, table.ui.table thead tr.table-filters-row
input input
margin: 0 margin: 0