diff --git a/app/Filament/Resources/Projektes/RelationManagers/ProjektInhaltsverzeichnisRelationManager.php b/app/Filament/Resources/Projektes/RelationManagers/ProjektInhaltsverzeichnisRelationManager.php index 37d61c2..002f777 100644 --- a/app/Filament/Resources/Projektes/RelationManagers/ProjektInhaltsverzeichnisRelationManager.php +++ b/app/Filament/Resources/Projektes/RelationManagers/ProjektInhaltsverzeichnisRelationManager.php @@ -2,12 +2,15 @@ namespace App\Filament\Resources\Projektes\RelationManagers; +use App\Models\KontoTextblock; use App\Models\TextblockKennung; +use Filament\Actions\Action; use Filament\Actions\BulkActionGroup; use Filament\Actions\CreateAction; use Filament\Actions\DeleteAction; use Filament\Actions\DeleteBulkAction; use Filament\Actions\EditAction; +use Filament\Forms\Components\Hidden; use Filament\Forms\Components\RichEditor; use Filament\Forms\Components\Select; use Filament\Forms\Components\TextInput; @@ -84,7 +87,65 @@ class ProjektInhaltsverzeichnisRelationManager extends RelationManager CreateAction::make(), ]) ->recordActions([ - EditAction::make()->iconButton()->color('gray'), + EditAction::make()->iconButton()->color('gray') + ->extraModalFooterActions([ + + Action::make('vorlage-sichern') + ->label('Textblock als Vorlage sichern') + ->schema([ + Hidden::make('namecheck')->default(function ($record) { + return $record['name']; + }), + TextInput::make('name')->required() + ->label('Name der Vorlage') + ->validationMessages([ + 'different' => 'Name ist schon in Verwendung bitte verwenden Sie einen eindeutig Namen.', + ]) + ->different('namecheck') + ->default(function ($record) { + return $record['name']; + }), + RichEditor::make('textblock') + ->label('Textblock Vorlage') + ->default(function ($record) { + return $record['textblock']; + }) + // ->default($this->ownerRecord->textblock) + ->toolbarButtons([ + ['bold', 'italic', 'underline', 'strike', 'subscript', 'superscript'], + ]), + ]) + ->icon('phosphor-floppy-disk') + ->tooltip('Ein personalisierter Textblock kann als neue Vorlage gespeichert werden.') + ->hidden(fn ($record): bool => ! $record['textblock_kennung_id']) + ->color('info') + ->action(function (array $mountedActions, $data) { + + $record = $mountedActions[0]->getRawData(); + + dd($record['textblock']); + + KontoTextblock::updateOrCreate( + [ + 'konto_id' => auth()->user()->konto_id, + 'name' => $data['name'], + 'textblock_kennung_id' => $record['textblock_kennung_id'], + ], + [ + 'textblock' => $record['textblock'], + ]); + }), + + Action::make('vorlage-importieren') + ->icon('phosphor-article') + ->tooltip('Ein veränderter Textblock kann als persönliche Vorlage gespeichert werden.') + ->hidden(fn ($record): bool => ! $record['textblock_kennung_id']) + ->color('info') + ->requiresConfirmation() + ->action(function (array $mountedActions) { + dd($mountedActions[0]->getRawData()); + }), + ]), DeleteAction::make()->iconButton(), ]) ->toolbarActions([ diff --git a/app/Models/KontoTextblock.php b/app/Models/KontoTextblock.php new file mode 100644 index 0000000..1cdf8a5 --- /dev/null +++ b/app/Models/KontoTextblock.php @@ -0,0 +1,20 @@ +hasMany(TextblockKennung::class, 'id'); + } +} diff --git a/bootstrap/cache/routes-v7.php b/bootstrap/cache/routes-v7.php index 276a1e1..7b97d84 100644 --- a/bootstrap/cache/routes-v7.php +++ b/bootstrap/cache/routes-v7.php @@ -511,7 +511,7 @@ app('router')->setCompiledRoutes( array ( 0 => array ( - '_route' => 'generated::72dvlQUT3DeuMnCR', + '_route' => 'generated::r8qwOhrBFr97OJpy', ), 1 => NULL, 2 => @@ -531,7 +531,7 @@ app('router')->setCompiledRoutes( array ( 0 => array ( - '_route' => 'generated::2FquvPUK0QPjy898', + '_route' => 'generated::68WmDIMECRFF2Y0d', ), 1 => NULL, 2 => @@ -589,7 +589,7 @@ app('router')->setCompiledRoutes( array ( 0 => array ( - '_route' => 'generated::LEBDUibewTYH5vdg', + '_route' => 'generated::U94dFsn56p7tAtAL', ), 1 => NULL, 2 => @@ -609,7 +609,7 @@ app('router')->setCompiledRoutes( array ( 0 => array ( - '_route' => 'generated::yAZVXGYa5kOiaO48', + '_route' => 'generated::brIvQ2hYFK9KD13e', ), 1 => NULL, 2 => @@ -629,7 +629,7 @@ app('router')->setCompiledRoutes( array ( 0 => array ( - '_route' => 'generated::rKOO0zfHV2AtlZa8', + '_route' => 'generated::QlCs3Yu0TXq8RHlp', ), 1 => NULL, 2 => @@ -649,7 +649,7 @@ app('router')->setCompiledRoutes( array ( 0 => array ( - '_route' => 'generated::BULbTYn3Q6ELpchc', + '_route' => 'generated::LwGntt2fOHLNT95n', ), 1 => NULL, 2 => @@ -669,7 +669,7 @@ app('router')->setCompiledRoutes( array ( 0 => array ( - '_route' => 'generated::086O3CfzKAMN4O68', + '_route' => 'generated::3c8bds3Cmtrpk7Ez', ), 1 => NULL, 2 => @@ -2595,7 +2595,7 @@ app('router')->setCompiledRoutes( 'waitSeconds' => NULL, 'withTrashed' => false, ), - 'generated::72dvlQUT3DeuMnCR' => + 'generated::r8qwOhrBFr97OJpy' => array ( 'methods' => array ( @@ -2607,7 +2607,7 @@ app('router')->setCompiledRoutes( array ( 'uses' => 'Livewire\\Mechanisms\\FrontendAssets\\FrontendAssets@returnJavaScriptAsFile', 'controller' => 'Livewire\\Mechanisms\\FrontendAssets\\FrontendAssets@returnJavaScriptAsFile', - 'as' => 'generated::72dvlQUT3DeuMnCR', + 'as' => 'generated::r8qwOhrBFr97OJpy', ), 'fallback' => false, 'defaults' => @@ -2623,7 +2623,7 @@ app('router')->setCompiledRoutes( 'waitSeconds' => NULL, 'withTrashed' => false, ), - 'generated::2FquvPUK0QPjy898' => + 'generated::68WmDIMECRFF2Y0d' => array ( 'methods' => array ( @@ -2635,7 +2635,7 @@ app('router')->setCompiledRoutes( array ( 'uses' => 'Livewire\\Mechanisms\\FrontendAssets\\FrontendAssets@maps', 'controller' => 'Livewire\\Mechanisms\\FrontendAssets\\FrontendAssets@maps', - 'as' => 'generated::2FquvPUK0QPjy898', + 'as' => 'generated::68WmDIMECRFF2Y0d', ), 'fallback' => false, 'defaults' => @@ -2737,7 +2737,7 @@ app('router')->setCompiledRoutes( 'waitSeconds' => NULL, 'withTrashed' => false, ), - 'generated::LEBDUibewTYH5vdg' => + 'generated::U94dFsn56p7tAtAL' => array ( 'methods' => array ( @@ -2766,7 +2766,7 @@ app('router')->setCompiledRoutes( \'exception\' => $exception, ]), status: $exception ? 500 : 200); }";s:5:"scope";s:54:"Illuminate\\Foundation\\Configuration\\ApplicationBuilder";s:4:"this";N;s:4:"self";s:32:"0000000000000f2d0000000000000000";}}', - 'as' => 'generated::LEBDUibewTYH5vdg', + 'as' => 'generated::U94dFsn56p7tAtAL', ), 'fallback' => false, 'defaults' => @@ -2782,7 +2782,7 @@ app('router')->setCompiledRoutes( 'waitSeconds' => NULL, 'withTrashed' => false, ), - 'generated::yAZVXGYa5kOiaO48' => + 'generated::brIvQ2hYFK9KD13e' => array ( 'methods' => array ( @@ -2804,7 +2804,7 @@ app('router')->setCompiledRoutes( 'where' => array ( ), - 'as' => 'generated::yAZVXGYa5kOiaO48', + 'as' => 'generated::brIvQ2hYFK9KD13e', ), 'fallback' => false, 'defaults' => @@ -2820,7 +2820,7 @@ app('router')->setCompiledRoutes( 'waitSeconds' => NULL, 'withTrashed' => false, ), - 'generated::rKOO0zfHV2AtlZa8' => + 'generated::QlCs3Yu0TXq8RHlp' => array ( 'methods' => array ( @@ -2842,7 +2842,7 @@ app('router')->setCompiledRoutes( 'where' => array ( ), - 'as' => 'generated::rKOO0zfHV2AtlZa8', + 'as' => 'generated::QlCs3Yu0TXq8RHlp', ), 'fallback' => false, 'defaults' => @@ -2858,7 +2858,7 @@ app('router')->setCompiledRoutes( 'waitSeconds' => NULL, 'withTrashed' => false, ), - 'generated::BULbTYn3Q6ELpchc' => + 'generated::LwGntt2fOHLNT95n' => array ( 'methods' => array ( @@ -2880,7 +2880,7 @@ app('router')->setCompiledRoutes( 'where' => array ( ), - 'as' => 'generated::BULbTYn3Q6ELpchc', + 'as' => 'generated::LwGntt2fOHLNT95n', ), 'fallback' => false, 'defaults' => @@ -2896,7 +2896,7 @@ app('router')->setCompiledRoutes( 'waitSeconds' => NULL, 'withTrashed' => false, ), - 'generated::086O3CfzKAMN4O68' => + 'generated::3c8bds3Cmtrpk7Ez' => array ( 'methods' => array ( @@ -2918,7 +2918,7 @@ app('router')->setCompiledRoutes( 'where' => array ( ), - 'as' => 'generated::086O3CfzKAMN4O68', + 'as' => 'generated::3c8bds3Cmtrpk7Ez', ), 'fallback' => false, 'defaults' => diff --git a/database/migrations/2025_10_11_095549_create_konto_textblocks_table.php b/database/migrations/2025_10_11_095549_create_konto_textblocks_table.php new file mode 100644 index 0000000..9a83c20 --- /dev/null +++ b/database/migrations/2025_10_11_095549_create_konto_textblocks_table.php @@ -0,0 +1,32 @@ +id(); + $table->foreignId('konto_id')->constrained(); + $table->string('name'); + $table->string('beschreibung')->nullable(); + $table->integer('textblock_kennung_id')->default(0)->nullable(); + $table->text('textblock'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('konto_textblocks'); + } +}; diff --git a/resources/views/filament/forms/components/rich-editor/rich-content-custom-blocks/vorlage/index.blade.php b/resources/views/filament/forms/components/rich-editor/rich-content-custom-blocks/vorlage/index.blade.php new file mode 100644 index 0000000..eb70f32 --- /dev/null +++ b/resources/views/filament/forms/components/rich-editor/rich-content-custom-blocks/vorlage/index.blade.php @@ -0,0 +1,3 @@ +
+ {{-- Custom block --}} +
diff --git a/resources/views/filament/forms/components/rich-editor/rich-content-custom-blocks/vorlage/preview.blade.php b/resources/views/filament/forms/components/rich-editor/rich-content-custom-blocks/vorlage/preview.blade.php new file mode 100644 index 0000000..cd3a053 --- /dev/null +++ b/resources/views/filament/forms/components/rich-editor/rich-content-custom-blocks/vorlage/preview.blade.php @@ -0,0 +1,3 @@ +
+ {{-- Custom block preview --}} +