-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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: add more decimal places to CurrencyInput #33686
feat: add more decimal places to CurrencyInput #33686
Conversation
WalkthroughWalkthroughThe changes introduce enhanced functionality to the Changes
Sequence Diagram(s) (Beta)No sequence diagrams are generated as the changes are primarily functional enhancements without significant modifications to control flow. Assessment against linked issues
Recent Review DetailsConfiguration used: CodeRabbit UI Files selected for processing (4)
Additional Context UsedBiome (50)
Additional comments not posted (3)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
Merge request for #33361 |
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.
Actionable comments posted: 0
Outside diff range and nitpick comments (3)
app/client/src/widgets/CurrencyInputWidget/component/utilities.ts (1)
52-65
: The extension to handle up to 6 decimal places inlimitDecimalValue
is implemented correctly.Consider adding a comment explaining why these specific cases (3 to 6) were added, as it might help future maintainers understand the context better.
app/client/src/widgets/CurrencyInputWidget/component/utilities.test.ts (1)
44-71
: The test cases forlimitDecimalValue
covering decimal places from 3 to 6 are comprehensive and correctly validate the functionality.Consider adding a comment explaining the choice of test values, especially for edge cases, to aid future maintainers.
app/client/src/widgets/JSONFormWidget/widget/propertyConfig/properties/input.ts (1)
344-359
: The addition of decimal place options from 3 to 6 in thePROPERTIES
object is implemented correctly and aligns with the PR's objectives.Consider adding a comment explaining the rationale behind these specific decimal options to help future maintainers understand the choice.
].forEach((d) => { | ||
expect(formatCurrencyNumber(d[0] as number, d[1] as string)).toBe(d[2]); | ||
expect(limitDecimalValue(d[0] as number, d[1] as string)).toBe(d[2]); |
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 seems wrong. You edited the wrong it
block.
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.
@AnnaHariprasad5123 You need to update the it
block for limitDecimalValue
instead of overriding the it
block for formatCurrencyNumber
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.
My mistake, I will correct it.
instead of commenting, I accidentally clicked on approve button.
@AnnaHariprasad5123 can you check my comments? |
6fa07a2
to
19bcbbd
Compare
Hi @jsartisan Could you check this once. |
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.
Actionable comments posted: 1
Outside diff range and nitpick comments (1)
app/client/src/widgets/CurrencyInputWidget/component/utilities.ts (1)
Line range hint
75-75
: ReplaceparseFloat
withNumber.parseFloat
for consistency and clarity.- return parseFloat( + return Number.parseFloat(
Hi @jsartisan Good morning, Please merge my pull request at your earliest convenience. |
@AnnaHariprasad5123 I just ran the PR on my local. Found a tiny problem. Validation need sot be updated. |
19bcbbd
to
28d44fa
Compare
Sorry about that, Could you check again @jsartisan |
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.
Actionable comments posted: 3
} else { | ||
return decimalValueArray[0]; | ||
} |
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 else clause can be omitted because previous branches break early.
if (decimalValueArray.length > 1) {
return (
decimalValueArray[0] +
decimalSeperator +
decimalValueArray[1].slice(0, decimals)
);
}
- else {
- return decimalValueArray[0];
- }
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
} else { | |
return decimalValueArray[0]; | |
} | |
if (decimalValueArray.length > 1) { | |
return ( | |
decimalValueArray[0] + | |
decimalSeperator + | |
decimalValueArray[1].slice(0, decimals) | |
); | |
} | |
return decimalValueArray[0]; |
case 3: | ||
case 4: | ||
case 5: | ||
case 6: | ||
const decimalValueArray = value.split(decimalSeperator); | ||
return ( | ||
decimalValueArray[0] + | ||
decimalSeperator + | ||
decimalValueArray[1].slice(0, decimals) | ||
); | ||
if (decimalValueArray.length > 1) { | ||
return ( | ||
decimalValueArray[0] + | ||
decimalSeperator + | ||
decimalValueArray[1].slice(0, decimals) | ||
); | ||
} else { | ||
return decimalValueArray[0]; | ||
} |
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.
Refactor the limitDecimalValue
function to improve scope handling and control flow.
case 6:
{
const decimalValueArray = value.split(decimalSeperator);
if (decimalValueArray.length > 1) {
return (
decimalValueArray[0] +
decimalSeperator +
decimalValueArray[1].slice(0, decimals)
);
}
return decimalValueArray[0];
}
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
case 3: | |
case 4: | |
case 5: | |
case 6: | |
const decimalValueArray = value.split(decimalSeperator); | |
return ( | |
decimalValueArray[0] + | |
decimalSeperator + | |
decimalValueArray[1].slice(0, decimals) | |
); | |
if (decimalValueArray.length > 1) { | |
return ( | |
decimalValueArray[0] + | |
decimalSeperator + | |
decimalValueArray[1].slice(0, decimals) | |
); | |
} else { | |
return decimalValueArray[0]; | |
} | |
case 3: | |
case 4: | |
case 5: | |
case 6: | |
{ | |
const decimalValueArray = value.split(decimalSeperator); | |
if (decimalValueArray.length > 1) { | |
return ( | |
decimalValueArray[0] + | |
decimalSeperator + | |
decimalValueArray[1].slice(0, decimals) | |
); | |
} | |
return decimalValueArray[0]; | |
} |
case 3: | ||
case 4: | ||
case 5: | ||
case 6: | ||
const decimalValueArray = value.split(decimalSeperator); |
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.
Wrap the decimalValueArray
declaration in a block to restrict its access to the switch clause.
case 6:
{
+ {
const decimalValueArray = value.split(decimalSeperator);
if (decimalValueArray.length > 1) {
return (
decimalValueArray[0] +
decimalSeperator +
decimalValueArray[1].slice(0, decimals)
);
}
return decimalValueArray[0];
+ }
}
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
const decimalValueArray = value.split(decimalSeperator); | |
case 6: | |
{ | |
{ | |
const decimalValueArray = value.split(decimalSeperator); | |
if (decimalValueArray.length > 1) { | |
return ( | |
decimalValueArray[0] + | |
decimalSeperator + | |
decimalValueArray[1].slice(0, decimals) | |
); | |
} | |
return decimalValueArray[0]; | |
} | |
} |
Hi CWatson,
What's in this PR?
JsonForm
andCurrencyInput
Widgets.Fixes #33361
Thank you.
/ok-to-test tags="@tag.CurrencyInput"