wip
This commit is contained in:
1 parent
7eaa8c0da2
commit
c149ed0a9f
15 files changed
+157
-77
No files matched your search
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Filament\Resources\Inhaltsverzeichnis\Schemas;
|
||||
|
||||
use App\Models\TextblockKennung;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
@@ -11,7 +13,14 @@ class InhaltsverzeichnisForm
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('ordnungszahl'),
|
||||
TextInput::make('ordnungszahl')->numeric(),
|
||||
Select::make('textblock_kennung_id')
|
||||
->label('Textblock Art')
|
||||
->options(function () {
|
||||
$relatedOptions = TextblockKennung::all()->pluck('name', 'id')->toArray();
|
||||
|
||||
return ['0' => 'ohne Textblock'] + $relatedOptions;
|
||||
}),
|
||||
TextInput::make('name'),
|
||||
])->columns(1);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Filament\Resources\Projektes\Pages;
|
||||
|
||||
use App\Actions\Create\CreateProjektInhaltsverzeichnis;
|
||||
use App\Filament\Resources\Projektes\ProjekteResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
@@ -19,6 +20,8 @@ class ListProjektes extends ListRecords
|
||||
$data['konto_id'] = auth()->user()->konto_id;
|
||||
|
||||
return $data;
|
||||
})->after(function ($record) {
|
||||
CreateProjektInhaltsverzeichnis::create($record);
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ use App\Filament\Resources\Projektes\Pages\EditProjekte;
|
||||
use App\Filament\Resources\Projektes\Pages\ListProjektes;
|
||||
use App\Filament\Resources\Projektes\RelationManagers\AllgemeinflaechensRelationManager;
|
||||
use App\Filament\Resources\Projektes\RelationManagers\OrientierungZuAbschlaegesRelationManager;
|
||||
use App\Filament\Resources\Projektes\RelationManagers\ProjektInhaltsverzeichnisRelationManager;
|
||||
use App\Filament\Resources\Projektes\RelationManagers\ProjektMethodesRelationManager;
|
||||
use App\Filament\Resources\Projektes\RelationManagers\RaeumeallesRelationManager;
|
||||
use App\Filament\Resources\Projektes\Schemas\ProjekteForm;
|
||||
@@ -49,6 +50,7 @@ class ProjekteResource extends Resource
|
||||
RaeumeallesRelationManager::class,
|
||||
ProjektMethodesRelationManager::class,
|
||||
OrientierungZuAbschlaegesRelationManager::class,
|
||||
ProjektInhaltsverzeichnisRelationManager::class,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
+50
-14
@@ -2,17 +2,19 @@
|
||||
|
||||
namespace App\Filament\Resources\Projektes\RelationManagers;
|
||||
|
||||
use Filament\Actions\AssociateAction;
|
||||
use App\Models\TextblockKennung;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\DissociateAction;
|
||||
use Filament\Actions\DissociateBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\RichEditor;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
@@ -20,14 +22,34 @@ class ProjektInhaltsverzeichnisRelationManager extends RelationManager
|
||||
{
|
||||
protected static string $relationship = 'projekt_inhaltsverzeichnis';
|
||||
|
||||
protected static ?string $title = 'Inhaltsverzeichnis';
|
||||
|
||||
protected static ?string $navigationLabel = 'Inhaltsverzeichnis';
|
||||
|
||||
protected static ?string $modelLabel = 'Inhaltsverzeichnis';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Inhaltsverzeichnis';
|
||||
|
||||
public function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('text')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
]);
|
||||
TextInput::make('ordnungszahl')->numeric(),
|
||||
TextInput::make('name'),
|
||||
Select::make('textblock_kennung_id')
|
||||
->label('Textblock Art')
|
||||
->options(function () {
|
||||
$relatedOptions = TextblockKennung::all()->pluck('name', 'id')->toArray();
|
||||
|
||||
return ['0' => 'ohne Textblock'] + $relatedOptions;
|
||||
})
|
||||
->live(),
|
||||
RichEditor::make('textblock')
|
||||
->hidden(fn (Get $get): bool => ! $get('textblock_kennung_id'))
|
||||
->toolbarButtons([
|
||||
['bold', 'italic', 'underline', 'strike', 'subscript', 'superscript'],
|
||||
]),
|
||||
])->columns(1);
|
||||
}
|
||||
|
||||
public function table(Table $table): Table
|
||||
@@ -35,24 +57,38 @@ class ProjektInhaltsverzeichnisRelationManager extends RelationManager
|
||||
return $table
|
||||
->recordTitleAttribute('text')
|
||||
->columns([
|
||||
TextColumn::make('text')
|
||||
->searchable(),
|
||||
// TextColumn::make('sort'),
|
||||
TextColumn::make('ordnungszahl')
|
||||
->getStateUsing(fn ($record): string => $record->ordnungszahl == '0' ? '' : number_format($record->ordnungszahl, 2)),
|
||||
IconColumn::make('textblock_kennung_id')
|
||||
->label('Text')
|
||||
->alignCenter()
|
||||
->icon('phosphor-article')
|
||||
->color(fn (string $state): string => match ($state) {
|
||||
'0' => 'gray',
|
||||
default => 'info',
|
||||
}),
|
||||
TextColumn::make('name')
|
||||
->description(fn ($record): string => $record->textblock_kennung->name ?? ''),
|
||||
TextColumn::make('seite')
|
||||
->alignCenter()
|
||||
->badge()
|
||||
->color('info')
|
||||
->getStateUsing(fn ($record): string => $record->seite == '0' ? '...' : $record->seite),
|
||||
])
|
||||
->reorderable('sort')
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->headerActions([
|
||||
CreateAction::make(),
|
||||
AssociateAction::make(),
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
DissociateAction::make(),
|
||||
DeleteAction::make(),
|
||||
EditAction::make()->iconButton()->color('gray'),
|
||||
DeleteAction::make()->iconButton(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DissociateBulkAction::make(),
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
|
||||
Reference in new issue
Block a user