FIX: better handling of category badge when displaying sub and parent cat
This commit is contained in:
parent
f07b1a5c05
commit
3ad0266dd8
|
@ -64,10 +64,11 @@ export default ComboBoxComponent.extend({
|
||||||
if (this.get("hasSelection")) {
|
if (this.get("hasSelection")) {
|
||||||
const category = Category.findById(content.value);
|
const category = Category.findById(content.value);
|
||||||
const parentCategoryId = category.get("parent_category_id");
|
const parentCategoryId = category.get("parent_category_id");
|
||||||
|
const hasParentCategory = Ember.isPresent(parentCategoryId);
|
||||||
|
|
||||||
let badge = "";
|
let badge = "";
|
||||||
|
|
||||||
if (!Ember.isNone(parentCategoryId)) {
|
if (hasParentCategory) {
|
||||||
const parentCategory = Category.findById(parentCategoryId);
|
const parentCategory = Category.findById(parentCategoryId);
|
||||||
badge += categoryBadgeHTML(parentCategory, {
|
badge += categoryBadgeHTML(parentCategory, {
|
||||||
link: false,
|
link: false,
|
||||||
|
@ -77,6 +78,7 @@ export default ComboBoxComponent.extend({
|
||||||
|
|
||||||
badge += categoryBadgeHTML(category, {
|
badge += categoryBadgeHTML(category, {
|
||||||
link: false,
|
link: false,
|
||||||
|
hideParent: hasParentCategory ? true : false,
|
||||||
allowUncategorized: true
|
allowUncategorized: true
|
||||||
}).htmlSafe();
|
}).htmlSafe();
|
||||||
|
|
||||||
|
|
|
@ -32,12 +32,12 @@ export default SelectKitRowComponent.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed("category")
|
@computed("category", "parentCategory")
|
||||||
badgeForCategory(category) {
|
badgeForCategory(category, parentCategory) {
|
||||||
return categoryBadgeHTML(category, {
|
return categoryBadgeHTML(category, {
|
||||||
link: this.get("categoryLink"),
|
link: this.get("categoryLink"),
|
||||||
allowUncategorized: this.get("allowUncategorized"),
|
allowUncategorized: this.get("allowUncategorized"),
|
||||||
hideParent: this.get("hideParentCategory")
|
hideParent: parentCategory ? true : false
|
||||||
}).htmlSafe();
|
}).htmlSafe();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ export default CategoryRowComponent.extend({
|
||||||
return categoryBadgeHTML(category, {
|
return categoryBadgeHTML(category, {
|
||||||
link: this.get("categoryLink"),
|
link: this.get("categoryLink"),
|
||||||
allowUncategorized: true,
|
allowUncategorized: true,
|
||||||
hideParent: this.get("hideParentCategory")
|
hideParent: true
|
||||||
}).htmlSafe();
|
}).htmlSafe();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue