Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for Null value of PrevStepIndex #403

Merged
merged 1 commit into from
Aug 6, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,10 @@ const cleanUpFormValues = (data: any): {} => {
const traverseFormValuesForCleanUp = (data: any) => {
Object.keys(data).forEach(key => {
if (typeof data[key] === "object") {
data[key] = traverseFormValuesForCleanUp(data[key])
if (Object.keys(data[key]).length === 0) delete data[key]
if (data[key] !== null) {
data[key] = traverseFormValuesForCleanUp(data[key])
if (Object.keys(data[key]).length === 0) delete data[key]
}
}
if (data[key] === "") {
delete data[key]
Expand Down Expand Up @@ -427,7 +429,6 @@ const FormOneOfField = ({
// Special handling for Expected Base Call Table > Processing > Complex Processing > Pipeline > Pipe Section > Prev Step Index
// Can be extended to other fields if needed
const itemValue = get(currentObject, pathToName(path))

if (itemValue) {
switch (lastPathItem) {
case "prevStepIndex":
Expand Down Expand Up @@ -464,16 +465,20 @@ const FormOneOfField = ({

return (
<ConnectForm>
{({ errors, unregister }) => {
{({ errors, unregister, setValue }) => {
const error = _.get(errors, name)
// Option change handling
const [field, setField] = useState(fieldValue)

const handleChange = event => {
const val = event.target.value
setField(val)

// Unregister if selecting "Complex Processing", "Null value" in Experiment form
if (val === "Complex Processing" || val === "Null value") unregister(name)
if (val === "Complex Processing") unregister(name)
if (val === "Null value") setValue(name, null)
}

const classes = helpIconStyle()
// Selected option
const selectedOption = options?.filter(option => option.title === field)[0]?.properties || {}
Expand Down