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 @@
/** var ApplicationRoute = Em.Route.extend({
Application route for Discourse
@class ApplicationRoute
@extends Ember.Route
@namespace Discourse
@module Discourse
**/
Discourse.ApplicationRoute = Em.Route.extend({
actions: { actions: {
error: function(err, transition) { error: function(err, transition) {
if (err.status === 404) { if (err.status === 404) {
// 404 // 404
@ -106,14 +97,15 @@ Discourse.ApplicationRoute = Em.Route.extend({
} }
}, },
activate: function() { _activate: function() {
this._super(); this._super();
Em.run.next(function() { Em.run.next(function() {
// Support for callbacks once the application has activated // 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 @@
/** export default Discourse.Route.extend({
The base route for showing a user's activity
@class UserActivityRoute
@extends Discourse.Route
@namespace Discourse
@module Discourse
**/
Discourse.UserActivityRoute = Discourse.Route.extend({
model: function() { model: function() {
return this.modelFor('user'); return this.modelFor('user');
}, },
setupController: function(controller, user) { setupController: function(controller, user) {
this.controllerFor('user-activity').set('model', user); this.controllerFor('user-activity').set('model', user);
this.controllerFor('user').set('pmView', null); 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({ Discourse.UserBadgesRoute = Discourse.Route.extend({
model: function() { model: function() {
return Discourse.UserBadge.findByUsername(this.modelFor('user').get('username_lower'), {grouped: true}); 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 @@
/** export default Discourse.Route.extend({
This route shows who a user has invited
@class UserInvitedRoute
@extends Discourse.Route
@namespace Discourse
@module Discourse
**/
Discourse.UserInvitedRoute = Discourse.Route.extend({
renderTemplate: function() { renderTemplate: function() {
this.render({ into: 'user', outlet: 'userOutlet' }); this.render({ into: 'user', outlet: 'userOutlet' });
}, },
@ -26,12 +18,6 @@ Discourse.UserInvitedRoute = Discourse.Route.extend({
}, },
actions: { actions: {
/**
Shows the invite modal to invite users to the forum.
@method showInvite
**/
showInvite: function() { showInvite: function() {
Discourse.Route.showModal(this, 'invite', Discourse.User.current()); Discourse.Route.showModal(this, 'invite', Discourse.User.current());
this.controllerFor('invite').reset(); 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 })); 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 @@
/** export default Discourse.Route.extend({
Handles routes related to users.
@class UserRoute
@extends Discourse.Route
@namespace Discourse
@module Discourse
**/
Discourse.UserRoute = Discourse.Route.extend({
actions: { actions: {
logout: function() { 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'));
}
});