33 lines
1012 B
CoffeeScript
33 lines
1012 B
CoffeeScript
import Ember from 'ember'
|
|
|
|
export default Ember.Component.extend
|
|
#filter_calls: 0
|
|
tagName: 'tr'
|
|
classNames: ['table-filters-row', 'ui', 'form']
|
|
filters: Ember.Object.create()
|
|
content: null # PagedRemoteArray from ember-cli-pagination
|
|
key: 'name_eq'
|
|
apply_filters: null # allow custom apply filters with application logic
|
|
|
|
init: ->
|
|
@_super arguments...
|
|
Ember.defineProperty @, 'filter_calls', Ember.computed.alias("filters.filter_calls")
|
|
|
|
actions:
|
|
apply_filters: ->
|
|
query = @get('filters')?.toProperties() || {}
|
|
if @get('apply_filters')
|
|
@get('apply_filters')(query)
|
|
else # use standard implementation
|
|
filter_calls = @incrementProperty('filter_calls')
|
|
console.log "QUERY"
|
|
console.log query
|
|
@set 'content.page', 1
|
|
@set 'content.lastPage', null
|
|
@get('content').setOtherParam?('q', query)
|
|
clear_filters: ->
|
|
@set 'filters', Ember.Object.create()
|
|
@send 'apply_filters'
|
|
@set 'filter_calls', 0
|
|
|