travis-web/assets/scripts/app/views/repo/list.coffee
Piotr Sarnacki e6800c80c6 Refactor our layout handling
Layout handling in travis-web was implemented in a dynamic way, so we
could change a main layout from any of the routes. This needed a
`rerender` call which was making things harder and needed some hacks. It
also broke a few transitions when upgrading to 1.8.1.

After examining our usage of layouts I've noticed that we don't need to
change the entire layout dynamically and instead we can set layout on
root routes (like "index", "profile" and other root routes).
2014-12-29 18:16:14 +01:00

50 lines
1.4 KiB
CoffeeScript

@Travis.reopen
ReposView: Travis.View.extend
templateName: 'repos/list'
ReposListView: Em.CollectionView.extend
elementId: 'repos'
tagName: 'ul'
emptyView: Ember.View.extend
template: Ember.Handlebars.compile('<div class="loading"><span>Loading</span></div>')
itemViewClass: Travis.View.extend
repoBinding: 'content'
classNames: ['repo']
classNameBindings: ['color', 'selected']
selected: (->
@get('content') == @get('controller.selectedRepo')
).property('controller.selectedRepo')
color: (->
Travis.Helpers.colorForState(@get('repo.lastBuildState'))
).property('repo.lastBuildState')
click: ->
@get('controller').transitionToRoute('/' + @get('repo.slug'))
ReposListTabsView: Travis.View.extend
templateName: 'repos/list/tabs'
tabBinding: 'controller.tab'
currentUserBinding: 'controller.currentUser.id'
classRecent: (->
'active' if @get('tab') == 'recent'
).property('tab')
classOwned: (->
classes = []
classes.push('active') if @get('tab') == 'owned'
classes.push('display-inline') if @get('currentUser')
classes.join(' ')
).property('tab', 'currentUser')
classSearch: (->
'active' if @get('tab') == 'search'
).property('tab')
classNew: (->
'display-inline' if @get('currentUser')
).property('currentUser')