backup commit
This commit is contained in:
@@ -78,7 +78,9 @@ export default Ember.Mixin.create ApplicationRouteMixin,
|
|||||||
options = {model: options.content}
|
options = {model: options.content}
|
||||||
else if typeof options isnt 'object'
|
else if typeof options isnt 'object'
|
||||||
options = {model: options}
|
options = {model: options}
|
||||||
options.model = options.model.content if options.model?.promise? and options.model.content
|
|
||||||
|
# opening a model on an unresolved promise is a bad thing, so we can assume (model) promise content for non paginated arrays as model
|
||||||
|
options.model = options.model.content if options.model?.promise? and options.model.content and not options.model.dunlop_remote_array
|
||||||
container = Ember.getOwner(@)
|
container = Ember.getOwner(@)
|
||||||
|
|
||||||
modalNameParts = modalName.split('/')
|
modalNameParts = modalName.split('/')
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
|
import Ember from 'ember'
|
||||||
import PagedRemoteArray from 'ember-cli-pagination/remote/paged-remote-array'
|
import PagedRemoteArray from 'ember-cli-pagination/remote/paged-remote-array'
|
||||||
|
{get} = Ember
|
||||||
|
|
||||||
export default PagedRemoteArray.extend
|
export default PagedRemoteArray.extend
|
||||||
a: 42
|
dunlop_remote_array: true # for identification
|
||||||
#params: {}
|
#params: {}
|
||||||
|
session: Ember.inject.service()
|
||||||
filters: {}
|
filters: {}
|
||||||
init: ->
|
init: ->
|
||||||
query = @get('filters')?.toProperties() || {}
|
query = @get('filters')?.toProperties() || {}
|
||||||
@@ -12,14 +15,35 @@ export default PagedRemoteArray.extend
|
|||||||
@_super arguments...
|
@_super arguments...
|
||||||
|
|
||||||
reload: ->
|
reload: ->
|
||||||
query = @get('filters')?.toProperties() || {}
|
|
||||||
@incrementProperty('filters.filter_calls')
|
@incrementProperty('filters.filter_calls')
|
||||||
@set 'page', 1
|
@set 'page', 1
|
||||||
@set 'lastPage', null
|
@set 'lastPage', null
|
||||||
@setOtherParam('q', query)
|
@setOtherParam('q', @getQuery())
|
||||||
|
|
||||||
|
getQuery: ->
|
||||||
|
@get('filters')?.toProperties() || {}
|
||||||
|
|
||||||
paramMapping:
|
paramMapping:
|
||||||
total_pages: 'total-pages'
|
total_pages: 'total-pages'
|
||||||
total_count: 'total-count'
|
total_count: 'total-count'
|
||||||
|
|
||||||
|
postRequest: (action_name, data = {}) ->
|
||||||
|
container = Ember.getOwner(@store)
|
||||||
|
adapter = @store.adapterFor(@modelName)
|
||||||
|
session = container.lookup('service:session')
|
||||||
|
base_url = adapter.buildURL(@modelName)
|
||||||
|
url = "#{base_url}/#{action_name}"
|
||||||
|
request_data = data
|
||||||
|
request_data = JSON.stringify(data) if typeof data is 'object'
|
||||||
|
|
||||||
|
request =
|
||||||
|
url: url
|
||||||
|
type: 'POST'
|
||||||
|
data: request_data
|
||||||
|
contentType: "application/json"
|
||||||
|
dataType: "json"
|
||||||
|
if session and get(session, 'isAuthenticated')
|
||||||
|
session.authorize 'authorizer:devise', (key, authorization) ->
|
||||||
|
request.crossDomain = true
|
||||||
|
request.headers = {"#{key}": authorization}
|
||||||
|
Ember.$.ajax(request)
|
||||||
|
|||||||
Reference in New Issue
Block a user