FIX: Categories are ordered by topic_count.

This commit is contained in:
Robin Ward 2014-01-09 13:05:05 -05:00
parent eba54653c3
commit b28a8e262f
3 changed files with 8 additions and 4 deletions

View file

@ -195,7 +195,7 @@ Discourse.Category.reopenClass({
}, },
list: function() { list: function() {
return Discourse.Site.currentProp('categories'); return Discourse.Site.currentProp('sortedCategories');
}, },
findSingleBySlug: function(slug) { findSingleBySlug: function(slug) {

View file

@ -22,6 +22,10 @@ Discourse.Site = Discourse.Model.extend({
return postActionTypes.filterProperty('is_flag', true); return postActionTypes.filterProperty('is_flag', true);
}.property('post_action_types.@each'), }.property('post_action_types.@each'),
sortedCategories: Em.computed.sort('categories', function(a, b) {
return (b.get('topic_count') || 0) - (a.get('topic_count') || 0);
}),
postActionTypeById: function(id) { postActionTypeById: function(id) {
return this.get("postActionByIdLookup.action" + id); return this.get("postActionByIdLookup.action" + id);
}, },

View file

@ -1,12 +1,12 @@
module("Discourse.NavItem", { module("Discourse.NavItem", {
setup: function() { setup: function() {
this.site = Discourse.Site.current(); this.site = Discourse.Site.current();
this.originalCategories = Discourse.Site.currentProp('categories') || []; this.asianCategory = Discourse.Category.create({name: '确实是这样', id: 343434});
this.site.set('categories', this.originalCategories.concat( [Discourse.Category.create({name: '确实是这样', id: 343434})] )); this.site.get('categories').addObject(this.asianCategory);
}, },
teardown: function() { teardown: function() {
this.site.set('categories', this.originalCategories); this.site.get('categories').removeObject(this.asianCategory);
} }
}); });