-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Feature : Adding percentage option to Input Number #8481
Conversation
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.
PR Summary
This PR adds percentage type support to number fields, allowing users to configure decimal precision and display values with percentage formatting.
- Added percentage type option in
SettingsDataModelFieldNumberForm.tsx
with a new Select component for choosing between 'Number' and 'Percentage' types - Modified
NumberFieldDisplay.tsx
andNumberFieldInput.tsx
to handle percentage values by multiplying/dividing by 100 and appending '%' - Updated
useNumberField.ts
hook to handle percentage persistence with proper value conversion - Restructured field settings to be accessed through
metadata.settings
instead of directsettings
property for better consistency - Added Zod validation schema in
field-metadata-validation.service.ts
to validate percentage type and decimal settings
16 file(s) reviewed, 14 comment(s)
Edit PR Review Bot Settings | Greptile
packages/twenty-front/src/modules/object-record/record-field/meta-types/hooks/useNumberField.ts
Outdated
Show resolved
Hide resolved
...ules/settings/data-model/fields/forms/number/components/SettingsDataModelFieldNumberForm.tsx
Outdated
Show resolved
Hide resolved
@@ -13,6 +13,7 @@ type FieldMetadataDefaultSettings = { | |||
type FieldMetadataNumberSettings = { | |||
dataType: NumberDataType; | |||
decimals?: number; | |||
type?: string; |
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.
style: Consider using a union type 'percentage' | 'number' instead of string for better type safety
packages/twenty-server/src/engine/metadata-modules/field-metadata/field-metadata.service.ts
Show resolved
Hide resolved
...wenty-server/src/engine/metadata-modules/field-metadata/field-metadata-validation.service.ts
Outdated
Show resolved
Hide resolved
packages/twenty-front/src/modules/object-record/record-field/meta-types/hooks/useNumberField.ts
Outdated
Show resolved
Hide resolved
...ront/src/modules/object-record/record-field/meta-types/input/components/NumberFieldInput.tsx
Outdated
Show resolved
Hide resolved
packages/twenty-front/src/modules/object-record/record-field/types/FieldMetadata.ts
Outdated
Show resolved
Hide resolved
...rc/modules/settings/data-model/object-details/components/SettingsObjectFieldItemTableRow.tsx
Outdated
Show resolved
Hide resolved
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.
Good job! Left a few comments and we can merge!
feedback from Charles : disable percentage option on standard object ! |
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.
LGTM, bravo!
Thanks @guillim for your contribution! |
fixing twentyhq#7375 --------- Co-authored-by: guillim <[email protected]>
fixing #7375