From 21d6c7f6b39f7522d761bf806ca72a5f4df36e5d Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Thu, 24 Aug 2017 16:54:10 +0200 Subject: [PATCH] FIX: duplicated categories in select-box --- .../discourse/components/category-select-box.js.es6 | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/discourse/components/category-select-box.js.es6 b/app/assets/javascripts/discourse/components/category-select-box.js.es6 index d411e2e8a09..9be9c3e689f 100644 --- a/app/assets/javascripts/discourse/components/category-select-box.js.es6 +++ b/app/assets/javascripts/discourse/components/category-select-box.js.es6 @@ -74,7 +74,6 @@ export default SelectBoxComponent.extend({ rowContentTemplate(item) { let category; - let result = '
'; // If we have no id, but text with the uncategorized name, we can use that badge. if (Ember.isEmpty(item.id)) { @@ -87,18 +86,20 @@ export default SelectBoxComponent.extend({ } if (!category) return item.text; - result += categoryBadgeHTML(category, {link: false, allowUncategorized: true, hideParent: true}); + let result = categoryBadgeHTML(category, {link: false, allowUncategorized: true, hideParent: true}); const parentCategoryId = category.get("parent_category_id"); if (parentCategoryId) { - result += categoryBadgeHTML(Category.findById(parentCategoryId), {link: false}) + " " + result; + result = `
${categoryBadgeHTML(Category.findById(parentCategoryId), {link: false})} ${result}`; + } else { + result = `
${result}`; } - result += ` × ${category.get("topic_count")}
`; + result += ` × ${category.get("topic_count")}
`; const description = category.get("description"); // TODO wtf how can this be null?; - if (description && description !== 'null') { + if (description && description !== "null") { result += `
${description.substr(0, 200)}${description.length > 200 ? '…' : ''}
`; }