FIX: Load more user admin details, even when passed from a list

This commit is contained in:
Robin Ward 2013-05-14 12:03:15 -04:00
parent 674818a26a
commit df2a718446
2 changed files with 18 additions and 15 deletions

View File

@ -18,12 +18,12 @@ Discourse.AdminUsersListController = Ember.ArrayController.extend(Discourse.Pres
@event selectAll @event selectAll
**/ **/
selectAllChanged: (function() { selectAllChanged: function() {
var _this = this; var _this = this;
this.get('content').each(function(user) { this.get('content').each(function(user) {
user.set('selected', _this.get('selectAll')); user.set('selected', _this.get('selectAll'));
}); });
}).observes('selectAll'), }.observes('selectAll'),
/** /**
Triggered when the username filter is changed Triggered when the username filter is changed
@ -39,9 +39,9 @@ Discourse.AdminUsersListController = Ember.ArrayController.extend(Discourse.Pres
@event orderChanged @event orderChanged
**/ **/
orderChanged: (function() { orderChanged: function() {
this.refreshUsers(); this.refreshUsers();
}).observes('query'), }.observes('query'),
/** /**
The title of the user list, based on which query was performed. The title of the user list, based on which query was performed.
@ -57,30 +57,30 @@ Discourse.AdminUsersListController = Ember.ArrayController.extend(Discourse.Pres
@property showApproval @property showApproval
**/ **/
showApproval: (function() { showApproval: function() {
if (!Discourse.SiteSettings.must_approve_users) return false; if (!Discourse.SiteSettings.must_approve_users) return false;
if (this.get('query') === 'new') return true; if (this.get('query') === 'new') return true;
if (this.get('query') === 'pending') return true; if (this.get('query') === 'pending') return true;
}).property('query'), }.property('query'),
/** /**
How many users are currently selected How many users are currently selected
@property selectedCount @property selectedCount
**/ **/
selectedCount: (function() { selectedCount: function() {
if (this.blank('content')) return 0; if (this.blank('content')) return 0;
return this.get('content').filterProperty('selected').length; return this.get('content').filterProperty('selected').length;
}).property('content.@each.selected'), }.property('content.@each.selected'),
/** /**
Do we have any selected users? Do we have any selected users?
@property hasSelection @property hasSelection
**/ **/
hasSelection: (function() { hasSelection: function() {
return this.get('selectedCount') > 0; return this.get('selectedCount') > 0;
}).property('selectedCount'), }.property('selectedCount'),
/** /**
Refresh the current list of users. Refresh the current list of users.

View File

@ -7,15 +7,18 @@
@module Discourse @module Discourse
**/ **/
Discourse.AdminUserRoute = Discourse.Route.extend({ Discourse.AdminUserRoute = Discourse.Route.extend({
model: function(params) {
return Discourse.AdminUser.find(params.username);
},
serialize: function(params) { serialize: function(params) {
return { username: Em.get(params, 'username').toLowerCase() }; return { username: Em.get(params, 'username').toLowerCase() };
}, },
renderTemplate: function() { renderTemplate: function() {
this.render('admin/templates/user', {into: 'admin/templates/admin'}); this.render('admin/templates/user', {into: 'admin/templates/admin'});
} },
setupController: function(controller, model) {
Discourse.AdminUser.find(Em.get(model, 'username').toLowerCase()).then(function (u) {
controller.set('content', u);
});
},
}); });