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

DataViews: Fix author sorting in templates and template parts #58167

Merged
merged 1 commit into from
Jan 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ export default function PageTemplatesTemplateParts( { postType } ) {
data: filteredData,
view,
fields,
textFields: [ 'title' ],
textFields: [ 'title', 'author' ],
Copy link
Member

Choose a reason for hiding this comment

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

I think this can work for now, but we could follow-up to do the following:

  • add text type to fields
  • remove textFields from sortByTextFields

Copy link
Member

@oandregal oandregal Jan 24, 2024

Choose a reason for hiding this comment

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

Now that I look at this utility, sortByTextFields can probably become sortByField with more type field info.

Copy link
Contributor Author

@ntsekouras ntsekouras Jan 24, 2024

Choose a reason for hiding this comment

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

It's not that straightforward right now because author is an type:enumeration. Maybe we could explore if we could use getValue for those fields too, but we would need to think of what other use cases we could have..

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with removing textFields. It's true that not all enums behave like regular text fields, but we can approach this more generally. Also, is sort-by-author currently sorting by the username? What about display name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For templates and template parts we use the author_text, which is a custom implementation due to the different kind of authors. For example for theme items the actual persisted value in db is author:0, but we extract the theme name as author.

} );
}
// Handle pagination.
Expand Down
Loading