mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-15 04:45:06 +01:00
change enum definition
This commit is contained in:
parent
1fdb2906b4
commit
d288adb7f7
6 changed files with 35 additions and 23 deletions
|
|
@ -33,10 +33,10 @@ export default {
|
|||
defaultValue: 150
|
||||
},
|
||||
color: {
|
||||
type: 'enum',
|
||||
type: 'string',
|
||||
defaultValue: "red",
|
||||
label: 'Color',
|
||||
options: [
|
||||
enum: [
|
||||
{
|
||||
label: 'Red',
|
||||
value: 'red'
|
||||
|
|
|
|||
|
|
@ -25,13 +25,22 @@ export default {
|
|||
paramsInfo: ({ sizeA, }) => `(${r(sizeA)} })`,
|
||||
schema: {
|
||||
edgeOperationType: {
|
||||
type: 'TextField',
|
||||
type: 'string',
|
||||
defaultValue: "FILLET",
|
||||
label: 'Operation Type',
|
||||
children: [
|
||||
"Fillet",
|
||||
"Champher",
|
||||
"2 Sided Champher",
|
||||
enum: [
|
||||
{
|
||||
label: "Fillet",
|
||||
value: "FILLET"
|
||||
},
|
||||
{
|
||||
label: "Champher",
|
||||
value: "CHAMPHER"
|
||||
},
|
||||
{
|
||||
label: "2 Sided Champher",
|
||||
value: "TWO_SIDED_CHAMPHER"
|
||||
}
|
||||
],
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -16,10 +16,10 @@ export default {
|
|||
paramsInfo: ({ diameter, depth, counterBoreDiameter, counterBoreDepth, countersinkDiameter, countersinkAngle, holeType, }) => `(${r(depth)} ${r(counterBoreDiameter)}) ${r(counterBoreDepth)})`,
|
||||
schema: {
|
||||
holeType: {
|
||||
type: 'enum',
|
||||
type: 'string',
|
||||
defaultValue: "counterbore",
|
||||
label: 'HoleType',
|
||||
options: [
|
||||
enum: [
|
||||
{
|
||||
label: 'Counterbore',
|
||||
value: 'counterbore'
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ function Icon(props: {
|
|||
|
||||
}
|
||||
|
||||
function getSizeInPx(sizeName: IconSize): number {
|
||||
export function getSizeInPx(sizeName: IconSize): number {
|
||||
switch (sizeName) {
|
||||
case 'small': return 16;
|
||||
case 'medium': return 24;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import React from 'react';
|
||||
import { ComboBoxOption } from 'ui/components/controls/ComboBoxControl';
|
||||
import Entity from '../craft/wizard/components/form/Entity';
|
||||
import { CheckboxField, NumberField, ComboBoxField, TextField} 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';
|
||||
|
||||
|
|
@ -16,16 +16,18 @@ export function generateForm(schema: OperationSchema) {
|
|||
|
||||
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 (fieldDef.type === 'string') {
|
||||
if (fieldDef.enum) {
|
||||
return <ComboBoxField name={key} label={label}>
|
||||
{fieldDef.enum.map(opt => <ComboBoxOption key={opt.value} value={opt.value}>
|
||||
{opt.label}
|
||||
</ComboBoxOption>)}
|
||||
</ComboBoxField>
|
||||
} else {
|
||||
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 === 'enum') {
|
||||
return <ComboBoxField name={key} label={label}>
|
||||
{fieldDef.options.map(opt => <ComboBoxOption key={opt.value} value={opt.value}>
|
||||
{opt.label}
|
||||
</ComboBoxOption>)}
|
||||
</ComboBoxField>
|
||||
} else if (fieldDef.type === 'boolean') {
|
||||
return <CheckboxField name={key} label={label} />;
|
||||
} else {
|
||||
|
|
@ -35,6 +37,4 @@ export function generateForm(schema: OperationSchema) {
|
|||
})}
|
||||
</Group>;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -25,8 +25,11 @@ export type OperationSchema = {
|
|||
};
|
||||
|
||||
export interface SchemaField {
|
||||
type: 'number' | 'face' | 'datumAxis' | 'edge' | 'sketchObject' | 'boolean' | 'enum'
|
||||
options: string[] | number[],
|
||||
type: 'number' | 'boolean' | 'string' | 'face' | 'datumAxis' | 'edge' | 'sketchObject',
|
||||
enum?: {
|
||||
value: string;
|
||||
label: string;
|
||||
}[];
|
||||
defaultValue: Coercable,
|
||||
optional: boolean,
|
||||
label?: string
|
||||
|
|
|
|||
Loading…
Reference in a new issue