Loheide-eu-mitarbeiterplatt.../app/Filament/Pages/QuickLinksSettings.php
Friederich Loheide c71131d054
All checks were successful
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 2m35s
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 2m37s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 2m41s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 2m52s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 3m56s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 4m2s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 4m21s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 4m5s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m10s
Symbole: alle Lucide-Symbole lokal verfügbar
- Vollständiger Satz (1.854 Symbole + Aliase älterer Namen) in
  resources/icons/svg.php (Admin) und resources/js/lib/icon-set.js
  (Portal, wird nur bei Bedarf geladen)
- Kuratierte 66 mit deutscher Bezeichnung bleiben im Hauptpaket und
  stehen in Auswahlfeldern vorne; die Suche findet alle
- AppIcon-Komponente für Menü, Schnellzugriffe und Pagebuilder;
  Symbolfeld im Pagebuilder mit Suche

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-26 14:50:13 +00:00

105 lines
4.1 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace App\Filament\Pages;
use App\Support\Icons;
use App\Support\QuickLinks;
use App\Support\Settings;
use BackedEnum;
use Filament\Forms\Components\Repeater;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Notifications\Notification;
use Filament\Pages\Page;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Schema;
use Filament\Support\Icons\Heroicon;
use UnitEnum;
class QuickLinksSettings extends Page
{
protected string $view = 'filament.pages.settings-form';
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedSquares2x2;
protected static string|UnitEnum|null $navigationGroup = 'Portal';
protected static ?string $navigationLabel = 'Schnellzugriffe';
protected static ?string $title = 'Schnellzugriffe';
public static function canAccess(): bool
{
return auth()->user()?->can('appearance.manage') ?? false;
}
protected static ?string $slug = 'schnellzugriffe';
/** @var array<string, mixed>|null */
public ?array $data = [];
public function mount(QuickLinks $quickLinks): void
{
$this->form->fill(['links' => $quickLinks->all()]);
}
public function form(Schema $schema): Schema
{
return $schema
->components([
Section::make('Schnellzugriffe auf der Startseite')
->description('Häufig genutzte Anwendungen und Seiten – z. B. Zeiterfassung, Urlaubsantrag oder IT-Support. Die Reihenfolge lässt sich per Ziehen ändern.')
->schema([
Repeater::make('links')
->hiddenLabel()
->columns(4)
->reorderable()
->collapsible()
->itemLabel(fn (array $state) => $state['label'] ?? null)
->addActionLabel('Schnellzugriff hinzufügen')
->maxItems(24)
->schema([
TextInput::make('label')
->label('Bezeichnung')
->required()
->maxLength(40),
TextInput::make('url')
->label('Adresse')
->placeholder('https://… oder /personen')
->required()
->maxLength(500)
->regex('#^(https?://|/)#i')
->validationMessages(['regex' => 'Bitte eine Adresse angeben, die mit https://, http:// oder / beginnt.'])
->columnSpan(2),
Select::make('icon')
->label('Symbol')
->options(Icons::options())
->allowHtml()
->searchable()
->getSearchResultsUsing(fn (string $search) => Icons::search($search))
->getOptionLabelUsing(fn (?string $value) => $value ? Icons::option($value) : null)
->helperText('Alle 1.800+ Symbole über die Suche (englische Namen, z. B. „calendar“).')
->default('link')
->required(),
Toggle::make('new_tab')
->label('In neuem Tab öffnen')
->columnSpanFull(),
]),
]),
])
->statePath('data');
}
public function save(Settings $settings): void
{
$links = array_values($this->form->getState()['links'] ?? []);
$settings->set('portal.quick_links', $links);
Notification::make()
->success()
->title('Schnellzugriffe gespeichert')
->send();
}
}