jam in task data

This commit is contained in:
burnettk 2022-10-06 18:00:12 -04:00
parent 94e335f2f5
commit 04918e0f41
3 changed files with 26 additions and 13 deletions

View File

@ -920,15 +920,30 @@ def task_show(process_instance_id: int, task_id: str) -> flask.wrappers.Response
)
# form_contents is a str
form_dict = json.loads(form_contents)
form_dict["definitions"]["Color"]["anyOf"] = [
{"type": "string", "enum": ["blue"], "title": "Blue"},
{"type": "string", "enum": ["green"], "title": "Green"},
{"type": "string", "enum": ["orange"], "title": "Orange"},
]
task_data_key_for_select_options = form_dict["definitions"]["Color"]["anyOf"][0]
select_options_from_task_data = task.data.get(
task_data_key_for_select_options, []
)
def map_function(x):
"""Map_function."""
return {"type": "string", "enum": [x["value"]], "title": x["label"]}
options_for_react_json_schema_form = list(
map(map_function, select_options_from_task_data)
)
form_dict["definitions"]["Color"]["anyOf"] = options_for_react_json_schema_form
task.form = form_dict
# form_dict["definitions"]["Color"]["anyOf"] = [
# {"type": "string", "enum": ["blue"], "title": "Blue"},
# {"type": "string", "enum": ["orange"], "title": "Orange"},
# {"type": "string", "enum": ["green"], "title": "Green"},
# ]
if form_contents:
# task.form_schema = form_contents
task.form_schema = json.dumps(form_dict)
# task.form_schema = json.dumps(form_dict)
task.form_schema = form_dict
if form_ui_schema_file_name:
ui_form_contents = prepare_form_data(

View File

@ -3,13 +3,7 @@
"Color": {
"title": "Color",
"type": "string",
"anyOf": [
{
"type": "string",
"enum": ["#0000ff"],
"title": "Blue"
}
]
"anyOf": ["awesome_color_options"]
}
},
"title": "Select Color",

View File

@ -991,6 +991,10 @@ class TestProcessApi(BaseTest):
headers=self.logged_in_headers(user),
)
assert response.json is not None
assert (
response.json["form_schema"]["definitions"]["Color"]["anyOf"][1]["title"]
== "Green"
)
print(f"response.json: {response.json}")
def test_process_instance_list_with_default_list(