Removed `modelReady` hack now that the async router exists
This commit is contained in:
parent
6929ee9f46
commit
4bfb546942
|
@ -238,9 +238,9 @@ Discourse.AdminUser = Discourse.User.extend({
|
||||||
|
|
||||||
loadDetails: function() {
|
loadDetails: function() {
|
||||||
var model = this;
|
var model = this;
|
||||||
if (model.get('loadedDetails')) { return; }
|
if (model.get('loadedDetails')) { return Ember.RSVP.resolve(model); }
|
||||||
|
|
||||||
Discourse.AdminUser.find(model.get('username_lower')).then(function (result) {
|
return Discourse.AdminUser.find(model.get('username_lower')).then(function (result) {
|
||||||
model.setProperties(result);
|
model.setProperties(result);
|
||||||
model.set('loadedDetails', true);
|
model.set('loadedDetails', true);
|
||||||
});
|
});
|
||||||
|
|
|
@ -11,14 +11,16 @@ var oneWeekAgo = function() {
|
||||||
return moment().subtract('days',7).format('YYYY-MM-DD');
|
return moment().subtract('days',7).format('YYYY-MM-DD');
|
||||||
};
|
};
|
||||||
|
|
||||||
Discourse.AdminEmailPreviewDigestRoute = Discourse.Route.extend(Discourse.ModelReady, {
|
Discourse.AdminEmailPreviewDigestRoute = Discourse.Route.extend({
|
||||||
|
|
||||||
model: function() {
|
model: function() {
|
||||||
return Discourse.EmailPreview.findDigest(oneWeekAgo());
|
return Discourse.EmailPreview.findDigest(oneWeekAgo());
|
||||||
},
|
},
|
||||||
|
|
||||||
modelReady: function(controller, model) {
|
afterModel: function(model) {
|
||||||
|
var controller = this.controllerFor('adminEmailPreviewDigest');
|
||||||
controller.setProperties({
|
controller.setProperties({
|
||||||
|
model: model,
|
||||||
lastSeen: oneWeekAgo(),
|
lastSeen: oneWeekAgo(),
|
||||||
showHtml: true
|
showHtml: true
|
||||||
});
|
});
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
@namespace Discourse
|
@namespace Discourse
|
||||||
@module Discourse
|
@module Discourse
|
||||||
**/
|
**/
|
||||||
Discourse.AdminUserRoute = Discourse.Route.extend(Discourse.ModelReady, {
|
Discourse.AdminUserRoute = Discourse.Route.extend({
|
||||||
|
|
||||||
serialize: function(params) {
|
serialize: function(params) {
|
||||||
return { username: Em.get(params, 'username').toLowerCase() };
|
return { username: Em.get(params, 'username').toLowerCase() };
|
||||||
|
@ -20,10 +20,14 @@ Discourse.AdminUserRoute = Discourse.Route.extend(Discourse.ModelReady, {
|
||||||
this.render({into: 'admin/templates/admin'});
|
this.render({into: 'admin/templates/admin'});
|
||||||
},
|
},
|
||||||
|
|
||||||
modelReady: function(controller, adminUser) {
|
afterModel: function(adminUser) {
|
||||||
adminUser.loadDetails();
|
var controller = this.controllerFor('adminUser');
|
||||||
controller.set('model', adminUser);
|
|
||||||
|
adminUser.loadDetails().then(function () {
|
||||||
adminUser.setOriginalTrustLevel();
|
adminUser.setOriginalTrustLevel();
|
||||||
|
controller.set('model', adminUser);
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
/**
|
|
||||||
Until the fully async router is merged into Ember, it is healthy to do some extra checking
|
|
||||||
that setupController is not passed a promise instead of the model we want.
|
|
||||||
|
|
||||||
This mixin handles that case, and calls modelReady instead.
|
|
||||||
|
|
||||||
@class Discourse.ModelReady
|
|
||||||
@extends Ember.Mixin
|
|
||||||
@namespace Discourse
|
|
||||||
@module Discourse
|
|
||||||
**/
|
|
||||||
Discourse.ModelReady = Em.Mixin.create({
|
|
||||||
|
|
||||||
setupController: function(controller, model) {
|
|
||||||
var route = this;
|
|
||||||
if (model.then) {
|
|
||||||
model.then(function (m) {
|
|
||||||
controller.set('model', m);
|
|
||||||
if (route.modelReady) { route.modelReady(controller, m); }
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
controller.set('model', model);
|
|
||||||
if (route.modelReady) { route.modelReady(controller, model); }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ Discourse.InviteList.reopenClass({
|
||||||
|
|
||||||
findInvitedBy: function(user) {
|
findInvitedBy: function(user) {
|
||||||
return Discourse.ajax("/users/" + (user.get('username_lower')) + "/invited.json").then(function (result) {
|
return Discourse.ajax("/users/" + (user.get('username_lower')) + "/invited.json").then(function (result) {
|
||||||
|
console.log('wat');
|
||||||
var invitedList = result.invited_list;
|
var invitedList = result.invited_list;
|
||||||
if (invitedList.pending) {
|
if (invitedList.pending) {
|
||||||
invitedList.pending = invitedList.pending.map(function(i) {
|
invitedList.pending = invitedList.pending.map(function(i) {
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
**/
|
**/
|
||||||
Discourse.RestrictedUserRoute = Discourse.Route.extend({
|
Discourse.RestrictedUserRoute = Discourse.Route.extend({
|
||||||
|
|
||||||
redirect: function() {
|
afterModel: function() {
|
||||||
var user = this.modelFor('user');
|
var user = this.modelFor('user');
|
||||||
if (!user.get('can_edit')) {
|
if (!user.get('can_edit')) {
|
||||||
this.transitionTo('user.activity', user);
|
this.transitionTo('user.activity', user);
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
@namespace Discourse
|
@namespace Discourse
|
||||||
@module Discourse
|
@module Discourse
|
||||||
**/
|
**/
|
||||||
Discourse.ListCategoriesRoute = Discourse.Route.extend(Discourse.ModelReady, {
|
Discourse.ListCategoriesRoute = Discourse.Route.extend({
|
||||||
|
|
||||||
redirect: function() { Discourse.redirectIfLoginRequired(this); },
|
redirect: function() { Discourse.redirectIfLoginRequired(this); },
|
||||||
|
|
||||||
|
@ -31,9 +31,11 @@ Discourse.ListCategoriesRoute = Discourse.Route.extend(Discourse.ModelReady, {
|
||||||
this.controllerFor('list').set('canCreateCategory', false);
|
this.controllerFor('list').set('canCreateCategory', false);
|
||||||
},
|
},
|
||||||
|
|
||||||
modelReady: function(controller, categoryList) {
|
renderTemplate: function() {
|
||||||
this.render('listCategories', { into: 'list', outlet: 'listView' });
|
this.render('listCategories', { into: 'list', outlet: 'listView' });
|
||||||
|
},
|
||||||
|
|
||||||
|
afterModel: function(categoryList) {
|
||||||
this.controllerFor('list').setProperties({
|
this.controllerFor('list').setProperties({
|
||||||
canCreateCategory: categoryList.get('can_create_category'),
|
canCreateCategory: categoryList.get('can_create_category'),
|
||||||
canCreateTopic: categoryList.get('can_create_topic'),
|
canCreateTopic: categoryList.get('can_create_topic'),
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
@namespace Discourse
|
@namespace Discourse
|
||||||
@module Discourse
|
@module Discourse
|
||||||
**/
|
**/
|
||||||
Discourse.UserInvitedRoute = Discourse.Route.extend(Discourse.ModelReady, {
|
Discourse.UserInvitedRoute = Discourse.Route.extend({
|
||||||
|
|
||||||
renderTemplate: function() {
|
renderTemplate: function() {
|
||||||
this.render({ into: 'user', outlet: 'userOutlet' });
|
this.render({ into: 'user', outlet: 'userOutlet' });
|
||||||
|
|
Loading…
Reference in New Issue