ES6: Start converting routes

This commit is contained in:
Robin Ward 2014-07-21 12:00:58 -04:00
parent 59c3ca7e7b
commit 90e2f1893c
8 changed files with 16 additions and 73 deletions

View File

@ -1,15 +1,6 @@
/**
Application route for Discourse
@class ApplicationRoute
@extends Ember.Route
@namespace Discourse
@module Discourse
**/
Discourse.ApplicationRoute = Em.Route.extend({
var ApplicationRoute = Em.Route.extend({
actions: {
error: function(err, transition) {
if (err.status === 404) {
// 404
@ -106,14 +97,15 @@ Discourse.ApplicationRoute = Em.Route.extend({
}
},
activate: function() {
_activate: function() {
this._super();
Em.run.next(function() {
// Support for callbacks once the application has activated
Discourse.ApplicationRoute.trigger('activate');
ApplicationRoute.trigger('activate');
});
}
});
RSVP.EventTarget.mixin(Discourse.ApplicationRoute);
RSVP.EventTarget.mixin(ApplicationRoute);
export default ApplicationRoute;

View File

@ -1,19 +1,9 @@
/**
The base route for showing a user's activity
@class UserActivityRoute
@extends Discourse.Route
@namespace Discourse
@module Discourse
**/
Discourse.UserActivityRoute = Discourse.Route.extend({
export default Discourse.Route.extend({
model: function() {
return this.modelFor('user');
},
setupController: function(controller, user) {
this.controllerFor('user-activity').set('model', user);
this.controllerFor('user').set('pmView', null);
@ -33,7 +23,4 @@ Discourse.UserActivityRoute = Discourse.Route.extend({
});
}
}
});
Discourse.UserPrivateMessagesRoute = Discourse.UserActivityRoute.extend({});

View File

@ -1,11 +1,3 @@
/**
This route shows a user's badges.
@class UserBadgesRoute
@extends Discourse.Route
@namespace Discourse
@module Discourse
**/
Discourse.UserBadgesRoute = Discourse.Route.extend({
model: function() {
return Discourse.UserBadge.findByUsername(this.modelFor('user').get('username_lower'), {grouped: true});

View File

@ -0,0 +1,5 @@
export default Em.Route.extend({
redirect: function() {
this.replaceWith('userActivity', this.modelFor('user'));
}
});

View File

@ -1,12 +1,4 @@
/**
This route shows who a user has invited
@class UserInvitedRoute
@extends Discourse.Route
@namespace Discourse
@module Discourse
**/
Discourse.UserInvitedRoute = Discourse.Route.extend({
export default Discourse.Route.extend({
renderTemplate: function() {
this.render({ into: 'user', outlet: 'userOutlet' });
},
@ -26,12 +18,6 @@ Discourse.UserInvitedRoute = Discourse.Route.extend({
},
actions: {
/**
Shows the invite modal to invite users to the forum.
@method showInvite
**/
showInvite: function() {
Discourse.Route.showModal(this, 'invite', Discourse.User.current());
this.controllerFor('invite').reset();
@ -45,5 +31,4 @@ Discourse.UserInvitedRoute = Discourse.Route.extend({
bootbox.alert(I18n.t("user.invited.bulk_invite.error", { filename: filename, message: message }));
}
}
});

View File

@ -0,0 +1,3 @@
import UserActivityRoute from 'discourse/routes/user-activity';
export default UserActivityRoute.extend();

View File

@ -1,12 +1,4 @@
/**
Handles routes related to users.
@class UserRoute
@extends Discourse.Route
@namespace Discourse
@module Discourse
**/
Discourse.UserRoute = Discourse.Route.extend({
export default Discourse.Route.extend({
actions: {
logout: function() {

View File

@ -1,13 +0,0 @@
/**
If we request /users/eviltrout without a sub route.
@class UserIndexRoute
@extends Discourse.Route
@namespace Discourse
@module Discourse
**/
Discourse.UserIndexRoute = Discourse.UserActivityRoute.extend({
redirect: function() {
this.replaceWith('userActivity', this.modelFor('user'));
}
});