when we replace variables in enum list in jsonschema ensure it is actually a non-empty list w/ burnettk (#455)
Co-authored-by: jasquat <jasquat@users.noreply.github.com>
This commit is contained in:
parent
9ea90a94bf
commit
bc4e475809
|
@ -932,6 +932,24 @@ def _update_form_schema_with_task_data_as_needed(in_dict: dict, task_model: Task
|
|||
)
|
||||
|
||||
select_options_from_task_data = task_model.data.get(task_data_var)
|
||||
if select_options_from_task_data == []:
|
||||
raise ApiError(
|
||||
error_code="invalid_form_data",
|
||||
message=(
|
||||
"This form depends on variables, but at least one variable was empty. The"
|
||||
f" variable '{task_data_var}' must be a list with at least one element."
|
||||
),
|
||||
status_code=500,
|
||||
)
|
||||
if isinstance(select_options_from_task_data, str):
|
||||
raise ApiError(
|
||||
error_code="invalid_form_data",
|
||||
message=(
|
||||
"This form depends on enum variables, but at least one variable was a string."
|
||||
f" The variable '{task_data_var}' must be a list with at least one element."
|
||||
),
|
||||
status_code=500,
|
||||
)
|
||||
if isinstance(select_options_from_task_data, list):
|
||||
if all("value" in d and "label" in d for d in select_options_from_task_data):
|
||||
|
||||
|
|
|
@ -12,7 +12,12 @@ import {
|
|||
modifyProcessIdentifierForPathParam,
|
||||
recursivelyChangeNullAndUndefined,
|
||||
} from '../helpers';
|
||||
import { BasicTask, EventDefinition, Task } from '../interfaces';
|
||||
import {
|
||||
BasicTask,
|
||||
ErrorForDisplay,
|
||||
EventDefinition,
|
||||
Task,
|
||||
} from '../interfaces';
|
||||
import CustomForm from '../components/CustomForm';
|
||||
import ProcessBreadcrumb from '../components/ProcessBreadcrumb';
|
||||
import InstructionsForEndUser from '../components/InstructionsForEndUser';
|
||||
|
@ -36,6 +41,8 @@ export default function TaskShow() {
|
|||
const [taskData, setTaskData] = useState<any>(null);
|
||||
const [autosaveOnFormChanges, setAutosaveOnFormChanges] =
|
||||
useState<boolean>(true);
|
||||
const [atLeastOneTaskFetchHasError, setAtLeastOneTaskFetchHasError] =
|
||||
useState<boolean>(false);
|
||||
|
||||
const { addError, removeError } = useAPIError();
|
||||
|
||||
|
@ -68,16 +75,20 @@ export default function TaskShow() {
|
|||
setTaskData(recursivelyChangeNullAndUndefined(taskDataToUse, undefined));
|
||||
setFormButtonsDisabled(false);
|
||||
};
|
||||
const handleTaskFetchError = (error: ErrorForDisplay) => {
|
||||
setAtLeastOneTaskFetchHasError(true);
|
||||
addError(error);
|
||||
};
|
||||
|
||||
HttpService.makeCallToBackend({
|
||||
path: `/tasks/${params.process_instance_id}/${params.task_id}`,
|
||||
successCallback: processBasicTaskResult,
|
||||
failureCallback: addError,
|
||||
failureCallback: handleTaskFetchError,
|
||||
});
|
||||
HttpService.makeCallToBackend({
|
||||
path: `/tasks/${params.process_instance_id}/${params.task_id}?with_form_data=true`,
|
||||
successCallback: processTaskWithDataResult,
|
||||
failureCallback: addError,
|
||||
failureCallback: handleTaskFetchError,
|
||||
});
|
||||
// FIXME: not sure what to do about addError. adding it to this array causes the page to endlessly reload
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
|
@ -387,7 +398,7 @@ export default function TaskShow() {
|
|||
} else if (basicTask && taskData) {
|
||||
pageElements.push(<InstructionsForEndUser task={taskWithTaskData} />);
|
||||
pageElements.push(formElement());
|
||||
} else {
|
||||
} else if (!atLeastOneTaskFetchHasError) {
|
||||
pageElements.push(getLoadingIcon());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue