mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 19:03:13 +08:00
FEATURE: displays category badge in {{category-chooser}} header
This commit is contained in:
parent
25dd8ff62a
commit
e3774c7bed
|
@ -3,6 +3,7 @@ import { on } from "ember-addons/ember-computed-decorators";
|
|||
import computed from "ember-addons/ember-computed-decorators";
|
||||
import PermissionType from "discourse/models/permission-type";
|
||||
import Category from "discourse/models/category";
|
||||
import { categoryBadgeHTML } from "discourse/helpers/category-link";
|
||||
const { get, isNone, isEmpty } = Ember;
|
||||
|
||||
export default ComboBoxComponent.extend({
|
||||
|
@ -57,6 +58,34 @@ export default ComboBoxComponent.extend({
|
|||
}
|
||||
},
|
||||
|
||||
computeHeaderContent() {
|
||||
let content = this.baseHeaderComputedContent();
|
||||
|
||||
if (this.get("hasSelection")) {
|
||||
const category = Category.findById(content.value);
|
||||
const parentCategoryId = category.get("parent_category_id");
|
||||
|
||||
let badge = "";
|
||||
|
||||
if (!Ember.isNone(parentCategoryId)) {
|
||||
const parentCategory = Category.findById(parentCategoryId);
|
||||
badge += categoryBadgeHTML(parentCategory, {
|
||||
link: false,
|
||||
allowUncategorized: true
|
||||
}).htmlSafe();
|
||||
}
|
||||
|
||||
badge += categoryBadgeHTML(category, {
|
||||
link: false,
|
||||
allowUncategorized: true
|
||||
}).htmlSafe();
|
||||
|
||||
content.label = badge;
|
||||
}
|
||||
|
||||
return content;
|
||||
},
|
||||
|
||||
@on("didRender")
|
||||
_bindComposerResizing() {
|
||||
this.appEvents.on("composer:resized", this, this.applyDirection);
|
||||
|
|
Loading…
Reference in New Issue
Block a user