Fix search to work with new way of handling repos tabs

This commit is contained in:
Piotr Sarnacki 2014-12-23 13:14:57 +01:00
parent 345dacff29
commit f355bc58f3
2 changed files with 26 additions and 6 deletions
assets/scripts/app

View File

@ -61,22 +61,20 @@ Travis.ReposController = Ember.ArrayController.extend
[]
).property('currentUser.login')
viewSearch: (params) ->
@set('content', Travis.Repo.search(params.search))
viewSearch: (phrase) ->
@set('search', phrase)
@set('content', Travis.Repo.search(phrase))
searchObserver: (->
search = @get('search')
if search
@searchFor search
else
@activate 'recent'
'recent'
).observes('search')
searchFor: (phrase) ->
Ember.run.cancel(@searchLater) if @searchLater
@searchLater = Ember.run.later(this, (->
@activate 'search', search: phrase
@transitionTo('index.search', phrase)
), 500)
noReposMessage: (->

View File

@ -54,6 +54,7 @@ Travis.Router.map ->
@resource 'getting_started'
@route 'recent'
@route 'my_repositories'
@route 'search', path: '/search/:phrase'
@resource 'repo', path: '/:owner/:name', ->
@route 'index', path: '/'
@resource 'build', path: '/builds/:build_id'
@ -185,6 +186,27 @@ Travis.IndexMyRepositoriesRoute = Travis.IndexTabRoute.extend
Travis.IndexRecentRoute = Travis.IndexTabRoute.extend
reposTabName: 'recent'
Travis.IndexSearchRoute = Travis.IndexTabRoute.extend
renderTemplate: ->
@render 'repo'
@render 'build', into: 'repo'
setupController: (controller, searchPhrase) ->
# TODO: this method is almost the same as _super, refactor this
@controllerFor('repo').activate('index')
@controllerFor('repos').activate('search', searchPhrase)
@currentRepoDidChange()
@controllerFor('repos').addObserver('firstObject', this, 'currentRepoDidChange')
model: (params) ->
params.phrase
deactivate: ->
@_super.apply(this, arguments)
@controllerFor('repos').set('search', undefined)
Travis.AbstractBuildsRoute = Travis.Route.extend
renderTemplate: ->
@render 'builds'