Skip to content

Instantly share code, notes, and snippets.

@jasonmit
Created December 18, 2013 23:49
Show Gist options
  • Save jasonmit/8031890 to your computer and use it in GitHub Desktop.
Save jasonmit/8031890 to your computer and use it in GitHub Desktop.
Ember list view
import LazyLoadingViewMixin from 'app/mixins/grouped_view';
import LoadingBarView from 'app/views/universal/loading_bar';
var EntityListView = Ember.CollectionView.extend(LazyLoadingViewMixin, {
tagName: 'ul',
classNames: ['list-group']
});
var ContainerView = Ember.ContainerView.extend({
childViews: ['loader', 'list'],
list: EntityListView.extend({
content: Ember.computed.alias('parentView.content'),
itemViewClass: Ember.computed.alias('parentView.itemViewClass'),
classNameBindings: ['parentView.classNames'],
loadMoreAction: function() {
return this.get('parentView.loadMoreAction') || 'loadMore';
}.property('parentView.loadMoreAction'),
infiniteEnabled: function() {
var inf = this.get('parentView.infiniteEnabled');
if(Ember.typeOf(inf) === 'boolean') {
return inf;
}
return true;
}.property('parentView.infiniteEnabled', 'infiniteEnabled'),
emptyView: Ember.View.extend({
tagName: 'div',
message: function() {
return this.get('parentView.emptyMessage') || 'There were no records found.'
}.property('parentView.emptyMessage'),
template: Ember.Handlebars.compile("<h2>{{view.message}}</h2>")
})
}),
loader: LoadingBarView.extend({
isVisible: function() {
return !!this.get('parentView.showLoader');
}.property('parentView.showLoader')
})
});
export default ContainerView;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment