Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m14s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m12s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m7s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m19s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 1m32s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 1m22s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 1m32s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 1m35s
CI / Build-Artefakte aktuell (pull_request) Failing after 1m7s
- Laravel 13 mit Filament 5 (Admin), Inertia 3 + Vue 3 + Vuetify 4 (Material 3) - Anmeldung über Fortify (Login, Passwort vergessen/ändern), keine Selbstregistrierung - Profil mit Profilbild (WebP in festen Größen), Personenseiten, Header mit Avatar-Menü - Material-3-Farbschema aus der Primärfarbe, hell/dunkel/System pro Person - Basis-Branding (Portalname, Logo, Primärfarbe) im Admin unter „Erscheinungsbild“ - Benutzerverwaltung im Admin, Zugang vorläufig über is_admin - vendor/ (ohne Dev-Pakete) und Frontend-Build mitversioniert, Dev-Pakete in vendor-dev/ - PHPUnit-Tests gegen MySQL/MariaDB, Forgejo-CI-Matrix, Docker-Entwicklungsumgebung - VERSION, CHANGELOG.md und CONTRIBUTING.md mit Release-Ablauf Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
104 lines
3.4 KiB
PHP
104 lines
3.4 KiB
PHP
<?php
|
|
|
|
namespace Filament\Tables\Table\Concerns;
|
|
|
|
use Closure;
|
|
use Filament\Actions\Action;
|
|
use Filament\Actions\ActionGroup;
|
|
use Filament\Actions\BulkAction;
|
|
use Filament\Tables\Actions\HeaderActionsPosition;
|
|
use Illuminate\Support\Arr;
|
|
use InvalidArgumentException;
|
|
|
|
trait HasHeaderActions
|
|
{
|
|
/**
|
|
* @var array<string, Action | BulkAction | ActionGroup>
|
|
*/
|
|
protected array $headerActions = [];
|
|
|
|
protected HeaderActionsPosition | Closure | null $headerActionsPosition = null;
|
|
|
|
public function headerActionsPosition(HeaderActionsPosition | Closure | null $position = null): static
|
|
{
|
|
$this->headerActionsPosition = $position;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @param array<Action | BulkAction | ActionGroup> | ActionGroup $actions
|
|
*/
|
|
public function headerActions(array | ActionGroup $actions, HeaderActionsPosition | Closure | null $position = null): static
|
|
{
|
|
// We must remove the existing cached header actions before setting the new ones, as
|
|
// the visibility of the checkboxes is determined by which bulk actions are visible.
|
|
// The `$this->flatActions` array is used to determine if any bulk actions are
|
|
// visible. We cannot simply clear it, as the bulk actions defined in the header
|
|
// of the table are also stored in this array, and we do not want to remove them,
|
|
// only the bulk actions that are stored in the `$this->headerActions` array.
|
|
foreach ($this->headerActions as $existingAction) {
|
|
if ($existingAction instanceof ActionGroup) {
|
|
/** @var array<Action> $flatExistingActions */
|
|
$flatExistingActions = $existingAction->getFlatActions();
|
|
|
|
$this->removeCachedActions($flatExistingActions);
|
|
} elseif ($existingAction instanceof Action) {
|
|
$this->removeCachedActions([$existingAction]);
|
|
}
|
|
}
|
|
|
|
$this->headerActions = [];
|
|
|
|
$this->pushHeaderActions($actions);
|
|
|
|
if ($position) {
|
|
$this->headerActionsPosition($position);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @param array<Action | BulkAction | ActionGroup> | ActionGroup $actions
|
|
*/
|
|
public function pushHeaderActions(array | ActionGroup $actions): static
|
|
{
|
|
foreach (Arr::wrap($actions) as $action) {
|
|
$action->table($this);
|
|
|
|
if ($action instanceof ActionGroup) {
|
|
foreach ($action->getFlatActions() as $flatAction) {
|
|
$this->cacheAction($flatAction);
|
|
}
|
|
} elseif ($action instanceof Action) {
|
|
$this->cacheAction($action);
|
|
} else {
|
|
throw new InvalidArgumentException('Table header actions must be an instance of [' . Action::class . '], [' . BulkAction::class . '] or [' . ActionGroup::class . '].');
|
|
}
|
|
|
|
$this->headerActions[] = $action;
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getHeaderActionsPosition(): HeaderActionsPosition
|
|
{
|
|
$position = $this->evaluate($this->headerActionsPosition);
|
|
|
|
if (filled($position)) {
|
|
return $position;
|
|
}
|
|
|
|
return HeaderActionsPosition::Adaptive;
|
|
}
|
|
|
|
/**
|
|
* @return array<string, Action | BulkAction | ActionGroup>
|
|
*/
|
|
public function getHeaderActions(): array
|
|
{
|
|
return $this->headerActions;
|
|
}
|
|
}
|