KontoTextblocksTable
This commit is contained in:
1 parent
ae828ab8f5
commit
eaed59cceb
19 files changed
+532
-97
No files matched your search
@@ -16,7 +16,7 @@ class InhaltsverzeichnisTable
|
||||
TextColumn::make('ordnungszahl')
|
||||
->getStateUsing(fn ($record): string => $record->ordnungszahl == '0' ? '' : number_format($record->ordnungszahl, 2)),
|
||||
TextColumn::make('name')
|
||||
->description(fn ($record): string => $record->textblock_kennung->name ?? ''),
|
||||
->description(fn ($record): string => $record->textblock_kennungs->name ?? ''),
|
||||
TextColumn::make('seite')
|
||||
->alignCenter()
|
||||
->badge()
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\KontoTextblocks;
|
||||
|
||||
use App\Filament\Clusters\Verwaltung\VerwaltungCluster;
|
||||
use App\Filament\Resources\KontoTextblocks\Pages\ListKontoTextblocks;
|
||||
use App\Filament\Resources\KontoTextblocks\Schemas\KontoTextblockForm;
|
||||
use App\Filament\Resources\KontoTextblocks\Tables\KontoTextblocksTable;
|
||||
use App\Models\KontoTextblock;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class KontoTextblockResource extends Resource
|
||||
{
|
||||
protected static ?string $model = KontoTextblock::class;
|
||||
|
||||
protected static ?int $navigationSort = 5;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = 'phosphor-article';
|
||||
|
||||
protected static ?string $cluster = VerwaltungCluster::class;
|
||||
|
||||
protected static ?string $navigationLabel = 'Textblock';
|
||||
|
||||
protected static ?string $modelLabel = 'Textblock';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Textblöcke';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return KontoTextblockForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return KontoTextblocksTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListKontoTextblocks::route('/'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()->where('konto_id', auth()->user()->konto_id);
|
||||
}
|
||||
|
||||
public static function getNavigationBadge(): ?string
|
||||
{
|
||||
return parent::getEloquentQuery()->where('konto_id', auth()->user()->konto_id)->count();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\KontoTextblocks\Pages;
|
||||
|
||||
use App\Filament\Resources\KontoTextblocks\KontoTextblockResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateKontoTextblock extends CreateRecord
|
||||
{
|
||||
protected static string $resource = KontoTextblockResource::class;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\KontoTextblocks\Pages;
|
||||
|
||||
use App\Filament\Resources\KontoTextblocks\KontoTextblockResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditKontoTextblock extends EditRecord
|
||||
{
|
||||
protected static string $resource = KontoTextblockResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\KontoTextblocks\Pages;
|
||||
|
||||
use App\Filament\Resources\KontoTextblocks\KontoTextblockResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListKontoTextblocks extends ListRecords
|
||||
{
|
||||
protected static string $resource = KontoTextblockResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\KontoTextblocks\Schemas;
|
||||
|
||||
use App\Models\TextblockKennung;
|
||||
use Filament\Forms\Components\RichEditor;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class KontoTextblockForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('name')
|
||||
->required(),
|
||||
Textarea::make('beschreibung')
|
||||
->afterLabel('Bei gleichen Textblockarten kann hier der Unterschied kurz angerissen werden.'),
|
||||
Select::make('textblock_kennung_id')
|
||||
->label('Textblock Art')
|
||||
->options(TextblockKennung::pluck('name', 'id')),
|
||||
RichEditor::make('textblock')
|
||||
->toolbarButtons([
|
||||
['bold', 'italic', 'underline', 'strike', 'subscript', 'superscript'],
|
||||
]),
|
||||
])->columns(1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\KontoTextblocks\Tables;
|
||||
|
||||
use App\Models\TextblockKennung;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Support\Enums\FontWeight;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Support\HtmlString;
|
||||
|
||||
class KontoTextblocksTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('textblock_kennung.name')
|
||||
->color('info')
|
||||
->wrap()
|
||||
->description(function ($record) {
|
||||
return new HtmlString($record->beschreibung);
|
||||
}),
|
||||
TextColumn::make('name')
|
||||
->weight(FontWeight::Bold)
|
||||
->wrap()
|
||||
->description(function ($record) {
|
||||
return new HtmlString($record->textblock);
|
||||
})
|
||||
->html(),
|
||||
])
|
||||
->filters([
|
||||
SelectFilter::make('textblock_kennung_id')
|
||||
->label('Textbock Art')
|
||||
->options(function (): array {
|
||||
return TextblockKennung::join('konto_textblocks', 'textblock_kennungs.id', '=', 'konto_textblocks.textblock_kennung_id')
|
||||
->pluck('textblock_kennungs.name', 'textblock_kennungs.id')->toArray();
|
||||
})
|
||||
->preload(),
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -39,13 +39,6 @@ class KontoResource extends Resource
|
||||
return KontosTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
|
||||
+9
-4
@@ -60,6 +60,8 @@ class ProjektInhaltsverzeichnisRelationManager extends RelationManager
|
||||
]),
|
||||
|
||||
Fieldset::make('Vorlagen')
|
||||
->hiddenLabel()
|
||||
->hidden(fn ($record): bool => ! isset($record) || ! $record['textblock_kennung_id'])
|
||||
->schema([
|
||||
Action::make('textblock_sichern')
|
||||
->schema([
|
||||
@@ -76,7 +78,7 @@ class ProjektInhaltsverzeichnisRelationManager extends RelationManager
|
||||
return $record['textblock'];
|
||||
}),
|
||||
TextInput::make('name')->required()
|
||||
->label('Name der Vorlage')
|
||||
->label('Geben sie dem Textblock einen eindeutigen Namen')
|
||||
->validationMessages([
|
||||
'different' => 'Name ist schon in Verwendung bitte verwenden Sie einen eindeutig Namen.',
|
||||
])
|
||||
@@ -85,9 +87,9 @@ class ProjektInhaltsverzeichnisRelationManager extends RelationManager
|
||||
return $record['name'];
|
||||
}),
|
||||
])
|
||||
->modalSubmitActionLabel('Sichern')
|
||||
->icon('phosphor-floppy-disk')
|
||||
->tooltip('Ein veränderter Textblock kann als persönliche Vorlage gespeichert werden.')
|
||||
->hidden(fn ($record): bool => ! $record['textblock_kennung_id'])
|
||||
->color('info')
|
||||
->action(function (array $mountedActions, $data) {
|
||||
|
||||
@@ -106,12 +108,15 @@ class ProjektInhaltsverzeichnisRelationManager extends RelationManager
|
||||
Action::make('textblock_laden')
|
||||
->schema([
|
||||
Radio::make('konto_textblock_id')
|
||||
->label('Personalsierte Vorlagen')
|
||||
->hiddenLabel()
|
||||
->options(function ($record) {
|
||||
return KontoTextblock::where('textblock_kennung_id', $record['textblock_kennung_id'])->where('konto_id', auth()->user()->konto_id)->pluck('name', 'id')->toArray();
|
||||
}),
|
||||
})->belowLabel([
|
||||
'Bitte eine Vorlage auswählen',
|
||||
]),
|
||||
])
|
||||
->icon('phosphor-article')
|
||||
->modalSubmitActionLabel('Einsetzen')
|
||||
->color('info')
|
||||
->tooltip('Personaliserten Texblock laden.')
|
||||
->action(function (Set $set, array $data) {
|
||||
|
||||
Reference in new issue
Block a user