-
Notifications
You must be signed in to change notification settings - Fork 2.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
toggle Field on label between singular and plural based on relation type #8817
toggle Field on label between singular and plural based on relation type #8817
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
Implemented dynamic label toggling for relation fields in the data model settings, switching between singular and plural forms based on the selected relation type.
- Added conditional label rendering in
/packages/twenty-front/src/modules/settings/data-model/fields/forms/relation/components/SettingsDataModelFieldRelationForm.tsx
usingselectedRelationType
- Integrated with
useRelationSettingsFormInitialValues
hook to handle initial label state - Connected label toggle logic to
RELATION_TYPES
constants for type-based switching - Leveraged
objectMetadataItem
propertieslabelSingular
andlabelPlural
for dynamic text display
💡 (1/5) You can manually trigger the bot by mentioning @greptileai in a comment!
2 file(s) reviewed, 2 comment(s)
Edit PR Review Bot Settings | Greptile
watchFormValue( | ||
'relation.objectMetadataId', | ||
initialRelationObjectMetadataItem?.id, | ||
|
||
), |
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: unnecessary whitespace after and before parentheses
const selectedRelationType=RELATION_TYPE_OPTIONS.find((relationType)=>{ | ||
|
||
return watchFormValue( | ||
'relation.type', | ||
initialRelationType, | ||
|
||
)===relationType.value | ||
}) |
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.
logic: missing null check - selectedRelationType could be undefined if no match is found
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.
Great, thank you
@FelixMalfait Thank you for reviewing and approving my pull request! I appreciate the opportunity to contribute to this project. |
#7683
Hello,
I’ve implemented the logic for dynamically toggling the Field on label between singular and plural based on the relation type selected by the user. Here's an overview of the changes:
Added a variable selectedRelationType to store the user’s selected relation type.
Based on this variable, I determine whether to use labelPlural or labelSingular from the selectedObjectMetadataItem.
Please review my changes and let me know if there's anything that needs improvement .