FIX: better handling of category badge when displaying sub and parent cat

This commit is contained in:
Joffrey JAFFEUX 2018-02-14 16:42:20 +01:00 committed by GitHub
parent f07b1a5c05
commit 3ad0266dd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 5 deletions

View File

@ -64,10 +64,11 @@ export default ComboBoxComponent.extend({
if (this.get("hasSelection")) {
const category = Category.findById(content.value);
const parentCategoryId = category.get("parent_category_id");
const hasParentCategory = Ember.isPresent(parentCategoryId);
let badge = "";
if (!Ember.isNone(parentCategoryId)) {
if (hasParentCategory) {
const parentCategory = Category.findById(parentCategoryId);
badge += categoryBadgeHTML(parentCategory, {
link: false,
@ -77,6 +78,7 @@ export default ComboBoxComponent.extend({
badge += categoryBadgeHTML(category, {
link: false,
hideParent: hasParentCategory ? true : false,
allowUncategorized: true
}).htmlSafe();

View File

@ -32,12 +32,12 @@ export default SelectKitRowComponent.extend({
}
},
@computed("category")
badgeForCategory(category) {
@computed("category", "parentCategory")
badgeForCategory(category, parentCategory) {
return categoryBadgeHTML(category, {
link: this.get("categoryLink"),
allowUncategorized: this.get("allowUncategorized"),
hideParent: this.get("hideParentCategory")
hideParent: parentCategory ? true : false
}).htmlSafe();
},

View File

@ -11,7 +11,7 @@ export default CategoryRowComponent.extend({
return categoryBadgeHTML(category, {
link: this.get("categoryLink"),
allowUncategorized: true,
hideParent: this.get("hideParentCategory")
hideParent: true
}).htmlSafe();
},