mirror of
https://github.com/discourse/discourse.git
synced 2024-12-13 00:23:43 +08:00
e4c373194d
This commit refactors the Wizard component code in preparation for moving it to the 'static' directory for Embroider route-splitting. It also includes a number of general improvements and simplifications. Extracted from https://github.com/discourse/discourse/pull/23678 Co-authored-by: Godfrey Chan <godfreykfc@gmail.com>
34 lines
809 B
JavaScript
34 lines
809 B
JavaScript
import Component from "@ember/component";
|
|
import { action, set } from "@ember/object";
|
|
import discourseComputed from "discourse-common/utils/decorators";
|
|
import ColorPalettes from "select-kit/components/color-palettes";
|
|
import ComboBox from "select-kit/components/combo-box";
|
|
|
|
export default Component.extend({
|
|
init() {
|
|
this._super(...arguments);
|
|
|
|
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")
|
|
component(id) {
|
|
return id === "color_scheme" ? ColorPalettes : ComboBox;
|
|
},
|
|
|
|
keyPress(e) {
|
|
e.stopPropagation();
|
|
},
|
|
|
|
@action
|
|
onChangeValue(value) {
|
|
this.set("field.value", value);
|
|
},
|
|
});
|