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(),
];

View file

@ -0,0 +1,36 @@
<?php
namespace App\Http\Controllers;
use App\Plugins\PluginAccess;
use App\Support\Hubs;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use Inertia\Inertia;
use Inertia\Response;
class HubController extends Controller
{
/** /wissen – Suche und die Bereiche zum Nachschlagen */
public function wissen(Request $request, Hubs $hubs): Response
{
return Inertia::render('Hubs/Wissen', [
'entries' => $hubs->forUser('wissen', $request->user()),
]);
}
/** /service – IT und die übrigen Anlaufstellen */
public function service(Request $request, Hubs $hubs): Response
{
$it = Route::has('it-service.index') && app(PluginAccess::class)->allows('it-service', $request->user());
return Inertia::render('Hubs/Service', [
'entries' => $hubs->forUser('service', $request->user()),
'it' => $it ? array_values(array_filter([
Route::has('it-service.tickets.create') ? ['label' => 'Problem melden', 'text' => 'Wir fragen kurz nach, dann geht es los', 'icon' => 'circle-alert', 'url' => route('it-service.tickets.create', absolute: false), 'primary' => true] : null,
Route::has('it-service.loans.devices') ? ['label' => 'Gerät ausleihen', 'text' => 'Laptop, Beamer, Diensthandy', 'icon' => 'laptop', 'url' => route('it-service.loans.devices', absolute: false), 'primary' => false] : null,
['label' => 'Meine IT', 'text' => 'Tickets und Ausleihen im Überblick', 'icon' => 'headset', 'url' => route('it-service.index', absolute: false), 'primary' => false],
])) : null,
]);
}
}

View file

@ -244,5 +244,25 @@ class Blocks
return ['people' => PersonResource::collection($people)->resolve()];
}));
// Gremien und Teams vorstellen: große Fotos, Name und Rolle (z. B. „Vorsitz“)
$this->add(BlockType::make('members', 'Mitglieder mit Rolle', 'users-round', 'dynamic')
->description('Für Gremien wie MAV oder Werkstattrat: Personen mit großem Foto und ihrer Rolle im Gremium.')
->fields([
Field::text('title', 'Überschrift', 150, 'Das sind wir'),
Field::repeater('members', 'Mitglieder', [
Field::people('person', 'Person', 1),
Field::text('role', 'Rolle', 80, '', 'z. B. Vorsitz'),
], 30, 'Mitglied'),
])
->resolveUsing(function (array $data) {
$entries = collect($data['members'] ?? [])->map(fn ($m) => ['id' => (int) (((array) ($m['person'] ?? []))[0] ?? 0), 'role' => (string) ($m['role'] ?? '')])->filter(fn ($m) => $m['id'] > 0);
$people = User::query()->active()->whereIn('id', $entries->pluck('id'))->get()->keyBy('id');
return ['members' => $entries->filter(fn ($m) => $people->has($m['id']))->map(fn ($m) => [
...PersonResource::make($people[$m['id']])->resolve(),
'role' => $m['role'],
])->values()->all()];
}));
}
}

View file

@ -29,6 +29,7 @@ use App\Support\Abilities;
use App\Support\Avatars;
use App\Support\BackgroundTasks;
use App\Support\Branding;
use App\Support\Hubs;
use App\Support\Installation;
use App\Support\License\LicenseStore;
use App\Support\MailSettings;
@ -79,6 +80,7 @@ class AppServiceProvider extends ServiceProvider
$this->app->singleton(QuickLinks::class);
$this->app->singleton(Tasks::class);
$this->app->singleton(Feed::class);
$this->app->singleton(Hubs::class);
$this->app->singleton(PluginAccess::class);
$this->app->singleton(GlobalSearch::class);
$this->app->singleton(LicenseStore::class);

96
app/Support/Hubs.php Normal file
View file

@ -0,0 +1,96 @@
<?php
namespace App\Support;
use App\Feed\Feed;
use App\Models\User;
use App\Plugins\PluginAccess;
use Illuminate\Support\Facades\Route;
/**
* Übersichtsseiten „Wissen“ (/wissen) und „Service“ (/service): Kacheln zu den Bereichen
* bzw. Anlaufstellen des Hauses – jeweils mit Ansprechperson. Die Administration pflegt sie
* unter Startseite & Menü → Wissen & Service; ohne eigene Pflege gilt ein Vorschlag aus den
* vorhandenen Bereichen.
*
* Je Kachel: Titel, Text, Symbol, Adresse, Knopf, Ansprechperson, „Sichtbar für“ und – bei
* Vorschlägen – das Plugin, zu dem sie gehört (gesperrt → Kachel entfällt).
*/
class Hubs
{
public const HUBS = ['wissen', 'service'];
public function __construct(private readonly Settings $settings) {}
/**
* Gespeicherte Kacheln – oder der Vorschlag.
*
* @return list<array{title: string, text: string, icon: string, url: string, action: string, person: int|null, roles: list<int>, plugin: string|null}>
*/
public function entries(string $hub): array
{
$stored = $this->settings->get("hubs.{$hub}");
return array_values(array_map(fn (array $entry) => [
'title' => (string) ($entry['title'] ?? ''),
'text' => (string) ($entry['text'] ?? ''),
'icon' => Icons::has($entry['icon'] ?? null) ? $entry['icon'] : 'link',
'url' => preg_match('#^(https?://|/)#i', (string) ($entry['url'] ?? '')) ? (string) $entry['url'] : '#',
'action' => (string) ($entry['action'] ?? ''),
'person' => filled($entry['person'] ?? null) ? (int) $entry['person'] : null,
'roles' => array_values(array_map('intval', array_filter((array) ($entry['roles'] ?? []), 'is_numeric'))),
'plugin' => filled($entry['plugin'] ?? null) ? (string) $entry['plugin'] : null,
], array_filter(is_array($stored) ? $stored : $this->suggestion($hub), fn ($entry) => is_array($entry) && filled($entry['title'] ?? null))));
}
/**
* Für eine Person: gefiltert nach Rolle und gesperrten Bereichen, Ansprechperson aufgelöst.
*
* @return list<array<string, mixed>>
*/
public function forUser(string $hub, User $user): array
{
$roleIds = $user->roles()->pluck('roles.id')->map(fn ($id) => (int) $id)->all();
$access = app(PluginAccess::class);
$entries = array_filter($this->entries($hub), fn (array $entry) => ($entry['roles'] === [] || array_intersect($entry['roles'], $roleIds) !== [])
&& ($entry['plugin'] === null || $access->allows($entry['plugin'], $user)));
$people = User::query()->active()->whereIn('id', array_filter(array_column($entries, 'person')))->get()->keyBy('id');
return array_values(array_map(fn (array $entry) => [
'title' => $entry['title'],
'text' => $entry['text'],
'icon' => $entry['icon'],
'url' => $entry['url'],
'action' => $entry['action'],
'person' => $entry['person'] ? Feed::person($people->get($entry['person'])) : null,
], $entries));
}
/**
* Vorschlag aus den vorhandenen Bereichen.
*
* @return list<array<string, mixed>>
*/
public function suggestion(string $hub): array
{
$candidates = $hub === 'wissen' ? [
['pages.index', 'pages', 'Handbuch', 'Wie wir arbeiten: Organisation, Abläufe, Regeln für den Alltag.', 'book-open'],
['downloads.index', 'downloads', 'Downloads', 'Vorlagen, Anträge und Infomaterial – immer in der aktuellen Fassung.', 'folder-down'],
['qm.index', 'qm', 'Qualität', 'Qualitätshandbuch, Verfahrensanweisungen und Formblätter.', 'shield-check'],
['people.index', null, 'Telefonbuch', 'Wer macht was, wer sitzt wo, wer vertritt wen.', 'contact'],
['glossary.index', 'glossar', 'Glossar', 'Abkürzungen und Fachbegriffe aus dem Haus.', 'book-a'],
['forms.index', 'forms', 'Formulare', 'Anträge und Meldungen online ausfüllen.', 'clipboard-list'],
] : [
['forms.index', 'forms', 'Anträge und Formulare', 'Urlaub, Fortbildung, Bescheinigungen und mehr – online beantragen.', 'clipboard-list'],
['verleih.index', 'verleih', 'Bilderverleih', 'Bilder vom Künstlerteam für Flure und Büros.', 'images'],
['speiseplan.index', 'speiseplan', 'Kantine', 'Speiseplan der Woche.', 'utensils'],
['ideas.index', 'ideen', 'Ideenbox', 'Verbesserungsvorschläge – jede Idee wird beantwortet.', 'lightbulb'],
['kleinanzeigen.index', 'kleinanzeigen', 'Kleinanzeigen', 'Suchen, verschenken, verkaufen – unter Kolleginnen und Kollegen.', 'shopping-bag'],
];
return array_values(array_filter(array_map(fn (array $c) => Route::has($c[0]) ? [
'title' => $c[2], 'text' => $c[3], 'icon' => $c[4], 'url' => route($c[0], absolute: false),
'action' => '', 'person' => null, 'roles' => [], 'plugin' => $c[1],
] : null, $candidates)));
}
}

View file

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