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
Updated multiinput submission for ukaddressfield #377
base: main
Are you sure you want to change the base?
Conversation
function flattenMultiInput(rawValue) { | ||
if (!rawValue) return rawValue; | ||
rawValue.forEach((value) => { | ||
Object.keys(value).map((key) => { | ||
if (typeof value[key] == "object" && value[key] !== null) { | ||
value[key] = Object.values(value[key]) | ||
.filter((p) => { | ||
return !!p; | ||
}) | ||
.join(", "); | ||
} | ||
}); | ||
}); | ||
return rawValue; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we sort of do this the other way round? Instead of changing the structured object to a string joined by commas, change the other way so that it matches the structured object?
Just in the past seen dates stored as raw strings and then end up getting a requirement or request to re-display specific parts, which ends up in using some library (libpostal) to parse the address or some hacky regex to extract specific parts (i.e postcode) - it'd be better if we store the structured form of the address and then just on any relevant view display it as a comma separated string, or any other display that is requested
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of the code on the assess side for rendering is already built for formatting the string that this creates and they are having errors on their side of the json object appearing in the tables so this fixes both of these issues though it may be good to have structure in the future by removing this function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool - how are we handling the state already stored in the database for this component? Do we need a migration script to replicate this change for persisted data with the old structure?
Description
Updated how multi-input fields push ukaddress data to the database so that it's consistent with ukaddressfields outside of multi-input fields.
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce
the testing if necessary.
Before PR's can be merged they will need to be tested by QA and approved where
applicable. To flag the change to QA assign @XGovFormBuilder/qa as one of the reviewers.
Checklist: