File tree 3 files changed +8
-4
lines changed
app/assets/javascripts/discourse/models 3 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -195,7 +195,7 @@ Discourse.Category.reopenClass({
195
195
} ,
196
196
197
197
list : function ( ) {
198
- return Discourse . Site . currentProp ( 'categories ' ) ;
198
+ return Discourse . Site . currentProp ( 'sortedCategories ' ) ;
199
199
} ,
200
200
201
201
findSingleBySlug : function ( slug ) {
Original file line number Diff line number Diff line change @@ -22,6 +22,10 @@ Discourse.Site = Discourse.Model.extend({
22
22
return postActionTypes . filterProperty ( 'is_flag' , true ) ;
23
23
} . property ( 'post_action_types.@each' ) ,
24
24
25
+ sortedCategories : Em . computed . sort ( 'categories' , function ( a , b ) {
26
+ return ( b . get ( 'topic_count' ) || 0 ) - ( a . get ( 'topic_count' ) || 0 ) ;
27
+ } ) ,
28
+
25
29
postActionTypeById : function ( id ) {
26
30
return this . get ( "postActionByIdLookup.action" + id ) ;
27
31
} ,
Original file line number Diff line number Diff line change 1
1
module ( "Discourse.NavItem" , {
2
2
setup : function ( ) {
3
3
this . site = Discourse . Site . current ( ) ;
4
- this . originalCategories = Discourse . Site . currentProp ( 'categories' ) || [ ] ;
5
- this . site . set ( 'categories' , this . originalCategories . concat ( [ Discourse . Category . create ( { name : '确实是这样' , id : 343434 } ) ] ) ) ;
4
+ this . asianCategory = Discourse . Category . create ( { name : '确实是这样' , id : 343434 } ) ;
5
+ this . site . get ( 'categories' ) . addObject ( this . asianCategory ) ;
6
6
} ,
7
7
8
8
teardown : function ( ) {
9
- this . site . set ( 'categories' , this . originalCategories ) ;
9
+ this . site . get ( 'categories' ) . removeObject ( this . asianCategory ) ;
10
10
}
11
11
} ) ;
12
12
You can’t perform that action at this time.
0 commit comments