diff --git a/app/assets/javascripts/discourse/models/category.js b/app/assets/javascripts/discourse/models/category.js index 7ba6aaf78af..5d9f5ea14bb 100644 --- a/app/assets/javascripts/discourse/models/category.js +++ b/app/assets/javascripts/discourse/models/category.js @@ -63,7 +63,13 @@ Discourse.Category = Discourse.Model.extend({ removeGroup: function(group){ this.get("groups").removeObject(group); this.get("availableGroups").addObject(group); - } + }, + + // note, this is used in a data attribute, data attributes get downcased + // to avoid confusion later on using this naming here. + description_text: function(){ + return $("
" + this.get("description") + "
").text(); + }.property("description") }); diff --git a/app/assets/javascripts/discourse/views/category_chooser_view.js b/app/assets/javascripts/discourse/views/category_chooser_view.js index ce3abd2e976..0808fb89726 100644 --- a/app/assets/javascripts/discourse/views/category_chooser_view.js +++ b/app/assets/javascripts/discourse/views/category_chooser_view.js @@ -9,7 +9,7 @@ Discourse.CategoryChooserView = Discourse.ComboboxView.extend({ classNames: ['combobox category-combobox'], overrideWidths: true, - dataAttributes: ['name', 'color', 'text_color', 'description', 'topic_count'], + dataAttributes: ['name', 'color', 'text_color', 'description_text', 'topic_count'], valueBinding: Ember.Binding.oneWay('source'), init: function() { @@ -23,15 +23,24 @@ Discourse.CategoryChooserView = Discourse.ComboboxView.extend({ template: function(text, templateData) { if (!templateData.color) return text; + var result = "" + templateData.name + ""; + result += " × " + templateData.topic_count + ""; - if (templateData.description && templateData.description !== 'null') { - result += '
' + templateData.description.substr(0,200) + (templateData.description.length > 200 ? '…' : '') + '
'; + + var description = templateData.description_text; + // TODO wtf how can this be null? + if (description && description !== 'null') { + + result += '
' + + description.substr(0,200) + + (description.length > 200 ? '…' : '') + + '
'; } return result; } }); -Discourse.View.registerHelper('categoryChooser', Discourse.CategoryChooserView); \ No newline at end of file +Discourse.View.registerHelper('categoryChooser', Discourse.CategoryChooserView);