FIX: Navigating to a user's admin page would not populate

`availableGroups`
This commit is contained in:
Robin Ward 2014-07-23 16:54:04 -04:00
parent 27f786e06a
commit c8a0bf35c5
3 changed files with 19 additions and 35 deletions

View File

@ -1,14 +1,3 @@
/**
The top-level controller for user pages in admin.
Ember assertion says that this class needs to be defined even if it's empty.
@class AdminUserController
@extends Discourse.ObjectController
@namespace Discourse
@module Discourse
**/
Discourse.AdminUserController = Discourse.ObjectController.extend({});
/** /**
A controller related to viewing a user in the admin section A controller related to viewing a user in the admin section
@ -19,6 +8,8 @@ Discourse.AdminUserController = Discourse.ObjectController.extend({});
**/ **/
Discourse.AdminUserIndexController = Discourse.ObjectController.extend({ Discourse.AdminUserIndexController = Discourse.ObjectController.extend({
editingTitle: false, editingTitle: false,
originalPrimaryGroupId: null,
availableGroups: null,
showApproval: Discourse.computed.setting('must_approve_users'), showApproval: Discourse.computed.setting('must_approve_users'),
showBadges: Discourse.computed.setting('enable_badges'), showBadges: Discourse.computed.setting('enable_badges'),

View File

@ -1,13 +1,4 @@
/**
Handles routes related to users in the admin section.
@class AdminUserRoute
@extends Discourse.Route
@namespace Discourse
@module Discourse
**/
Discourse.AdminUserRoute = Discourse.Route.extend({ Discourse.AdminUserRoute = Discourse.Route.extend({
serialize: function(model) { serialize: function(model) {
return { username: model.get('username').toLowerCase() }; return { username: model.get('username').toLowerCase() };
}, },
@ -21,22 +12,30 @@ Discourse.AdminUserRoute = Discourse.Route.extend({
}, },
afterModel: function(adminUser) { afterModel: function(adminUser) {
var controller = this.controllerFor('adminUser');
Discourse.Group.findAll().then(function(groups){
controller.set("availableGroups", groups.filterBy("automatic", false));
}.bind(this));
return adminUser.loadDetails().then(function () { return adminUser.loadDetails().then(function () {
adminUser.setOriginalTrustLevel(); adminUser.setOriginalTrustLevel();
controller.set('model', adminUser); return adminUser;
});
}
});
Discourse.AdminUserIndexRoute = Discourse.Route.extend({
model: function() {
return this.modelFor('adminUser');
},
afterModel: function(model) {
var self = this;
return Discourse.Group.findAll().then(function(groups){
self._availableGroups = groups.filterBy('automatic', false);
return model;
}); });
}, },
setupController: function(controller, model) { setupController: function(controller, model) {
controller.setProperties({ controller.setProperties({
originalPrimaryGroupId: model.get('primary_group_id'), originalPrimaryGroupId: model.get('primary_group_id'),
availableGroups: this._availableGroups,
model: model model: model
}); });
}, },
@ -47,11 +46,4 @@ Discourse.AdminUserRoute = Discourse.Route.extend({
this.controllerFor('modal').set('modalClass', 'suspend-user-modal'); this.controllerFor('modal').set('modalClass', 'suspend-user-modal');
} }
} }
});
Discourse.AdminUserIndexRoute = Discourse.Route.extend({
setupController: function(c) {
c.set('model', this.controllerFor('adminUser').get('model'));
}
}); });

View File

@ -9,6 +9,7 @@ var ApplicationRoute = Em.Route.extend({
} }
var exceptionController = this.controllerFor('exception'); var exceptionController = this.controllerFor('exception');
Em.warn(err);
exceptionController.setProperties({ lastTransition: transition, thrown: err }); exceptionController.setProperties({ lastTransition: transition, thrown: err });
this.intermediateTransitionTo('exception'); this.intermediateTransitionTo('exception');