This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/components/breadcrumbs_component.js

35 lines
978 B
JavaScript

/**
A breadcrumb including category drop downs
@class DiscourseBreadcrumbsComponent
@extends Ember.Component
@namespace Discourse
@module Discourse
**/
Discourse.DiscourseBreadcrumbsComponent = Ember.Component.extend({
classNames: ['category-breadcrumb'],
tagName: 'ol',
parentCategory: Em.computed.alias('category.parentCategory'),
parentCategories: Em.computed.filter('categories', function(c) {
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')
});