refactor: add options field for enum args

This commit is contained in:
duanhongbo committed 2020-12-03 18:50:58 +08:00
1 parent 7994e9c515
commit a6c1f51b5d
2 files changed
+11 -4

No files matched your search

+6
View File
@@ -1,10 +1,16 @@
import { TreeGraphData } from "@antv/g6/lib/types";
export interface ArgsOptional{
name:string;
value:string|number;
}
export interface ArgsDefType {
name: string;
type: string;
desc: string;
default: string;
options: ArgsOptional[];
}
export interface BehaviorNodeTypeModel {
name: string;
+5 -4
View File
@@ -214,11 +214,12 @@ export default class NodePanel extends React.Component<NodePanelProps> {
} else if (e.type.indexOf("lua") >= 0) {
return <Input onBlur={this.handleSubmit} placeholder={"公式"} />;
} else if (e.type.indexOf("enum") >= 0 ) {
const list = e.type.substring(e.type.indexOf("|")+1).split(',')
return <Select style={{ width: 120 }} onChange={this.handleSubmit} >
{list.map((e)=>{
return (<Option key={e} value={e}>{e}</Option>)
})}
{
e.options.map((e)=>{
return (<Option key={e.name} value={e.value}>{e.name}</Option>)
})
}
</Select>;
}
};