diff --git a/app/assets/javascripts/discourse/app/static/wizard/components/fields/index.js b/app/assets/javascripts/discourse/app/static/wizard/components/fields/index.js index deb2152be4e..6127a0281dc 100644 --- a/app/assets/javascripts/discourse/app/static/wizard/components/fields/index.js +++ b/app/assets/javascripts/discourse/app/static/wizard/components/fields/index.js @@ -2,6 +2,7 @@ import Checkbox from "./checkbox"; import Checkboxes from "./checkboxes"; import Dropdown from "./dropdown"; import Image from "./image"; +import Radio from "./radio"; import StylingPreview from "./styling-preview"; import Text from "./text"; @@ -12,4 +13,5 @@ export default { dropdown: Dropdown, image: Image, text: Text, + radio: Radio, }; diff --git a/app/assets/javascripts/discourse/app/static/wizard/components/fields/radio.gjs b/app/assets/javascripts/discourse/app/static/wizard/components/fields/radio.gjs new file mode 100644 index 00000000000..51f6db63547 --- /dev/null +++ b/app/assets/javascripts/discourse/app/static/wizard/components/fields/radio.gjs @@ -0,0 +1,72 @@ +import Component from "@glimmer/component"; +import { hash } from "@ember/helper"; +import { on } from "@ember/modifier"; +import { action, set } from "@ember/object"; +import PluginOutlet from "discourse/components/plugin-outlet"; +import concatClass from "discourse/helpers/concat-class"; +import withEventValue from "discourse/helpers/with-event-value"; +import icon from "discourse-common/helpers/d-icon"; + +export default class Radio extends Component { + constructor() { + super(...arguments); + + this._setSelected(); + } + + get field() { + return this.args.field; + } + + @action + selectionChanged(input) { + this.field.value = input; + this._setSelected(); + } + + _setSelected() { + for (let choice of this.field.choices) { + set(choice, "selected", this.field.value === choice.id); + } + } + + +} diff --git a/app/assets/javascripts/discourse/app/static/wizard/components/wizard-field.gjs b/app/assets/javascripts/discourse/app/static/wizard/components/wizard-field.gjs index a2f96fddfe7..b2bd553a47d 100644 --- a/app/assets/javascripts/discourse/app/static/wizard/components/wizard-field.gjs +++ b/app/assets/javascripts/discourse/app/static/wizard/components/wizard-field.gjs @@ -3,6 +3,7 @@ import { assert } from "@ember/debug"; import { hash } from "@ember/helper"; import { dasherize } from "@ember/string"; import { htmlSafe } from "@ember/template"; +import { or } from "truth-helpers"; import PluginOutlet from "discourse/components/plugin-outlet"; import fields from "./fields"; @@ -42,7 +43,7 @@ export default class WizardFieldComponent extends Component {