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

Prefill Relation Fields with Initiating Object Icon and Name #7363

Merged
merged 4 commits into from
Oct 10, 2024

Conversation

sid0-0
Copy link
Contributor

@sid0-0 sid0-0 commented Sep 30, 2024

feat: #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.
Screen.Recording.2024-10-01.at.1.45.21.AM.mp4

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 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 the objectMetadataItem 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

Comment on lines +51 to 57
label: [
RelationDefinitionType.ManyToMany,
RelationDefinitionType.ManyToOne,
].includes(initialRelationType)
? initialRelationObjectMetadataItem.labelPlural
: initialRelationObjectMetadataItem.labelSingular,
},
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 extracting this logic into a separate function for better readability and maintainability

@sid0-0
Copy link
Contributor Author

sid0-0 commented Sep 30, 2024

TODO: cover #7083 also in this PR
(Just saw this issue)
Added in the new commit

@lucasbordeau
Copy link
Contributor

lucasbordeau commented Oct 9, 2024

@sid0-0 Very nice work, thank you for the video it's well appreciated by the reviewer ;)

@lucasbordeau lucasbordeau merged commit e45e45d into twentyhq:main Oct 10, 2024
11 checks passed
ehconitin added a commit to ehconitin/twenty that referenced this pull request Oct 11, 2024
@ehconitin ehconitin mentioned this pull request Oct 11, 2024
thomtrp added a commit that referenced this pull request Oct 11, 2024
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 added a commit that referenced this pull request Oct 11, 2024
@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]>
harshit078 pushed a commit to harshit078/twenty that referenced this pull request Oct 14, 2024
…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]>
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