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