Skip to content

Commit

Permalink
Merge pull request #379 from AutomatingSciencePipeline/default-ui-fix
Browse files Browse the repository at this point in the history
REFACTOR: fix copy default UI
  • Loading branch information
rhit-windsors authored Dec 16, 2024
2 parents da8c8aa + 23d8604 commit c9c759d
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions apps/frontend/app/components/Parameter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,21 @@ const Parameter = ({ form, type, index, confirmedValues, setConfirmedValues, ...
if (form.values.hyperparameters[index].values && (form.values.hyperparameters[index].values.length != 1 && form.values.hyperparameters[index].values[0] != '')) {
updateConfirmedValues(index, form.values.hyperparameters[index].values);
}

if (form.values.hyperparameters[index].default && form.values.hyperparameters[index].default != -1) {
setUseDefault(true);
}
else {
setUseDefault(false);
}
}, []);

useEffect(() => {
if (form.values.hyperparameters[index].useDefault == false) {
form.setFieldValue(`hyperparameters.${index}.default`, -1);
}
}, [useDefault]);


const handleRemove = () => {
form.removeListItem('hyperparameters', index);
Expand All @@ -54,7 +67,15 @@ const Parameter = ({ form, type, index, confirmedValues, setConfirmedValues, ...

const handleSwitchChange = () => {
setUseDefault(!useDefault);
form.setFieldValue(`hyperparameters.${index}.useDefault`, !useDefault);
// @ts-ignore
if(`hyperparameters.${index}.default` != -1){
form.setFieldValue(`hyperparameters.${index}.useDefault`, !useDefault);
}
else {
form.setFieldValue(`hyperparameters.${index}.useDefault`, false);
}


};

return (
Expand Down Expand Up @@ -89,7 +110,7 @@ const Parameter = ({ form, type, index, confirmedValues, setConfirmedValues, ...
)}

<Component form={form} type={type} index={index} updateConfirmedValues={updateConfirmedValues} {...rest} />

<div className='flex flex-col items-center ml-2'>
<Switch
checked={useDefault}
Expand Down

0 comments on commit c9c759d

Please sign in to comment.