mirror of
https://github.com/filamentphp/filament.git
synced 2026-09-24 15:42:09 +08:00
wip
This commit is contained in:
@@ -44,27 +44,18 @@ ActionGroup::make([
|
||||
|
||||
## Adding dividers between actions
|
||||
|
||||
You may add dividers between each action in the dropdown by using the `divided()` method:
|
||||
You may add dividers between groups of actions by using nested `ActionGroup` objects:
|
||||
|
||||
```php
|
||||
ActionGroup::make([
|
||||
ActionGroup::make([
|
||||
// Array of actions
|
||||
])->dropdown(false),
|
||||
// Array of actions
|
||||
])
|
||||
->divided()
|
||||
```
|
||||
|
||||
If you'd like to group multiple actions together within one division, you may nest another `ActionGroup` within the main `ActionGroup`, and disable the dropdown on the nested group using `dropdown(false)`:
|
||||
|
||||
```php
|
||||
ActionGroup::make([
|
||||
// Array of individually divided actions
|
||||
ActionGroup::make([
|
||||
// Array of actions within one division
|
||||
])->dropdown(false),
|
||||
// Array of individually divided actions
|
||||
])
|
||||
->divided()
|
||||
```
|
||||
The `dropdown(false)` method puts the actions inside the parent dropdown, instead of a new nested dropdown.
|
||||
|
||||
## Setting the width of the dropdown
|
||||
|
||||
|
||||
@@ -53,29 +53,31 @@
|
||||
@endforeach
|
||||
@else
|
||||
@php
|
||||
$actions = array_filter(
|
||||
$group->getActions(),
|
||||
fn ($action): bool => $action->isVisible(),
|
||||
);
|
||||
|
||||
$actionLists = [];
|
||||
$actionList = [];
|
||||
$singleActions = [];
|
||||
|
||||
foreach ($group->getActions() as $action) {
|
||||
if ($action->isHidden()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($actions as $action) {
|
||||
if ($action instanceof \Filament\Actions\ActionGroup && (! $action->hasDropdown())) {
|
||||
if (count($actionList)) {
|
||||
$actionLists[] = $actionList;
|
||||
$actionList = [];
|
||||
if (count($singleActions)) {
|
||||
$actionLists[] = $singleActions;
|
||||
$singleActions = [];
|
||||
}
|
||||
|
||||
$actionLists[] = $action->getActions();
|
||||
$actionLists[] = array_filter(
|
||||
$action->getActions(),
|
||||
fn ($action): bool => $action->isVisible(),
|
||||
);
|
||||
} else {
|
||||
$actionList[] = $action;
|
||||
$singleActions[] = $action;
|
||||
}
|
||||
}
|
||||
|
||||
if (count($actionList)) {
|
||||
$actionLists[] = $actionList;
|
||||
if (count($singleActions)) {
|
||||
$actionLists[] = $singleActions;
|
||||
}
|
||||
@endphp
|
||||
|
||||
|
||||
Reference in New Issue
Block a user