mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
Category controller should use the correct category object
This commit is contained in:
parent
c0c97487d8
commit
1dae46021e
3 changed files with 19 additions and 10 deletions
|
@ -37,6 +37,11 @@ Discourse.Site = Discourse.Model.extend({
|
|||
});
|
||||
|
||||
Discourse.Site.reopenClass({
|
||||
|
||||
find: function() {
|
||||
return Discourse.Site.create(PreloadStore.get('site'));
|
||||
},
|
||||
|
||||
create: function(obj) {
|
||||
var _this = this;
|
||||
return Object.tap(this._super(obj), function(result) {
|
||||
|
|
|
@ -8,13 +8,13 @@
|
|||
**/
|
||||
Discourse.ApplicationRoute = Discourse.Route.extend({
|
||||
setupController: function(controller) {
|
||||
Discourse.set('site', Discourse.Site.create(PreloadStore.get('site')));
|
||||
Discourse.set('site', Discourse.Site.find());
|
||||
|
||||
var currentUser = PreloadStore.get('currentUser');
|
||||
if (currentUser) {
|
||||
Discourse.set('currentUser', Discourse.User.create(currentUser));
|
||||
}
|
||||
// make sure we delete preloaded data
|
||||
PreloadStore.remove('site');
|
||||
PreloadStore.remove('currentUser');
|
||||
}
|
||||
});
|
||||
|
|
|
@ -8,17 +8,22 @@
|
|||
**/
|
||||
Discourse.ListCategoryRoute = Discourse.FilteredListRoute.extend({
|
||||
|
||||
setupController: function(controller, model) {
|
||||
var slug = Em.get(model, 'slug');
|
||||
var category = Discourse.get('site.categories').findProperty('slug', slug);
|
||||
model: function(params) {
|
||||
var categories = Discourse.Site.find().get('categories');
|
||||
|
||||
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) {
|
||||
category = Discourse.get('site.categories').findProperty('id', parseInt(slug, 10));
|
||||
}
|
||||
if (!category) {
|
||||
category = Discourse.Category.create({ name: slug, slug: slug });
|
||||
category = categories.findProperty('id', parseInt(slug, 10));
|
||||
}
|
||||
|
||||
return category;
|
||||
},
|
||||
|
||||
setupController: function(controller, category) {
|
||||
var listTopicsController = this.controllerFor('listTopics');
|
||||
if (listTopicsController) {
|
||||
var listContent = listTopicsController.get('content');
|
||||
|
@ -27,7 +32,6 @@ Discourse.ListCategoryRoute = Discourse.FilteredListRoute.extend({
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
var listController = this.controllerFor('list');
|
||||
var urlId = Discourse.Utilities.categoryUrlId(category);
|
||||
listController.set('filterMode', "category/" + urlId);
|
||||
|
|
Loading…
Reference in a new issue