-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[Admin] Mass deletion on admin grid (fixes #93) #8491
Conversation
Could someone of the Sylius team help me with a review? I'm not sure if this is the good approach, but I also think it's a valuable feature for 1.0. |
$event = $this->eventDispatcher->dispatchPreEvent(ResourceActions::DELETE, $configuration, $resource); | ||
|
||
if ($event->isStopped() && !$configuration->isHtmlRequest()) { | ||
throw new HttpException($event->getErrorCode(), $event->getMessage()); |
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 it actually do an exception here? In this case only part of the data will be removed, if there is some condition on the resource that might prevent deletion on some of them, but you need to continue further anyway? Or maybe it needs to be transnational - everything or nothing.
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.
why massAction and not bulkAction?
I know its a matter of semantics, but I find bulk more appropriate. WDYT?
I'm fine with bulk. @CoderMaggie had that also as feedback. |
@gabiudrescu @stefandoorn I am strongly for "bulk action" :) |
one more question for @stefandoorn: if I select the first entry in the list and then while keeping shift on my keyboard I select the last entry, is the browser going to select all the entries in the list? if yes, then great -> you won a beer. WDYT? |
Haven't tested ;-) It's just select boxes - didn't do anything else fancy to it. So I guess it doesn't work.. There is also no way yet to select ALL - not only just what you see on the screen. I'll keep it in mind ;-) |
c92aa57
to
3834cea
Compare
@GSadee is helping on the implementation. Renaming to 'bulk' has been done already. More updates expected over the next days. |
@GSadee WDYT about transforming It will make things more complicated in this phase, but might make it more easy to add additional bulk actions later on (e.g. mass transform, invoice creation, sending them to external system, etc.). |
@GSadee Might not be needed actually, as the configs allow to render own templates in which own routes can be called of course. First idea would mean introducing an extra dependency to ResourceController, which is not preferable. The current dependencies already suit us for delete, update & state machine transitions. Anything else can be achieved by registering own bulk action templates I think. |
@stefandoorn regarding multiple select, I did a PoC with https://github.com/rmariuzzo/checkboxes.js. you can check it out here: gabiudrescu@bbfcc4b it's a dirty PoC, I added the dependency through yarn, but didn't know how to include it in the compiled app.js. maybe you can share this knowledge. on my local host, I manually created this file (web/assets/shop/js/checkboxes.js) and included it in the template for javascripts. let me know what you think. |
@gabiudrescu This allows to use shift button to select multiple? We also need to think about the option to select ALL (unregardless of the pagination).. |
I guess that in this PR we should focus on basic bulk delete action functionality with proper tests, and maybe in future add to that e.g. select all button or other js magic 😃 |
Sure @GSadee :) Will PR it afterwards if the base functionality works :)) |
@stefandoorn yes, this is what my PoC is all about. doing it with a button that selects all items on the page is a matter of a small JS:
you do the PHP stuff, I'll help with the UI / JS. |
True, but what I meant earlier: how to do a bulk action on ALL items (e.g. on all 100 products in the database) while pagination only shows 10 on the current page? @GSadee Ideas on that one? Or should we PR that separate afterwards? |
IMO this will be a nice feature but definitely in a seperate PR, after adding the basic functionality of bulk delete action. |
@stefandoorn i find it as a bad idea to have a "delete all" button from the database. consider this:
I think being able to multiple select the products currently displayed in the view it's enough. as @GSadee says, let's ensure the PHP part reaches the codebase and we'll add more JS flavour later 😁 also, if you know how to add a new js dependency in sylius, I would be grateful if you could share this knowledge. |
Alright, I agree. @gabiudrescu Load it via yarn/npm, make sure it got added in Then run |
15ab868
to
11691fc
Compare
Thanks to the tremendous help of @GSadee the current PR should reflect a reviewable version :-) |
11691fc
to
db3e454
Compare
Updated PR description. |
3660f99
to
b8f183c
Compare
Refactor bulk delete action Fixes
Fix unit test
b8f183c
to
0bf3484
Compare
Thank you Stefan & Grzesiu! :) Amazing work. I'd only discuss if adding the public method to the grid render interface was a BC Break. I think yes, but let me hear your thoughts. /cc @pamil |
Makes sense that that is BC. Not directly sure how to get around it though. |
* | ||
* @return mixed | ||
*/ | ||
public function renderBulkAction(GridViewInterface $gridView, Action $bulkAction, $data = 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.
It's a BC break for sure, we need to revert these changes and think of a better, backwards compatibility solution.
@@ -491,7 +664,10 @@ function it_generates_routing_for_a_section( | |||
'permission' => false, | |||
], | |||
]; | |||
$routeFactory->createRoute('/products/', $indexDefaults, [], [], '', [], ['GET'])->willReturn($indexRoute); | |||
$routeFactory |
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.
Let's not do this kind of coding standard changes in a feature PR, it makes the real changes less clear.
[Admin] Mass deletion on admin grid (fixes Sylius#93)
Done:
Example screenshot:
To do / discuss:
ResourceController
.