-
Notifications
You must be signed in to change notification settings - Fork 17
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
feat: dynamic unit on input number #803
base: 1.7
Are you sure you want to change the base?
Conversation
QRuhier
commented
Sep 11, 2024
•
edited
Loading
edited
- Dynamic Unit on InputNumber #695
4a76142
to
3ba78e7
Compare
d37c2f2
to
a1d4e9f
Compare
Quality Gate failedFailed conditions |
@@ -521,10 +521,18 @@ const dictionary = { | |||
en: 'Please respect the date format', | |||
fr: 'Merci de respecter le format de la date', | |||
}, | |||
dynamicUnit: { | |||
en: 'Custom unit of measure', |
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.
Customized unit of measurement
unit: { | ||
en: 'Unit of measure', | ||
fr: 'Unité de mesure', | ||
}, | ||
dynamicUnitFormula: { | ||
en: 'Formula of the unit of measure', |
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.
Unit of measurement formula
@@ -135,7 +135,7 @@ describe('response tranformations', () => { | |||
expect(result.Datatype.Maximum).toEqual(maximum); | |||
}); | |||
test('when Decimals is defined', () => { | |||
const typeName = 'DATE'; |
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.
Why is it not 'DATE'
anymore?
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.
it actually does not change anything because we manage it in the same way whatever the type
// Convert string "true"/"false" to boolean true/false when storing in Redux form | ||
parse={value => value === 'true'} | ||
// Convert boolean true/false to string "true"/"false" when displaying the form | ||
format={value => (value === true ? 'true' : 'false')} |
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.
To simplify we could have defined this function as:
value => `${value}`
But to each their own
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.
i'll change the comment, actually value can be undefined and i want to handle it as a false value
// Convert boolean true/false to string "true"/"false" when displaying the form | ||
format={value => (value === true ? 'true' : 'false')} | ||
> | ||
<GenericOption key="1" value="true"> |
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.
If the key
is meant as an React key
to identify an item in a list, it is better practice to use some sort of id
instead of an index (eg "dictionary-true"
instead of "1"
) since the key
id should never change for each item.
See: https://react.dev/learn/rendering-lists#keeping-list-items-in-order-with-key
Here it doesn't seem to be useful since it's not an array though so we should remove this property since key
does not seem to be used by the GenericOption
component.