2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-06 10:50:21 +08:00
discourse/app/assets/javascripts/discourse/components/bread_crumbs_component.js

38 lines
1.2 KiB
JavaScript

/**
A breadcrumb including category drop downs
@class BreadCrumbsComponent
@extends Ember.Component
@namespace Discourse
@module Discourse
**/
Discourse.BreadCrumbsComponent = Ember.Component.extend({
classNames: ['category-breadcrumb'],
tagName: 'ol',
parentCategory: Em.computed.alias('category.parentCategory'),
parentCategories: Em.computed.filter('categories', function(c) {
if (c.id === Discourse.Site.currentProp("uncategorized_category_id") && !Discourse.SiteSettings.allow_uncategorized_topics) {
// Don't show "uncategorized" if allow_uncategorized_topics setting is false.
return false;
}
return !c.get('parentCategory');
}),
firstCategory: function() {
return this.get('parentCategory') || this.get('category');
}.property('parentCategory', 'category'),
secondCategory: function() {
if (this.get('parentCategory')) return this.get('category');
return null;
}.property('category', 'parentCategory'),
childCategories: function() {
var self = this;
return this.get('categories').filter(function (c) {
return c.get('parentCategory') === self.get('firstCategory');
});
}.property('firstCategory')
});