-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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]: Update the view config to include fields visibility #55247
Conversation
@@ -31,6 +32,12 @@ export default function PagePages() { | |||
field: 'date', | |||
direction: 'desc', | |||
}, | |||
fields: { | |||
// All fields are visible by default, so it's | |||
// better to keep track of the hidden ones. |
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.
I'm not sure this assumption is true for all the views. I'd think that it's probably the opposite: most fields should be hidden by default but I'm ok starting this way.
Size Change: +168 B (0%) Total Size: 1.65 MB
ℹ️ View Unchanged
|
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.
LGTM 👍
); | ||
return <time>{ formattedDate }</time>; | ||
}, | ||
enableSorting: false, |
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.
This field is used to sort the table by default. Why a user shouldn't be able to?
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.
Maybe a user can do it in the future, but it might be more convoluted when we have composite fields or something that would need to provide the sorting args. I think more of the APIs will evolve/created per iteration and use case.
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.
Follow-up in #55388
{ | ||
header: 'Date', | ||
id: 'date', | ||
cell: ( props ) => { |
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.
Following up this rationale, what do you think of doing this instead (pseudo-code):
accessorFn: ( page ) => {
return dateI18n(
getSettings().formats.datetimeAbbreviated,
getDate( props.row.original.date )
);
}
cell: ( props ) => { return <time>{props.row.getValue()}</time> }
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.
I think we need to redo accessorFn
and cell
to be less tied to the API of tanstack at some point, and yeah we need to agree on a given way of retrieving the fields data.
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.
I'd echo Riad on this. We need to start forming the API that will map internally to tanstack.
cell: ( props ) => { | ||
const formattedDate = dateI18n( | ||
getSettings().formats.datetimeAbbreviated, | ||
getDate( props.row.original.date ) |
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.
The default edit.php page seems to fallback to the modified data for drafts
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.
The date
field in this PR was just a placeholder without the proper handling of this field to showcase the API. We can address this in follow ups.
I'm landing this and let's address small minor improvements in follow ups. |
What?
Part of: #55083
This PR updates the passed view config in DataViews component to handle the fields visibility.
Testing Instructions
date
field which is not visible by default.