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

toggle Field on label between singular and plural based on relation type #8817

Conversation

omarNaifer12
Copy link
Contributor

#7683
labelPlural
labelSingular
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 .

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

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 using selectedRelationType
  • Integrated with useRelationSettingsFormInitialValues hook to handle initial label state
  • Connected label toggle logic to RELATION_TYPES constants for type-based switching
  • Leveraged objectMetadataItem properties labelSingular and labelPlural 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

Comment on lines 104 to 108
watchFormValue(
'relation.objectMetadataId',
initialRelationObjectMetadataItem?.id,

),
Copy link
Contributor

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

Comment on lines 111 to 118
const selectedRelationType=RELATION_TYPE_OPTIONS.find((relationType)=>{

return watchFormValue(
'relation.type',
initialRelationType,

)===relationType.value
})
Copy link
Contributor

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

@FelixMalfait FelixMalfait self-assigned this Dec 2, 2024
Copy link
Member

@FelixMalfait FelixMalfait left a 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 FelixMalfait merged commit 2b0f671 into twentyhq:main Dec 2, 2024
12 checks passed
@omarNaifer12 omarNaifer12 deleted the feature/7683-toggle-singular-plural-relation-label branch December 2, 2024 17:40
@omarNaifer12
Copy link
Contributor Author

@FelixMalfait Thank you for reviewing and approving my pull request! I appreciate the opportunity to contribute to this project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants