ReproNim / reproschema-ui

UI to render ReproSchema based protocols and assessments.
https://www.repronim.org/reproschema-ui/
Other
3 stars 18 forks source link

fix: don't extract the first element from vectors #331

Closed satra closed 2 months ago

satra commented 3 months ago

this PR attempts to fix the multiple choice selection issue that @ibevers faced.

i'm going to leave this as draft.

@ibevers - you'll need to add a github workflow and config in your repo like the nimh-minimal protocol to be able to use this committish for your UI.

satra commented 3 months ago

i'm not sure what the piece of code that i changed is doing, hence i need to study the implications a bit. in the meantime, this did not seem to break things (on initial eval).

fabiocat93 commented 2 months ago

Hi @satra, here is my 2 cents. From what I understand, your recent changes help with dropdowns and checkboxes accepting multiple options, but I encountered a new issue. When saving the response to this form:

Screenshot 2024-08-07 at 11 55 50 AM

The expected output should be:

"value": {
    "first_name": "a",
    "middle_name": "b",
    "last_name": "ccccc"
}

However, the actual output is:

"value": {
    "first_name": "a"
}

This is my first time touching the code of rephoschema and I don't have a bigger picture of the code, but it seems that removing the if block entirely it resolves the problem without introducing new issues. Here's the block I'm referring to:

if (_.isObject(val) && !_.isArray(val) && !val.hasOwnProperty('unitCode') && !(val instanceof Blob)) {
    const sectionItemKey = Object.keys(val)[0];
    const sectionItemValue = Object.values(val)[0];
    exportVal = sectionItemValue;
    usedList.push(sectionItemKey);
    isAboutUrl = sectionItemKey;
}
satra commented 2 months ago

thanks @fabiocat93 - i think we have arrived at the same conclusion for now.

satra commented 2 months ago

and the example you shared provides a clue to what should perhaps replace that block. i'll take a look. thank you.

satra commented 2 months ago

closing in favor of #335