Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import Ember from 'ember';
import Utils from 'docket/utils';
import Status from 'docket/models/status';
import User from 'docket/models/user';
export default Ember.Route.extend({
activate: function() {
this._super();
// do some setup related to event_source here
},
beforeModel: function() {
// if we return a promise this should block until it is resolved
var store = this.get('store');
var promises = [
// where I do Utils.current_user = user; you could do store.push, I believe
store.find('user', Utils.current_user_id).then(function(user) {Utils.current_user = user;}),
store.find('status', Status.OPEN_ID).then(function(status) {Status.OPEN = status;}),
store.find('status', Status.CLOSED_ID).then(function(status) {Status.CLOSED = status;}),
store.find('status', Status.REVIEWED_ID).then(function(status) {Status.REVIEWED = status;}),
store.find('status', Status.INVOICED_ID).then(function(status) {Status.INVOICED = status;})
]
return Ember.RSVP.all(promises, 'preloading');
},
// this sets up the application controller, not necessary
setupController: function(controller, model) {
this._super(controller, model);
controller.set('current_user', Utils.current_user);
// status for sidebar filtering
controller.set('status_open_id', Status.OPEN_ID);
controller.set('status_closed_id', Status.CLOSED_ID);
controller.set('status_reviewed_id', Status.REVIEWED_ID);
controller.set('status_invoiced_id', Status.INVOICED_ID);
// user ids for sidebar filtering
controller.set('current_user_id', Utils.current_user_id);
controller.set('user_unclaimed_id', User.UNCLAIMED_ID);
controller.set('user_all_id', User.ALL_ID);
}
});
@tpitale

This comment has been minimized.

Copy link
Owner Author

@tpitale tpitale commented Jun 16, 2017

This is in routes/application.es6 for me. I have not updated Ember stuff in some time. YMMV. Hope it helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment