Files
nutzwerte_fi4/app/Filament/Resources/Projektes/Schemas/ProjekteForm.php
T
2025-11-27 12:41:26 +01:00

129 lines
7.7 KiB
PHP

<?php
namespace App\Filament\Resources\Projektes\Schemas;
use App\Enums\ProjektStatus;
use App\Models\Projekte;
use Filament\Actions\Action;
use Filament\Forms\Components\ColorPicker;
use Filament\Forms\Components\DatePicker;
use Filament\Forms\Components\Radio;
use Filament\Forms\Components\RichEditor;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Components\Tabs;
use Filament\Schemas\Components\Tabs\Tab;
use Filament\Schemas\Schema;
class ProjekteForm
{
public static function configure(Schema $schema): Schema
{
return $schema
->components([
Section::make('Projekt Daten')
->label(fn (?Projekte $record): ?string => ($record?->created_at) ? 'Erstellt: '.$record?->created_at->diffForHumans().', Geändert: '.$record?->updated_at->diffForHumans() : '')
->collapsed(fn ($operation) => $operation == 'create' ? false : true)
->icon('heroicon-o-rectangle-stack')
->schema([
Tabs::make('Tabs')
->contained(false)
->tabs([
Tab::make('Benennung')
->icon('phosphor-article-medium')
->schema([
TextInput::make('offizieller_name')
->label('Offizieller Name')
->suffixAction(
Action::make('copy')
->tooltip('Kopieren')
->icon('heroicon-s-clipboard-document-check')
->action(function ($livewire, $state) {
$livewire->js('window.navigator.clipboard.writeText("'.$state.'");');
})
)
->belowContent([
'Als Platzhalter "###OFFIZIELLER_NAME###"',
])
->required(),
TextInput::make('interner_name')
->label('Interner Name')
->suffixAction(
Action::make('copy')
->tooltip('Kopieren')
->icon('heroicon-s-clipboard-document-check')
->action(function ($livewire, $state) {
$livewire->js('window.navigator.clipboard.writeText("'.$state.'");');
})
)
->belowContent([
'Als Platzhalter "###INTERNER_NAME###"',
])
->required(),
])->columns(2),
Tab::make('Ort & Datum')
->icon('phosphor-calendar-check')
->schema([
TextInput::make('ort')->required()->suffix('am')
->belowContent([
'Als Platzhalter "###ORT###"',
]),
DatePicker::make('erstellung')
->label('Datum der Erstellung')
->required()
->belowContent([
'Als Platzhalter "###DATUM###"',
]),
])->columns(2),
Tab::make('Gutachter & Auftraggeber')
->icon('phosphor-identification-card')
->schema([
Select::make('gutachter_id')->relationship(name: 'gutachter', titleAttribute: 'company')->required(),
Select::make('auftraggeber_id')
->searchable()
->loadingMessage('Lade Auftraggeber...')
->relationship(name: 'auftraggeber', titleAttribute: 'company')
->required(),
Radio::make('status')->options(ProjektStatus::class)->required(),
]),
Tab::make('Notizen')
->icon('phosphor-notebook')
->schema([
RichEditor::make('beschreibung')
->label('Notizen')
->extraInputAttributes(['style' => 'min-height: 20rem; max-height: 50vh; overflow-y: auto;'])
->toolbarButtons([
['bold', 'italic', 'underline', 'strike', 'subscript', 'superscript', 'link', 'textColor', 'clearFormatting'],
['alignStart', 'alignCenter', 'alignEnd'],
['bulletList', 'orderedList', 'table'],
['undo', 'redo'],
])->floatingToolbars([
'table' => [
'tableAddColumnBefore', 'tableAddColumnAfter', 'tableDeleteColumn',
'tableAddRowBefore', 'tableAddRowAfter', 'tableDeleteRow',
'tableMergeCells', 'tableSplitCell',
'tableToggleHeaderRow',
'tableDelete',
],
])
->columnSpan(2),
]),
Tab::make('Farben')
->icon('phosphor-palette')
->schema([
ColorPicker::make('deckblatt_bg')->label('Deckblatt')
->belowContent('Farbe des Hintergrundes am Deckblatt.'),
ColorPicker::make('schmuckfarbe_header')->label('Überschriften')
->belowContent('Farbe des Hintergrundes bei Überschriften.'),
ColorPicker::make('farbe_borders')->label('Rahmen')
->belowContent('Farbe von Rahmen und Rändern bei Tabellen und Boxen.'),
])->columns(3)
->columnSpanFull(),
]),
])->columnSpanFull(),
]);
}
}