Created
April 29, 2014 01:55
-
-
Save ghempton/11389007 to your computer and use it in GitHub Desktop.
Epf Route
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
`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