Skip to content

Commit

Permalink
Merge pull request #278 from compute-tooling/fix-mp-handling
Browse files Browse the repository at this point in the history
Check if meta_parameter value is a ValueObject
  • Loading branch information
hdoupe authored Apr 7, 2020
2 parents 48f4176 + 12d4a10 commit 0621531
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
15 changes: 12 additions & 3 deletions src/ParamTools/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,9 +366,18 @@ export function convertToFormik(
let yupObj = yupValidator(data.meta_parameters, mp_data);
let mpVal = mp_data.value[0].value;
mpShape[mp_name] = yupObj;
initialValues["meta_parameters"][mp_name] = yupObj.cast(
meta_parameters && mp_name in meta_parameters ? meta_parameters[mp_name] : mpVal
);
if (meta_parameters && mp_name in meta_parameters) {
if (
Array.isArray(meta_parameters[mp_name]) &&
(meta_parameters[mp_name] as Array<ValueObject>).length >= 1 &&
!!meta_parameters[mp_name][0].value
) {
mpVal = meta_parameters[mp_name][0].value;
} else {
mpVal = meta_parameters[mp_name] as ValueObject["value"];
}
}
initialValues["meta_parameters"][mp_name] = yupObj.cast(mpVal);
}
let schema = {
adjustment: yup.object().shape(adjShape),
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export interface InputsDetail {
errors_warnings: { [msect: string]: { errors: { [paramName: string]: Array<string> } } };
gui_url: string;
job_id: string;
meta_parameters: { [paramName: string]: Array<ValueObject> };
meta_parameters: { [paramName: string]: Array<ValueObject> | ValueObject["value"] };
parent_model_pk: number;
sim: MiniSimulation;
status: "FAIL" | "WORKER_FAILURE" | "PENDING" | "SUCCESS" | "STARTED";
Expand Down
2 changes: 1 addition & 1 deletion static/js/sim.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion static/js/sim.js.map

Large diffs are not rendered by default.

0 comments on commit 0621531

Please sign in to comment.