Don't recalculate trustLevels combobox

This commit is contained in:
Robin Ward 2013-07-12 16:24:15 -04:00
parent 62d161fd70
commit 0c7ead339b
3 changed files with 7 additions and 7 deletions

View File

@ -67,10 +67,8 @@ Discourse.AdminUser = Discourse.User.extend({
}, },
trustLevels: function() { trustLevels: function() {
return Discourse.Site.instance().get('trustLevels').map(function (tl) { return Discourse.Site.instance().get('trustLevels');
return {id: tl.get('id'), name: tl.get('detailedName') }; }.property(),
});
}.property('trust_level'),
dirty: Discourse.computed.propertyNotEqual('originalTrustLevel', 'trustLevel.id'), dirty: Discourse.computed.propertyNotEqual('originalTrustLevel', 'trustLevel.id'),

View File

@ -165,7 +165,7 @@
<div class='display-row'> <div class='display-row'>
<div class='field'>{{i18n trust_level}}</div> <div class='field'>{{i18n trust_level}}</div>
<div class="value"> <div class="value">
{{combobox content=trustLevels value=trust_level }} {{combobox content=trustLevels value=trust_level nameProperty="detailedName"}}
</div> </div>
<div class="controls"> <div class="controls">
{{#if dirty}} {{#if dirty}}

View File

@ -13,6 +13,8 @@ Discourse.ComboboxView = Discourse.View.extend({
render: function(buffer) { render: function(buffer) {
var nameProperty = this.get('nameProperty') || 'name';
// Add none option if required // Add none option if required
if (this.get('none')) { if (this.get('none')) {
buffer.push('<option value="">' + (I18n.t(this.get('none'))) + "</option>"); buffer.push('<option value="">' + (I18n.t(this.get('none'))) + "</option>");
@ -33,10 +35,10 @@ Discourse.ComboboxView = Discourse.View.extend({
var data = ""; var data = "";
if (comboboxView.dataAttributes) { if (comboboxView.dataAttributes) {
comboboxView.dataAttributes.forEach(function(a) { comboboxView.dataAttributes.forEach(function(a) {
data += "data-" + a + "=\"" + (o.get(a)) + "\" "; data += "data-" + a + "=\"" + o.get(a) + "\" ";
}); });
} }
buffer.push("<option " + selectedText + " value=\"" + val + "\" " + data + ">" + o.name + "</option>"); buffer.push("<option " + selectedText + " value=\"" + val + "\" " + data + ">" + Em.get(o, nameProperty) + "</option>");
}); });
} }
}, },