Last active
August 29, 2015 14:08
-
-
Save bazzel/99f9b3f8e6433359523b to your computer and use it in GitHub Desktop.
https://github.com/bazzel/ember-workshop, tag 10.0.0
This file contains hidden or 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 DS from 'ember-data'; | |
export default DS.ActiveModelSerializer.extend(DS.EmbeddedRecordsMixin, { | |
attrs: { | |
category: {embedded: 'always'} | |
} | |
}); |
This file contains hidden or 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'; | |
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') | |
}); |
We don't. Thx for notifying.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why do we need the content from category in products-controller.js#7