Skip to content

Commit 4816d23

Browse files
authored
compatible with old enums\ (#5221)
1 parent 4275de9 commit 4816d23

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

projects/app/src/components/core/app/VariableEdit.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ const TableItem = ({
385385
onClick={() => {
386386
const formattedItem = {
387387
...item,
388-
list: item.enums || []
388+
list: item.enums?.map((item) => ({ label: item.value, value: item.value })) || []
389389
};
390390
reset(formattedItem);
391391
}}

projects/app/src/components/core/app/formRender/index.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,14 @@ const InputRender = (props: InputRenderProps) => {
100100
}
101101

102102
if (inputType === InputTypeEnum.select) {
103-
return <MySelect {...commonProps} list={props.list || []} h={10} />;
103+
const list =
104+
props.list || props.enums?.map((item) => ({ label: item.value, value: item.value })) || [];
105+
return <MySelect {...commonProps} list={list} h={10} />;
104106
}
105107

106108
if (inputType === InputTypeEnum.multipleSelect) {
107-
const { list = [] } = props;
109+
const list =
110+
props.list || props.enums?.map((item) => ({ label: item.value, value: item.value })) || [];
108111
return (
109112
<MultipleSelect<string>
110113
{...commonProps}

projects/app/src/components/core/app/formRender/type.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ type SpecificProps =
4040
// select & multipleSelect
4141
inputType: InputTypeEnum.select | InputTypeEnum.multipleSelect;
4242
list?: { label: string; value: string }[];
43+
44+
// old version
45+
enums?: { value: string }[];
4346
}
4447
| {
4548
// JSONEditor

0 commit comments

Comments
 (0)