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

Rename view.sort.field to view.sort.orderby #55205

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions packages/edit-site/src/components/dataviews/dataviews.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default function DataViews( {
sorting: view.sort
? [
{
id: view.sort.field,
id: view.sort.orderby,
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not opinionated about the new name (orderby or any alternative), but I think it's best to avoid field for clarity.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why is field unclear for you?

Copy link
Member Author

Choose a reason for hiding this comment

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

Why is field unclear for you?

It suggests the table is sorted by a field (fields API), but it is sorted by the dataset instead.

For example, let's say there was a field called date in addition to the date property of the dataset. Let's say we have view.sort.field: date set. Wouldn't it be confusing, given the view is actually sorted by the dataset date and not by the field date?

Copy link
Member Author

Choose a reason for hiding this comment

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

More context about accessing the dataset (underlying raw data) vs accessing the fields (cell value) at #55196 (comment).

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not entirely sure what you mean by "dataset". For me it's actually the field. If a dev defines a field that is "full name" that is a computed field from say two properties on the object (first and last name), the sort is the "name" of the field, aka "full name" regardless of how it's really applied under the hood (using two columns to sort for instance)

Copy link
Contributor

Choose a reason for hiding this comment

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

"columns" is specific to table views, and with the same config we want to be able different kind of views starting with table but also rendering things like "grids", "kanban"... So columns doesn't make sense cross "layout". We're basically just defining the "fields" of our data.

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 @youknowriad here. For us this is a field and is using the data internally temporarily.

Choose a reason for hiding this comment

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

Yeah, I agree column(s) is inherently restrictive to a certain view type, but in my opinion fields(s) comes with its own connotations, especially in the context of WordPress.

I personally associate it with a single piece of data vs. what has been described as a possible need in the future of combining pieces of data.

I'm not opinionated about the new name (orderby or any alternative), but I think it's best to avoid field for clarity.

(emphasis mine) I think this also applies to fields (plural) as the higher level.

Choose a reason for hiding this comment

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

I have no other suggestion/aternative, so please don't let this hold progress, but something about field(s) seems as restrictive a column(s) to me 🤷🏻

Copy link
Member Author

Choose a reason for hiding this comment

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

ok, I see where you are coming from. Let's wrap up this conversation and iterate towards that vision.

desc: view.sort.direction === 'desc',
},
]
Expand All @@ -64,7 +64,7 @@ export default function DataViews( {
currentView.sort
? [
{
id: currentView.sort.field,
id: currentView.sort.orderby,
desc:
currentView.sort
.direction === 'desc',
Expand All @@ -82,7 +82,7 @@ export default function DataViews( {
const [ { id, desc } ] = sort;
return {
...currentView,
sort: { field: id, direction: desc ? 'desc' : 'asc' },
sort: { orderby: id, direction: desc ? 'desc' : 'asc' },
};
} );
},
Expand Down
4 changes: 2 additions & 2 deletions packages/edit-site/src/components/page-pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function PagePages() {
page: 0,
perPage: 5,
sort: {
field: 'date',
orderby: 'date',
direction: 'desc',
},
} );
Expand All @@ -49,7 +49,7 @@ export default function PagePages() {
page: view.page + 1, // tanstack starts from zero.
_embed: 'author',
order: view.sort.direction,
orderby: view.sort.field,
orderby: view.sort.orderby,
search: view.search,
status: [ 'publish', 'draft' ],
} ),
Expand Down
Loading