Beta#560
Conversation
| }, | ||
| } as BaseResource | ||
|
|
||
| it('converts empty string to an empty array', function () { |
There was a problem hiding this comment.
requst parser changes now constant to empty array.
| return { ...memo, [path]: null } | ||
| } | ||
| } | ||
| if (property.isArray() && value === '') { |
There was a problem hiding this comment.
line 24 handles that
| onChange(property.name, selected.value, selected.record) | ||
| } else { | ||
| onChange(property.name, '') | ||
| onChange(property.name, null) |
There was a problem hiding this comment.
now null can be handled by onChange so we can clear select fields
| * @param {RecordJSON} record | ||
| * @return {FormData} | ||
| */ | ||
| export default function recordToFormData(record: RecordJSON): FormData { |
There was a problem hiding this comment.
this function allows onChange to transport string, [], null and {} to the backend
| @@ -0,0 +1,78 @@ | |||
| import flat from 'flat' | |||
There was a problem hiding this comment.
left this file as it was but moved to use-record/
| Object.keys(flattened).forEach((key) => { | ||
| paramsCopy[`${property}.${key}`] = flattened[key] | ||
| }) | ||
| } else if (Array.isArray(value)) { |
There was a problem hiding this comment.
I added that, so before when user gave {} or [] nothing happened. Now it is stored as "[]" or "{}" and then in toFormData converted to constants so it can be passed in the correct form to the backend
| } | ||
| } | ||
|
|
||
| if (selectedRecord) { |
There was a problem hiding this comment.
before this was in the above if. But I think that users may set populated record even when value is null like this:
onChange('populatedPropertyName', null, record).
to reset the param but to maintain the value in populated. This is not super likely but possible, and I don't see a place when it could break something
|
|
||
| const payload = Object.entries(originalPayload || {}).reduce((memo, [path, value]) => { | ||
| const payload = Object.entries(originalPayload || {}).reduce((memo, [path, formValue]) => { | ||
| const property = resource.property(path) |
There was a problem hiding this comment.
here is a known issue - resource.property doesn't take into consideration nested properties and options. So when user changes type of the property it wont be affected here. The same goes for nested properties - they wont be properly converted back.
I am on it
…ies-send-by-the-wire fix: disabled fields are stripped from the payloadrelates to #430
# [3.1.0-beta.3](v3.1.0-beta.2...v3.1.0-beta.3) (2020-08-27) ### Bug Fixes * make sure old adapters also work ([cb0bd3f](cb0bd3f))
…-updated-from-other-inputs fix: onChange can also update other fields
# [3.1.0-beta.4](v3.1.0-beta.3...v3.1.0-beta.4) (2020-08-27) ### Bug Fixes * onChange can also update other fields ([46dacb9](46dacb9))
|
🎉 This PR is included in version 3.1.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
fixes: #352, #304 and #161
What I did I:
useRecordfolder - along with useRecord hook