mirror of
https://github.com/codeninjasllc/discourse.git
synced 2025-02-17 12:11:16 -05:00
FIX: Show the renamed uncategorized name instead of "(no category)"
This commit is contained in:
parent
c900ee055b
commit
25070dcde7
2 changed files with 26 additions and 22 deletions
|
@ -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';
|
||||
}
|
||||
|
|
|
@ -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('<option value="">' + (I18n.t(this.get('none'))) + "</option>");
|
||||
if (typeof none === "string") {
|
||||
buffer.push('<option value="">' + I18n.t(none) + "</option>");
|
||||
} else if (typeof none === "object") {
|
||||
buffer.push("<option value=\"\" " + this.buildData(none) + ">" + Em.get(none, nameProperty) + "</option>");
|
||||
}
|
||||
|
||||
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("<option " + selectedText + " value=\"" + val + "\" " + data + ">" + Em.get(o, nameProperty) + "</option>");
|
||||
buffer.push("<option " + selectedText + " value=\"" + val + "\" " + self.buildData(o) + ">" + Em.get(o, nameProperty) + "</option>");
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
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());
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue