Category controller should use the correct category object
This commit is contained in:
parent
c0c97487d8
commit
1dae46021e
|
@ -37,6 +37,11 @@ Discourse.Site = Discourse.Model.extend({
|
||||||
});
|
});
|
||||||
|
|
||||||
Discourse.Site.reopenClass({
|
Discourse.Site.reopenClass({
|
||||||
|
|
||||||
|
find: function() {
|
||||||
|
return Discourse.Site.create(PreloadStore.get('site'));
|
||||||
|
},
|
||||||
|
|
||||||
create: function(obj) {
|
create: function(obj) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
return Object.tap(this._super(obj), function(result) {
|
return Object.tap(this._super(obj), function(result) {
|
||||||
|
|
|
@ -8,13 +8,13 @@
|
||||||
**/
|
**/
|
||||||
Discourse.ApplicationRoute = Discourse.Route.extend({
|
Discourse.ApplicationRoute = Discourse.Route.extend({
|
||||||
setupController: function(controller) {
|
setupController: function(controller) {
|
||||||
Discourse.set('site', Discourse.Site.create(PreloadStore.get('site')));
|
Discourse.set('site', Discourse.Site.find());
|
||||||
|
|
||||||
var currentUser = PreloadStore.get('currentUser');
|
var currentUser = PreloadStore.get('currentUser');
|
||||||
if (currentUser) {
|
if (currentUser) {
|
||||||
Discourse.set('currentUser', Discourse.User.create(currentUser));
|
Discourse.set('currentUser', Discourse.User.create(currentUser));
|
||||||
}
|
}
|
||||||
// make sure we delete preloaded data
|
// make sure we delete preloaded data
|
||||||
PreloadStore.remove('site');
|
|
||||||
PreloadStore.remove('currentUser');
|
PreloadStore.remove('currentUser');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -8,17 +8,22 @@
|
||||||
**/
|
**/
|
||||||
Discourse.ListCategoryRoute = Discourse.FilteredListRoute.extend({
|
Discourse.ListCategoryRoute = Discourse.FilteredListRoute.extend({
|
||||||
|
|
||||||
setupController: function(controller, model) {
|
model: function(params) {
|
||||||
var slug = Em.get(model, 'slug');
|
var categories = Discourse.Site.find().get('categories');
|
||||||
var category = Discourse.get('site.categories').findProperty('slug', slug);
|
|
||||||
|
|
||||||
|
var slug = Em.get(params, 'slug');
|
||||||
|
|
||||||
|
category = categories.findProperty('slug', Em.get(params, 'slug'))
|
||||||
|
|
||||||
|
// In case the slug didn't work, try to find it by id instead.
|
||||||
if (!category) {
|
if (!category) {
|
||||||
category = Discourse.get('site.categories').findProperty('id', parseInt(slug, 10));
|
category = categories.findProperty('id', parseInt(slug, 10));
|
||||||
}
|
|
||||||
if (!category) {
|
|
||||||
category = Discourse.Category.create({ name: slug, slug: slug });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return category;
|
||||||
|
},
|
||||||
|
|
||||||
|
setupController: function(controller, category) {
|
||||||
var listTopicsController = this.controllerFor('listTopics');
|
var listTopicsController = this.controllerFor('listTopics');
|
||||||
if (listTopicsController) {
|
if (listTopicsController) {
|
||||||
var listContent = listTopicsController.get('content');
|
var listContent = listTopicsController.get('content');
|
||||||
|
@ -27,7 +32,6 @@ Discourse.ListCategoryRoute = Discourse.FilteredListRoute.extend({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var listController = this.controllerFor('list');
|
var listController = this.controllerFor('list');
|
||||||
var urlId = Discourse.Utilities.categoryUrlId(category);
|
var urlId = Discourse.Utilities.categoryUrlId(category);
|
||||||
listController.set('filterMode', "category/" + urlId);
|
listController.set('filterMode', "category/" + urlId);
|
||||||
|
|
Loading…
Reference in New Issue