Wissen, Service, Gremien-Baustein und Menü-Vorschlag (0.56.0)
Some checks failed
CI / PHP 8.4 / mariadb:10.6 (pull_request) Failing after 9m9s
CI / PHP 8.3 / mariadb:10.6 (pull_request) Failing after 9m19s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Failing after 10m30s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Failing after 11m5s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 13m15s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 13m54s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 10m57s
CI / Bekannte Sicherheitslücken in Paketen (pull_request) Successful in 45s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 11m44s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m20s

Übersichtsseiten /wissen und /service (Hubs, im Admin pflegbar), Baustein
„Mitglieder mit Rolle“, Menü-Vorschlag für die Mitarbeiter-App.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Friederich Loheide 2026-09-30 16:03:08 +00:00
parent 68f90c2c68
commit 4d0a2984ec
156 changed files with 1021 additions and 363 deletions

View file

@ -0,0 +1,129 @@
<?php
namespace App\Filament\Pages;
use App\Filament\Clusters\HomepageCluster;
use App\Models\Role;
use App\Models\User;
use App\Support\Hubs;
use App\Support\Icons;
use App\Support\Settings;
use BackedEnum;
use Filament\Actions\Action;
use Filament\Forms\Components\Hidden;
use Filament\Forms\Components\Repeater;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Notifications\Notification;
use Filament\Pages\Page;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Schema;
use Filament\Support\Icons\Heroicon;
/**
* Kacheln der Übersichtsseiten „Wissen“ (/wissen) und „Service“ (/service) pflegen.
*/
class HubsSettings extends Page
{
protected string $view = 'filament.pages.settings-form';
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedLifebuoy;
protected static ?string $cluster = HomepageCluster::class;
protected static ?int $navigationSort = 4;
protected static ?string $navigationLabel = 'Wissen & Service';
protected static ?string $title = 'Wissen & Service';
protected static ?string $slug = 'wissen-service';
/** @var array<string, mixed>|null */
public ?array $data = [];
public static function canAccess(): bool
{
return auth()->user()?->can('appearance.manage') ?? false;
}
public function getSubheading(): ?string
{
return 'Kacheln der Seiten „Wissen“ (/wissen) und „Service“ (/service) – jeweils mit Ansprechperson. Im Menü als Link eintragen, z. B. mit „Menü → Vorschlag für die Mitarbeiter-App“.';
}
public function mount(Hubs $hubs): void
{
$this->form->fill(['wissen' => $hubs->entries('wissen'), 'service' => $hubs->entries('service')]);
}
public function form(Schema $schema): Schema
{
return $schema
->components([
Section::make('Wissen')->description('Bereiche zum Nachschlagen – unter der großen Suche.')
->schema([$this->repeater('wissen')]),
Section::make('Service')->description('Anlaufstellen neben dem IT-Service (der erscheint automatisch, wenn das Plugin aktiv ist).')
->schema([$this->repeater('service')]),
])
->statePath('data');
}
private function repeater(string $name): Repeater
{
return Repeater::make($name)
->hiddenLabel()
->columns(4)
->reorderable()
->collapsible()
->collapsed()
->itemLabel(fn (array $state) => $state['title'] ?? null)
->addActionLabel('Kachel hinzufügen')
->maxItems(24)
->schema([
TextInput::make('title')->label('Titel')->required()->maxLength(60),
TextInput::make('url')->label('Adresse')->placeholder('/downloads oder https://…')->required()->maxLength(500)
->regex('#^(https?://|/)#i')->validationMessages(['regex' => 'Bitte eine Adresse, 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)
->default('link')->required(),
TextInput::make('text')->label('Beschreibung')->maxLength(160)->columnSpan(2),
TextInput::make('action')->label('Knopf (optional)')->placeholder('z. B. Antrag stellen')->maxLength(30),
Select::make('person')->label('Ansprechperson')->searchable()
->getSearchResultsUsing(fn (string $search) => User::query()->active()
->where(fn ($q) => $q->where('name', 'like', "%{$search}%")->orWhere('email', 'like', "%{$search}%"))
->orderBy('name')->limit(30)->pluck('name', 'id')->all())
->getOptionLabelUsing(fn ($value) => User::query()->find($value)?->name),
Select::make('roles')->label('Sichtbar für')->multiple()
->options(fn () => Role::query()->orderBy('name')->pluck('name', 'id')->all())
->placeholder('Alle')->columnSpan(2),
Hidden::make('plugin'),
]);
}
protected function getHeaderActions(): array
{
return [
Action::make('suggest')->label('Vorschlag laden')->icon(Heroicon::OutlinedSparkles)->color('gray')
->requiresConfirmation()
->modalDescription('Ersetzt die Kacheln im Formular durch einen Vorschlag aus den vorhandenen Bereichen. Gespeichert wird erst mit „Speichern“.')
->action(fn (Hubs $hubs) => $this->form->fill(['wissen' => $hubs->suggestion('wissen'), 'service' => $hubs->suggestion('service')])),
];
}
public function save(Settings $settings): void
{
$state = $this->form->getState();
foreach (Hubs::HUBS as $hub) {
$settings->set("hubs.{$hub}", array_values(array_map(fn (array $entry) => [
...$entry,
'person' => filled($entry['person'] ?? null) ? (int) $entry['person'] : null,
'roles' => array_values(array_map('intval', (array) ($entry['roles'] ?? []))),
], $state[$hub] ?? [])));
}
Notification::make()->success()->title('Wissen & Service gespeichert')->send();
}
}

View file

@ -197,6 +197,50 @@ class MenuSettings extends Page
return $items;
}
/**
* Menü der Mitarbeiter-App: Start · Menschen · Wissen · Qualität · Service · Termine, dann der Rest.
*
* @return list<array<string, mixed>>
*/
private function appSuggestion(Navigation $navigation): array
{
$modules = $navigation->modules();
$used = [];
$item = fn (array $fields) => ['id' => (string) Str::uuid(), 'label' => null, 'icon' => null, 'roles' => [], 'children' => [], ...$fields];
$module = function (string $key, ?string $label = null) use ($modules, &$used, $item, $navigation) {
if (! isset($modules[$key])) {
return null;
}
$used[] = $key;
return $item(['type' => 'module', 'module' => $key, 'label' => $label, 'icon' => $navigation->iconFor($key)]);
};
$link = fn (string $label, string $url, string $icon) => $item(['type' => 'link', 'url' => $url, 'label' => $label, 'icon' => $icon]);
$people = array_values(array_filter([
$module('people', 'Telefonbuch'),
$module('gruppen'),
]));
$items = array_values(array_filter([
$module('home', 'Start'),
$people !== [] ? $item(['type' => 'group', 'label' => 'Menschen', 'icon' => 'users-round', 'children' => $people]) : null,
$link('Wissen', '/wissen', 'book-open'),
$module('qm', 'Qualität'),
$link('Service', '/service', 'life-buoy'),
$module('events'),
]));
// Alles Übrige dahinter – die Kopfzeile schiebt es unter „Mehr“
foreach (array_keys($modules) as $key) {
if (! in_array($key, $used, true) && ! in_array($key, ['editorial'], true)) {
$items[] = $item(['type' => 'module', 'module' => $key, 'icon' => $navigation->iconFor($key)]);
}
}
return $items;
}
public function save(Settings $settings): void
{
$items = $this->form->getState()['items'] ?? [];
@ -237,6 +281,10 @@ class MenuSettings extends Page
$this->form->fill(['items' => $this->fromAutomatic($navigation)]);
Notification::make()->success()->title('Automatisches Menü aktiv')->send();
}),
Action::make('suggestApp')->label('Vorschlag für die Mitarbeiter-App')->icon(Heroicon::OutlinedSparkles)->color('gray')
->requiresConfirmation()
->modalDescription('Ersetzt das Menü im Formular durch: Start · Menschen (Telefonbuch, Gruppen, Gremien …) · Wissen · Qualität · Service · Termine – der Rest steht dahinter unter „Mehr“. Gespeichert wird erst mit „Speichern“.')
->action(fn (Navigation $navigation) => $this->form->fill(['items' => $this->appSuggestion($navigation)])),
Action::make('preview')->label('Portal ansehen')->icon(Heroicon::OutlinedEye)->color('gray')
->url('/')->openUrlInNewTab(),
];