2019-11-07 16:38:28 -05:00
|
|
|
import discourseComputed from "discourse-common/utils/decorators";
|
2019-10-30 16:13:48 -04:00
|
|
|
import Mixin from "@ember/object/mixin";
|
2018-03-04 19:04:23 -05:00
|
|
|
|
2019-10-30 15:03:08 -04:00
|
|
|
export default Mixin.create({
|
2019-11-07 16:38:28 -05:00
|
|
|
@discourseComputed("value", "default")
|
2019-04-26 06:16:21 -04:00
|
|
|
overridden(val, defaultVal) {
|
2018-06-15 11:03:24 -04:00
|
|
|
if (val === null) val = "";
|
|
|
|
if (defaultVal === null) defaultVal = "";
|
2018-03-04 19:04:23 -05:00
|
|
|
|
|
|
|
return val.toString() !== defaultVal.toString();
|
2019-04-26 06:16:21 -04:00
|
|
|
},
|
2018-03-04 19:04:23 -05:00
|
|
|
|
2019-11-07 16:38:28 -05:00
|
|
|
@discourseComputed("valid_values")
|
2019-04-26 06:16:21 -04:00
|
|
|
validValues(validValues) {
|
2018-03-04 19:04:23 -05:00
|
|
|
const vals = [],
|
2019-05-27 04:15:39 -04:00
|
|
|
translateNames = this.translate_names;
|
2018-03-04 19:04:23 -05:00
|
|
|
|
2019-04-26 06:16:21 -04:00
|
|
|
validValues.forEach(v => {
|
2018-03-04 19:04:23 -05: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 06:16:21 -04:00
|
|
|
},
|
2018-03-04 19:04:23 -05:00
|
|
|
|
2019-11-07 16:38:28 -05:00
|
|
|
@discourseComputed("valid_values")
|
2019-04-26 06:16:21 -04:00
|
|
|
allowsNone(validValues) {
|
2018-11-22 11:38:58 -05:00
|
|
|
if (validValues && validValues.indexOf("") >= 0) {
|
2018-06-15 11:03:24 -04:00
|
|
|
return "admin.settings.none";
|
2018-11-22 11:38:58 -05:00
|
|
|
}
|
2019-04-26 06:16:21 -04:00
|
|
|
}
|
2018-03-04 19:04:23 -05:00
|
|
|
});
|