Skip to content
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

Allow input and display of floats for Number fields #7340

Merged
merged 5 commits into from
Oct 4, 2024
Merged

Conversation

gitstart-app[bot]
Copy link
Contributor

@gitstart-app gitstart-app bot commented Sep 30, 2024

Description

  • We added a decimal field for a Number Field type in the settings
  • We updated the Number Field type create a form with decimals input
  • We are not implementing the dropdown present on the Figma because it seems not related

Demo

https://www.loom.com/share/18a8d4b712a14f6d8b66806764f8467f?sid=3fc79b46-ae32-46e3-8635-d0eee02e53b2

Fixes #6987

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This pull request implements the ability to input and display float values for Number fields in the Twenty application. Here's a concise summary of the major changes:

  • Added 'settings' property with 'decimals' field to FieldMetadataItem and FieldDefinition types
  • Introduced new SettingsDataModelFieldNumberDecimalsInput component for configuring decimal places
  • Updated NumberFieldDisplay and NumberDisplay components to support decimal formatting
  • Modified useNumberField hook to handle float values instead of just integers
  • Replaced integer-specific utility functions with more flexible number handling functions
  • Added unit tests for new number casting functions in cast-as-number-or-null.test.ts
  • Updated server-side field metadata settings interface to include 'decimals' property

21 file(s) reviewed, 5 comment(s)
Edit PR Review Bot Settings

Comment on lines 38 to 41
settings
defaultValue
options
settings
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

syntax: Duplicate 'settings' field in the response. Remove one instance to avoid redundancy.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed with greptile !

Comment on lines 43 to 45
settings
options
settings
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

syntax: Duplicate 'settings' field. Remove one instance.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

<StyledCounterInnerContainer>
<StyledExampleText>Example: {exampleValue}</StyledExampleText>
<StyledCounterControlsIcons>
<StyledInfoButton variant="tertiary" Icon={IconInfoCircle} />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: The info button lacks an onClick handler or tooltip to provide additional information

Comment on lines +119 to +121
if (castedNumber === null) {
onChange(MIN_VALUE);
return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Consider setting the value to an empty string or undefined instead of MIN_VALUE when input is invalid

Comment on lines +61 to +63
it(`should throw if trying to cast a float string to an integer`, () => {
expect(castAsNumberOrNull('9.9')).toBe(9.9);
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: The test description says 'should throw' but the expectation is not to throw. Consider updating the description to 'should cast a float string to a float'.

Copy link
Collaborator

@ijreilly ijreilly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice work, a few things to address still!

Comment on lines 38 to 41
settings
defaultValue
options
settings
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed with greptile !

Comment on lines 43 to 45
settings
options
settings
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

packages/twenty-front/src/utils/format/number.ts Outdated Show resolved Hide resolved
Copy link
Collaborator

@ijreilly ijreilly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved!
Allowed mysef to push some changes notably to keep on displaying numbers US-style (ex 800000 should be displayed 800,000)
Just waiting on confirmation from @Bonapara on the minimal number of decimals we want to show (not sure if 0 or settings.decimals)
thanks!

@ijreilly ijreilly merged commit 97eff77 into main Oct 4, 2024
9 of 15 checks passed
@ijreilly ijreilly deleted the TWNTY-6987 branch October 4, 2024 08:45
Copy link

github-actions bot commented Oct 4, 2024

Fails
🚫

node failed.

Log

�[31mError: �[39m SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
�[90m    at parseJSONFromBytes (node:internal/deps/undici/undici:5584:19)�[39m
�[90m    at successSteps (node:internal/deps/undici/undici:5555:27)�[39m
�[90m    at fullyReadBody (node:internal/deps/undici/undici:1665:9)�[39m
�[90m    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)�[39m
�[90m    at async specConsumeBody (node:internal/deps/undici/undici:5564:7)�[39m
danger-results://tmp/danger-results-1d232ec4.json

Generated by 🚫 dangerJS against 4acbb14

harshit078 pushed a commit to harshit078/twenty that referenced this pull request Oct 14, 2024
### Description

- We added a decimal field for a Number Field type in the settings
- We updated the Number Field type create a form with decimals input
- We are not implementing the dropdown present on the Figma because it
seems not related

### Demo


<https://www.loom.com/share/18a8d4b712a14f6d8b66806764f8467f?sid=3fc79b46-ae32-46e3-8635-d0eee02e53b2>

Fixes twentyhq#6987

---------

Co-authored-by: gitstart-twenty <[email protected]>
Co-authored-by: Marie Stoppa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow input and display of floats for Number fields
2 participants