mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
FIX: Categories are ordered by topic_count
.
This commit is contained in:
parent
eba54653c3
commit
b28a8e262f
3 changed files with 8 additions and 4 deletions
|
@ -195,7 +195,7 @@ Discourse.Category.reopenClass({
|
|||
},
|
||||
|
||||
list: function() {
|
||||
return Discourse.Site.currentProp('categories');
|
||||
return Discourse.Site.currentProp('sortedCategories');
|
||||
},
|
||||
|
||||
findSingleBySlug: function(slug) {
|
||||
|
|
|
@ -22,6 +22,10 @@ Discourse.Site = Discourse.Model.extend({
|
|||
return postActionTypes.filterProperty('is_flag', true);
|
||||
}.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) {
|
||||
return this.get("postActionByIdLookup.action" + id);
|
||||
},
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
module("Discourse.NavItem", {
|
||||
setup: function() {
|
||||
this.site = Discourse.Site.current();
|
||||
this.originalCategories = Discourse.Site.currentProp('categories') || [];
|
||||
this.site.set('categories', this.originalCategories.concat( [Discourse.Category.create({name: '确实是这样', id: 343434})] ));
|
||||
this.asianCategory = Discourse.Category.create({name: '确实是这样', id: 343434});
|
||||
this.site.get('categories').addObject(this.asianCategory);
|
||||
},
|
||||
|
||||
teardown: function() {
|
||||
this.site.set('categories', this.originalCategories);
|
||||
this.site.get('categories').removeObject(this.asianCategory);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue