-
Notifications
You must be signed in to change notification settings - Fork 155
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
Bulk delete #611
Merged
lchrusciel
merged 2 commits into
Sylius:poc-new-resource-metadata
from
loic425:feature/bulk-delete
Mar 17, 2023
Merged
Bulk delete #611
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -137,6 +137,22 @@ public function it_allows_deleting_a_subscription(): void | |
$this->assertEmpty($subscriptions); | ||
} | ||
|
||
/** @test */ | ||
public function it_allows_deleting_multiple_subscriptions(): void | ||
{ | ||
$this->loadFixturesFromFile('subscriptions.yml'); | ||
|
||
$this->client->request('GET', '/admin/subscriptions'); | ||
$this->client->submitForm('Bulk delete'); | ||
|
||
$this->assertResponseRedirects(null, expectedCode: Response::HTTP_FOUND); | ||
Comment on lines
+145
to
+148
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this test correct? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, It checks that the redirect is ok. (it's a code from @Zales0123 on ScienceBookUiTest) |
||
|
||
/** @var Subscription[] $subscriptions */ | ||
$subscriptions = static::getContainer()->get('app.repository.subscription')->findAll(); | ||
|
||
$this->assertEmpty($subscriptions); | ||
} | ||
|
||
/** @test */ | ||
public function it_allows_accepting_a_subscription(): void | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/Bundle/test/templates/grid/bulk_action/delete.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{% set path = options.link.url|default(path(options.link.route|default(grid.requestConfiguration.getRouteName('bulk_delete')), options.link.parameters|default({}))) %} | ||
|
||
<form action="{{ path }}" method="post"> | ||
<input type="hidden" name="_method" value="DELETE"> | ||
<button type="submit"> | ||
<i class="icon trash"></i> Bulk delete | ||
</button> | ||
<input type="hidden" name="_csrf_token" value="{{ csrf_token('bulk_delete') }}" /> | ||
|
||
{% for resource in grid.data %} | ||
<input type="hidden" name="ids[]" value="{{ resource.id }}" /> | ||
{% endfor %} | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Paweł Jędrzejewski | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sylius\Component\Resource\Metadata; | ||
|
||
/** | ||
* @experimental | ||
*/ | ||
#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::IS_REPEATABLE)] | ||
final class BulkDelete extends HttpOperation implements DeleteOperationInterface, BulkOperationInterface | ||
{ | ||
public function __construct( | ||
?array $methods = null, | ||
?string $path = null, | ||
?string $routePrefix = null, | ||
?string $template = null, | ||
?string $shortName = null, | ||
?string $name = null, | ||
string|callable|null $provider = null, | ||
string|callable|null $processor = null, | ||
string|callable|null $responder = null, | ||
string|callable|null $repository = null, | ||
?string $repositoryMethod = null, | ||
?bool $read = null, | ||
?bool $write = null, | ||
?string $formType = null, | ||
?array $formOptions = null, | ||
?string $redirectToRoute = null, | ||
) { | ||
parent::__construct( | ||
methods: $methods ?? ['DELETE'], | ||
path: $path, | ||
routePrefix: $routePrefix, | ||
template: $template, | ||
shortName: $shortName ?? 'bulk_delete', | ||
name: $name, | ||
provider: $provider, | ||
processor: $processor, | ||
responder: $responder, | ||
repository: $repository, | ||
repositoryMethod: $repositoryMethod, | ||
read: $read, | ||
write: $write, | ||
formType: $formType, | ||
formOptions: $formOptions, | ||
redirectToRoute: $redirectToRoute, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Paweł Jędrzejewski | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sylius\Component\Resource\Metadata; | ||
|
||
/** | ||
* The Operation returns a collection. | ||
* | ||
* @experimental | ||
*/ | ||
interface BulkOperationInterface | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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've simplified this cause I had some troubles. But it works on a test project with an uuid on a mysql database.
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.
What were the troubles?
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 findById($ids) did not work with SQLite, but I have to check it that again later.
But if there is a bug with that on SQLite, we already have a bug on current implementation.