2019-11-08 05:38:28 +08:00
|
|
|
import discourseComputed from "discourse-common/utils/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-11-08 05:38:28 +08:00
|
|
|
@discourseComputed("value", "default")
|
2019-04-26 18:16:21 +08:00
|
|
|
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-11-08 05:38:28 +08:00
|
|
|
@discourseComputed("valid_values")
|
2019-04-26 18:16:21 +08:00
|
|
|
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-11-08 05:38:28 +08:00
|
|
|
@discourseComputed("valid_values")
|
2019-04-26 18:16:21 +08:00
|
|
|
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
|
|
|
});
|