Created
October 22, 2015 13:24
-
-
Save pablobm/1de0e8ff351c8dc56063 to your computer and use it in GitHub Desktop.
Adding parameters to query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import ApplicationAdapter from 'london-waits/pods/application/adapter'; | |
import config from 'london-waits/config/environment'; | |
function readStopId(id) { | |
return id.split(':')[0]; | |
} | |
export default ApplicationAdapter.extend({ | |
pathForType(type) { | |
Ember.assert(`Expected type='stop'. Got ${type}`, type === 'stop'); | |
return 'StopPoint'; | |
}, | |
findRecord(store, type, id) { | |
id = readStopId(id); | |
return this._super(store, type, id); | |
}, | |
query: function(store, type, query) { | |
Ember.$.extend(query, { | |
stopTypes: 'NaptanPublicBusCoachTram,NaptanRailEntrance,NaptanMetroStation', | |
modes: 'bus,overground,dlr,tube', | |
useStopPointHierarchy: false, | |
includeChildren: false, | |
returnLines: true, | |
radius: config.APP.vicinityRadius, | |
}); | |
const url = this.buildURL(type.modelName, null, null, 'query', query); | |
if (this.sortQueryParams) { | |
query = this.sortQueryParams(query); | |
} | |
return this.ajax(url, 'GET', { data: query }); | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment