diff --git a/app/assets/javascripts/admin/models/admin_user.js b/app/assets/javascripts/admin/models/admin_user.js index e66f22dd7..85cb39e53 100644 --- a/app/assets/javascripts/admin/models/admin_user.js +++ b/app/assets/javascripts/admin/models/admin_user.js @@ -216,6 +216,17 @@ Discourse.AdminUser = Discourse.User.extend({ }); } }); + }, + + loadDetails: function() { + var model = this; + if (model.get('loadedDetails')) { return; } + + Discourse.AdminUser.find(model.get('username_lower')).then(function (result) { + console.log("loaded details"); + model.setProperties(result); + model.set('loadedDetails', true); + }); } }); @@ -243,6 +254,7 @@ Discourse.AdminUser.reopenClass({ find: function(username) { return Discourse.ajax("/admin/users/" + username).then(function (result) { + result.loadedDetails = true; return Discourse.AdminUser.create(result); }); }, diff --git a/app/assets/javascripts/admin/routes/admin_user_route.js b/app/assets/javascripts/admin/routes/admin_user_route.js index d95770f55..ab38ba419 100644 --- a/app/assets/javascripts/admin/routes/admin_user_route.js +++ b/app/assets/javascripts/admin/routes/admin_user_route.js @@ -6,7 +6,7 @@ @namespace Discourse @module Discourse **/ -Discourse.AdminUserRoute = Discourse.Route.extend({ +Discourse.AdminUserRoute = Discourse.Route.extend(Discourse.ModelReady, { serialize: function(params) { return { username: Em.get(params, 'username').toLowerCase() }; @@ -18,6 +18,11 @@ Discourse.AdminUserRoute = Discourse.Route.extend({ renderTemplate: function() { this.render({into: 'admin/templates/admin'}); + }, + + modelReady: function(controller, adminUser) { + adminUser.loadDetails(); + controller.set('model', adminUser); } });