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

Add Grid bulk action methods #1920

Merged

Conversation

mhuser
Copy link
Contributor

@mhuser mhuser commented Oct 28, 2022

fix #1727

This PR aims to add the bulk action feature to process a selection or multiple records in Grid. Currently it is easy to perform an operation:

  1. on a single record e.g. with addModalAction()
  2. on the whole grid e.g. with $grid->menu->addItem())

It is complex to work with the results of $grid->addSelection() outside writing verbose code with static modals and a hidden field.

demos/collection/grid.php Outdated Show resolved Hide resolved
// Executing a modal on a bulk selection
$callback = function ($m, $ids) use ($grid) {
if (!$ids) {
Message::addTo($m, [
Copy link
Member

Choose a reason for hiding this comment

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

Build action button should be disabled instead when nothing is selected.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nice idea. have you an example of such magic?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe the master checkbox code could enable/disable bulk action button by querying a dedicated class

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wait on #1921 in the meantime, the action will return a void array, then iterating through it will do nothing.

src/Grid.php Outdated Show resolved Hide resolved
demos/collection/grid.php Outdated Show resolved Hide resolved
@mvorisek mvorisek changed the title Add addModalBulkAction() to process a selection of rows in a Grid Add Grid::addModalBulkAction() method May 29, 2023
src/Grid.php Outdated Show resolved Hide resolved
src/Grid.php Outdated Show resolved Hide resolved
src/Grid.php Outdated Show resolved Hide resolved
src/Grid.php Outdated Show resolved Hide resolved
@mhuser
Copy link
Contributor Author

mhuser commented Aug 15, 2023

Maybe there is an interest to addBulkAction too, that would fire without Modal.

@mhuser mhuser marked this pull request as ready for review August 15, 2023 18:34
@mvorisek mvorisek changed the title Add Grid::addModalBulkAction() method Add Grid bulk action methods Sep 4, 2023
@mvorisek mvorisek merged commit 01ef91e into atk4:develop Sep 4, 2023
24 checks passed
@mvorisek
Copy link
Member

mvorisek commented Sep 4, 2023

Quality PR, thank you!

@mhuser mhuser deleted the fix-1727-bind-modal-and-grid-addSelection branch September 4, 2023 20:22
@mhuser
Copy link
Contributor Author

mhuser commented Sep 4, 2023

Quality PR, thank you!

Great !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Execute php callback on Grid->addSelection() for multiple selection
2 participants