filter down the top level navs
This commit is contained in:
parent
270fde7dbd
commit
572f036e74
|
@ -7,32 +7,34 @@
|
|||
@module Discourse
|
||||
**/
|
||||
Discourse.ListController = Discourse.Controller.extend({
|
||||
categoryBinding: 'topicList.category',
|
||||
categoryBinding: "topicList.category",
|
||||
canCreateCategory: false,
|
||||
canCreateTopic: false,
|
||||
needs: ['composer', 'modal', 'listTopics'],
|
||||
needs: ["composer", "modal", "listTopics"],
|
||||
|
||||
availableNavItems: function() {
|
||||
var loggedOn = !!Discourse.User.current();
|
||||
var category = this.get("category");
|
||||
|
||||
return Discourse.SiteSettings.top_menu.split("|").map(function(i) {
|
||||
return Discourse.NavItem.fromText(i, {
|
||||
loggedOn: loggedOn
|
||||
loggedOn: loggedOn,
|
||||
category: category
|
||||
});
|
||||
}).filter(function(i) {
|
||||
return i !== null;
|
||||
return i !== null && !(category && i.get("name") === "categories");
|
||||
});
|
||||
}.property(),
|
||||
}.property("category"),
|
||||
|
||||
createTopicText: function() {
|
||||
if (this.get('category.name')) {
|
||||
if (this.get("category.name")) {
|
||||
return I18n.t("topic.create_in", {
|
||||
categoryName: this.get('category.name')
|
||||
categoryName: this.get("category.name")
|
||||
});
|
||||
} else {
|
||||
return I18n.t("topic.create");
|
||||
}
|
||||
}.property('category.name'),
|
||||
}.property("category.name"),
|
||||
|
||||
/**
|
||||
Refresh our current topic list
|
||||
|
|
|
@ -42,7 +42,7 @@ Discourse.NavItem = Discourse.Model.extend({
|
|||
count: function() {
|
||||
var state = this.get('topicTrackingState');
|
||||
if (state) {
|
||||
return state.lookupCount(this.get('name'));
|
||||
return state.lookupCount(this.get('name'), this.get('category'));
|
||||
}
|
||||
}.property('topicTrackingState.messageCount'),
|
||||
|
||||
|
@ -71,7 +71,8 @@ Discourse.NavItem.reopenClass({
|
|||
opts = {
|
||||
name: name,
|
||||
hasIcon: name === "unread" || name === "favorited",
|
||||
filters: split.splice(1)
|
||||
filters: split.splice(1),
|
||||
category: opts.category
|
||||
};
|
||||
|
||||
return Discourse.NavItem.create(opts);
|
||||
|
|
|
@ -159,15 +159,16 @@ Discourse.TopicTrackingState = Discourse.Model.extend({
|
|||
return count;
|
||||
},
|
||||
|
||||
lookupCount: function(name){
|
||||
lookupCount: function(name, category){
|
||||
var categoryName = Em.get(category, "name");
|
||||
if(name==="new") {
|
||||
return this.countNew();
|
||||
return this.countNew(categoryName);
|
||||
} else if(name==="unread") {
|
||||
return this.countUnread();
|
||||
return this.countUnread(categoryName);
|
||||
} else {
|
||||
var category = name.split("/")[1];
|
||||
if(category) {
|
||||
return this.countCategory(category);
|
||||
categoryName = name.split("/")[1];
|
||||
if(categoryName) {
|
||||
return this.countCategory(categoryName);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue