travis-web/assets/javascripts/app/controllers/repository.coffee
Piotr Sarnacki 1134028996 Travis mostly works with new router
I haven't touched almost all of the things related to profile. I'm not
also sure what's the state of authentication at this point.

Conflicts:

	Gemfile
	Gemfile.lock
	Procfile
	assets/javascripts/app/app.coffee
	assets/javascripts/app/controllers.coffee
	assets/javascripts/app/controllers/auth.coffee
	assets/javascripts/app/controllers/profile.coffee
	assets/javascripts/app/routes.coffee
	assets/javascripts/app/templates/builds/list.hbs
	assets/javascripts/app/templates/builds/show.hbs
	assets/javascripts/app/templates/jobs/list.hbs
	assets/javascripts/app/templates/layouts/top.hbs
	assets/javascripts/app/templates/repos/list.hbs
	assets/javascripts/app/templates/repos/show/tabs.hbs
	assets/javascripts/app/templates/workers/list.hbs
	assets/javascripts/app/views.coffee
	assets/javascripts/app/views/repo/show.coffee
	assets/javascripts/travis.coffee
	public/index.html
	public/javascripts/application.js
	public/stylesheets/application.css
2012-09-26 16:30:16 +02:00

98 lines
2.7 KiB
CoffeeScript

Travis.RepositoryController = Travis.Controller.extend
bindings: []
params: {}
init: ->
@_super.apply this, arguments
Ember.run.later(@updateTimes.bind(this), Travis.INTERVALS.updateTimes)
updateTimes: ->
if builds = @get('builds')
builds.forEach (b) -> b.updateTimes()
if build = @get('build')
build.updateTimes()
build.get('jobs').forEach (j) -> j.updateTimes()
Ember.run.later(@updateTimes.bind(this), Travis.INTERVALS.updateTimes)
activate: (action, params) ->
@_unbind()
@setParams(params)
this["view#{$.camelize(action)}"]()
viewIndex: ->
@_bind('repository', 'controllers.repositoriesController.firstObject')
@_bind('build', 'repository.lastBuild')
@connectTab('current')
viewCurrent: ->
@connectTab('current')
@_bind('repository', 'repositoriesByParams.firstObject')
@_bind('build', 'repository.lastBuild')
viewBuilds: ->
@connectTab('builds')
@_bind('repository', 'repositoriesByParams.firstObject')
@_bind('builds', 'repository.builds')
viewPullRequests: ->
@connectTab('pull_requests')
@_bind('repository', 'repositoriesByParams.firstObject')
@_bind('builds', 'repository.pullRequests')
viewBranches: ->
@connectTab('branches')
@_bind('repository', 'repositoriesByParams.firstObject')
@_bind('builds', 'repository.branches')
viewBuild: ->
@_bind('repository', 'repositoriesByParams.firstObject')
@_bind('build', 'buildById')
@connectTab('build')
viewJob: ->
@_bind('repository', 'repositoriesByParams.firstObject')
@_bind('build', 'job.build')
@_bind('job', 'jobById')
@connectTab('job')
repositoriesByParams: (->
Travis.Repository.bySlug("#{@get('params.owner')}/#{@get('params.name')}")
).property('params.owner', 'params.name')
buildById: (->
Travis.Build.find(id) if id = @get('params.id')
).property('params.id')
jobById: (->
Travis.Job.find(id) if id = @get('params.id')
).property('params.id')
repositoryObserver: (->
repository = @get('repository')
repository.select() if repository
).observes('repository.id')
connectTab: (tab) ->
name = if tab == 'current' then 'build' else tab
viewClass = if name in ['builds', 'branches', 'pull_requests']
Travis.BuildsView
else
Travis["#{$.camelize(name)}View"]
@set('tab', tab)
@connectOutlet(outletName: 'pane', controller: this, viewClass: viewClass)
setParams: (params) ->
# TODO if we just @set('params', params) it will update the repositoriesByParams property
@set("params.#{key}", params[key]) for key, value of params
_bind: (to, from) ->
@bindings.push Ember.oneWay(this, to, from)
_unbind: ->
binding.disconnect(this) for binding in @bindings
@bindings.length = 0