Feste Profilfelder in Formularen, Geburtstage, anpassbare Startseite
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 2m18s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 2m21s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 2m40s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 2m34s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 3m8s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 3m6s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 2m43s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 2m47s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m1s
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 2m18s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 2m21s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 2m40s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 2m34s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 3m8s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 3m6s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 2m43s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 2m47s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m1s
- Formulare: Felder fest aus dem Profil (nicht änderbar, Server setzt den Profilwert ein), Hinweis bei fehlender Profilangabe - Geburtstage (optionales Plugin, standardmäßig aus): Tag und Monat freiwillig im Profil, Kachel, Liste /geburtstage, Pagebuilder-Block, Glückwunsch am eigenen Geburtstag; Sichtbarkeit alle/Abteilung/Standort - Startseite: Kacheln je Bereich sortieren und ausblenden; eigene Kacheln (Bild mit Link, Text, Hinweis) mit Zeitraum und Zielgruppe - Kern: optionale mitgelieferte Plugins, Startseitenbereich „top“, Profilabschnitte für Plugins, Kachel-Bezeichnungen Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
435960725d
commit
ee8dde93c0
262 changed files with 2385 additions and 692 deletions
108
app/Filament/Pages/DashboardSettings.php
Normal file
108
app/Filament/Pages/DashboardSettings.php
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Dashboard\Widgets;
|
||||
use App\Filament\Resources\DashboardTiles\DashboardTileResource;
|
||||
use App\Support\Settings;
|
||||
use BackedEnum;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\Hidden;
|
||||
use Filament\Forms\Components\Repeater;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use UnitEnum;
|
||||
|
||||
/**
|
||||
* Anordnung der Startseite: Kacheln je Bereich sortieren und ausblenden –
|
||||
* mitgelieferte wie eigene.
|
||||
*/
|
||||
class DashboardSettings extends Page
|
||||
{
|
||||
protected string $view = 'filament.pages.settings-form';
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedHome;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Portal';
|
||||
|
||||
protected static ?int $navigationSort = 10;
|
||||
|
||||
protected static ?string $navigationLabel = 'Startseite';
|
||||
|
||||
protected static ?string $title = 'Startseite';
|
||||
|
||||
protected static ?string $slug = 'startseite';
|
||||
|
||||
private const AREAS = [
|
||||
'top' => ['Ganz oben (volle Breite)', 'Hinweise und Banner über allem.'],
|
||||
'hero' => ['Groß links oben', 'Nur die erste sichtbare Kachel wird gezeigt.'],
|
||||
'feed' => ['Neben dem großen Bereich', ''],
|
||||
'main' => ['Hauptspalte', ''],
|
||||
'aside' => ['Seitenleiste (rechts)', ''],
|
||||
];
|
||||
|
||||
/** @var array<string, mixed>|null */
|
||||
public ?array $data = [];
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return auth()->user()?->can('appearance.manage') ?? false;
|
||||
}
|
||||
|
||||
public function mount(Widgets $widgets): void
|
||||
{
|
||||
$this->form->fill(collect(self::AREAS)->mapWithKeys(fn ($info, $area) => [$area => $widgets->forAdmin($area)])->all());
|
||||
}
|
||||
|
||||
public function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema->statePath('data')->components(
|
||||
collect(self::AREAS)->map(fn ($info, $area) => Section::make($info[0])
|
||||
->description($info[1] ?: null)
|
||||
->visible(fn () => app(Widgets::class)->forAdmin($area) !== [])
|
||||
->schema([
|
||||
Repeater::make($area)
|
||||
->hiddenLabel()
|
||||
->reorderable()
|
||||
->reorderableWithDragAndDrop()
|
||||
->addable(false)
|
||||
->deletable(false)
|
||||
->itemLabel(fn (array $state) => $state['label'] ?? $state['key'])
|
||||
->schema([
|
||||
Hidden::make('key'),
|
||||
Hidden::make('label'),
|
||||
Toggle::make('visible')->label('Anzeigen'),
|
||||
]),
|
||||
]))->values()->all()
|
||||
);
|
||||
}
|
||||
|
||||
public function save(Settings $settings): void
|
||||
{
|
||||
$layout = [];
|
||||
|
||||
foreach (array_keys(self::AREAS) as $area) {
|
||||
foreach (array_values($this->data[$area] ?? []) as $index => $item) {
|
||||
$layout[$item['key']] = ['sort' => $index * 10, 'visible' => (bool) ($item['visible'] ?? true)];
|
||||
}
|
||||
}
|
||||
|
||||
$settings->set('dashboard.layout', $layout);
|
||||
|
||||
Notification::make()->success()->title('Startseite gespeichert')->send();
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('tiles')->label('Eigene Kacheln')->icon(Heroicon::OutlinedRectangleGroup)->color('gray')
|
||||
->url(fn () => DashboardTileResource::getUrl()),
|
||||
Action::make('preview')->label('Startseite ansehen')->icon(Heroicon::OutlinedEye)->color('gray')
|
||||
->url('/')->openUrlInNewTab(),
|
||||
];
|
||||
}
|
||||
}
|
||||
104
app/Filament/Resources/DashboardTiles/DashboardTileResource.php
Normal file
104
app/Filament/Resources/DashboardTiles/DashboardTileResource.php
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\DashboardTiles;
|
||||
|
||||
use App\Filament\Components\AudienceSection;
|
||||
use App\Filament\Resources\DashboardTiles\Pages\ManageDashboardTiles;
|
||||
use App\Models\DashboardTile;
|
||||
use BackedEnum;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\RichEditor;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
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“.
|
||||
*/
|
||||
class DashboardTileResource extends Resource
|
||||
{
|
||||
protected static ?string $model = DashboardTile::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedRectangleGroup;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Portal';
|
||||
|
||||
protected static ?int $navigationSort = 11;
|
||||
|
||||
protected static ?string $modelLabel = 'Eigene Kachel';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Eigene Kacheln';
|
||||
|
||||
protected static ?string $slug = 'kacheln';
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return auth()->user()?->can('appearance.manage') ?? false;
|
||||
}
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
$type = fn (string ...$types) => fn (Get $get) => in_array($get('type'), $types, true);
|
||||
|
||||
return $schema->columns(2)->components([
|
||||
TextInput::make('name')->label('Name (nur im Admin)')->required()->maxLength(100),
|
||||
Select::make('type')->label('Art')->options(DashboardTile::TYPES)->default('image')->required()->live()->native(false),
|
||||
Select::make('area')->label('Bereich')->options(DashboardTile::AREAS)->default('aside')->required()->native(false)
|
||||
->helperText('Die Reihenfolge innerhalb des Bereichs legen Sie unter „Startseite“ fest.'),
|
||||
TextInput::make('title')->label(fn (Get $get) => $get('type') === 'image' ? 'Bildunterschrift (optional)' : 'Überschrift')->maxLength(150),
|
||||
|
||||
FileUpload::make('image_path')->label('Bild')->image()->disk('uploads')->directory('dashboard')->visibility('public')
|
||||
->maxSize(8 * 1024)->required($type('image'))->visible($type('image'))->columnSpanFull()
|
||||
->helperText('Für die Seitenleiste z. B. 800 × 600 Pixel, für „ganz oben“ ein breites Banner (z. B. 2400 × 500).'),
|
||||
TextInput::make('alt')->label('Alternativtext')->maxLength(200)->visible($type('image'))->helperText('Beschreibt das Bild für Screenreader.'),
|
||||
|
||||
RichEditor::make('body')->label('Text')->toolbarButtons([['bold', 'italic', 'link'], ['bulletList', 'orderedList'], ['undo', 'redo']])
|
||||
->required($type('text', 'notice'))->visible($type('text', 'notice'))->columnSpanFull(),
|
||||
Select::make('variant')->label('Farbe')->options(DashboardTile::VARIANTS)->default('brand')->visible($type('notice'))->native(false),
|
||||
|
||||
TextInput::make('url')->label('Link')->placeholder('https://… oder /seiten/…')->maxLength(2000),
|
||||
Toggle::make('new_tab')->label('In neuem Tab öffnen')->inline(false),
|
||||
|
||||
Section::make('Anzeige')->columnSpanFull()->columns(3)->schema([
|
||||
Toggle::make('is_active')->label('Aktiv')->default(true)->inline(false),
|
||||
DateTimePicker::make('starts_at')->label('Ab')->native(false)->seconds(false)->displayFormat('d.m.Y H:i'),
|
||||
DateTimePicker::make('ends_at')->label('Bis')->native(false)->seconds(false)->displayFormat('d.m.Y H:i')->after('starts_at'),
|
||||
]),
|
||||
AudienceSection::make('dashboard_tile', 'Wer die Kachel sieht. Leer lassen = alle.')->columnSpanFull(),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
ImageColumn::make('image_path')->label('')->disk('uploads')->width(64)->height(40),
|
||||
TextColumn::make('name')->label('Name')->weight('medium')->searchable(),
|
||||
TextColumn::make('type')->label('Art')->formatStateUsing(fn (string $state) => DashboardTile::TYPES[$state] ?? $state),
|
||||
TextColumn::make('area')->label('Bereich')->formatStateUsing(fn (string $state) => DashboardTile::AREAS[$state] ?? $state),
|
||||
IconColumn::make('is_active')->label('Aktiv')->boolean(),
|
||||
TextColumn::make('ends_at')->label('Bis')->dateTime('d.m.Y H:i')->placeholder('–'),
|
||||
])
|
||||
->recordActions([EditAction::make(), DeleteAction::make()])
|
||||
->emptyStateHeading('Noch keine eigenen Kacheln')
|
||||
->emptyStateDescription('Zum Beispiel ein verlinktes Bild in der Seitenleiste oder ein Hinweis ganz oben.');
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return ['index' => ManageDashboardTiles::route('/')];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\DashboardTiles\Pages;
|
||||
|
||||
use App\Filament\Pages\DashboardSettings;
|
||||
use App\Filament\Resources\DashboardTiles\DashboardTileResource;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ManageRecords;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
|
||||
class ManageDashboardTiles extends ManageRecords
|
||||
{
|
||||
protected static string $resource = DashboardTileResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('layout')->label('Anordnung der Startseite')->icon(Heroicon::OutlinedSquares2x2)->color('gray')
|
||||
->url(fn () => DashboardSettings::getUrl()),
|
||||
CreateAction::make()->label('Kachel anlegen'),
|
||||
];
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue