-
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
Refactor Records Show page to show fields as per view #9354
base: main
Are you sure you want to change the base?
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 implements field sorting logic for the Records Show page, introducing a new hook useSortRecordByView
and refactoring the FieldsCard component to display fields in a specific order based on the current view.
- Implementation in
useSortRecordByView.ts
doesn't fully satisfy requirements - missing separation between relation/non-relation fields in sorting logic FieldsCard.tsx
needs to handle relation fields separately to match required order: visible non-relation -> visible relation -> non-visible relation -> non-visible non-relation- Current sorting logic in
useSortRecordByView.ts
only splits fields into visible/non-visible without considering field types - Missing view context preservation for relation field ordering as specified in requirements
- New "Other Fields" section styling matches Figma but placement needs adjustment per field type requirements
2 file(s) reviewed, 3 comment(s)
Edit PR Review Bot Settings | Greptile
const orderedFields = visibleTableColumns | ||
.map((column) => | ||
fieldMetadataItems.find((item) => item.id === column.fieldMetadataId), | ||
) | ||
.filter((fieldMetadataItem): fieldMetadataItem is FieldMetadataItem => | ||
Boolean(fieldMetadataItem), | ||
); |
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: This implementation only handles visible vs non-visible fields, but doesn't separate relation fields from non-relation fields as required in the issue
const remainingFields = fieldMetadataItems | ||
.filter( | ||
(item) => | ||
!visibleTableColumns.some( | ||
(column) => column.fieldMetadataId === item.id, | ||
), | ||
) | ||
.sort((a, b) => a.label.localeCompare(b.label)); |
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: Non-visible fields need to be split into relation and non-relation fields, with relations maintaining view order and non-relations sorted alphabetically
packages/twenty-front/src/modules/object-record/record-show/components/FieldsCard.tsx
Outdated
Show resolved
Hide resolved
Great work!!! Thanks a lot @harshrajeevsingh Haven't checked the code yet but it works! When I tried it, it raised a few design questions: If no view is passed then we should use the field order from the default All view, current behavior: For related objects we might want to show the fields from the default All view, current behavior: For kanban view do we want to always display the kanban field at the top? it feels a bit odd to have it at the bottom while it's the most important field, current behavior: cc @Bonapara for input as I'm not sure. The downside of this is that it feels a bit "magical" and it's hard to figure this out. Probably it will help if we had a view picker on show page or something in following PRs... |
</FieldContext.Provider> | ||
))} | ||
|
||
{renderRelationFields(orderedRelationFields)} |
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.
Please create a component instead
fieldMetadataItems.find((item) => item.id === column.fieldMetadataId), | ||
) | ||
.filter((fieldMetadataItem): fieldMetadataItem is FieldMetadataItem => | ||
Boolean(fieldMetadataItem), |
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.
isDefined
Seems good to me, Not sure about introducing a view switcher but that's something we could offer in the ⌘K menu if needed |
@FelixMalfait @lucasbordeau, I'm Sorry! I made a mistake here. I just used the table's view to render those fields and did not consider other views like Kanban. I will look at the codebase again and make the required changes. |
Closes: #9320
Please review thoroughly and be harsh with edge cases.