From 7b5807089b8cf4fff7cf8a943fecfd0c67459808 Mon Sep 17 00:00:00 2001 From: Mike Molinari Date: Tue, 25 Oct 2022 03:49:34 +0000 Subject: [PATCH] update choice widget to add radio buttons option. --- web/app/cad/mdf/ui/ChoiceWidget.tsx | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/web/app/cad/mdf/ui/ChoiceWidget.tsx b/web/app/cad/mdf/ui/ChoiceWidget.tsx index e38fcc82..ad0ae21f 100644 --- a/web/app/cad/mdf/ui/ChoiceWidget.tsx +++ b/web/app/cad/mdf/ui/ChoiceWidget.tsx @@ -3,6 +3,10 @@ import React from "react"; import {FieldBasicProps, fieldToSchemaGeneric} from "cad/mdf/ui/field"; import {Types} from "cad/craft/schema/types"; import {ComboBoxOption} from "ui/components/controls/ComboBoxControl"; +import {RadioButton} from 'ui/components/controls/RadioButtons'; + +import {RadioButtonsField} from '../../craft/wizard/components/form/Fields'; + type ValueDef = [string, string] | string; @@ -18,7 +22,6 @@ export interface ChoiceWidgetProps extends FieldBasicProps { export function ChoiceWidget(props: ChoiceWidgetProps) { if (!props.style || props.style === 'dropdown') { - return {props.values.map((value: any) => { let val, name; @@ -31,9 +34,20 @@ export function ChoiceWidget(props: ChoiceWidgetProps) { return {name} })} ; - - } else { - throw 'implement me'; + } + if (props.style === 'radio'){ + return + {props.values.map((value: any) => { + let val, name; + if (Array.isArray(value)) { + [val, name] = value; + } else { + val = value; + name = value; + } + return {name} + })} + ; } }