2019-04-26 18:16:21 +08:00
|
|
|
import computed from "ember-addons/ember-computed-decorators";
|
2019-10-31 04:13:48 +08:00
|
|
|
import Mixin from "@ember/object/mixin";
|
2018-03-05 08:04:23 +08:00
|
|
|
|
2019-10-31 03:03:08 +08:00
|
|
|
export default Mixin.create({
|
2019-04-26 18:16:21 +08:00
|
|
|
@computed("value", "default")
|
|
|
|
overridden(val, defaultVal) {
|
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();
|
2019-04-26 18:16:21 +08:00
|
|
|
},
|
2018-03-05 08:04:23 +08:00
|
|
|
|
2019-04-26 18:16:21 +08:00
|
|
|
@computed("valid_values")
|
|
|
|
validValues(validValues) {
|
2018-03-05 08:04:23 +08:00
|
|
|
const vals = [],
|
2019-05-27 16:15:39 +08:00
|
|
|
translateNames = this.translate_names;
|
2018-03-05 08:04:23 +08:00
|
|
|
|
2019-04-26 18:16:21 +08:00
|
|
|
validValues.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;
|
2019-04-26 18:16:21 +08:00
|
|
|
},
|
2018-03-05 08:04:23 +08:00
|
|
|
|
2019-04-26 18:16:21 +08:00
|
|
|
@computed("valid_values")
|
|
|
|
allowsNone(validValues) {
|
2018-11-23 00:38:58 +08:00
|
|
|
if (validValues && validValues.indexOf("") >= 0) {
|
2018-06-15 23:03:24 +08:00
|
|
|
return "admin.settings.none";
|
2018-11-23 00:38:58 +08:00
|
|
|
}
|
2019-04-26 18:16:21 +08:00
|
|
|
}
|
2018-03-05 08:04:23 +08:00
|
|
|
});
|