2019-10-24 00:30:52 +08:00
|
|
|
import Component from "@ember/component";
|
2022-06-05 01:19:49 +08:00
|
|
|
import { action, set } from "@ember/object";
|
2023-10-11 02:38:59 +08:00
|
|
|
import discourseComputed from "discourse-common/utils/decorators";
|
2020-10-06 01:40:41 +08:00
|
|
|
|
2019-10-24 00:30:52 +08:00
|
|
|
export default Component.extend({
|
2022-06-17 20:50:21 +08:00
|
|
|
init() {
|
|
|
|
this._super(...arguments);
|
2021-08-26 05:10:12 +08:00
|
|
|
|
|
|
|
if (this.field.id === "color_scheme") {
|
|
|
|
for (let choice of this.field.choices) {
|
|
|
|
if (choice?.data?.colors) {
|
|
|
|
set(choice, "colors", choice.data.colors);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
@discourseComputed("field.id")
|
|
|
|
componentName(id) {
|
2022-06-17 20:50:21 +08:00
|
|
|
return id === "color_scheme" ? "color-palettes" : "combo-box";
|
2021-08-26 05:10:12 +08:00
|
|
|
},
|
|
|
|
|
2018-09-05 20:40:38 +08:00
|
|
|
keyPress(e) {
|
|
|
|
e.stopPropagation();
|
|
|
|
},
|
2021-08-26 05:10:12 +08:00
|
|
|
|
2022-06-05 01:19:49 +08:00
|
|
|
@action
|
|
|
|
onChangeValue(value) {
|
|
|
|
this.set("field.value", value);
|
2021-08-26 05:10:12 +08:00
|
|
|
},
|
2018-09-05 20:40:38 +08:00
|
|
|
});
|