Öffne Katalog, Bibliothek und Testkauf für den MVP.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
463851d402
commit
fd6860efda
51 files changed
+2331
-31
No files matched your search
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Compositions;
|
||||
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Filament\Resources\Compositions\Pages\ListCompositions;
|
||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class CompositionResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Composition::class;
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Redaktion';
|
||||
|
||||
protected static ?string $navigationLabel = 'Kompositionen';
|
||||
|
||||
protected static ?string $modelLabel = 'Komposition';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Kompositionen';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'designation';
|
||||
|
||||
public static function canViewAny(): bool
|
||||
{
|
||||
return ContentElementResource::editor();
|
||||
}
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema;
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table->columns([
|
||||
TextColumn::make('designation')->label('Bezeichnung')->searchable(),
|
||||
TextColumn::make('versions_count')->counts('versions')->label('Fassungen'),
|
||||
])->recordUrl(null);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListCompositions::route('/'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Compositions\Pages;
|
||||
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\CompositionVersion;
|
||||
use App\Domain\Catalog\ContentElementVersion;
|
||||
use App\Domain\Catalog\ContentService;
|
||||
use App\Filament\Resources\Compositions\CompositionResource;
|
||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||
use App\Filament\Support\CatalogOptions;
|
||||
use App\Filament\Support\ReportsDomainRules;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\Repeater;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListCompositions extends ListRecords
|
||||
{
|
||||
use ReportsDomainRules;
|
||||
|
||||
protected static string $resource = CompositionResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('create')
|
||||
->label('Komposition anlegen')
|
||||
->visible(fn (): bool => ContentElementResource::editor())
|
||||
->schema([
|
||||
TextInput::make('designation')->label('Bezeichnung')->required(),
|
||||
])
|
||||
->action(function (array $data): void {
|
||||
$this->report(function () use ($data): void {
|
||||
app(ContentService::class)->createComposition($data['designation']);
|
||||
}, 'Die Komposition ist angelegt.');
|
||||
}),
|
||||
Action::make('publish')
|
||||
->label('Fassung veröffentlichen')
|
||||
->visible(fn (): bool => ContentElementResource::editor())
|
||||
->schema([
|
||||
Select::make('composition_id')->label('Komposition')->options(fn (): array => CatalogOptions::compositions())->required(),
|
||||
Repeater::make('members')->label('Mitglieder')->schema([
|
||||
TextInput::make('role')->label('Rolle')->required(),
|
||||
Select::make('target')->label('Fassung')->options(fn (): array => CatalogOptions::readyTargets())->required(),
|
||||
])->minItems(1),
|
||||
TextInput::make('note')->label('Bestätigungsnotiz'),
|
||||
])
|
||||
->action(function (array $data): void {
|
||||
$this->report(function () use ($data): void {
|
||||
$members = [];
|
||||
|
||||
foreach ($data['members'] as $member) {
|
||||
[$type, $id] = explode(':', $member['target'], 2);
|
||||
$target = $type === 'composition'
|
||||
? CompositionVersion::query()->findOrFail($id)
|
||||
: ContentElementVersion::query()->findOrFail($id);
|
||||
$members[] = ['role' => $member['role'], 'target' => $target];
|
||||
}
|
||||
|
||||
app(ContentService::class)->publishComposition(
|
||||
Composition::query()->findOrFail($data['composition_id']),
|
||||
$members,
|
||||
auth()->user(),
|
||||
$data['note'] ?? null,
|
||||
);
|
||||
}, 'Die Kompositionsfassung ist bestätigt und bereit.');
|
||||
}),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user