-
Notifications
You must be signed in to change notification settings - Fork 15
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
#88 Add the DropdownAction #110
Closed
Closed
Changes from 9 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
087f567
Changed the renamed attribute
alexandre-castelain 29c330c
Merge branch 'Kreyu:main' into main
alexandre-castelain 080bf6c
#88 Create the DropdownActionType
alexandre-castelain 6a6f4fe
#88 Add the bootstrap 5 theme
alexandre-castelain 10913c8
#88 Extract the RowActionBuilder methods in another interface.
alexandre-castelain 3c90c86
#88 Run php-cs-fixer
alexandre-castelain 80b6d34
Merge branch 'refs/heads/main' into #88
alexandre-castelain ffbe186
Add the LinkDropdownItemActionType and handle it in the views
alexandre-castelain c6d98f3
Format code
alexandre-castelain 9776d67
Remove the RowActionBuilderInterface
alexandre-castelain c4b2a65
Force the ActionBuilderInterface type
alexandre-castelain 55e9d68
Remove useless style
alexandre-castelain 9ec9217
Make the confirmation modal work in the dropdown
alexandre-castelain 8def4c4
Move files to have everything in the same folder
alexandre-castelain 37eddaf
Revert the DataTableBuilderInterface.php
alexandre-castelain 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import {Controller} from '@hotwired/stimulus' | ||
|
||
export default class extends Controller { | ||
static values = { | ||
toggledClass: { type: String, default: 'show' }, | ||
} | ||
|
||
static targets = [ | ||
'content', | ||
]; | ||
|
||
toggle() { | ||
this.contentTarget.classList.toggle(this.toggledClassValue) | ||
} | ||
} |
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,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Kreyu\Bundle\DataTableBundle\Action\Type; | ||
|
||
use Kreyu\Bundle\DataTableBundle\Action\ActionBuilderInterface; | ||
use Kreyu\Bundle\DataTableBundle\Action\ActionInterface; | ||
use Kreyu\Bundle\DataTableBundle\Action\ActionView; | ||
use Symfony\Component\OptionsResolver\OptionsResolver; | ||
|
||
class DropdownActionType extends AbstractActionType | ||
{ | ||
public function buildView(ActionView $view, ActionInterface $action, array $options): void | ||
{ | ||
$itemActions = []; | ||
/** @var ActionBuilderInterface $itemActionBuilder */ | ||
foreach ($options['actions'] as $itemActionBuilder) { | ||
$itemAction = $itemActionBuilder->getAction(); | ||
$itemAction->setDataTable($action->getDataTable()); | ||
|
||
$itemActions[] = $itemAction->createView($view->parent); | ||
} | ||
|
||
$view->vars['actions'] = $itemActions; | ||
} | ||
|
||
public function configureOptions(OptionsResolver $resolver): void | ||
{ | ||
$resolver->define('actions') | ||
->allowedTypes('array') | ||
alexandre-castelain marked this conversation as resolved.
Show resolved
Hide resolved
|
||
->required() | ||
; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/Action/Type/DropdownItemActionType/LinkDropdownItemActionType.php
alexandre-castelain marked this conversation as resolved.
Show resolved
Hide resolved
|
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,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Kreyu\Bundle\DataTableBundle\Action\Type\DropdownItemActionType; | ||
|
||
use Kreyu\Bundle\DataTableBundle\Action\Type\AbstractActionType; | ||
use Kreyu\Bundle\DataTableBundle\Action\Type\LinkActionType; | ||
|
||
class LinkDropdownItemActionType extends AbstractActionType | ||
{ | ||
public function getParent(): ?string | ||
{ | ||
return LinkActionType::class; | ||
} | ||
} |
alexandre-castelain marked this conversation as resolved.
Show resolved
Hide resolved
|
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,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Kreyu\Bundle\DataTableBundle\Builder; | ||
|
||
use Kreyu\Bundle\DataTableBundle\Action\ActionBuilderInterface; | ||
use Kreyu\Bundle\DataTableBundle\Action\Type\ActionTypeInterface; | ||
use Kreyu\Bundle\DataTableBundle\Exception\InvalidArgumentException; | ||
|
||
interface RowActionBuilderInterface | ||
{ | ||
/** | ||
* @throws InvalidArgumentException if row action of given name does not exist | ||
*/ | ||
public function getRowAction(string $name): ActionBuilderInterface; | ||
|
||
public function hasRowAction(string $name): bool; | ||
|
||
/** | ||
* @param class-string<ActionTypeInterface>|null $type | ||
*/ | ||
public function createRowAction(string $name, ?string $type = null, array $options = []): ActionBuilderInterface; | ||
|
||
/** | ||
* @param class-string<ActionTypeInterface>|null $type | ||
*/ | ||
public function addRowAction(ActionBuilderInterface|string $action, ?string $type = null, array $options = []): static; | ||
|
||
public function removeRowAction(string $name): static; | ||
} |
alexandre-castelain marked this conversation as resolved.
Show resolved
Hide resolved
|
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
alexandre-castelain marked this conversation as resolved.
Show resolved
Hide resolved
|
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.
Do we need this controller at all? I don't think we really need a custom solution to dropdowns - the Bootstrap provides its own scripts we're using with data params, and base theme doesn't need a functional dropdown, because it is not meant to be used directly. I would assume that themes that extend the base theme should provide their own implementation of dropdown, like we do with Bootstrap.
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 don't know why, but I didn't manage to make any dropdown from bootstrap properly.
If this works well with bootstrap, I totally agree with you, we can remove this controller.
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'll have to check the issue with Bootstrap modals in an application and try some things. I'll come back to you.