diff --git a/app/assets/javascripts/discourse/views/category_chooser_view.js b/app/assets/javascripts/discourse/views/category_chooser_view.js index 9615f85f150..cb6712c8bcb 100644 --- a/app/assets/javascripts/discourse/views/category_chooser_view.js +++ b/app/assets/javascripts/discourse/views/category_chooser_view.js @@ -26,7 +26,7 @@ Discourse.CategoryChooserView = Discourse.ComboboxView.extend({ none: function() { if (Discourse.User.currentProp('staff') || Discourse.SiteSettings.allow_uncategorized_topics) { - return 'category.none'; + return Discourse.Category.list().findBy('id', Discourse.Site.currentProp('uncategorized_category_id')); } else { return 'category.choose'; } diff --git a/app/assets/javascripts/discourse/views/combobox_view.js b/app/assets/javascripts/discourse/views/combobox_view.js index 07364d8db51..8469c0f707d 100644 --- a/app/assets/javascripts/discourse/views/combobox_view.js +++ b/app/assets/javascripts/discourse/views/combobox_view.js @@ -11,41 +11,45 @@ Discourse.ComboboxView = Discourse.View.extend({ classNames: ['combobox'], valueAttribute: 'id', - render: function(buffer) { + buildData: function(o) { + var data = ""; + if (this.dataAttributes) { + this.dataAttributes.forEach(function(a) { + data += "data-" + a + "=\"" + o.get(a) + "\" "; + }); + } + return data; + }, - var nameProperty = this.get('nameProperty') || 'name'; + render: function(buffer) { + var nameProperty = this.get('nameProperty') || 'name', + none = this.get('none'); // Add none option if required - if (this.get('none')) { - buffer.push('"); + if (typeof none === "string") { + buffer.push('"); + } else if (typeof none === "object") { + buffer.push(""); } var selected = this.get('value'); if (selected) { selected = selected.toString(); } if (this.get('content')) { - - var comboboxView = this; - _.each(this.get('content'),function(o) { - var val = o[comboboxView.get('valueAttribute')]; + var self = this; + this.get('content').forEach(function(o) { + var val = o[self.get('valueAttribute')]; if (val) { val = val.toString(); } var selectedText = (val === selected) ? "selected" : ""; - - var data = ""; - if (comboboxView.dataAttributes) { - comboboxView.dataAttributes.forEach(function(a) { - data += "data-" + a + "=\"" + o.get(a) + "\" "; - }); - } - buffer.push(""); + buffer.push(""); }); } }, valueChanged: function() { - var $combo = this.$(); - var val = this.get('value'); + var $combo = this.$(), + val = this.get('value'); if (val !== undefined && val !== null) { $combo.val(val.toString()); } else { @@ -55,8 +59,8 @@ Discourse.ComboboxView = Discourse.View.extend({ }.observes('value'), didInsertElement: function() { - var $elem = this.$(); - var comboboxView = this; + var $elem = this.$(), + self = this; $elem.chosen({ template: this.template, disable_search_threshold: 5 }); if (this.overrideWidths) { @@ -74,7 +78,7 @@ Discourse.ComboboxView = Discourse.View.extend({ } $elem.chosen().change(function(e) { - comboboxView.set('value', $(e.target).val()); + self.set('value', $(e.target).val()); }); }