Backend: eigenes kompaktes Theme, Übersicht, Cluster mit Unterseiten, Plugin-Liste
Some checks failed
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 3m29s
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 3m31s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 3m56s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 4m2s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 5m20s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 5m22s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 4m42s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 4m41s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m18s
Some checks failed
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 3m29s
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 3m31s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 3m56s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 4m2s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 5m20s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 5m22s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 4m42s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 4m41s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m18s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
ff4a26ecb4
commit
c495dfa1cb
144 changed files with 1601 additions and 813 deletions
29
app/Filament/Clusters/AppearanceCluster.php
Normal file
29
app/Filament/Clusters/AppearanceCluster.php
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Clusters;
|
||||
|
||||
use BackedEnum;
|
||||
use Filament\Clusters\Cluster;
|
||||
use Filament\Pages\Enums\SubNavigationPosition;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use UnitEnum;
|
||||
|
||||
/**
|
||||
* „Erscheinungsbild“ mit Unterseiten je Bereich (Identität, Farben, Schrift …).
|
||||
*/
|
||||
class AppearanceCluster extends Cluster
|
||||
{
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedPaintBrush;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Portal';
|
||||
|
||||
protected static ?int $navigationSort = 1;
|
||||
|
||||
protected static ?string $navigationLabel = 'Erscheinungsbild';
|
||||
|
||||
protected static ?string $clusterBreadcrumb = 'Erscheinungsbild';
|
||||
|
||||
protected static ?string $slug = 'erscheinungsbild';
|
||||
|
||||
protected static ?SubNavigationPosition $subNavigationPosition = SubNavigationPosition::Top;
|
||||
}
|
||||
29
app/Filament/Clusters/HomepageCluster.php
Normal file
29
app/Filament/Clusters/HomepageCluster.php
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Clusters;
|
||||
|
||||
use BackedEnum;
|
||||
use Filament\Clusters\Cluster;
|
||||
use Filament\Pages\Enums\SubNavigationPosition;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use UnitEnum;
|
||||
|
||||
/**
|
||||
* „Startseite & Menü“: Startseite, Schnellzugriffe, Menü und eigene Kacheln.
|
||||
*/
|
||||
class HomepageCluster extends Cluster
|
||||
{
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedHome;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Portal';
|
||||
|
||||
protected static ?int $navigationSort = 2;
|
||||
|
||||
protected static ?string $navigationLabel = 'Startseite & Menü';
|
||||
|
||||
protected static ?string $clusterBreadcrumb = 'Startseite & Menü';
|
||||
|
||||
protected static ?string $slug = 'startseite-menue';
|
||||
|
||||
protected static ?SubNavigationPosition $subNavigationPosition = SubNavigationPosition::Start;
|
||||
}
|
||||
29
app/Filament/Clusters/ModulesCluster.php
Normal file
29
app/Filament/Clusters/ModulesCluster.php
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Clusters;
|
||||
|
||||
use BackedEnum;
|
||||
use Filament\Clusters\Cluster;
|
||||
use Filament\Pages\Enums\SubNavigationPosition;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use UnitEnum;
|
||||
|
||||
/**
|
||||
* „Module“: Einstellungen der einzelnen Module.
|
||||
*/
|
||||
class ModulesCluster extends Cluster
|
||||
{
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedPuzzlePiece;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Portal';
|
||||
|
||||
protected static ?int $navigationSort = 3;
|
||||
|
||||
protected static ?string $navigationLabel = 'Module';
|
||||
|
||||
protected static ?string $clusterBreadcrumb = 'Module';
|
||||
|
||||
protected static ?string $slug = 'module';
|
||||
|
||||
protected static ?SubNavigationPosition $subNavigationPosition = SubNavigationPosition::Start;
|
||||
}
|
||||
187
app/Filament/Pages/AdminDashboard.php
Normal file
187
app/Filament/Pages/AdminDashboard.php
Normal file
|
|
@ -0,0 +1,187 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Models\AuditLog;
|
||||
use App\Models\User;
|
||||
use App\Plugins\PluginManager;
|
||||
use App\Support\SiteHealth;
|
||||
use App\Support\Update\InstalledVersion;
|
||||
use Filament\Pages\Dashboard;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Übersicht im Backend: Kennzahlen, offene Aufgaben, Schnellzugriffe und die
|
||||
* letzten Änderungen – statt einer leeren Startseite.
|
||||
*/
|
||||
class AdminDashboard extends Dashboard
|
||||
{
|
||||
protected string $view = 'filament.pages.admin-dashboard';
|
||||
|
||||
protected static ?string $title = 'Übersicht';
|
||||
|
||||
protected static ?string $navigationLabel = 'Übersicht';
|
||||
|
||||
/** Lesbare Bezeichnungen für Einträge im Protokoll */
|
||||
private const ACTIONS = [
|
||||
'appearance.published' => 'Erscheinungsbild veröffentlicht',
|
||||
'demo.installed' => 'Demo-Inhalte angelegt',
|
||||
'demo.removed' => 'Demo-Inhalte entfernt',
|
||||
'downloads.uploaded' => 'Download hochgeladen',
|
||||
'downloads.version_added' => 'Neue Download-Version',
|
||||
'downloads.deleted' => 'Download gelöscht',
|
||||
'forms.fields_updated' => 'Formular geändert',
|
||||
'forms.exported' => 'Formular-Ergebnisse exportiert',
|
||||
'identity.provider_created' => 'Anmeldeverfahren angelegt',
|
||||
'identity.provider_updated' => 'Anmeldeverfahren geändert',
|
||||
'identity.user_created' => 'Person bei Anmeldung angelegt',
|
||||
'identity.user_deactivated' => 'Person deaktiviert',
|
||||
'license.saved' => 'Lizenz gespeichert',
|
||||
'mail.settings_updated' => 'E-Mail-Versand geändert',
|
||||
'media.replaced' => 'Bild ersetzt',
|
||||
'media.deleted' => 'Bild gelöscht',
|
||||
'media.bulk_deleted' => 'Bilder aufgeräumt',
|
||||
'navigation.menu_saved' => 'Menü gespeichert',
|
||||
'news.published' => 'Beitrag veröffentlicht',
|
||||
'news.submitted' => 'Beitrag zur Freigabe eingereicht',
|
||||
'news.returned' => 'Beitrag zurückgegeben',
|
||||
'news.deleted' => 'Beitrag gelöscht',
|
||||
'news.comment.deleted' => 'Kommentar moderiert',
|
||||
'page.created' => 'Seite angelegt',
|
||||
'page.published' => 'Seite veröffentlicht',
|
||||
'page.scheduled' => 'Seite geplant',
|
||||
'page.unpublished' => 'Seite offline genommen',
|
||||
'page.deleted' => 'Seite gelöscht',
|
||||
'page.review_requested' => 'Freigabe einer Seite angefordert',
|
||||
'plugin.activated' => 'Plugin aktiviert',
|
||||
'plugin.deactivated' => 'Plugin deaktiviert',
|
||||
'plugin.deleted' => 'Plugin gelöscht',
|
||||
'plugin.installed' => 'Plugin installiert',
|
||||
'plugin.access' => 'Zugang zu einem Modul geändert',
|
||||
'qm.entry_created' => 'QM-Dokument angelegt',
|
||||
'qm.entry_updated' => 'QM-Dokument geändert',
|
||||
'qm.entry_deleted' => 'QM-Dokument gelöscht',
|
||||
'role.created' => 'Rolle angelegt',
|
||||
'role.updated' => 'Rolle geändert',
|
||||
'speiseplan.uploaded' => 'Speiseplan hochgeladen',
|
||||
'update.installed' => 'Aktualisierung installiert',
|
||||
'update.failed' => 'Aktualisierung fehlgeschlagen',
|
||||
'wordpress.imported' => 'WordPress-Import',
|
||||
];
|
||||
|
||||
/** Anmeldungen und ähnliche Routine gehören nicht in die Übersicht */
|
||||
private const HIDDEN = ['identity.login', 'identity.roles_synced', 'feedback.sent'];
|
||||
|
||||
public function getColumns(): int|array
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
protected function getViewData(): array
|
||||
{
|
||||
$user = auth()->user();
|
||||
$plugins = app(PluginManager::class);
|
||||
$all = $plugins->all();
|
||||
$version = app(InstalledVersion::class);
|
||||
|
||||
return [
|
||||
'user' => $user,
|
||||
'stats' => array_values(array_filter([
|
||||
['label' => 'Aktive Personen', 'value' => User::query()->active()->count(), 'hint' => User::query()->active()->where('created_at', '>=', now()->subDays(30))->count().' neu in 30 Tagen', 'icon' => 'heroicon-o-users', 'url' => $user->can('users.manage') ? '/admin/benutzer' : null],
|
||||
$plugins->isLoaded('news') ? ['label' => 'Neuigkeiten', 'value' => $this->count('news_posts', fn ($q) => $q->whereNotNull('published_at')->where('published_at', '>=', now()->subDays(30))), 'hint' => 'veröffentlicht in 30 Tagen', 'icon' => 'heroicon-o-newspaper', 'url' => '/admin/neuigkeiten'] : null,
|
||||
['label' => 'Plugins', 'value' => count(array_filter(array_keys($all), fn ($slug) => $plugins->isEnabled($slug))).' / '.count($all), 'hint' => 'aktiv', 'icon' => 'heroicon-o-puzzle-piece', 'url' => $user->can('plugins.manage') ? '/admin/plugins' : null],
|
||||
['label' => 'Version', 'value' => $version->release(), 'hint' => $version->short() ? 'Stand '.$version->short() : 'Aktualisierung', 'icon' => 'heroicon-o-arrow-path', 'url' => $user->can('updates.manage') ? '/admin/aktualisierung' : null],
|
||||
])),
|
||||
'tasks' => $this->tasks($user),
|
||||
'shortcuts' => array_values(array_filter([
|
||||
$plugins->isLoaded('news') ? ['label' => 'Neuer Beitrag', 'icon' => 'heroicon-o-pencil-square', 'url' => '/redaktion/neuigkeiten/neu'] : null,
|
||||
$plugins->isLoaded('pages') ? ['label' => 'Seiten', 'icon' => 'heroicon-o-document-text', 'url' => '/admin/seiten'] : null,
|
||||
$user->can('users.manage') ? ['label' => 'Person anlegen', 'icon' => 'heroicon-o-user-plus', 'url' => '/admin/benutzer/create'] : null,
|
||||
$user->can('appearance.manage') ? ['label' => 'Erscheinungsbild', 'icon' => 'heroicon-o-paint-brush', 'url' => '/admin/erscheinungsbild'] : null,
|
||||
$user->can('appearance.manage') ? ['label' => 'Startseite & Menü', 'icon' => 'heroicon-o-home', 'url' => '/admin/startseite-menue'] : null,
|
||||
$user->can('roles.manage') ? ['label' => 'Rechte prüfen', 'icon' => 'heroicon-o-shield-check', 'url' => '/admin/rechte-pruefen'] : null,
|
||||
])),
|
||||
'activity' => $user->can('updates.manage') ? $this->activity() : [],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array{label: string, detail: string, url: ?string, tone: string}>
|
||||
*/
|
||||
private function tasks(User $user): array
|
||||
{
|
||||
$tasks = [];
|
||||
|
||||
if (app(PluginManager::class)->isLoaded('news') && ($user->can('news.manage') || $user->can('news.post.publish'))) {
|
||||
$pending = $this->count('news_posts', fn ($q) => $q->where('status', 'pending'));
|
||||
|
||||
if ($pending > 0) {
|
||||
$tasks[] = ['label' => $pending === 1 ? '1 Beitrag wartet auf Freigabe' : "{$pending} Beiträge warten auf Freigabe", 'detail' => 'In der Redaktion prüfen und veröffentlichen', 'url' => '/redaktion', 'tone' => 'warning'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($user->can('updates.manage')) {
|
||||
try {
|
||||
$problems = Cache::remember('admin.health-problems', 300, fn () => collect(app(SiteHealth::class)->all())->flatten(1)
|
||||
->filter(fn ($check) => in_array($check['status'], [SiteHealth::WARNING, SiteHealth::ERROR], true))
|
||||
->map(fn ($check) => ['label' => $check['label'], 'status' => $check['status']])->values()->all());
|
||||
} catch (Throwable) {
|
||||
$problems = [];
|
||||
}
|
||||
|
||||
foreach (array_slice($problems, 0, 4) as $problem) {
|
||||
$tasks[] = ['label' => $problem['label'], 'detail' => $problem['status'] === SiteHealth::ERROR ? 'Fehler im Systemzustand' : 'Hinweis im Systemzustand', 'url' => '/admin/systemzustand', 'tone' => $problem['status'] === SiteHealth::ERROR ? 'danger' : 'warning'];
|
||||
}
|
||||
}
|
||||
|
||||
return $tasks;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array{label: string, who: ?string, when: string, ago: string}>
|
||||
*/
|
||||
private function activity(): array
|
||||
{
|
||||
return AuditLog::query()->with('user')->whereNotIn('action', self::HIDDEN)->latest('id')->limit(10)->get()
|
||||
->map(fn (AuditLog $log) => [
|
||||
'label' => self::ACTIONS[$log->action] ?? Str::of($log->action)->replace(['.', '_'], ' ')->ucfirst()->toString(),
|
||||
'detail' => $this->detail((array) $log->data),
|
||||
'who' => $log->user?->name,
|
||||
'when' => $log->created_at?->format('d.m.Y H:i') ?? '',
|
||||
'ago' => $log->created_at?->diffForHumans() ?? '',
|
||||
])->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $data
|
||||
*/
|
||||
private function detail(array $data): ?string
|
||||
{
|
||||
if (is_string($data['plugin'] ?? null) && ($plugin = app(PluginManager::class)->find($data['plugin']))) {
|
||||
return $plugin->name;
|
||||
}
|
||||
|
||||
foreach (['title', 'plugin', 'name', 'sha', 'channel'] as $key) {
|
||||
if (is_scalar($data[$key] ?? null) && (string) $data[$key] !== '') {
|
||||
return Str::limit((string) $data[$key], 60);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private function count(string $table, callable $scope): int
|
||||
{
|
||||
try {
|
||||
return $scope(DB::table($table))->count();
|
||||
} catch (Throwable) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,243 +2,12 @@
|
|||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Support\Audit;
|
||||
use App\Support\Branding;
|
||||
use App\Support\Theme\Contrast;
|
||||
use App\Support\Theme\Fonts;
|
||||
use App\Support\Theme\Icons;
|
||||
use App\Support\Theme\Theme;
|
||||
use App\Support\Theme\ThemeCompiler;
|
||||
use App\Support\Theme\ThemeTransfer;
|
||||
use BackedEnum;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\ActionGroup;
|
||||
use Filament\Forms\Components\ColorPicker;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Radio;
|
||||
use Filament\Forms\Components\Repeater;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Components\Tabs;
|
||||
use Filament\Schemas\Components\Tabs\Tab;
|
||||
use Filament\Schemas\Components\Text;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\HtmlString;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
use Throwable;
|
||||
use UnitEnum;
|
||||
|
||||
/**
|
||||
* „Erscheinungsbild“ (docs/PLAN.md, Abschnitt 12): Entwurf bearbeiten, in der
|
||||
* Vorschau ansehen, dann für alle veröffentlichen.
|
||||
* Platzhalter: „Erscheinungsbild“ lebt jetzt als Cluster mit Unterseiten in
|
||||
* App\Filament\Pages\Appearance\*. Der Self-Updater löscht nie Dateien – diese
|
||||
* Datei überschreibt die frühere Seite, und als abstrakte Klasse übergeht sie
|
||||
* die Seitensuche von Filament.
|
||||
*/
|
||||
class Appearance extends Page
|
||||
{
|
||||
protected string $view = 'filament.pages.appearance';
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedPaintBrush;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Portal';
|
||||
|
||||
protected static ?string $navigationLabel = 'Erscheinungsbild';
|
||||
|
||||
protected static ?string $title = 'Erscheinungsbild';
|
||||
|
||||
protected static ?string $slug = 'erscheinungsbild';
|
||||
|
||||
/** @var array<string, mixed>|null */
|
||||
public ?array $data = [];
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return auth()->user()?->can('appearance.manage') ?? false;
|
||||
}
|
||||
|
||||
public function mount(Theme $theme): void
|
||||
{
|
||||
$this->form->fill($theme->working());
|
||||
}
|
||||
|
||||
public function hasDraft(): bool
|
||||
{
|
||||
return app(Theme::class)->hasDraft();
|
||||
}
|
||||
|
||||
public function form(Schema $schema): Schema
|
||||
{
|
||||
$image = fn (string $name, string $label, string $help) => FileUpload::make($name)->label($label)->helperText($help)
|
||||
->disk('uploads')->directory('theme')->visibility('public')->maxSize(4096);
|
||||
|
||||
return $schema->statePath('data')->components([
|
||||
Tabs::make()->persistTabInQueryString()->tabs([
|
||||
Tab::make('Identität')->icon(Heroicon::OutlinedIdentification)->columns(2)->schema([
|
||||
TextInput::make('portal_name')->label('Name des Portals')->required()->maxLength(60)
|
||||
->helperText('Erscheint im Kopfbereich, im Browser-Tab, in E-Mails und auf dem Homescreen.')->columnSpanFull(),
|
||||
$image('logo_light', 'Logo für helle Flächen', 'SVG, PNG oder WebP mit transparentem Hintergrund.')
|
||||
->acceptedFileTypes(['image/svg+xml', 'image/png', 'image/webp']),
|
||||
$image('logo_dark', 'Logo für dunkle Flächen', 'Für den Dunkelmodus und farbige Kopfleisten, z. B. in Weiß. Leer = wie hell.')
|
||||
->acceptedFileTypes(['image/svg+xml', 'image/png', 'image/webp']),
|
||||
$image('logo_mark', 'Signet (quadratisch)', 'Kurzform für Smartphones, z. B. nur das Bildzeichen.')
|
||||
->acceptedFileTypes(['image/svg+xml', 'image/png', 'image/webp']),
|
||||
$image('app_icon', 'App-Symbol', 'Quadratisch, mindestens 512 × 512 Pixel (PNG oder JPG). Daraus entstehen Favicon und Homescreen-Symbole.')
|
||||
->image()->acceptedFileTypes(['image/png', 'image/jpeg', 'image/webp']),
|
||||
]),
|
||||
|
||||
Tab::make('Farben')->icon(Heroicon::OutlinedSwatch)->columns(2)->schema([
|
||||
ColorPicker::make('primary_color')->label('Markenfarbe')->required()->regex('/^#[0-9a-fA-F]{6}$/')->live(onBlur: true)
|
||||
->helperText('Wird exakt übernommen: Schaltflächen, aktive Navigation, Begrüßungskarte. Die Abstufungen werden berechnet.'),
|
||||
ColorPicker::make('secondary_color')->label('Zweite Akzentfarbe (optional)')->regex('/^#[0-9a-fA-F]{6}$/')->live(onBlur: true)
|
||||
->helperText('Für Kategorien und Datumsangaben. Leer = Markenfarbe.'),
|
||||
Radio::make('header_style')->label('Kopfleiste')->options(Theme::HEADER_STYLES)->inline()->required()->columnSpanFull(),
|
||||
Section::make('Kontrastprüfung (WCAG AA)')->columnSpanFull()->compact()->schema([
|
||||
Text::make(fn (Get $get) => $this->contrastReport((string) $get('primary_color'), $get('secondary_color'))),
|
||||
]),
|
||||
]),
|
||||
|
||||
Tab::make('Schrift & Form')->icon(Heroicon::OutlinedLanguage)->columns(2)->schema([
|
||||
Select::make('font_body')->label('Schrift')->options(fn (Get $get) => Fonts::options((bool) $get('custom_font')))->required()->native(false),
|
||||
Select::make('font_heading')->label('Schrift für Überschriften')->options(fn (Get $get) => ['same' => 'Wie die Schrift'] + Fonts::options((bool) $get('custom_font')))->required()->native(false),
|
||||
FileUpload::make('custom_font')->label('Eigene Schrift (WOFF2)')
|
||||
->helperText('Z. B. die Hausschrift aus dem Corporate Design. Wird lokal ausgeliefert – keine Verbindung zu Google oder anderen Diensten. Bitte die Lizenz für die Nutzung im Web beachten.')
|
||||
->disk('uploads')->directory('theme/fonts')->visibility('public')->maxSize(2048)
|
||||
->acceptedFileTypes(['font/woff2', 'application/font-woff2', 'application/octet-stream'])
|
||||
->rule('extensions:woff2')->live()->columnSpanFull(),
|
||||
Radio::make('radius')->label('Ecken')->options(collect(Theme::RADII)->map(fn ($r) => $r[0])->all())->inline()->required(),
|
||||
Radio::make('density')->label('Abstände')->options(collect(Theme::DENSITIES)->map(fn ($d) => $d[0])->all())->inline()->required(),
|
||||
Radio::make('dark_mode')->label('Dunkelmodus')->options(Theme::DARK_MODES)->required()->columnSpanFull(),
|
||||
]),
|
||||
|
||||
Tab::make('Anmeldeseite')->icon(Heroicon::OutlinedArrowRightOnRectangle)->columns(2)->schema([
|
||||
Radio::make('login_layout')->label('Aufteilung')->options(Theme::LOGIN_LAYOUTS)->required()->columnSpanFull(),
|
||||
TextInput::make('login_title')->label('Begrüßung')->maxLength(200)->columnSpanFull(),
|
||||
Textarea::make('login_text')->label('Text darunter')->rows(2)->maxLength(500)->columnSpanFull(),
|
||||
$image('login_image', 'Hintergrundbild', 'Querformat, mindestens 1600 Pixel breit. Leer = Fläche in der Markenfarbe.')
|
||||
->image()->acceptedFileTypes(['image/jpeg', 'image/png', 'image/webp'])->maxSize(8192)->columnSpanFull(),
|
||||
]),
|
||||
|
||||
Tab::make('Fußzeile & E-Mails')->icon(Heroicon::OutlinedEnvelope)->schema([
|
||||
TextInput::make('footer_text')->label('Text in der Fußzeile')->placeholder('© 2027 Musterstift gGmbH')->maxLength(200),
|
||||
Repeater::make('footer_links')->label('Links in der Fußzeile')->columns(2)->defaultItems(0)->reorderable()
|
||||
->addActionLabel('Link hinzufügen')->maxItems(8)
|
||||
->schema([
|
||||
TextInput::make('label')->label('Bezeichnung')->required()->maxLength(60)->placeholder('Impressum'),
|
||||
TextInput::make('url')->label('Adresse')->required()->maxLength(500)->placeholder('https://… oder /seiten/impressum'),
|
||||
]),
|
||||
Textarea::make('email_footer')->label('Fußzeile in E-Mails')->rows(3)->maxLength(500)
|
||||
->helperText('Z. B. Anschrift und Hinweis. Logo und Markenfarbe übernehmen die E-Mails automatisch.'),
|
||||
]),
|
||||
|
||||
Tab::make('Erweitert')->icon(Heroicon::OutlinedCodeBracket)->schema([
|
||||
Textarea::make('custom_css')->label('Eigenes CSS')->rows(12)->maxLength(50000)
|
||||
->extraInputAttributes(['class' => 'font-mono text-xs', 'spellcheck' => 'false'])
|
||||
->helperText('Für Fortgeschrittene. Wird nach dem Portal-CSS geladen und bei Aktualisierungen unverändert übernommen. Klassennamen können sich mit neuen Versionen ändern – bitte nach jedem Update prüfen. Verfügbare Variablen: --brand, --brand-50 … --brand-950, --radius, --font-body, --font-heading.'),
|
||||
]),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
private function contrastReport(string $primary, ?string $secondary): HtmlString
|
||||
{
|
||||
if (! preg_match('/^#[0-9a-fA-F]{6}$/', $primary)) {
|
||||
return new HtmlString('');
|
||||
}
|
||||
|
||||
$colors = ['ok' => '#15803d', 'info' => '#0369a1', 'warning' => '#b45309'];
|
||||
$icons = ['ok' => '✓', 'info' => 'i', 'warning' => '!'];
|
||||
|
||||
return new HtmlString(collect(Contrast::report(strtoupper($primary), $secondary && preg_match('/^#[0-9a-fA-F]{6}$/', $secondary) ? strtoupper($secondary) : null))
|
||||
->map(fn ($note) => '<p style="display:flex;gap:.5rem;margin:.25rem 0"><span style="font-weight:700;color:'.$colors[$note['level']].';width:1rem;text-align:center">'.$icons[$note['level']].'</span><span>'.e($note['text']).'</span></p>')
|
||||
->implode(''));
|
||||
}
|
||||
|
||||
/**
|
||||
* Entwurf speichern und die Vorschau aktualisieren.
|
||||
*/
|
||||
public function save(Theme $theme, Branding $branding): void
|
||||
{
|
||||
$theme->saveDraft($this->form->getState());
|
||||
session()->put(Branding::PREVIEW_SESSION_KEY, true);
|
||||
$branding->refresh();
|
||||
|
||||
$this->dispatch('theme-preview-reload');
|
||||
Notification::make()->success()->title('Entwurf gespeichert')->body('Die Vorschau zeigt jetzt den Entwurf. Für alle sichtbar wird er erst mit „Veröffentlichen“.')->send();
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('publish')->label('Veröffentlichen')->icon(Heroicon::OutlinedRocketLaunch)
|
||||
->requiresConfirmation()
|
||||
->modalHeading('Erscheinungsbild veröffentlichen?')
|
||||
->modalDescription('Der gespeicherte Entwurf wird für alle sichtbar. Ungespeicherte Änderungen im Formular werden vorher als Entwurf gespeichert.')
|
||||
->action(function (Theme $theme, ThemeCompiler $compiler, Icons $icons, Branding $branding) {
|
||||
$theme->saveDraft($this->form->getState());
|
||||
$theme->publish($compiler, $icons);
|
||||
session()->forget(Branding::PREVIEW_SESSION_KEY);
|
||||
$branding->refresh();
|
||||
Audit::log('appearance.published');
|
||||
|
||||
$this->form->fill($theme->working());
|
||||
$this->dispatch('theme-preview-reload');
|
||||
Notification::make()->success()->title('Erscheinungsbild veröffentlicht')->send();
|
||||
}),
|
||||
Action::make('discard')->label('Entwurf verwerfen')->icon(Heroicon::OutlinedArrowUturnLeft)->color('gray')
|
||||
->visible(fn () => $this->hasDraft())
|
||||
->requiresConfirmation()
|
||||
->action(function (Theme $theme, Branding $branding) {
|
||||
$theme->discardDraft();
|
||||
session()->forget(Branding::PREVIEW_SESSION_KEY);
|
||||
$branding->refresh();
|
||||
$this->form->fill($theme->working());
|
||||
$this->dispatch('theme-preview-reload');
|
||||
}),
|
||||
ActionGroup::make([
|
||||
Action::make('export')->label('Exportieren')->icon(Heroicon::OutlinedArrowDownTray)
|
||||
->action(fn (ThemeTransfer $transfer): StreamedResponse => response()->streamDownload(
|
||||
fn () => print (json_encode($transfer->export(app(Theme::class)->working()), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)),
|
||||
'erscheinungsbild-'.now()->format('Y-m-d').'.json',
|
||||
['Content-Type' => 'application/json'],
|
||||
)),
|
||||
Action::make('import')->label('Importieren')->icon(Heroicon::OutlinedArrowUpTray)
|
||||
->modalDescription('Erscheinungsbild aus einer exportierten Datei übernehmen – als Entwurf, damit Sie es erst ansehen können.')
|
||||
->schema([
|
||||
FileUpload::make('file')->label('Datei (.json)')->disk('local')->directory('theme-import')
|
||||
->acceptedFileTypes(['application/json', 'text/plain'])->maxSize(20 * 1024)->required(),
|
||||
])
|
||||
->action(function (array $data, ThemeTransfer $transfer, Theme $theme) {
|
||||
try {
|
||||
$values = $transfer->import((string) Storage::disk('local')->get($data['file']));
|
||||
} catch (Throwable $e) {
|
||||
Notification::make()->danger()->title('Import nicht möglich')->body($e->getMessage())->send();
|
||||
|
||||
return;
|
||||
} finally {
|
||||
Storage::disk('local')->delete($data['file']);
|
||||
}
|
||||
|
||||
$theme->saveDraft($values);
|
||||
session()->put(Branding::PREVIEW_SESSION_KEY, true);
|
||||
$this->form->fill($theme->working());
|
||||
$this->dispatch('theme-preview-reload');
|
||||
Notification::make()->success()->title('Als Entwurf importiert')->send();
|
||||
}),
|
||||
Action::make('reset')->label('Auf Standard zurücksetzen')->icon(Heroicon::OutlinedArrowPath)->color('danger')
|
||||
->requiresConfirmation()
|
||||
->modalDescription('Setzt Farben, Schriften, Logos und Texte auf die Standardwerte zurück – als Entwurf. Der Portalname bleibt.')
|
||||
->action(function (Theme $theme) {
|
||||
$theme->resetToDefaults();
|
||||
session()->put(Branding::PREVIEW_SESSION_KEY, true);
|
||||
$this->form->fill($theme->working());
|
||||
$this->dispatch('theme-preview-reload');
|
||||
}),
|
||||
])->label('Mehr')->icon(Heroicon::OutlinedEllipsisVertical)->button()->color('gray'),
|
||||
];
|
||||
}
|
||||
}
|
||||
abstract class Appearance extends Page {}
|
||||
|
|
|
|||
31
app/Filament/Pages/Appearance/AppearanceAdvanced.php
Normal file
31
app/Filament/Pages/Appearance/AppearanceAdvanced.php
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Pages\Appearance;
|
||||
|
||||
use BackedEnum;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
|
||||
class AppearanceAdvanced extends AppearancePage
|
||||
{
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedCodeBracket;
|
||||
|
||||
protected static int $formColumns = 1;
|
||||
|
||||
protected static ?int $navigationSort = 6;
|
||||
|
||||
protected static ?string $navigationLabel = 'Erweitert';
|
||||
|
||||
protected static ?string $title = 'Erweitert';
|
||||
|
||||
protected static ?string $slug = 'erweitert';
|
||||
|
||||
protected function fields(): array
|
||||
{
|
||||
return [
|
||||
Textarea::make('custom_css')->label('Eigenes CSS')->rows(12)->maxLength(50000)
|
||||
->extraInputAttributes(['class' => 'font-mono text-xs', 'spellcheck' => 'false'])
|
||||
->helperText('Für Fortgeschrittene. Wird nach dem Portal-CSS geladen und bei Aktualisierungen unverändert übernommen. Klassennamen können sich mit neuen Versionen ändern – bitte nach jedem Update prüfen. Verfügbare Variablen: --brand, --brand-50 … --brand-950, --radius, --font-body, --font-heading.'),
|
||||
];
|
||||
}
|
||||
}
|
||||
39
app/Filament/Pages/Appearance/AppearanceColors.php
Normal file
39
app/Filament/Pages/Appearance/AppearanceColors.php
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Pages\Appearance;
|
||||
|
||||
use App\Support\Theme\Theme;
|
||||
use BackedEnum;
|
||||
use Filament\Forms\Components\ColorPicker;
|
||||
use Filament\Forms\Components\Radio;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Components\Text;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
|
||||
class AppearanceColors extends AppearancePage
|
||||
{
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedSwatch;
|
||||
|
||||
protected static ?int $navigationSort = 2;
|
||||
|
||||
protected static ?string $navigationLabel = 'Farben';
|
||||
|
||||
protected static ?string $title = 'Farben';
|
||||
|
||||
protected static ?string $slug = 'farben';
|
||||
|
||||
protected function fields(): array
|
||||
{
|
||||
return [
|
||||
ColorPicker::make('primary_color')->label('Markenfarbe')->required()->regex('/^#[0-9a-fA-F]{6}$/')->live(onBlur: true)
|
||||
->helperText('Wird exakt übernommen: Schaltflächen, aktive Navigation, Begrüßungskarte. Die Abstufungen werden berechnet.'),
|
||||
ColorPicker::make('secondary_color')->label('Zweite Akzentfarbe (optional)')->regex('/^#[0-9a-fA-F]{6}$/')->live(onBlur: true)
|
||||
->helperText('Für Kategorien und Datumsangaben. Leer = Markenfarbe.'),
|
||||
Radio::make('header_style')->label('Kopfleiste')->options(Theme::HEADER_STYLES)->inline()->required()->columnSpanFull(),
|
||||
Section::make('Kontrastprüfung (WCAG AA)')->columnSpanFull()->compact()->schema([
|
||||
Text::make(fn (Get $get) => $this->contrastReport((string) $get('primary_color'), $get('secondary_color'))),
|
||||
]),
|
||||
];
|
||||
}
|
||||
}
|
||||
39
app/Filament/Pages/Appearance/AppearanceFooter.php
Normal file
39
app/Filament/Pages/Appearance/AppearanceFooter.php
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Pages\Appearance;
|
||||
|
||||
use BackedEnum;
|
||||
use Filament\Forms\Components\Repeater;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
|
||||
class AppearanceFooter extends AppearancePage
|
||||
{
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedEnvelope;
|
||||
|
||||
protected static int $formColumns = 1;
|
||||
|
||||
protected static ?int $navigationSort = 5;
|
||||
|
||||
protected static ?string $navigationLabel = 'Fußzeile & E-Mails';
|
||||
|
||||
protected static ?string $title = 'Fußzeile & E-Mails';
|
||||
|
||||
protected static ?string $slug = 'fusszeile';
|
||||
|
||||
protected function fields(): array
|
||||
{
|
||||
return [
|
||||
TextInput::make('footer_text')->label('Text in der Fußzeile')->placeholder('© 2027 Musterstift gGmbH')->maxLength(200),
|
||||
Repeater::make('footer_links')->label('Links in der Fußzeile')->columns(2)->defaultItems(0)->reorderable()
|
||||
->addActionLabel('Link hinzufügen')->maxItems(8)
|
||||
->schema([
|
||||
TextInput::make('label')->label('Bezeichnung')->required()->maxLength(60)->placeholder('Impressum'),
|
||||
TextInput::make('url')->label('Adresse')->required()->maxLength(500)->placeholder('https://… oder /seiten/impressum'),
|
||||
]),
|
||||
Textarea::make('email_footer')->label('Fußzeile in E-Mails')->rows(3)->maxLength(500)
|
||||
->helperText('Z. B. Anschrift und Hinweis. Logo und Markenfarbe übernehmen die E-Mails automatisch.'),
|
||||
];
|
||||
}
|
||||
}
|
||||
36
app/Filament/Pages/Appearance/AppearanceIdentity.php
Normal file
36
app/Filament/Pages/Appearance/AppearanceIdentity.php
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Pages\Appearance;
|
||||
|
||||
use BackedEnum;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
|
||||
class AppearanceIdentity extends AppearancePage
|
||||
{
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedIdentification;
|
||||
|
||||
protected static ?int $navigationSort = 1;
|
||||
|
||||
protected static ?string $navigationLabel = 'Identität & Logos';
|
||||
|
||||
protected static ?string $title = 'Identität & Logos';
|
||||
|
||||
protected static ?string $slug = 'identitaet';
|
||||
|
||||
protected function fields(): array
|
||||
{
|
||||
return [
|
||||
TextInput::make('portal_name')->label('Name des Portals')->required()->maxLength(60)
|
||||
->helperText('Erscheint im Kopfbereich, im Browser-Tab, in E-Mails und auf dem Homescreen.')->columnSpanFull(),
|
||||
static::image('logo_light', 'Logo für helle Flächen', 'SVG, PNG oder WebP mit transparentem Hintergrund.')
|
||||
->acceptedFileTypes(['image/svg+xml', 'image/png', 'image/webp']),
|
||||
static::image('logo_dark', 'Logo für dunkle Flächen', 'Für den Dunkelmodus und farbige Kopfleisten, z. B. in Weiß. Leer = wie hell.')
|
||||
->acceptedFileTypes(['image/svg+xml', 'image/png', 'image/webp']),
|
||||
static::image('logo_mark', 'Signet (quadratisch)', 'Kurzform für Smartphones, z. B. nur das Bildzeichen.')
|
||||
->acceptedFileTypes(['image/svg+xml', 'image/png', 'image/webp']),
|
||||
static::image('app_icon', 'App-Symbol', 'Quadratisch, mindestens 512 × 512 Pixel (PNG oder JPG). Daraus entstehen Favicon und Homescreen-Symbole.')
|
||||
->image()->acceptedFileTypes(['image/png', 'image/jpeg', 'image/webp']),
|
||||
];
|
||||
}
|
||||
}
|
||||
34
app/Filament/Pages/Appearance/AppearanceLogin.php
Normal file
34
app/Filament/Pages/Appearance/AppearanceLogin.php
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Pages\Appearance;
|
||||
|
||||
use App\Support\Theme\Theme;
|
||||
use BackedEnum;
|
||||
use Filament\Forms\Components\Radio;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
|
||||
class AppearanceLogin extends AppearancePage
|
||||
{
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedArrowRightOnRectangle;
|
||||
|
||||
protected static ?int $navigationSort = 4;
|
||||
|
||||
protected static ?string $navigationLabel = 'Anmeldeseite';
|
||||
|
||||
protected static ?string $title = 'Anmeldeseite';
|
||||
|
||||
protected static ?string $slug = 'anmeldeseite';
|
||||
|
||||
protected function fields(): array
|
||||
{
|
||||
return [
|
||||
Radio::make('login_layout')->label('Aufteilung')->options(Theme::LOGIN_LAYOUTS)->required()->columnSpanFull(),
|
||||
TextInput::make('login_title')->label('Begrüßung')->maxLength(200)->columnSpanFull(),
|
||||
Textarea::make('login_text')->label('Text darunter')->rows(2)->maxLength(500)->columnSpanFull(),
|
||||
static::image('login_image', 'Hintergrundbild', 'Querformat, mindestens 1600 Pixel breit. Leer = Fläche in der Markenfarbe.')
|
||||
->image()->acceptedFileTypes(['image/jpeg', 'image/png', 'image/webp'])->maxSize(8192)->columnSpanFull(),
|
||||
];
|
||||
}
|
||||
}
|
||||
174
app/Filament/Pages/Appearance/AppearancePage.php
Normal file
174
app/Filament/Pages/Appearance/AppearancePage.php
Normal file
|
|
@ -0,0 +1,174 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Pages\Appearance;
|
||||
|
||||
use App\Filament\Clusters\AppearanceCluster;
|
||||
use App\Support\Audit;
|
||||
use App\Support\Branding;
|
||||
use App\Support\Theme\Contrast;
|
||||
use App\Support\Theme\Icons;
|
||||
use App\Support\Theme\Theme;
|
||||
use App\Support\Theme\ThemeCompiler;
|
||||
use App\Support\Theme\ThemeTransfer;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\ActionGroup;
|
||||
use Filament\Forms\Components\Field;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Schemas\Components\Component;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\HtmlString;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* „Erscheinungsbild“ (docs/PLAN.md, Abschnitt 12): Entwurf bearbeiten, in der
|
||||
* Vorschau ansehen, dann für alle veröffentlichen. Jede Unterseite zeigt nur
|
||||
* ihre Felder; gespeichert wird immer in denselben Entwurf (saveDraft führt zusammen).
|
||||
*/
|
||||
abstract class AppearancePage extends Page
|
||||
{
|
||||
protected static ?string $cluster = AppearanceCluster::class;
|
||||
|
||||
/** Spalten des Formulars (einspaltig für längere Texte) */
|
||||
protected static int $formColumns = 2;
|
||||
|
||||
/**
|
||||
* Felder dieser Unterseite.
|
||||
*
|
||||
* @return array<int, Component|Field>
|
||||
*/
|
||||
abstract protected function fields(): array;
|
||||
|
||||
protected static function image(string $name, string $label, string $help): FileUpload
|
||||
{
|
||||
return FileUpload::make($name)->label($label)->helperText($help)
|
||||
->disk('uploads')->directory('theme')->visibility('public')->maxSize(4096);
|
||||
}
|
||||
|
||||
protected string $view = 'filament.pages.appearance';
|
||||
|
||||
/** @var array<string, mixed>|null */
|
||||
public ?array $data = [];
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return auth()->user()?->can('appearance.manage') ?? false;
|
||||
}
|
||||
|
||||
public function mount(Theme $theme): void
|
||||
{
|
||||
$this->form->fill($theme->working());
|
||||
}
|
||||
|
||||
public function hasDraft(): bool
|
||||
{
|
||||
return app(Theme::class)->hasDraft();
|
||||
}
|
||||
|
||||
public function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema->statePath('data')->columns(static::$formColumns)->components($this->fields());
|
||||
}
|
||||
|
||||
protected function contrastReport(string $primary, ?string $secondary): HtmlString
|
||||
{
|
||||
if (! preg_match('/^#[0-9a-fA-F]{6}$/', $primary)) {
|
||||
return new HtmlString('');
|
||||
}
|
||||
|
||||
$colors = ['ok' => '#15803d', 'info' => '#0369a1', 'warning' => '#b45309'];
|
||||
$icons = ['ok' => '✓', 'info' => 'i', 'warning' => '!'];
|
||||
|
||||
return new HtmlString(collect(Contrast::report(strtoupper($primary), $secondary && preg_match('/^#[0-9a-fA-F]{6}$/', $secondary) ? strtoupper($secondary) : null))
|
||||
->map(fn ($note) => '<p style="display:flex;gap:.5rem;margin:.25rem 0"><span style="font-weight:700;color:'.$colors[$note['level']].';width:1rem;text-align:center">'.$icons[$note['level']].'</span><span>'.e($note['text']).'</span></p>')
|
||||
->implode(''));
|
||||
}
|
||||
|
||||
/**
|
||||
* Entwurf speichern und die Vorschau aktualisieren.
|
||||
*/
|
||||
public function save(Theme $theme, Branding $branding): void
|
||||
{
|
||||
$theme->saveDraft($this->form->getState());
|
||||
session()->put(Branding::PREVIEW_SESSION_KEY, true);
|
||||
$branding->refresh();
|
||||
|
||||
$this->dispatch('theme-preview-reload');
|
||||
Notification::make()->success()->title('Entwurf gespeichert')->body('Die Vorschau zeigt jetzt den Entwurf. Für alle sichtbar wird er erst mit „Veröffentlichen“.')->send();
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('publish')->label('Veröffentlichen')->icon(Heroicon::OutlinedRocketLaunch)
|
||||
->requiresConfirmation()
|
||||
->modalHeading('Erscheinungsbild veröffentlichen?')
|
||||
->modalDescription('Der gespeicherte Entwurf wird für alle sichtbar. Ungespeicherte Änderungen im Formular werden vorher als Entwurf gespeichert.')
|
||||
->action(function (Theme $theme, ThemeCompiler $compiler, Icons $icons, Branding $branding) {
|
||||
$theme->saveDraft($this->form->getState());
|
||||
$theme->publish($compiler, $icons);
|
||||
session()->forget(Branding::PREVIEW_SESSION_KEY);
|
||||
$branding->refresh();
|
||||
Audit::log('appearance.published');
|
||||
|
||||
$this->form->fill($theme->working());
|
||||
$this->dispatch('theme-preview-reload');
|
||||
Notification::make()->success()->title('Erscheinungsbild veröffentlicht')->send();
|
||||
}),
|
||||
Action::make('discard')->label('Entwurf verwerfen')->icon(Heroicon::OutlinedArrowUturnLeft)->color('gray')
|
||||
->visible(fn () => $this->hasDraft())
|
||||
->requiresConfirmation()
|
||||
->action(function (Theme $theme, Branding $branding) {
|
||||
$theme->discardDraft();
|
||||
session()->forget(Branding::PREVIEW_SESSION_KEY);
|
||||
$branding->refresh();
|
||||
$this->form->fill($theme->working());
|
||||
$this->dispatch('theme-preview-reload');
|
||||
}),
|
||||
ActionGroup::make([
|
||||
Action::make('export')->label('Exportieren')->icon(Heroicon::OutlinedArrowDownTray)
|
||||
->action(fn (ThemeTransfer $transfer): StreamedResponse => response()->streamDownload(
|
||||
fn () => print (json_encode($transfer->export(app(Theme::class)->working()), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)),
|
||||
'erscheinungsbild-'.now()->format('Y-m-d').'.json',
|
||||
['Content-Type' => 'application/json'],
|
||||
)),
|
||||
Action::make('import')->label('Importieren')->icon(Heroicon::OutlinedArrowUpTray)
|
||||
->modalDescription('Erscheinungsbild aus einer exportierten Datei übernehmen – als Entwurf, damit Sie es erst ansehen können.')
|
||||
->schema([
|
||||
FileUpload::make('file')->label('Datei (.json)')->disk('local')->directory('theme-import')
|
||||
->acceptedFileTypes(['application/json', 'text/plain'])->maxSize(20 * 1024)->required(),
|
||||
])
|
||||
->action(function (array $data, ThemeTransfer $transfer, Theme $theme) {
|
||||
try {
|
||||
$values = $transfer->import((string) Storage::disk('local')->get($data['file']));
|
||||
} catch (Throwable $e) {
|
||||
Notification::make()->danger()->title('Import nicht möglich')->body($e->getMessage())->send();
|
||||
|
||||
return;
|
||||
} finally {
|
||||
Storage::disk('local')->delete($data['file']);
|
||||
}
|
||||
|
||||
$theme->saveDraft($values);
|
||||
session()->put(Branding::PREVIEW_SESSION_KEY, true);
|
||||
$this->form->fill($theme->working());
|
||||
$this->dispatch('theme-preview-reload');
|
||||
Notification::make()->success()->title('Als Entwurf importiert')->send();
|
||||
}),
|
||||
Action::make('reset')->label('Auf Standard zurücksetzen')->icon(Heroicon::OutlinedArrowPath)->color('danger')
|
||||
->requiresConfirmation()
|
||||
->modalDescription('Setzt Farben, Schriften, Logos und Texte auf die Standardwerte zurück – als Entwurf. Der Portalname bleibt.')
|
||||
->action(function (Theme $theme) {
|
||||
$theme->resetToDefaults();
|
||||
session()->put(Branding::PREVIEW_SESSION_KEY, true);
|
||||
$this->form->fill($theme->working());
|
||||
$this->dispatch('theme-preview-reload');
|
||||
}),
|
||||
])->label('Mehr')->icon(Heroicon::OutlinedEllipsisVertical)->button()->color('gray'),
|
||||
];
|
||||
}
|
||||
}
|
||||
41
app/Filament/Pages/Appearance/AppearanceTypography.php
Normal file
41
app/Filament/Pages/Appearance/AppearanceTypography.php
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Pages\Appearance;
|
||||
|
||||
use App\Support\Theme\Fonts;
|
||||
use App\Support\Theme\Theme;
|
||||
use BackedEnum;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Radio;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
|
||||
class AppearanceTypography extends AppearancePage
|
||||
{
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedLanguage;
|
||||
|
||||
protected static ?int $navigationSort = 3;
|
||||
|
||||
protected static ?string $navigationLabel = 'Schrift & Form';
|
||||
|
||||
protected static ?string $title = 'Schrift & Form';
|
||||
|
||||
protected static ?string $slug = 'schrift';
|
||||
|
||||
protected function fields(): array
|
||||
{
|
||||
return [
|
||||
Select::make('font_body')->label('Schrift')->options(fn (Get $get) => Fonts::options((bool) $get('custom_font')))->required()->native(false),
|
||||
Select::make('font_heading')->label('Schrift für Überschriften')->options(fn (Get $get) => ['same' => 'Wie die Schrift'] + Fonts::options((bool) $get('custom_font')))->required()->native(false),
|
||||
FileUpload::make('custom_font')->label('Eigene Schrift (WOFF2)')
|
||||
->helperText('Z. B. die Hausschrift aus dem Corporate Design. Wird lokal ausgeliefert – keine Verbindung zu Google oder anderen Diensten. Bitte die Lizenz für die Nutzung im Web beachten.')
|
||||
->disk('uploads')->directory('theme/fonts')->visibility('public')->maxSize(2048)
|
||||
->acceptedFileTypes(['font/woff2', 'application/font-woff2', 'application/octet-stream'])
|
||||
->rule('extensions:woff2')->live()->columnSpanFull(),
|
||||
Radio::make('radius')->label('Ecken')->options(collect(Theme::RADII)->map(fn ($r) => $r[0])->all())->inline()->required(),
|
||||
Radio::make('density')->label('Abstände')->options(collect(Theme::DENSITIES)->map(fn ($d) => $d[0])->all())->inline()->required(),
|
||||
Radio::make('dark_mode')->label('Dunkelmodus')->options(Theme::DARK_MODES)->required()->columnSpanFull(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Dashboard\Widgets;
|
||||
use App\Filament\Clusters\HomepageCluster;
|
||||
use App\Filament\Resources\DashboardTiles\DashboardTileResource;
|
||||
use App\Support\ContactCards;
|
||||
use App\Support\Settings;
|
||||
|
|
@ -10,7 +11,9 @@ use BackedEnum;
|
|||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\Hidden;
|
||||
use Filament\Forms\Components\Repeater;
|
||||
use Filament\Forms\Components\Repeater\TableColumn;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Pages\Page;
|
||||
|
|
@ -18,7 +21,6 @@ use Filament\Schemas\Components\Section;
|
|||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use UnitEnum;
|
||||
|
||||
/**
|
||||
* Anordnung der Startseite: Kacheln je Bereich sortieren und ausblenden –
|
||||
|
|
@ -30,9 +32,9 @@ class DashboardSettings extends Page
|
|||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedHome;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Portal';
|
||||
protected static ?string $cluster = HomepageCluster::class;
|
||||
|
||||
protected static ?int $navigationSort = 10;
|
||||
protected static ?int $navigationSort = 1;
|
||||
|
||||
protected static ?string $navigationLabel = 'Startseite';
|
||||
|
||||
|
|
@ -95,18 +97,21 @@ class DashboardSettings extends Page
|
|||
->reorderableWithDragAndDrop()
|
||||
->addable(false)
|
||||
->deletable(false)
|
||||
->itemLabel(fn (array $state) => $state['label'] ?? $state['key'])
|
||||
->columns(2)
|
||||
// Kompakt als Tabelle: eine Zeile je Kachel
|
||||
->table([
|
||||
TableColumn::make('Kachel'),
|
||||
TableColumn::make('Anzeigen')->width('7rem'),
|
||||
TableColumn::make('Platzierung')->width('16rem'),
|
||||
])
|
||||
->schema([
|
||||
Hidden::make('key'),
|
||||
Hidden::make('label'),
|
||||
Toggle::make('visible')->label('Anzeigen')->inline(false),
|
||||
TextInput::make('label')->hiddenLabel()->readOnly()->dehydrated(false)->extraInputAttributes(['tabindex' => '-1'])->extraFieldWrapperAttributes(['class' => 'ih-plain']),
|
||||
Toggle::make('visible')->hiddenLabel(),
|
||||
Select::make('area')
|
||||
->label('Platzierung')
|
||||
->hiddenLabel()
|
||||
->options(fn (Get $get) => collect(self::areasOf($get('key')))->mapWithKeys(fn ($a) => [$a => self::AREAS[$a][0]])->all())
|
||||
->selectablePlaceholder(false)
|
||||
->visible(fn (Get $get) => count(self::areasOf($get('key'))) > 1)
|
||||
->helperText('Wird nach dem Speichern in den gewählten Bereich verschoben.'),
|
||||
->visible(fn (Get $get) => count(self::areasOf($get('key'))) > 1),
|
||||
]),
|
||||
]))->values()->all(),
|
||||
Section::make('Kachel „Kolleg:innen finden“')
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Filament\Clusters\HomepageCluster;
|
||||
use App\Models\Role;
|
||||
use App\Support\Audit;
|
||||
use App\Support\Icons;
|
||||
|
|
@ -22,7 +23,6 @@ use Filament\Schemas\Schema;
|
|||
use Filament\Support\Icons\Heroicon;
|
||||
use Illuminate\Support\HtmlString;
|
||||
use Illuminate\Support\Str;
|
||||
use UnitEnum;
|
||||
|
||||
/**
|
||||
* Hauptmenü des Portals selbst gestalten: Bereiche, Seiten, Links und Gruppen,
|
||||
|
|
@ -34,9 +34,9 @@ class MenuSettings extends Page
|
|||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedBars3;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Portal';
|
||||
protected static ?string $cluster = HomepageCluster::class;
|
||||
|
||||
protected static ?int $navigationSort = 5;
|
||||
protected static ?int $navigationSort = 3;
|
||||
|
||||
protected static ?string $navigationLabel = 'Menü';
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ class Plugins extends Page
|
|||
->label('Zugang')
|
||||
->icon(Heroicon::OutlinedNoSymbol)
|
||||
->color('gray')
|
||||
->size('sm')
|
||||
->iconButton()->tooltip('Zugang: Rollen ausschließen')
|
||||
->modalHeading(fn (array $arguments) => 'Zugang: '.(app(PluginManager::class)->find($arguments['slug'] ?? '')?->name ?? ''))
|
||||
->modalDescription('Personen mit einer dieser Rollen sehen den Bereich nicht: kein Menüpunkt, keine Seiten, keine Kacheln auf der Startseite, keine Suchtreffer. Wer Plugins verwalten darf, ist nie ausgeschlossen.')
|
||||
->fillForm(fn (array $arguments) => ['roles' => array_map('strval', app(PluginAccess::class)->excludedRoles($arguments['slug'] ?? ''))])
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Filament\Clusters\HomepageCluster;
|
||||
use App\Support\Icons;
|
||||
use App\Support\QuickLinks;
|
||||
use App\Support\Settings;
|
||||
|
|
@ -15,7 +16,6 @@ use Filament\Pages\Page;
|
|||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use UnitEnum;
|
||||
|
||||
class QuickLinksSettings extends Page
|
||||
{
|
||||
|
|
@ -23,7 +23,9 @@ class QuickLinksSettings extends Page
|
|||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedSquares2x2;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Portal';
|
||||
protected static ?int $navigationSort = 2;
|
||||
|
||||
protected static ?string $cluster = HomepageCluster::class;
|
||||
|
||||
protected static ?string $navigationLabel = 'Schnellzugriffe';
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Filament\Resources\DashboardTiles;
|
||||
|
||||
use App\Filament\Clusters\HomepageCluster;
|
||||
use App\Filament\Components\AudienceSection;
|
||||
use App\Filament\Resources\DashboardTiles\Pages\ManageDashboardTiles;
|
||||
use App\Models\DashboardTile;
|
||||
|
|
@ -23,7 +24,6 @@ use Filament\Tables\Columns\IconColumn;
|
|||
use Filament\Tables\Columns\ImageColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
use UnitEnum;
|
||||
|
||||
/**
|
||||
* Eigene Kacheln der Startseite. Reihenfolge und Ein-/Ausblenden unter „Startseite“.
|
||||
|
|
@ -34,9 +34,9 @@ class DashboardTileResource extends Resource
|
|||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedRectangleGroup;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Portal';
|
||||
protected static ?string $cluster = HomepageCluster::class;
|
||||
|
||||
protected static ?int $navigationSort = 11;
|
||||
protected static ?int $navigationSort = 4;
|
||||
|
||||
protected static ?string $modelLabel = 'Eigene Kachel';
|
||||
|
||||
|
|
|
|||
|
|
@ -144,8 +144,8 @@ class AppServiceProvider extends ServiceProvider
|
|||
$usages = $this->app->make(MediaUsages::class);
|
||||
$usages->add('dashboard_tiles', 'Startseiten-Kacheln',
|
||||
fn (DashboardTile $tile) => [
|
||||
['context' => 'Kachelbild', 'label' => $tile->name ?: (string) $tile->title, 'url' => '/admin/kacheln', 'draft' => $tile->is_active === false, 'paths' => [$tile->image_path]],
|
||||
['context' => ImagePaths::HTML_CONTEXT, 'label' => $tile->name ?: (string) $tile->title, 'url' => '/admin/kacheln', 'draft' => $tile->is_active === false, 'paths' => ImagePaths::fromHtml($tile->body_html)],
|
||||
['context' => 'Kachelbild', 'label' => $tile->name ?: (string) $tile->title, 'url' => '/admin/startseite-menue/kacheln', 'draft' => $tile->is_active === false, 'paths' => [$tile->image_path]],
|
||||
['context' => ImagePaths::HTML_CONTEXT, 'label' => $tile->name ?: (string) $tile->title, 'url' => '/admin/startseite-menue/kacheln', 'draft' => $tile->is_active === false, 'paths' => ImagePaths::fromHtml($tile->body_html)],
|
||||
],
|
||||
fn (callable $each) => DashboardTile::query()->chunkById(100, fn ($tiles) => $tiles->each($each)));
|
||||
$usages->watch('dashboard_tiles', DashboardTile::class, ['image_path', 'body_html', 'name', 'title', 'is_active']);
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\Providers\Filament;
|
||||
|
||||
use App\Filament\AvatarProviders\InitialsAvatarProvider;
|
||||
use App\Filament\Pages\AdminDashboard;
|
||||
use App\Filament\Pages\Feedback;
|
||||
use App\Filament\Resources\DashboardTiles\DashboardTileResource;
|
||||
use App\Filament\Resources\IdentityProviders\IdentityProviderResource;
|
||||
|
|
@ -17,11 +18,10 @@ use Filament\Http\Middleware\AuthenticateSession;
|
|||
use Filament\Http\Middleware\DisableBladeIconComponents;
|
||||
use Filament\Http\Middleware\DispatchServingFilamentEvent;
|
||||
use Filament\Navigation\NavigationItem;
|
||||
use Filament\Pages\Dashboard;
|
||||
use Filament\Panel;
|
||||
use Filament\PanelProvider;
|
||||
use Filament\Support\Enums\Width;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Widgets\AccountWidget;
|
||||
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;
|
||||
use Illuminate\Cookie\Middleware\EncryptCookies;
|
||||
use Illuminate\Foundation\Http\Middleware\PreventRequestForgery;
|
||||
|
|
@ -43,12 +43,15 @@ class AdminPanelProvider extends PanelProvider
|
|||
->brandName(fn () => app(Branding::class)->portalName())
|
||||
->brandLogo(fn () => app(Branding::class)->logoUrl())
|
||||
->darkModeBrandLogo(fn () => app(Branding::class)->logoDarkUrl())
|
||||
->brandLogoHeight('2rem')
|
||||
->brandLogoHeight('1.75rem')
|
||||
->viteTheme('resources/css/filament/admin/theme.css')
|
||||
->maxContentWidth(Width::Full)
|
||||
->sidebarCollapsibleOnDesktop()
|
||||
->favicon(fn () => app(Branding::class)->faviconUrl())
|
||||
->colors(fn () => [
|
||||
'primary' => app(Branding::class)->palette(),
|
||||
])
|
||||
->navigationGroups(['Inhalte', 'Benutzer & Rechte', 'Portal', 'System', 'Hilfe'])
|
||||
->navigationGroups(['Inhalte', 'Qualitätsmanagement', 'Benutzer & Rechte', 'Portal', 'System', 'Hilfe'])
|
||||
->databaseNotifications()
|
||||
->userMenuItems([
|
||||
Action::make('feedback')
|
||||
|
|
@ -79,14 +82,13 @@ class AdminPanelProvider extends PanelProvider
|
|||
DashboardTileResource::class,
|
||||
IdentityProviderResource::class,
|
||||
])
|
||||
->discoverClusters(in: app_path('Filament/Clusters'), for: 'App\Filament\Clusters')
|
||||
->discoverPages(in: app_path('Filament/Pages'), for: 'App\Filament\Pages')
|
||||
->pages([
|
||||
Dashboard::class,
|
||||
AdminDashboard::class,
|
||||
])
|
||||
->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\Filament\Widgets')
|
||||
->widgets([
|
||||
AccountWidget::class,
|
||||
])
|
||||
->widgets([])
|
||||
->middleware([
|
||||
EncryptCookies::class,
|
||||
AddQueuedCookiesToResponse::class,
|
||||
|
|
|
|||
|
|
@ -9,5 +9,5 @@ namespace App;
|
|||
*/
|
||||
final class Version
|
||||
{
|
||||
public const VERSION = '0.18.1';
|
||||
public const VERSION = '0.19.0';
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue