Molecular-Biophysics-Database / mbdb-input-ui

Prototype implementation of the input forms
Other
0 stars 0 forks source link

Deserialization of complex input from MBDB data is too convoluted #83

Closed MadCatX closed 10 months ago

MadCatX commented 10 months ago

This section of code (https://github.com/Molecular-Biophysics-Database/mbdb-input-ui/blob/54547b74d9cc1b03e60092c524c106a1c019c461/src/mbdb/deserialize.ts#L77) that handles import of items from MBDB record objects uses unnecessarily convoluted logic. It is also modifying the mbdbData object that is supposed to be read-only in the context of deserialization.

The deserialization function creates a datatree in the mbdb-input-ui internal format. This datatree is then passed on to FormContext and merged with a datatree that has been initialized to default values (= an empty form). Because of this merge, the datatree that we create from the MBDB record can have as many "holes" in it as possible. It is not necessary to insert "fake" data anywhere.

See #82 for a cleaner solution.