Skip to content

Instantly share code, notes, and snippets.

@bazzel
Last active August 29, 2015 14:08
Show Gist options
  • Save bazzel/99f9b3f8e6433359523b to your computer and use it in GitHub Desktop.
Save bazzel/99f9b3f8e6433359523b to your computer and use it in GitHub Desktop.
import DS from 'ember-data';
export default DS.ActiveModelSerializer.extend(DS.EmbeddedRecordsMixin, {
attrs: {
category: {embedded: 'always'}
}
});
import Ember from 'ember';
export default Ember.ArrayController.extend({
needs: ['application'],
queryParams: ['category'],
category: '',
categories: Ember.computed.mapBy('model', 'category'),
uniqCategories: Ember.computed.uniq('categories'),
search: Ember.computed.alias('controllers.application.search'),
filteredContent: function() {
var products = this.model,
search = new RegExp(this.get('search'), 'i'),
category = this.get('category');
products = products.filter(function(product) {
var str = product.get('title') + product.get('description');
return search.test(str);
});
if (category) {
products = products.filterBy('category.name', category);
}
return products;
}.property('@each.isDirty', 'search', 'category')
});
@JeroenKnoops
Copy link

Why do we need the content from category in products-controller.js#7

@bazzel
Copy link
Author

bazzel commented Nov 10, 2014

We don't. Thx for notifying.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment