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

Refactor Records Show page to show fields as per view #9354

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

harshrajeevsingh
Copy link
Contributor

@harshrajeevsingh harshrajeevsingh commented Jan 5, 2025

Closes: #9320

Please review thoroughly and be harsh with edge cases.

@harshrajeevsingh harshrajeevsingh marked this pull request as ready for review January 6, 2025 09:04
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 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

Comment on lines +9 to +15
const orderedFields = visibleTableColumns
.map((column) =>
fieldMetadataItems.find((item) => item.id === column.fieldMetadataId),
)
.filter((fieldMetadataItem): fieldMetadataItem is FieldMetadataItem =>
Boolean(fieldMetadataItem),
);
Copy link
Contributor

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

Comment on lines +17 to +24
const remainingFields = fieldMetadataItems
.filter(
(item) =>
!visibleTableColumns.some(
(column) => column.fieldMetadataId === item.id,
),
)
.sort((a, b) => a.label.localeCompare(b.label));
Copy link
Contributor

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

@FelixMalfait
Copy link
Member

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:
Screenshot 2025-01-06 at 11 26 28

For related objects we might want to show the fields from the default All view, current behavior:
Screenshot 2025-01-06 at 11 27 01

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:
Screenshot 2025-01-06 at 11 28 05

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)}
Copy link
Contributor

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),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isDefined

@lucasbordeau lucasbordeau self-assigned this Jan 6, 2025
@Bonapara
Copy link
Member

Bonapara commented Jan 6, 2025

Seems good to me, Not sure about introducing a view switcher but that's something we could offer in the ⌘K menu if needed

@harshrajeevsingh
Copy link
Contributor Author

@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.

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

Successfully merging this pull request may close these issues.

Field order on show page should reflect the view I'm coming from
5 participants