Created
December 18, 2013 23:49
-
-
Save jasonmit/8031890 to your computer and use it in GitHub Desktop.
Ember list view
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 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