A platform for community discussion. Free, open, simple.
FIX: better handling of category badge when displaying sub and parent cat
Joffrey JAFFEUX3ad0266dd816
diff --git a/app/assets/javascripts/select-kit/components/category-chooser.js.es6 b/app/assets/javascripts/select-kit/components/category-chooser.js.es6index 1acada02721..82c9f27d091 100644--- a/app/assets/javascripts/select-kit/components/category-chooser.js.es6+++ b/app/assets/javascripts/select-kit/components/category-chooser.js.es6@@ -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();diff --git a/app/assets/javascripts/select-kit/components/category-row.js.es6 b/app/assets/javascripts/select-kit/components/category-row.js.es6index fe8584e3a78..8d1c8cd3ed2 100644--- a/app/assets/javascripts/select-kit/components/category-row.js.es6+++ b/app/assets/javascripts/select-kit/components/category-row.js.es6@@ -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();},diff --git a/app/assets/javascripts/select-kit/components/none-category-row.js.es6 b/app/assets/javascripts/select-kit/components/none-category-row.js.es6index b575a4c9cc2..51b6b4add0f 100644--- a/app/assets/javascripts/select-kit/components/none-category-row.js.es6+++ b/app/assets/javascripts/select-kit/components/none-category-row.js.es6@@ -11,7 +11,7 @@ export default CategoryRowComponent.extend({return categoryBadgeHTML(category, {link: this.get("categoryLink"),allowUncategorized: true,- hideParent: this.get("hideParentCategory")+ hideParent: true}).htmlSafe();},