twenty icon indicating copy to clipboard operation
twenty copied to clipboard

Sort Metadata Fields by Custom Status and Creation Date

Open Jeong-Min-Cho opened this issue 1 year ago • 2 comments

Summary

This pull request closes #3253 and introduces a change in the way we display metadata fields in objects such as People, Opportunities, Companies. With this change, the fields are sorted first by their isCustom status (standard fields first, then custom fields), and then by their creationDate (older fields first).

Changes:

  1. Created a new function sortFieldMetadataItem in utils.ts that takes two fields and returns a sorting score based on the isCustom status and creationDate.

  2. Used the sortFieldMetadataItem function to sort activeMetadataFields and disabledMetadataFields before they are displayed in SettingsObjectDetails.tsx

  3. Created Jest tests for sortFieldMetadataItem utility file.

Test

  1. Navigate to the settings page of an object (http://localhost:3001/settings/objects).
  2. Add a new custom field and verify that it appears last in the list of fields.
  3. Verify that both of the active and disabled fields are sorted first by Custom status (standard first, then custom), and then by Creation Date (older first).

Screenshots

Before

image

After

image

Checklist

  • [x] Extract the sort fucntion to util.ts
  • [x] Add Jest tests for it

Jeong-Min-Cho avatar Jan 05 '24 12:01 Jeong-Min-Cho

@charlesBochet Gladly. I also don't want any regression from my pull request either. 😊

Jeong-Min-Cho avatar Jan 05 '24 14:01 Jeong-Min-Cho

@charlesBochet Hello again! The changes are up now 🚀

Jeong-Min-Cho avatar Jan 06 '24 06:01 Jeong-Min-Cho