refreshAllgemeinflaechen dispatch
This commit is contained in:
1 parent
261fb0916d
commit
d473bdc2b3
12 files changed
+157
-126
No files matched your search
+45
-29
@@ -4,6 +4,7 @@ namespace App\Filament\Resources\Projektes\RelationManagers;
|
||||
|
||||
use App\Actions\Create\CreateProjektInhaltsverzeichnis;
|
||||
use App\Models\KontoTextblock;
|
||||
use App\Models\ProjektInhaltsverzeichnis;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\CreateAction;
|
||||
@@ -11,7 +12,6 @@ use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\Checkbox;
|
||||
use Filament\Forms\Components\Hidden;
|
||||
use Filament\Forms\Components\RichEditor;
|
||||
use Filament\Forms\Components\RichEditor\RichContentRenderer;
|
||||
use Filament\Forms\Components\Select;
|
||||
@@ -79,6 +79,7 @@ class ProjektInhaltsverzeichnisRelationManager extends RelationManager
|
||||
Grid::make()
|
||||
->columns(6)
|
||||
->schema([
|
||||
TextInput::make('konto_textblock_id')->hidden(),
|
||||
RichEditor::make('textblock')
|
||||
->extraInputAttributes(['style' => 'min-height: 20rem; max-height: 50vh; overflow-y: auto;'])
|
||||
->columnSpan(5)
|
||||
@@ -89,15 +90,31 @@ class ProjektInhaltsverzeichnisRelationManager extends RelationManager
|
||||
Fieldset::make('')
|
||||
->contained(false)
|
||||
->schema([
|
||||
Action::make('textblock_sichern')
|
||||
Action::make('sichern')
|
||||
->iconButton()
|
||||
->tooltip('Änderungen in der Vorlage speichern')
|
||||
->icon('phosphor-floppy-disk')
|
||||
->schema([
|
||||
Hidden::make('konto_id')->default(auth()->user()->konto_id),
|
||||
RichEditor::make('textblock')
|
||||
->extraInputAttributes(['style' => 'min-height: 20rem; max-height: 50vh; overflow-y: auto;'])
|
||||
->hidden()
|
||||
TextInput::make('name')->required()
|
||||
->label('Ändern sie gegebeben Falls den Namen')
|
||||
->default(function ($record) {
|
||||
return $record['textblock'];
|
||||
return KontoTextblock::where('id', $record['konto_textblock_id'])->pluck('name')->first();
|
||||
}),
|
||||
])
|
||||
->hidden(function ($record) {
|
||||
return (bool) ! $record['konto_textblock_id'];
|
||||
})
|
||||
->action(function (array $mountedActions, array $data) {
|
||||
$record = $mountedActions[0]->getRawData();
|
||||
|
||||
KontoTextblock::where('id', $record['konto_textblock_id'])
|
||||
->update(['name' => $data['name'], 'textblock' => RichContentRenderer::make($record['textblock'])->toHtml()]);
|
||||
|
||||
}),
|
||||
Action::make('neu')
|
||||
->iconButton()
|
||||
->icon('phosphor-file-plus')
|
||||
->schema([
|
||||
TextInput::make('name')->required()
|
||||
->label('Geben sie der Vorlage einen eindeutigen Namen')
|
||||
->default(function ($record) {
|
||||
@@ -105,41 +122,40 @@ class ProjektInhaltsverzeichnisRelationManager extends RelationManager
|
||||
}),
|
||||
])
|
||||
->modalSubmitActionLabel('Sichern')
|
||||
->iconButton()
|
||||
->icon('phosphor-floppy-disk')
|
||||
->tooltip('Als persönliche Vorlage speichern')
|
||||
->action(function (array $mountedActions, $data) {
|
||||
->tooltip('Neue Vorlage erstellen')
|
||||
->action(function (array $mountedActions, array $data) {
|
||||
|
||||
$record = $mountedActions[0]->getRawData();
|
||||
|
||||
KontoTextblock::updateOrCreate(
|
||||
[
|
||||
'konto_id' => auth()->user()->konto_id,
|
||||
'name' => $data['name'],
|
||||
], [
|
||||
'textblock' => RichContentRenderer::make($record['textblock'])->toHtml(),
|
||||
]);
|
||||
$block = new KontoTextblock;
|
||||
$block->konto_id = auth()->user()->konto_id;
|
||||
$block->name = $data['name'];
|
||||
$block->textblock = RichContentRenderer::make($record['textblock'])->toHtml();
|
||||
$block->save();
|
||||
|
||||
ProjektInhaltsverzeichnis::where('id', $record['id'])->update(['konto_textblock_id' => $block->id]);
|
||||
}),
|
||||
Action::make('textblock_laden')
|
||||
Action::make('laden')
|
||||
->iconButton()
|
||||
->icon('phosphor-article')
|
||||
->schema([
|
||||
Select::make('konto_textblock_id')
|
||||
->hiddenLabel()
|
||||
->searchable()
|
||||
->options(function ($record) {
|
||||
return KontoTextblock::where('konto_id', auth()->user()->konto_id)->pluck('name', 'id')->toArray();
|
||||
})->belowLabel([
|
||||
->options(KontoTextblock::where('konto_id', auth()->user()->konto_id)->pluck('name', 'id'))
|
||||
->belowLabel([
|
||||
'Bitte eine Vorlage auswählen',
|
||||
]),
|
||||
])
|
||||
->icon('phosphor-article')
|
||||
->iconButton()
|
||||
->modalSubmitActionLabel('Einsetzen')
|
||||
->tooltip('Persönliche Vorlage laden.')
|
||||
->action(function (Set $set, array $data) {
|
||||
$set('textblock', KontoTextblock::query()->pluck('textblock')->first());
|
||||
->tooltip('Vorlage laden.')
|
||||
->action(function (Set $set, array $mountedActions, array $data) {
|
||||
$record = $mountedActions[0]->getRawData();
|
||||
ProjektInhaltsverzeichnis::where('id', $record['id'])->update(['konto_textblock_id' => $data['konto_textblock_id']]);
|
||||
$set('konto_textblock_id', $data['konto_textblock_id']);
|
||||
$set('textblock', KontoTextblock::where('id', $data['konto_textblock_id'])->pluck('textblock')->first());
|
||||
}),
|
||||
])
|
||||
->columns(1),
|
||||
])->columns(1),
|
||||
]),
|
||||
]),
|
||||
])->columnSpanFull(),
|
||||
|
||||
Reference in new issue
Block a user