added text field to form generator

This commit is contained in:
Mike Molinari 2021-09-22 01:52:31 +00:00 committed by GitHub
parent e8f74be0f2
commit e7d7103f6d

View file

@ -1,6 +1,6 @@
import React from 'react';
import Entity from '../craft/wizard/components/form/Entity';
import { CheckboxField, NumberField } from '../craft/wizard/components/form/Fields';
import { CheckboxField, NumberField, ComboBoxField, TextField} from '../craft/wizard/components/form/Fields';
import { Group } from '../craft/wizard/components/form/Form';
import { OperationSchema, SchemaField } from './mdf';
@ -11,21 +11,23 @@ export function generateForm(schema: OperationSchema) {
{Object.keys(schema).map(key => {
const fieldDef: SchemaField = schema[key];
const label = fieldDef.label || key;
const label = fieldDef.label || key;
if (fieldDef.type === 'number') {
return <NumberField name={key} defaultValue={fieldDef.defaultValue} label={label} />
} else if (fieldDef.type === 'TextField') {
return <TextField name={key} label={label} />;
} else if (['face', 'edge', 'sketchObject', 'datumAxis'].includes(fieldDef.type)) {
return <Entity name={key} label={label} />;
} else if (fieldDef.type === 'boolean') {
return <CheckboxField name={key} label={label} />;
} else {
return "I don't know";
}
}
})}
</Group>;
};
}