-
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
Prefill Relation Fields with Initiating Object Icon and Name #7363
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 pull request implements the desired behavior for prefilling relation fields with the initiating object's icon and name. Here's a concise summary of the changes:
- Added logic to automatically update the relation field name based on the selected relation type
- Implemented prefilling of the initiating object's icon for the relation field
- Introduced a mechanism to prevent automatic updates if the user manually edits the field name
- Modified the
useRelationSettingsFormInitialValues
hook to use appropriate labels (plural or singular) based on the relation type - Updated the
SettingsDataModelFieldRelationSettingsFormCard
component to pass theobjectMetadataItem
prop, enabling access to the initiating object's information
These changes significantly improve the user experience when creating relations between objects by providing intelligent defaults and reducing manual input.
3 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings
label: [ | ||
RelationDefinitionType.ManyToMany, | ||
RelationDefinitionType.ManyToOne, | ||
].includes(initialRelationType) | ||
? initialRelationObjectMetadataItem.labelPlural | ||
: initialRelationObjectMetadataItem.labelSingular, | ||
}, |
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 extracting this logic into a separate function for better readability and maintainability
|
@sid0-0 Very nice work, thank you for the video it's well appreciated by the reviewer ;) |
…wentyhq#7363)" This reverts commit e45e45d.
Bug introduced by #7363 Input value was not set during edition for field that were not relations Fixed <img width="893" alt="Capture d’écran 2024-10-11 à 16 53 56" src="https://github.com/user-attachments/assets/511077c6-5dff-49a1-b058-24a83d998dcf">
@lucasbordeau forms are broken! revert - #7363 used useRelationSettingsFormInitialValues hook from that commit. TODO - figure out a way to change the relation name label from singular to plural and vice versa, until it is edited. related issue - #7355 --------- Co-authored-by: Lucas Bordeau <[email protected]>
…q#7363) feat: twentyhq#7355 Behaviour implemented: 1. Relation field name field is updated when relation type is updated 2. Icon is only prefilled in the beginning 3. If user manually edits the field name, then no subsequent updates are made to that field upon relation type change. https://github.com/user-attachments/assets/d372b106-8dcb-458d-8374-a76cd130f091 --------- Co-authored-by: sid0-0 <[email protected]> Co-authored-by: Lucas Bordeau <[email protected]>
feat: #7355
Behaviour implemented:
Screen.Recording.2024-10-01.at.1.45.21.AM.mp4