big change Inhaltstabelle und PDF

This commit is contained in:
salam committed 2025-11-03 18:14:46 +01:00
1 parent 2f6ae7e4a1
commit d5d1f743bb
58 files changed
+1244 -922

No files matched your search

@@ -3,9 +3,9 @@
namespace App\Filament\Resources\Projektes\RelationManagers;
use App\Actions\Create\CreateProjektInhaltsverzeichnis;
use App\Models\Inhaltselement;
use App\Models\KontoTextblock;
use App\Models\ProjektInhaltsverzeichnis;
use App\Models\Tabellen;
use Filament\Actions\Action;
use Filament\Actions\BulkActionGroup;
use Filament\Actions\CreateAction;
@@ -29,7 +29,6 @@ use Filament\Tables\Columns\IconColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Filters\SelectFilter;
use Filament\Tables\Table;
use Illuminate\Support\HtmlString;
class ProjektInhaltsverzeichnisRelationManager extends RelationManager
{
@@ -50,23 +49,19 @@ class ProjektInhaltsverzeichnisRelationManager extends RelationManager
Tabs::make('Tabs')
->tabs([
Tab::make('Überschrift')
->hidden(fn ($record) => $record?->name == 'DECKBLATT' ? true : false)
// ->hidden(fn ($record) => $record?->name == 'DECKBLATT' ? true : false)
->schema([
Checkbox::make('neue_seite')
->label('Start neuer Seite'),
Checkbox::make('ueberschrift_anzeigen')
->label('Überschrift angezeigen'),
// Checkbox::make('ueberschrift_anzeigen')
// ->label('Überschrift angezeigen'),
Textarea::make('name')
->required()
->label('Überschrift in der Inhaltsangabe')
->label('Überschrift')
->columnSpan(2),
Textarea::make('name2')
->label('Überschrift im Dokument')
->belowContent([
'Bei abweichender Überschrift im Dokument',
])
->columnSpan(2),
]),
Tab::make('Kapitel Index')
->schema([
TextInput::make('ordnungszahl')
->label('Kapitel Index')
->placeholder('3.21')
@@ -76,6 +71,11 @@ class ProjektInhaltsverzeichnisRelationManager extends RelationManager
'Bei "0" wird der Index im PDF nicht angezeigt',
])
->columnSpan(1),
]),
Tab::make('Seitenzahl')
->schema([
Checkbox::make('seitenzahl_anzeige')
->label('Seitenzahl angezeigen'),
TextInput::make('seite')
->label('Seitenzahl')
->numeric()
@@ -85,16 +85,18 @@ class ProjektInhaltsverzeichnisRelationManager extends RelationManager
])
->columnSpan(1),
]),
Tab::make('Textblock')
->hidden(fn ($record) => in_array($record?->name, ['INHALTSVERZEICHNIS']) ? true : false)
Tab::make('Textblock Abschnitt A')
->schema([
Grid::make()
->columns(6)
->schema([
TextInput::make('textblock_name')
->columnSpan(5)
->label('Textblock Name'),
TextInput::make('konto_textblock_id')->hidden(),
RichEditor::make('textblock')
->hiddenLabel()
->aboveLabel(fn ($record): string => $record?->tabellen_id != 0 ? 'Ausgabe Textblock vor Tabelle' : '')
->aboveLabel(fn ($record): string => $record?->inhaltselement_id != 0 ? 'Ausgabe Textblock vor Tabelle' : '')
->columnSpan(5)
->extraInputAttributes(['style' => 'min-height: 20rem; max-height: 50vh; overflow-y: auto;'])
->toolbarButtons([
@@ -186,23 +188,120 @@ class ProjektInhaltsverzeichnisRelationManager extends RelationManager
])->columns(1),
]),
]),
Tab::make('Tabellen')
->hidden(fn ($record) => in_array($record?->name, ['DECKBLATT']) ? true : false)
Tab::make('Inhalts Elemente')
->schema([
Select::make('tabellen_id')->label('Tabelle')
Select::make('inhaltselement_id')->label('Inhalts Element')
->prefixIcon('phosphor-table')
->prefixIconColor(
fn ($record): string => $record?->tabellen_id == 0 ? 'gray' : 'primary'
)
->default(0)
->options(function () {
$res = Tabellen::all()->pluck('name', 'id')->toArray();
array_unshift($res, 'Ohne Tabelle');
$res = Inhaltselement::all()->pluck('name', 'id')->toArray();
array_push($res, 'Ohne');
return $res;
}),
]),
])->columnSpanFull(),
Tab::make('Textblock Abschnitt B')
->schema([
Grid::make()
->columns(6)
->schema([
TextInput::make('konto_textblock_id')->hidden(),
RichEditor::make('textblock2')
->hiddenLabel()
->aboveLabel(fn ($record): string => $record?->inhaltselement_id != 0 ? 'Ausgabe Textblock vor Tabelle' : '')
->columnSpan(5)
->extraInputAttributes(['style' => 'min-height: 20rem; max-height: 50vh; overflow-y: auto;'])
->toolbarButtons([
['bold', 'italic', 'underline', 'strike', 'subscript', 'superscript', 'horizontalRule', 'table'],
])->floatingToolbars([
'paragraph' => [
'bold', 'italic', 'underline', 'strike', 'subscript', 'superscript',
],
'heading' => [
'h1', 'h2', 'h3',
],
'table' => [
'tableAddColumnBefore', 'tableAddColumnAfter', 'tableDeleteColumn',
'tableAddRowBefore', 'tableAddRowAfter', 'tableDeleteRow',
'tableMergeCells', 'tableSplitCell',
'tableToggleHeaderRow',
'tableDelete',
],
]),
Fieldset::make('')
->contained(false)
->schema([
Action::make('sichern')
->iconButton()
->tooltip('Änderungen in der Vorlage speichern')
->icon('phosphor-floppy-disk')
->schema([
TextInput::make('name')->required()
->label('Ändern sie gegebeben Falls den Namen')
->default(function ($record) {
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) {
return $record?->name;
}),
])
->modalSubmitActionLabel('Sichern')
->tooltip('Neue Vorlage erstellen')
->action(function (array $mountedActions, array $data) {
$record = $mountedActions[0]->getRawData();
$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('laden')
->iconButton()
->icon('phosphor-article')
->schema([
Select::make('konto_textblock_id')
->hiddenLabel()
->searchable()
->options(KontoTextblock::where('konto_id', auth()->user()->konto_id)->pluck('name', 'id'))
->belowLabel([
'Bitte eine Vorlage auswählen',
]),
])
->modalSubmitActionLabel('Einsetzen')
->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),
]),
]),
])->vertical()->columnSpanFull(),
]);
}
@@ -230,27 +329,15 @@ class ProjektInhaltsverzeichnisRelationManager extends RelationManager
default => ''
}),
TextColumn::make('name')
->color('primary')
->wrap()
->searchable()
->description(fn ($record): string => $record->textblock_kennung->name ?? ''),
->searchable(),
IconColumn::make('ueberschrift_anzeigen')
->label('Anzeigen')
->alignCenter()
->tooltip('Überschrift anzeigen')
->color(fn ($state): string => $state ? 'primary' : 'gray')
->icon(fn ($state): string => $state ? 'phosphor-article-ny-times' : ''),
IconColumn::make('textblock')
->color('primary')
->alignCenter()
->icon('phosphor-article')
->tooltip(fn ($record): HtmlString => new HtmlString($record->textblock)),
IconColumn::make('tabellen')
->label('Tabelle')
->color('primary')
->alignCenter()
->icon('phosphor-table')
->tooltip(fn ($record): HtmlString => new HtmlString($record->name)),
TextColumn::make('textblock_name')
->label('Textblock')
->wrap(),
TextColumn::make('inhaltselement.name')
->label('Inhalts Element'),
TextColumn::make('seite')
->alignCenter()
->badge()
@@ -579,6 +579,6 @@ class ProjektObjekteRelationManager extends RelationManager
}
}
return round($sum);
return $sum;
}
}