refactoring into clusters
This commit is contained in:
1 parent
042a5a8b58
commit
48deb69379
97 files changed
+186
-198
No files matched your search
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Administration\Textblocks\Pages;
|
||||
|
||||
use App\Filament\Clusters\Administration\Textblocks\TextblockResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateTextblock extends CreateRecord
|
||||
{
|
||||
protected static string $resource = TextblockResource::class;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Administration\Textblocks\Pages;
|
||||
|
||||
use App\Filament\Clusters\Administration\Textblocks\TextblockResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditTextblock extends EditRecord
|
||||
{
|
||||
protected static string $resource = TextblockResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
// DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Administration\Textblocks\Pages;
|
||||
|
||||
use App\Filament\Clusters\Administration\Textblocks\TextblockResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListTextblocks extends ListRecords
|
||||
{
|
||||
protected static string $resource = TextblockResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make()
|
||||
->icon('phosphor-file-plus')
|
||||
->createAnother(false),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Administration\Textblocks\Schemas;
|
||||
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\RichEditor;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Components\Tabs;
|
||||
use Filament\Schemas\Components\Tabs\Tab;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class TextblockForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Tabs::make('Tabs')
|
||||
->tabs([
|
||||
Tab::make('Inhaltselement')
|
||||
->icon('phosphor-textbox')
|
||||
->schema([
|
||||
TextInput::make('name')
|
||||
->label('Element Name')
|
||||
->afterLabel([
|
||||
'Wird im Gutachten nicht verwendet, dient nur zur Erkennen des Inhaltselements.',
|
||||
])
|
||||
->required(),
|
||||
RichEditor::make('textblock')
|
||||
->label('Abschnitt A')
|
||||
->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',
|
||||
],
|
||||
]),
|
||||
RichEditor::make('textblock2')
|
||||
->label('Abschnitt B')
|
||||
->afterLabel([
|
||||
'Textblock uner der Überschrift.',
|
||||
])
|
||||
->belowContent([
|
||||
'Dieses Feld kann auch leer bleiben. Sollten im selben Punkt des Inhaltsvereichnisses auch eine Tabelle verwendet werden, dann wird dieser Text nach dieser angezeigt.',
|
||||
])
|
||||
->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',
|
||||
],
|
||||
]),
|
||||
]),
|
||||
Tab::make('Benutzer Hilfe')
|
||||
->icon('phosphor-chat-text')
|
||||
->schema([
|
||||
TextInput::make('hilfe_titel')
|
||||
->aboveLabel([
|
||||
'Wird dem Benutzer bei der Bearbeitung dieses Inhaltselements angezeigt.',
|
||||
])
|
||||
->label('Überschrift')
|
||||
->columnSpanFull(),
|
||||
Textarea::make('hilfe_description')
|
||||
->label('Text'),
|
||||
FileUpload::make('hilfe_image')
|
||||
->image()
|
||||
->label('Bild')
|
||||
->disk('public')
|
||||
->maxSize(3072) // 3MB limit
|
||||
->acceptedFileTypes(['image/jpeg', 'image/png', 'image/webp'])
|
||||
->directory('gutachten_hilfe')
|
||||
->visibility('public')
|
||||
->columnSpanFull(),
|
||||
]),
|
||||
]),
|
||||
|
||||
])->columns(1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Administration\Textblocks\Tables;
|
||||
|
||||
use App\Models\Textblock;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Enums\FiltersLayout;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class TextblocksTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->defaultPaginationPageOption(5)
|
||||
->columns([
|
||||
TextColumn::make('name')
|
||||
->description(function ($record) {
|
||||
return view('pages.textblock')->with('record', $record);
|
||||
})
|
||||
->html(),
|
||||
])
|
||||
->deferFilters(false)
|
||||
->filtersFormColumns(3)
|
||||
->filters([
|
||||
SelectFilter::make('id')
|
||||
->label('Textblock')
|
||||
->preload()
|
||||
->default(1)
|
||||
->options(function (): array {
|
||||
return Textblock::pluck('name', 'id')->toArray();
|
||||
}),
|
||||
], layout: FiltersLayout::AboveContent)
|
||||
->persistFiltersInSession()
|
||||
->paginated(false)
|
||||
->recordActions([
|
||||
EditAction::make()->iconButton(),
|
||||
DeleteAction::make()->iconButton(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Administration\Textblocks;
|
||||
|
||||
use App\Filament\Clusters\Administration\AdministrationCluster;
|
||||
use App\Filament\Clusters\Administration\Textblocks\Pages\ListTextblocks;
|
||||
use App\Filament\Clusters\Administration\Textblocks\Schemas\TextblockForm;
|
||||
use App\Filament\Clusters\Administration\Textblocks\Tables\TextblocksTable;
|
||||
use App\Models\Textblock;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Table;
|
||||
use UnitEnum;
|
||||
|
||||
class TextblockResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Textblock::class;
|
||||
|
||||
protected static ?string $cluster = AdministrationCluster::class;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Vorlagen';
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = 'phosphor-article';
|
||||
|
||||
protected static ?string $navigationLabel = 'Textblöcke';
|
||||
|
||||
protected static ?string $modelLabel = 'Textblock';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Textblöcke';
|
||||
|
||||
protected static ?int $navigationSort = 2;
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return TextblockForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return TextblocksTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListTextblocks::route('/'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getNavigationBadge(): ?string
|
||||
{
|
||||
return parent::getEloquentQuery()->count();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user