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>
133 lines
3.7 KiB
PHP
133 lines
3.7 KiB
PHP
<?php
|
|
|
|
namespace Filament\Actions;
|
|
|
|
use Closure;
|
|
use Filament\Actions\Concerns\HasId;
|
|
use Filament\Support\Components\Contracts\HasEmbeddedView;
|
|
use Filament\Support\Contracts\HasLabel as LabelInterface;
|
|
use Filament\Support\View\ComponentAttributeBag as FilamentComponentAttributeBag;
|
|
use Illuminate\Contracts\Support\Arrayable;
|
|
use UnitEnum;
|
|
|
|
class SelectAction extends Action implements HasEmbeddedView
|
|
{
|
|
use HasId;
|
|
|
|
public const SELECT_VIEW = 'filament-actions::select-action';
|
|
|
|
protected string $view = self::SELECT_VIEW;
|
|
|
|
/**
|
|
* @var array<string> | Arrayable | string | Closure
|
|
*/
|
|
protected array | Arrayable | string | Closure $options = [];
|
|
|
|
protected ?string $placeholder = null;
|
|
|
|
/**
|
|
* @param array<string> | Arrayable | string | Closure $options
|
|
*/
|
|
public function options(array | Arrayable | string | Closure $options): static
|
|
{
|
|
$this->options = $options;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function placeholder(string $placeholder): static
|
|
{
|
|
$this->placeholder = $placeholder;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return array<string>
|
|
*/
|
|
public function getOptions(): array
|
|
{
|
|
$options = $this->evaluate($this->options) ?? [];
|
|
|
|
if (
|
|
is_string($options) &&
|
|
enum_exists($enum = $options)
|
|
) {
|
|
if (is_a($enum, LabelInterface::class, allow_string: true)) {
|
|
return array_reduce($enum::cases(), function (array $carry, LabelInterface & UnitEnum $case): array {
|
|
$carry[$case->value ?? $case->name] = $case->getLabel() ?? $case->name;
|
|
|
|
return $carry;
|
|
}, []);
|
|
}
|
|
|
|
return array_reduce($enum::cases(), function (array $carry, UnitEnum $case): array {
|
|
$carry[$case->value ?? $case->name] = $case->name;
|
|
|
|
return $carry;
|
|
}, []);
|
|
}
|
|
|
|
if ($options instanceof Arrayable) {
|
|
$options = $options->toArray();
|
|
}
|
|
|
|
return $options;
|
|
}
|
|
|
|
public function getPlaceholder(): ?string
|
|
{
|
|
return $this->placeholder;
|
|
}
|
|
|
|
public function toEmbeddedHtml(): string
|
|
{
|
|
$id = $this->getId();
|
|
$isDisabled = $this->isDisabled();
|
|
|
|
$inputWrapperAttributes = (new FilamentComponentAttributeBag)
|
|
->class([
|
|
'fi-input-wrp',
|
|
'fi-disabled' => $isDisabled,
|
|
]);
|
|
|
|
$inputAttributes = (new FilamentComponentAttributeBag)
|
|
->merge([
|
|
'disabled' => $isDisabled,
|
|
'id' => $id,
|
|
'wire:model.live' => $this->getName(),
|
|
], escape: false)
|
|
->class([
|
|
'fi-select-input',
|
|
]);
|
|
|
|
ob_start(); ?>
|
|
|
|
<div class="fi-ac-select-action">
|
|
<label for="<?= $id ?>" class="fi-sr-only">
|
|
<?= e($this->getLabel()) ?>
|
|
</label>
|
|
|
|
<div <?= $inputWrapperAttributes->toHtml() ?>>
|
|
<select <?= $inputAttributes->toHtml() ?>>
|
|
<?php if (($placeholder = $this->getPlaceholder()) !== null) { ?>
|
|
<option value=""><?= e($placeholder) ?></option>
|
|
<?php } ?>
|
|
|
|
<?php foreach ($this->getOptions() as $value => $label) { ?>
|
|
<option value="<?= e($value) ?>">
|
|
<?= e($label) ?>
|
|
</option>
|
|
<?php } ?>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
<?php return ob_get_clean();
|
|
}
|
|
|
|
public function hasView(): bool
|
|
{
|
|
return ($this->getView() !== static::SELECT_VIEW) && parent::hasView();
|
|
}
|
|
}
|