-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Localize decimal separator #9800
Changes from all commits
59f4c9d
08b075d
30b40bd
9d80857
bcf54e6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,16 +77,13 @@ class WorkspaceReimburseView extends React.Component { | |
} | ||
|
||
getRateDisplayValue(value) { | ||
const numValue = parseFloat(value); | ||
if (Number.isNaN(numValue)) { | ||
return ''; | ||
} | ||
|
||
return numValue.toFixed(3); | ||
return value.toString().replace('.', this.props.fromLocaleDigit('.')); | ||
} | ||
|
||
setRate(value) { | ||
const isInvalidRateValue = value !== '' && !CONST.REGEX.RATE_VALUE.test(value); | ||
const decimalSeparator = this.props.fromLocaleDigit('.'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use of fromLocaleDigit accepts a localized char, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Thanks, that is a good catch. They return the same value when passing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Easy to miss, thanks @parasharrajat! Need to update this @eVoloshchak! cc: @sketchydroide There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I can fix this in #10028, would that be ok? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sketchydroide are we okay with it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please hold on to it. We are first trying to decide why are these changes needed at all. |
||
const rateValueRegex = RegExp(String.raw`^\d{1,8}([${decimalSeparator}]\d{0,3})?$`, 'i'); | ||
const isInvalidRateValue = value !== '' && !rateValueRegex.test(value); | ||
|
||
this.setState(prevState => ({ | ||
rateValue: !isInvalidRateValue ? value : prevState.rateValue, | ||
|
@@ -115,16 +112,12 @@ class WorkspaceReimburseView extends React.Component { | |
} | ||
|
||
updateRateValue(value) { | ||
const numValue = parseFloat(value); | ||
const numValue = parseFloat(value.replace(this.props.fromLocaleDigit('.'), '.')); | ||
|
||
if (_.isNaN(numValue)) { | ||
return; | ||
} | ||
|
||
this.setState({ | ||
rateValue: numValue.toFixed(3), | ||
}); | ||
|
||
Policy.setCustomUnitRate(this.props.policyID, this.state.unitID, { | ||
customUnitRateID: this.state.rateID, | ||
name: this.state.rateName, | ||
|
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.
How is this change related to this PR? cc: @Santhosh-Sellavel
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.
Previously
BigNumberPad
was displaying,
while still passing.
tothis.props.numberPressed
on Spanish, now it's passing the sybmol that is displayed on the keyThere 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.
That is how it is supposed to work Internally the values will always be in English for eg.
22,23
is really22.23
which will be saved to the backend. So it was working correctly.Manipulating this value here is not a good approach. These changes break the whole concept.
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.
@parasharrajat
We are not saving it as
22,23
or22.33
. We are rounding it off after multiplying by a hundred, so it's saved as2233
. I'm not sure about what we broke here?cc: @sketchydroide
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.
by the backend, I mean internally not DB. Why do we have to change this piece of code? It does not look related to the issue. Can anyone please help me understand this?
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.
This keyboard is used only on
IOUAmountPage
, so it seemed logical to make it return the displayed symbol.Alternatively we can move this logic to
IOUAmountPage
, change this line toThere 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.
Do we really need this change? Commit before the merge commit shows the correct behavior of showing
,
on UI and Allowing the user to type,
for Spanish and.
for English.How?
,
for spanish.,
for spanish.Both of these were already happening so why is change needed?
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.
Do you think there was any bug on IOUAmountPage that you solved here? What was that? Issue talks about the problem with the rate field on the reimbursement form. Can we fix the rate field issue without touching IOUAmountPage?
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.
But the screenshot in the issue description features
Request money
screen. I've asked about this a couple of times, there must have been a miscommunicationYes we can
I've checked new.expensify.com and it does indeed support comma for Spanish language on Request Money screen.
I'm guessing we need o revert this PR and clarify what the requirements for this issue are, it it's just for the rate field
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 seems yes issue details are incorrect. Unfortunately, it was not captured during the proposal review. As a suggestion, please try to get a full consensus before you start if you feel something is off. You can also suggest corrections to the requirements.
Thanks for understanding. I will open this discussion on the issue so that this PR can be reverted and you can start new.