FIX: displayCategoryDescription was not working correctly

This commit is contained in:
Joffrey JAFFEUX 2017-11-21 15:38:30 +01:00 committed by GitHub
parent 77b5a49079
commit 5dd890eb3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 8 deletions

View File

@ -6,7 +6,15 @@ import { categoryBadgeHTML } from "discourse/helpers/category-link";
export default SelectKitRowComponent.extend({
layoutName: "select-kit/templates/components/category-row",
classNames: "category-row",
displayCategoryDescription: true,
@computed("options.displayCategoryDescription")
displayCategoryDescription(displayCategoryDescription) {
if (Ember.isNone(displayCategoryDescription)) {
return true;
}
return displayCategoryDescription;
},
@computed("computedContent.value", "computedContent.name")
category(value, name) {
@ -51,8 +59,8 @@ export default SelectKitRowComponent.extend({
topicCount: Ember.computed.alias("category.topic_count"),
@computed("options.displayCategoryDescription", "category.description")
hasDescription(displayCategoryDescription, description) {
@computed("displayCategoryDescription", "category.description")
shouldDisplayDescription(displayCategoryDescription, description) {
return displayCategoryDescription && description && description !== "null";
},

View File

@ -11,13 +11,13 @@ export default MultiSelectComponent.extend({
init() {
this._super();
this.set("headerComponentOptions", Ember.Object.create({
this.get("headerComponentOptions").setProperties({
selectedNameComponent: "multi-select/selected-category"
}));
});
this.set("rowComponentOptions", Ember.Object.create({
this.get("rowComponentOptions").setProperties({
displayCategoryDescription: false
}));
});
},
computeValues() {

View File

@ -9,6 +9,14 @@ export default CategoryChooserComponent.extend({
allowUncategorized: true,
clearable: true,
init() {
this._super();
this.get("rowComponentOptions").setProperties({
displayCategoryDescription: false
});
},
mutateValue(value) {
if (value) {
this.set("value", Category.findById(value));

View File

@ -11,7 +11,7 @@
</div>
{{/if}}
{{#if hasDescription}}
{{#if shouldDisplayDescription}}
<div class="category-desc">{{description}}</div>
{{/if}}
{{else}}