mirror of
https://github.com/discourse/discourse.git
synced 2025-03-20 05:25:31 +08:00
REFACTOR: bread-crumbs (#7064)
This commit is contained in:
parent
6930706830
commit
c0dd171cf1
@ -1,7 +1,10 @@
|
||||
import { default as computed } from "ember-addons/ember-computed-decorators";
|
||||
|
||||
// A breadcrumb including category drop downs
|
||||
export default Ember.Component.extend({
|
||||
classNameBindings: ["hidden:hidden", ":category-breadcrumb"],
|
||||
tagName: "ol",
|
||||
|
||||
parentCategory: Ember.computed.alias("category.parentCategory"),
|
||||
|
||||
parentCategories: Ember.computed.filter("categories", function(c) {
|
||||
@ -12,42 +15,44 @@ export default Ember.Component.extend({
|
||||
// Don't show "uncategorized" if allow_uncategorized_topics setting is false.
|
||||
return false;
|
||||
}
|
||||
|
||||
return !c.get("parentCategory");
|
||||
}),
|
||||
|
||||
parentCategoriesSorted: function() {
|
||||
let cats = this.get("parentCategories");
|
||||
@computed("parentCategories")
|
||||
parentCategoriesSorted(parentCategories) {
|
||||
if (this.siteSettings.fixed_category_positions) {
|
||||
return cats;
|
||||
return parentCategories;
|
||||
}
|
||||
|
||||
return cats.sortBy("totalTopicCount").reverse();
|
||||
}.property("parentCategories"),
|
||||
return parentCategories.sortBy("totalTopicCount").reverse();
|
||||
},
|
||||
|
||||
hidden: function() {
|
||||
return this.site.mobileView && !this.get("category");
|
||||
}.property("category"),
|
||||
@computed("category")
|
||||
hidden(category) {
|
||||
return this.site.mobileView && !category;
|
||||
},
|
||||
|
||||
firstCategory: function() {
|
||||
return this.get("parentCategory") || this.get("category");
|
||||
}.property("parentCategory", "category"),
|
||||
firstCategory: Ember.computed.or("{parentCategory,category}"),
|
||||
|
||||
secondCategory: function() {
|
||||
if (this.get("parentCategory")) return this.get("category");
|
||||
@computed("category", "parentCategory")
|
||||
secondCategory(category, parentCategory) {
|
||||
if (parentCategory) return category;
|
||||
return null;
|
||||
}.property("category", "parentCategory"),
|
||||
},
|
||||
|
||||
childCategories: function() {
|
||||
if (this.get("hideSubcategories")) {
|
||||
@computed("firstCategory", "hideSubcategories")
|
||||
childCategories(firstCategory, hideSubcategories) {
|
||||
if (hideSubcategories) {
|
||||
return [];
|
||||
}
|
||||
var firstCategory = this.get("firstCategory");
|
||||
|
||||
if (!firstCategory) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return this.get("categories").filter(function(c) {
|
||||
return c.get("parentCategory") === firstCategory;
|
||||
});
|
||||
}.property("firstCategory", "hideSubcategories")
|
||||
return this.get("categories").filter(
|
||||
c => c.get("parentCategory") === firstCategory
|
||||
);
|
||||
}
|
||||
});
|
||||
|
@ -13,9 +13,12 @@
|
||||
{{/if}}
|
||||
|
||||
{{#if siteSettings.tagging_enabled}}
|
||||
{{tag-drop firstCategory=firstCategory secondCategory=secondCategory tagId=tagId}}
|
||||
{{tag-drop
|
||||
firstCategory=firstCategory
|
||||
secondCategory=secondCategory
|
||||
tagId=tagId}}
|
||||
{{/if}}
|
||||
|
||||
{{plugin-outlet name="bread-crumbs-right" connectorTagName="li"}}
|
||||
|
||||
<div class='clear'></div>
|
||||
<div class="clear"></div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user