Skip to content

Commit d5b2946

Browse files
committed
Emit options in input_fields
1 parent 500c1a7 commit d5b2946

File tree

3 files changed

+3
-17
lines changed

3 files changed

+3
-17
lines changed

apps/schemas.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class InputField(BaseModel):
2424
title: str
2525
type: str = "string"
2626
widget: Optional[str]
27+
options: Optional[List[Any]]
2728

2829

2930
class OutputTemplate(BaseModel):

apps/yaml_loader.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,11 @@ def get_input_model_from_fields(name: str, input_fields: list) -> Type['BaseMode
6868
field['pattern'] = "data:(.*);name=(.*);base64,(.*)"
6969

7070
if field_type == 'select' and 'options' in field and len(field['options']) > 0:
71-
field['enumNames'] = [option['label']
72-
or '' for option in field['options']]
73-
field['enum'] = [option['value']
74-
or None for option in field['options']]
7571
field['widget'] = 'select'
7672

7773
# For select fields, the datatype is the type of the first option
7874
datatype = type(field['options'][0]['value'])
7975

80-
field.pop('options', None)
81-
8276
fields[field['name']] = (datatype, Field(
8377
**{k: field[k] for k in field}))
8478

@@ -109,15 +103,6 @@ def get_app_template_from_yaml(yaml_file: str) -> dict:
109103
input_model.schema())
110104
page.pop('input_fields')
111105

112-
app = yaml_dict.get('app', {})
113-
input_fields = app.get('input_fields', [])
114-
input_model = get_input_model_from_fields(
115-
app["name"], input_fields)
116-
app['input_schema'] = input_model.schema()
117-
app['input_schema'].pop('title')
118-
app['input_ui_schema'] = get_ui_schema_from_json_schema(
119-
input_model.schema())
120-
121106
return AppTemplate(**yaml_dict)
122107

123108

client/src/data/utils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,10 @@ export function getJSONSchemaFromInputFields(inputFields) {
118118
uiSchema[field.name] = {
119119
"ui:widget": "select",
120120
};
121-
schema.properties[field.name].enum = field.options.map(
121+
schema.properties[field.name].enum = field.options?.map(
122122
(option) => option.value,
123123
);
124-
schema.properties[field.name].enumNames = field.options.map(
124+
schema.properties[field.name].enumNames = field.options?.map(
125125
(option) => option.label,
126126
);
127127
}

0 commit comments

Comments
 (0)