FIX: Couldn't navigate to Categories list via link

This commit is contained in:
Robin Ward 2013-06-05 12:40:06 -04:00
parent a0bd51862e
commit 07cd87f941
8 changed files with 57 additions and 26 deletions

View file

@ -8,9 +8,13 @@
**/
Discourse.AdminFlagsActiveRoute = Discourse.Route.extend({
setupController: function() {
model: function() {
return Discourse.FlaggedPost.findAll('active');
},
setupController: function(controller, model) {
var adminFlagsController = this.controllerFor('adminFlags');
adminFlagsController.set('content', Discourse.FlaggedPost.findAll('active'));
adminFlagsController.set('content', model);
adminFlagsController.set('query', 'active');
}

View file

@ -8,9 +8,13 @@
**/
Discourse.AdminFlagsOldRoute = Discourse.Route.extend({
model: function() {
return Discourse.FlaggedPost.findAll('old');
},
setupController: function(controller, model) {
var adminFlagsController = this.controllerFor('adminFlags');
adminFlagsController.set('content', Discourse.FlaggedPost.findAll('old'));
adminFlagsController.set('content', model);
adminFlagsController.set('query', 'old');
}

View file

@ -1,10 +1,12 @@
Discourse.AdminGroupsRoute = Discourse.Route.extend({
renderTemplate: function() {
this.render('admin/templates/groups',{into: 'admin/templates/admin'});
model: function() {
return Discourse.Group.findAll();
},
setupController: function(controller, model) {
controller.set('model', Discourse.Group.findAll());
renderTemplate: function() {
this.render('admin/templates/groups',{into: 'admin/templates/admin'});
}
});

View file

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

View file

@ -1,4 +1,4 @@
{{#if loaded}}
<h3>{{model.title}}</h3>
<p class='description'>{{model.description}}</p>
@ -30,7 +30,3 @@
</button>
{{#if saved}}{{i18n saved}}{{/if}}
</div>
{{else}}
<div class='spinner'>{{i18n loading}}</div>
{{/if}}

View file

@ -0,0 +1,29 @@
/**
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); }
}
}
});

View file

@ -6,7 +6,7 @@
@namespace Discourse
@module Discourse
**/
Discourse.ListCategoriesRoute = Discourse.Route.extend({
Discourse.ListCategoriesRoute = Discourse.Route.extend(Discourse.ModelReady, {
redirect: function() { Discourse.redirectIfLoginRequired(this); },
@ -28,9 +28,8 @@ Discourse.ListCategoriesRoute = Discourse.Route.extend({
this.controllerFor('list').set('canCreateCategory', false);
},
setupController: function(controller, categoryList) {
modelReady: function(controller, categoryList) {
this.render('listCategories', { into: 'list', outlet: 'listView' });
controller.set('model', categoryList);
this.controllerFor('list').setProperties({
canCreateCategory: categoryList.get('can_create_category'),

View file

@ -6,16 +6,14 @@
@namespace Discourse
@module Discourse
**/
Discourse.UserInvitedRoute = Discourse.Route.extend({
Discourse.UserInvitedRoute = Discourse.Route.extend(Discourse.ModelReady, {
renderTemplate: function() {
this.render({ into: 'user', outlet: 'userOutlet' });
},
setupController: function(controller) {
Discourse.InviteList.findInvitedBy(this.controllerFor('user').get('content')).then(function(invited) {
controller.set('content', invited);
});
model: function() {
return Discourse.InviteList.findInvitedBy(this.modelFor('user'));
}
});