Make profiles code a bit simpler

We don't need to nest "profile" tab in account view
This commit is contained in:
Piotr Sarnacki 2014-05-23 18:10:41 +02:00
parent a39d031925
commit 459089f0cd
2 changed files with 10 additions and 13 deletions

View File

@ -73,7 +73,7 @@ Travis.Router.map ->
@resource 'profile', path: '/profile', -> @resource 'profile', path: '/profile', ->
@resource 'account', path: '/:login', -> @resource 'account', path: '/:login', ->
@route 'profile', path: '/profile' @route 'info', path: '/info'
@route 'notFound', path: "/*path" @route 'notFound', path: "/*path"
@ -297,14 +297,6 @@ Travis.ProfileIndexRoute = Travis.Route.extend
@render 'hooks', controller: 'profile' @render 'hooks', controller: 'profile'
Travis.AccountRoute = Travis.Route.extend Travis.AccountRoute = Travis.Route.extend
setupController: (controller, account) ->
profileController = @container.lookup('controller:profile')
profileController.activate 'hooks'
if account
params = { login: account.get('login') }
profileController.setParams(params)
model: (params) -> model: (params) ->
controller = @container.lookup('controller:accounts') controller = @container.lookup('controller:accounts')
account = controller.findByLogin(params.login) account = controller.findByLogin(params.login)
@ -330,13 +322,18 @@ Travis.AccountRoute = Travis.Route.extend
{} {}
Travis.AccountIndexRoute = Travis.Route.extend Travis.AccountIndexRoute = Travis.Route.extend
setupController: -> setupController: (controller) ->
@container.lookup('controller:profile').activate 'hooks' profileController = @container.lookup('controller:profile')
profileController.activate 'hooks'
if account = @modelFor('account')
params = { login: account.get('login') }
profileController.setParams(params)
renderTemplate: -> renderTemplate: ->
@render 'hooks' @render 'hooks'
Travis.AccountProfileRoute = Travis.Route.extend Travis.ProfileInfoRoute = Travis.Route.extend
setupController: -> setupController: ->
@container.lookup('controller:profile').activate 'user' @container.lookup('controller:profile').activate 'user'

View File

@ -11,7 +11,7 @@
{{#if view.displayUser}} {{#if view.displayUser}}
<li id="tab_user" {{bind-attr class="view.classUser"}}> <li id="tab_user" {{bind-attr class="view.classUser"}}>
<h5> <h5>
{{#link-to "account.profile" view.account}}Profile{{/link-to}} {{#link-to "profile.info"}}Profile{{/link-to}}
</h5> </h5>
</li> </li>
{{/if}} {{/if}}