Skip to content

Instantly share code, notes, and snippets.

@ghempton
Created April 29, 2014 01:55
Show Gist options
  • Save ghempton/11389007 to your computer and use it in GitHub Desktop.
Save ghempton/11389007 to your computer and use it in GitHub Desktop.
Epf Route
`import CurrentUserMixin from 'outreach/core/current_user_mixin'`
`import Model from 'outreach/core/model'`
class Route extends Em.Route with CurrentUserMixin
+computed
title: ->
'Outreach'
enter: ->
super()
# Set title
$(document).attr('title', @title)
beforeModel: (transition) ->
routes = transition.state.handlerInfos.mapProperty('handler')
parentSession = null
index = routes.indexOf(@)
while(!parentSession && index >= 1)
index -= 1
parentRoute = routes[index]
parentSession = parentRoute.session
@session = @resolveSession(parentSession)
afterModel: (model, transition) ->
if model && model instanceof Model
self = @
transition.resolvedModels[this.routeName] = if Ember.isArray(model) then model.map((m) -> self.session.add(m)) else @session.add(model)
setupController: (controller, context) ->
super(controller, context)
controller.session = @session
resolveSession: (parentSession) ->
parentSession
`export default Route`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment