Skip to content

Instantly share code, notes, and snippets.

@wayne-o
Last active November 13, 2015 09:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wayne-o/0eb466933d4b0279e4a4 to your computer and use it in GitHub Desktop.
Save wayne-o/0eb466933d4b0279e4a4 to your computer and use it in GitHub Desktop.
import Ember from 'ember';
import InfinityRoute from "ember-infinity/mixins/route";
import computed from 'ember-computed-decorators';
import observes from 'ember-computed-decorators';
export default Ember.Route.extend(InfinityRoute, {
slug: null,
selected: [],
model() {
var slug = this.modelFor('event').params.slug;
this.set('slug', slug);
return Ember.run(() => {
return Ember.RSVP.hash({
eventInstance: this.store.query('eventInstance', {
slug: slug
}),
lineup: this.infinityModel("lineup", { perPage: 24, startingPage: 0, slug: slug, sort: 'familiarity desc', currentUserAttending: false, locations: this.get('locations'), listingevent: this.get('listingEvents') })
});
});
},
_modelPath: 'currentModel.lineup',
setupController(controller, models) {
controller.set('eventInstance', models.eventInstance.get('firstObject'));
controller.set('lineup', models.lineup);
},
@computed('selected', 'selected.[]')
locations(selected){
var locationsString = '';
if (selected !== null) {
for (var i = 0; i < selected.length; i++) {
var filter = selected[i];
switch (filter.model_type) {
case 'location':
if (locationsString === '') {
locationsString = filter.name;
}else {
locationsString += ',' + filter.name;
}
break;
default:
}
}
}
return locationsString;
},
listingEvents: null,
/* jshint ignore:start */
@computed('selected', 'selected.[]')
/* jshint ignore:end */
listingEventsObserver(selected){
var listingEventsString = '';
if (selected !== null) {
for (var i = 0; i < selected.length; i++) {
var filter = selected[i];
switch (filter.model_type) {
case 'listingevent':
if (listingEventsString === '') {
listingEventsString = filter.name;
}else {
listingEventsString += ',' + filter.name;
}
break;
default:
}
}
}
return listingEventsString;
},
actions:{
filtersChanged(selected){
this.set('selected', selected);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment