2018-03-05 08:04:23 +08:00
|
|
|
export default Ember.Mixin.create({
|
|
|
|
overridden: function() {
|
2018-06-15 23:03:24 +08:00
|
|
|
let val = this.get("value"),
|
|
|
|
defaultVal = this.get("default");
|
2018-03-05 08:04:23 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
if (val === null) val = "";
|
|
|
|
if (defaultVal === null) defaultVal = "";
|
2018-03-05 08:04:23 +08:00
|
|
|
|
|
|
|
return val.toString() !== defaultVal.toString();
|
2018-06-15 23:03:24 +08:00
|
|
|
}.property("value", "default"),
|
2018-03-05 08:04:23 +08:00
|
|
|
|
|
|
|
validValues: function() {
|
|
|
|
const vals = [],
|
2018-06-15 23:03:24 +08:00
|
|
|
translateNames = this.get("translate_names");
|
2018-03-05 08:04:23 +08:00
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
this.get("valid_values").forEach(v => {
|
2018-03-05 08:04:23 +08:00
|
|
|
if (v.name && v.name.length > 0 && translateNames) {
|
|
|
|
vals.addObject({ name: I18n.t(v.name), value: v.value });
|
|
|
|
} else {
|
|
|
|
vals.addObject(v);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return vals;
|
2018-06-15 23:03:24 +08:00
|
|
|
}.property("valid_values"),
|
2018-03-05 08:04:23 +08:00
|
|
|
|
|
|
|
allowsNone: function() {
|
2018-06-15 23:03:24 +08:00
|
|
|
if (_.indexOf(this.get("valid_values"), "") >= 0)
|
|
|
|
return "admin.settings.none";
|
|
|
|
}.property("valid_values")
|
2018-03-05 08:04:23 +08:00
|
|
|
});
|