Schnellzugriffe mit Logo, Kategorien und Sichtbar für (0.51.0)
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 7m7s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 7m30s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 8m6s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 8m21s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 17m13s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 17m12s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 9m52s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 9m29s
CI / Bekannte Sicherheitslücken in Paketen (pull_request) Successful in 47s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m23s

Untertitel, Logo, Kategorie, Rollen und Anheften je Eintrag; Knopf
„Anwendungen“ in der Kopfzeile mit allen sichtbaren Einträgen.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Friederich Loheide 2026-09-29 18:44:53 +00:00
parent 25fe5e8c37
commit a618927a52
152 changed files with 653 additions and 379 deletions

View file

@ -25,9 +25,11 @@ class CoreWidgets
'actions' => array_values(array_filter((array) Hooks::apply('greeting.actions', [], $user), fn ($action) => is_array($action) && isset($action['label'], $action['href']))),
], label: 'Begrüßung mit Profil', mobileSort: 0);
$widgets->add('core.quick-links', 'core::QuickLinks', 'main', sort: 10, props: fn () => [
'links' => app(QuickLinks::class)->all(),
], label: 'Schnellzugriffe', mobileSort: 40, areas: ['main', 'aside']);
$widgets->add('core.quick-links', 'core::QuickLinks', 'main', sort: 10, props: function (User $user) {
$links = app(QuickLinks::class)->forUser($user);
return $links === [] ? null : ['links' => QuickLinks::pinned($links), 'total' => count($links)];
}, label: 'Schnellzugriffe', mobileSort: 40, areas: ['main', 'aside']);
$widgets->add('core.new-colleagues', 'core::NewColleagues', 'main', sort: 90, props: function (User $user) {
$people = User::query()

View file

@ -3,10 +3,13 @@
namespace App\Filament\Pages;
use App\Filament\Clusters\HomepageCluster;
use App\Filament\Components\SafeUpload;
use App\Models\Role;
use App\Support\Icons;
use App\Support\QuickLinks;
use App\Support\Settings;
use BackedEnum;
use Filament\Forms\Components\FileUpload;
use Filament\Forms\Components\Repeater;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
@ -50,22 +53,28 @@ class QuickLinksSettings extends Page
{
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.')
Section::make('Schnellzugriffe')
->description('Anwendungen und Seiten, die viele täglich brauchen – z. B. Dienstplan, Dokumentation oder Archiv. Angeheftete stehen auf der Startseite, alle zusammen unter „Anwendungen“ in der Kopfzeile. Die Reihenfolge lässt sich per Ziehen ändern.')
->schema([
Repeater::make('links')
->hiddenLabel()
->columns(4)
->reorderable()
->collapsible()
->itemLabel(fn (array $state) => $state['label'] ?? null)
->collapsed(fn (array $state) => count($state) > 6)
->itemLabel(fn (array $state) => trim(($state['label'] ?? '').(($state['pinned'] ?? false) ? ' · angeheftet' : '').(filled($state['roles'] ?? null) ? ' · eingeschränkt' : '')) ?: null)
->addActionLabel('Schnellzugriff hinzufügen')
->maxItems(24)
->maxItems(60)
->schema([
TextInput::make('label')
->label('Bezeichnung')
->required()
->maxLength(40),
TextInput::make('subtitle')
->label('Untertitel')
->placeholder('z. B. Dienstplan')
->helperText('Hilft, wenn der Name allein nicht sagt, wofür es ist.')
->maxLength(60),
TextInput::make('url')
->label('Adresse')
->placeholder('https://… oder /personen')
@ -81,12 +90,33 @@ class QuickLinksSettings extends Page
->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“).')
->helperText('Wird gezeigt, wenn kein Logo hochgeladen ist.')
->default('link')
->required(),
SafeUpload::apply(FileUpload::make('logo'), [...SafeUpload::IMAGES, 'image/svg+xml'])
->label('Logo')
->helperText('Optional, quadratisch am besten (PNG, SVG, WebP).')
->disk('uploads')->directory('quick-links')->visibility('public')
->image()->maxSize(1024),
TextInput::make('category')
->label('Kategorie')
->placeholder('z. B. Pflege, Verwaltung')
->helperText('Ordnet die Liste unter „Anwendungen“.')
->datalist(fn () => collect(app(QuickLinks::class)->all())->pluck('category')->filter()->unique()->values()->all())
->maxLength(40),
Select::make('roles')
->label('Sichtbar für')
->multiple()
->options(fn () => Role::query()->orderBy('name')->pluck('name', 'id')->all())
->placeholder('Alle')
->helperText('Leer = alle. Sonst nur Personen mit einer dieser Rollen.'),
Toggle::make('pinned')
->label('Auf der Startseite anheften')
->helperText('Ohne angeheftete Einträge stehen alle auf der Startseite.')
->columnSpan(2),
Toggle::make('new_tab')
->label('In neuem Tab öffnen')
->columnSpanFull(),
->columnSpan(2),
]),
]),
])
@ -95,7 +125,10 @@ class QuickLinksSettings extends Page
public function save(Settings $settings): void
{
$links = array_values($this->form->getState()['links'] ?? []);
$links = array_values(array_map(fn (array $link) => [
...$link,
'roles' => array_values(array_map('intval', (array) ($link['roles'] ?? []))),
], $this->form->getState()['links'] ?? []));
$settings->set('portal.quick_links', $links);

View file

@ -9,6 +9,7 @@ use App\Push\WebPush;
use App\Support\Branding;
use App\Support\Impersonation;
use App\Support\Navigation;
use App\Support\QuickLinks;
use Illuminate\Http\Request;
use Inertia\Inertia;
use Inertia\Middleware;
@ -50,6 +51,8 @@ class HandleInertiaRequests extends Middleware
] : null,
],
'navigation' => fn () => $user ? $this->navigation->items($request, $user) : [],
// Schnellzugriffe für „Anwendungen“ in der Kopfzeile (je Person gefiltert)
'apps' => fn () => $user ? app(QuickLinks::class)->forUser($user) : [],
'impersonation' => fn () => $user && app(Impersonation::class)->active() ? ['name' => $user->name, 'by' => app(Impersonation::class)->impersonator()?->name] : null,
'notifications' => fn () => $user ? ['unread' => $user->unreadNotifications()->count()] : null,
// Web-Push: öffentlicher Schlüssel für dieses Portal

View file

@ -2,15 +2,25 @@
namespace App\Support;
use App\Models\User;
use Illuminate\Support\Facades\Storage;
/**
* Schnellzugriffe auf der Startseite (App-Launcher), gepflegt im Admin-Bereich.
* Schnellzugriffe (App-Launcher): Anwendungen und Seiten, die viele täglich brauchen –
* z. B. Dienstplan, Dokumentation, Archiv. Gepflegt im Admin-Bereich.
*
* Je Eintrag: Bezeichnung, Untertitel, Adresse, Symbol oder Logo, Kategorie, „Sichtbar für“
* (Rollen; leer = alle) und „oben anheften“. Auf der Startseite stehen die angehefteten
* (ohne angeheftete: alle), der Rest steckt hinter „Alle Anwendungen“ in der Kopfzeile.
*/
class QuickLinks
{
public function __construct(private readonly Settings $settings) {}
/**
* @return list<array{label: string, url: string, icon: string, new_tab: bool}>
* Alle Einträge, wie gespeichert (für die Verwaltung).
*
* @return list<array{label: string, subtitle: string, url: string, icon: string, logo: string|null, category: string, roles: list<int>, pinned: bool, new_tab: bool}>
*/
public function all(): array
{
@ -22,20 +32,62 @@ class QuickLinks
return array_values(array_map(fn (array $link) => [
'label' => (string) ($link['label'] ?? ''),
'subtitle' => (string) ($link['subtitle'] ?? ''),
'url' => preg_match('#^(https?://|/)#i', (string) ($link['url'] ?? '')) ? (string) $link['url'] : '#',
'icon' => Icons::has($link['icon'] ?? null) ? $link['icon'] : 'link',
'logo' => filled($link['logo'] ?? null) ? (string) $link['logo'] : null,
'category' => trim((string) ($link['category'] ?? '')),
'roles' => array_values(array_map('intval', array_filter((array) ($link['roles'] ?? []), 'is_numeric'))),
'pinned' => (bool) ($link['pinned'] ?? false),
'new_tab' => (bool) ($link['new_tab'] ?? false),
], $links));
], array_filter($links, 'is_array')));
}
/**
* @return list<array{label: string, url: string, icon: string, new_tab: bool}>
* Was eine Person sehen darf – fertig für die Oberfläche (Logo als Adresse).
*
* @return list<array{label: string, subtitle: string, url: string, icon: string, logo_url: string|null, category: string, pinned: bool, new_tab: bool}>
*/
public function forUser(?User $user): array
{
$roleIds = $user ? $user->roles()->pluck('roles.id')->map(fn ($id) => (int) $id)->all() : [];
return array_values(array_map(fn (array $link) => [
'label' => $link['label'],
'subtitle' => $link['subtitle'],
'url' => $link['url'],
'icon' => $link['icon'],
'logo_url' => $link['logo'] ? Storage::disk('uploads')->url($link['logo']) : null,
'category' => $link['category'],
'pinned' => $link['pinned'],
'new_tab' => $link['new_tab'],
], array_filter(
$this->all(),
fn (array $link) => $link['roles'] === [] || array_intersect($link['roles'], $roleIds) !== [],
)));
}
/**
* Für die Startseite: angeheftete Einträge – oder alle, wenn keiner angeheftet ist.
*
* @param list<array<string, mixed>> $links aus forUser()
* @return list<array<string, mixed>>
*/
public static function pinned(array $links): array
{
$pinned = array_values(array_filter($links, fn (array $link) => $link['pinned']));
return $pinned !== [] ? $pinned : $links;
}
/**
* @return list<array{label: string, subtitle: string, url: string, icon: string, logo: string|null, category: string, roles: list<int>, pinned: bool, new_tab: bool}>
*/
public function defaults(): array
{
return [
['label' => 'Personen', 'url' => '/personen', 'icon' => 'users', 'new_tab' => false],
['label' => 'Mein Profil', 'url' => '/profil/bearbeiten', 'icon' => 'file-text', 'new_tab' => false],
['label' => 'Personen', 'subtitle' => '', 'url' => '/personen', 'icon' => 'users', 'logo' => null, 'category' => '', 'roles' => [], 'pinned' => false, 'new_tab' => false],
['label' => 'Mein Profil', 'subtitle' => '', 'url' => '/profil/bearbeiten', 'icon' => 'file-text', 'logo' => null, 'category' => '', 'roles' => [], 'pinned' => false, 'new_tab' => false],
];
}
}

View file

@ -9,5 +9,5 @@ namespace App;
*/
final class Version
{
public const VERSION = '0.50.0';
public const VERSION = '0.51.0';
}