Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m43s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m52s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m49s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m49s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 2m12s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 2m22s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 1m57s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 1m59s
CI / Build-Artefakte aktuell (pull_request) Successful in 57s
- Profilfelder frei definierbar (Typ, Sichtbarkeit, selbst pflegbar), Werte als JSON am Benutzer - Attribut-Zuordnung je Anbieter statt fester Feldliste: jedes Graph-Attribut inkl. verschachtelter Pfade, onPremisesExtensionAttributes und Verzeichniserweiterungen - Erweiterungsattribute per Knopf aus Entra laden - $select dynamisch aus der Zuordnung; Delta-Abgleich startet bei geänderter Zuordnung neu - Rückfall auf Grundattribute, wenn einzelne Attribute nicht lesbar sind - Ältere Konfiguration (synced_fields) wird weiter gelesen Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
96 lines
4.2 KiB
PHP
96 lines
4.2 KiB
PHP
<?php
|
||
|
||
namespace App\Filament\Resources\ProfileFields;
|
||
|
||
use App\Filament\Resources\ProfileFields\Pages\ManageProfileFields;
|
||
use App\Models\ProfileField;
|
||
use BackedEnum;
|
||
use Filament\Actions\DeleteAction;
|
||
use Filament\Actions\EditAction;
|
||
use Filament\Forms\Components\Select;
|
||
use Filament\Forms\Components\TextInput;
|
||
use Filament\Forms\Components\Toggle;
|
||
use Filament\Resources\Resource;
|
||
use Filament\Schemas\Schema;
|
||
use Filament\Support\Icons\Heroicon;
|
||
use Filament\Tables\Columns\IconColumn;
|
||
use Filament\Tables\Columns\TextColumn;
|
||
use Filament\Tables\Table;
|
||
use UnitEnum;
|
||
|
||
/**
|
||
* Frei definierbare Profilfelder – etwa Personalnummer, Kostenstelle, Eintrittsdatum.
|
||
* Können von den Personen selbst gepflegt oder aus Entra ID übernommen werden.
|
||
*/
|
||
class ProfileFieldResource extends Resource
|
||
{
|
||
protected static ?string $model = ProfileField::class;
|
||
|
||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedIdentification;
|
||
|
||
protected static string|UnitEnum|null $navigationGroup = 'Benutzer & Rechte';
|
||
|
||
protected static ?int $navigationSort = 3;
|
||
|
||
protected static ?string $modelLabel = 'Profilfeld';
|
||
|
||
protected static ?string $pluralModelLabel = 'Profilfelder';
|
||
|
||
protected static ?string $slug = 'profilfelder';
|
||
|
||
public static function canAccess(): bool
|
||
{
|
||
return auth()->user()?->can('users.manage') ?? false;
|
||
}
|
||
|
||
public static function form(Schema $schema): Schema
|
||
{
|
||
return $schema
|
||
->columns(2)
|
||
->components([
|
||
TextInput::make('label')->label('Bezeichnung')->required()->maxLength(100),
|
||
TextInput::make('key')->label('Technischer Schlüssel')
|
||
->helperText('Wird aus der Bezeichnung erzeugt, wenn leer. Nachträglich nicht änderbar.')
|
||
->regex('/^[a-z][a-z0-9_]*$/')
|
||
->validationMessages(['regex' => 'Nur Kleinbuchstaben, Ziffern und Unterstriche, beginnend mit einem Buchstaben.'])
|
||
->maxLength(60)
|
||
->unique(ignoreRecord: true)
|
||
->disabledOn('edit'),
|
||
Select::make('type')->label('Typ')->options(ProfileField::TYPES)->default('text')->required()->native(false),
|
||
Select::make('visibility')->label('Sichtbarkeit')->options(ProfileField::VISIBILITIES)->default('public')->required()->native(false),
|
||
Toggle::make('editable')->label('Von der Person selbst pflegbar')->default(true)
|
||
->helperText('Aus Entra ID übernommene Felder sind unabhängig davon schreibgeschützt.'),
|
||
TextInput::make('sort')->label('Reihenfolge')->numeric()->default(0)->minValue(0),
|
||
TextInput::make('help')->label('Hinweis im Profilformular')->maxLength(255)->columnSpanFull(),
|
||
]);
|
||
}
|
||
|
||
public static function table(Table $table): Table
|
||
{
|
||
return $table
|
||
->defaultSort('sort')
|
||
->reorderable('sort')
|
||
->columns([
|
||
TextColumn::make('label')->label('Bezeichnung')->weight('medium'),
|
||
TextColumn::make('key')->label('Schlüssel')->fontFamily('mono')->color('gray'),
|
||
TextColumn::make('type')->label('Typ')->formatStateUsing(fn (string $state) => ProfileField::TYPES[$state] ?? $state),
|
||
TextColumn::make('visibility')->label('Sichtbarkeit')->badge()
|
||
->formatStateUsing(fn (string $state) => $state === 'public' ? 'Alle' : 'Eingeschränkt')
|
||
->color(fn (string $state) => $state === 'public' ? 'gray' : 'warning'),
|
||
IconColumn::make('editable')->label('Selbst pflegbar')->boolean(),
|
||
])
|
||
->recordActions([
|
||
EditAction::make(),
|
||
DeleteAction::make()->modalDescription('Die gespeicherten Werte bleiben erhalten, werden aber nicht mehr angezeigt.'),
|
||
])
|
||
->emptyStateHeading('Noch keine Profilfelder')
|
||
->emptyStateDescription('Zum Beispiel Personalnummer, Kostenstelle oder Eintrittsdatum – selbst gepflegt oder aus Entra ID übernommen.');
|
||
}
|
||
|
||
public static function getPages(): array
|
||
{
|
||
return [
|
||
'index' => ManageProfileFields::route('/'),
|
||
];
|
||
}
|
||
}
|