-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Dataform bulk editing support #67344
base: trunk
Are you sure you want to change the base?
Conversation
( fieldDefinition ) => fieldDefinition.id === fieldId | ||
)?.supportsBulk; | ||
} ); | ||
} |
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.
Checks if 'any' of the nested fields support bulk, returns 'true' in that case.
@@ -111,6 +113,10 @@ function PanelDropdown< Item >( { | |||
[ popoverAnchor ] | |||
); | |||
|
|||
const fieldValue = fieldDefinition.getValue( { item: data } ); | |||
const showMixedValue = | |||
isBulkEditing && ( fieldValue === undefined || fieldValue === '' ); |
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 is where having a central intersected object falls short, and why I am leaning towards moving the array of items down so the field layout has more control and also optionally the field.
As in this case the getValue
for title, returns an empty string if it isn't defined. While empty string may be a valid case for another field and different from undefined
or null
.
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.
yeah value undefined or '' might be valid values, this is why I suggested the "Symbol"
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.
@youknowriad Where was it that you suggested Symbol?
And are you thinking we did use it to define the Mixed
value. That in the getIntersectingValues
function for example when it is a mixed value we set it to Symbol.for( 'unique dataform mixed value key' )
? and than check for that in the above? or are you thinking something else?
I did try the above, but ran into this error Cannot use 'in' operator to search for 'rendered' in Symbol(DATAFORM_MIXED_VALUE)
within the getItemTitle
function. So in order to make this work I did probably have to do what I suggested above:
I am leaning towards pushing the intersecting logic down to the field view and rely on getValue, but this will cascade into quite a few other changes.
@@ -15,6 +15,7 @@ const authorField: Field< BasePostWithEmbeddedAuthor > = { | |||
id: 'author', | |||
type: 'integer', | |||
elements: [], | |||
supportsBulk: true, |
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.
Should a type
also be able to decide if it supports bulk or not?
Maybe only if no custom Edit
is being passed in?
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: +420 B (+0.02%) Total Size: 1.83 MB
ℹ️ View Unchanged
|
@gigitux, @youknowriad, @oandregal this PR is ready for review, it is an initial stab at the bulk editing. I left some open questions and it will likely require some follow up, depending on how integral we want to make it. |
Flaky tests detected in ac03ed1. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/12122182106
|
Thanks for working on this! I'm considering whether For example, the slug field doesn't support bulk editing. An extension might need to have the same slug for different entities, given that the |
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.
Nice work :)
packages/dataviews/src/types.ts
Outdated
/** | ||
* Whether the action can be used as a bulk action. | ||
*/ | ||
supportsBulk?: boolean; |
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.
Should we be more explicit? supportsBulkEditing or something like that. We may have bulk actions or something else.
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 like the supportsBulkEditing
, done in 4df0165
@@ -111,6 +113,10 @@ function PanelDropdown< Item >( { | |||
[ popoverAnchor ] | |||
); | |||
|
|||
const fieldValue = fieldDefinition.getValue( { item: data } ); | |||
const showMixedValue = | |||
isBulkEditing && ( fieldValue === undefined || fieldValue === '' ); |
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.
yeah value undefined or '' might be valid values, this is why I suggested the "Symbol"
} ); | ||
if ( intersects ) { | ||
intersectingValues[ key ] = firstRecord[ key ]; | ||
} |
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.
Should we be more explicit? supportsBulkEditing or something like that. We may have bulk actions or something else.
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 is an exact replicate of this comment: #67344 (comment) I am not sure if you meant to do that or if GH messed up?
7fb76cf
to
ac03ed1
Compare
What?
Allows consumers to pass in an array of items to be edited. The panel view will show "Mixed" when the values are different across the items.
Why?
Partially addresses: #65685
The header for bulk editing will be addressed in a separate PR.
How?
DataForm allows an array of items to be passed in.
When an array of items is passed in it does a couple things:
bulkEditing
and only shows fields withbulkEditing
support.Some questions/follow up:
getValue
, but this will cascade into quite a few other changes.getValue
and pass thedata
object by default, this will break if thedata
object can also be an array.onChange
method with the intersecting changes only make sense? or are we better off passing the array back with the updates.Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast
bulk-editing.mp4