discourse/app/assets/javascripts/admin/mixins/setting-object.js.es6

34 lines
824 B
Plaintext
Raw Normal View History

import computed from "ember-addons/ember-computed-decorators";
export default Ember.Mixin.create({
@computed("value", "default")
overridden(val, defaultVal) {
2018-06-15 23:03:24 +08:00
if (val === null) val = "";
if (defaultVal === null) defaultVal = "";
return val.toString() !== defaultVal.toString();
},
@computed("valid_values")
validValues(validValues) {
const vals = [],
translateNames = this.translate_names;
validValues.forEach(v => {
if (v.name && v.name.length > 0 && translateNames) {
vals.addObject({ name: I18n.t(v.name), value: v.value });
} else {
vals.addObject(v);
}
});
return vals;
},
@computed("valid_values")
allowsNone(validValues) {
if (validValues && validValues.indexOf("") >= 0) {
2018-06-15 23:03:24 +08:00
return "admin.settings.none";
}
}
});