Ö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\Bundles;
|
||||
|
||||
use App\Domain\Catalog\Bundle;
|
||||
use App\Filament\Resources\Bundles\Pages\ListBundles;
|
||||
use App\Filament\Resources\LicenseArticles\LicenseArticleResource;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class BundleResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Bundle::class;
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Katalog';
|
||||
|
||||
protected static ?string $navigationLabel = 'Pakete';
|
||||
|
||||
protected static ?string $modelLabel = 'Paket';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Pakete';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
public static function canViewAny(): bool
|
||||
{
|
||||
return LicenseArticleResource::keeper();
|
||||
}
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema;
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table->columns([
|
||||
TextColumn::make('name')->label('Name')->searchable(),
|
||||
TextColumn::make('versions_count')->counts('versions')->label('Fassungen'),
|
||||
])->recordUrl(null);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListBundles::route('/'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Bundles\Pages;
|
||||
|
||||
use App\Domain\Catalog\Bundle;
|
||||
use App\Domain\Catalog\BundleService;
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Filament\Resources\Bundles\BundleResource;
|
||||
use App\Filament\Support\CatalogOptions;
|
||||
use App\Filament\Support\ReportsDomainRules;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\CheckboxList;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListBundles extends ListRecords
|
||||
{
|
||||
use ReportsDomainRules;
|
||||
|
||||
protected static string $resource = BundleResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('create')->label('Paket anlegen')->schema([
|
||||
TextInput::make('name')->label('Name')->required(),
|
||||
])->action(function (array $data): void {
|
||||
$this->report(function () use ($data): void {
|
||||
app(BundleService::class)->create($data['name']);
|
||||
}, 'Das Paket ist angelegt.');
|
||||
}),
|
||||
Action::make('publish')->label('Fassung veröffentlichen')->schema([
|
||||
Select::make('bundle_id')->label('Paket')->options(fn (): array => CatalogOptions::bundles())->required(),
|
||||
CheckboxList::make('articles')->label('Lizenzartikel')->options(fn (): array => CatalogOptions::articles()),
|
||||
CheckboxList::make('bundles')->label('Enthaltene Pakete')->options(fn (): array => CatalogOptions::bundles()),
|
||||
])->action(function (array $data): void {
|
||||
$this->report(function () use ($data): void {
|
||||
$items = [];
|
||||
|
||||
foreach ($data['articles'] ?? [] as $id) {
|
||||
$items[] = LicenseArticle::query()->findOrFail($id);
|
||||
}
|
||||
|
||||
foreach ($data['bundles'] ?? [] as $id) {
|
||||
if ((int) $id === (int) $data['bundle_id']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$items[] = Bundle::query()->findOrFail($id);
|
||||
}
|
||||
|
||||
app(BundleService::class)->publish(Bundle::query()->findOrFail($data['bundle_id']), $items);
|
||||
}, 'Die Paketfassung ist veröffentlicht.');
|
||||
}),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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.');
|
||||
}),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ContentElements;
|
||||
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Identity\StaffRole;
|
||||
use App\Filament\Resources\ContentElements\Pages\ListContentElements;
|
||||
use App\Models\User;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class ContentElementResource extends Resource
|
||||
{
|
||||
protected static ?string $model = ContentElement::class;
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Redaktion';
|
||||
|
||||
protected static ?string $navigationLabel = 'Inhaltselemente';
|
||||
|
||||
protected static ?string $modelLabel = 'Inhaltselement';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Inhaltselemente';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'working_title';
|
||||
|
||||
public static function canViewAny(): bool
|
||||
{
|
||||
return self::editor();
|
||||
}
|
||||
|
||||
public static function editor(): bool
|
||||
{
|
||||
$user = Filament::auth()->user();
|
||||
|
||||
return $user instanceof User && $user->hasStaffRole(StaffRole::Redakteur);
|
||||
}
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema;
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table->columns([
|
||||
TextColumn::make('working_title')->label('Arbeitstitel')->searchable(),
|
||||
TextColumn::make('kind')->label('Art'),
|
||||
TextColumn::make('output_class')->label('Ausgabeklasse'),
|
||||
TextColumn::make('versions_count')->counts('versions')->label('Fassungen'),
|
||||
])->recordUrl(null);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListContentElements::route('/'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ContentElements\Pages;
|
||||
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\ContentService;
|
||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||
use App\Filament\Support\CatalogOptions;
|
||||
use App\Filament\Support\ReportsDomainRules;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListContentElements extends ListRecords
|
||||
{
|
||||
use ReportsDomainRules;
|
||||
|
||||
protected static string $resource = ContentElementResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('create')
|
||||
->label('Element anlegen')
|
||||
->visible(fn (): bool => ContentElementResource::editor())
|
||||
->schema([
|
||||
TextInput::make('working_title')->label('Arbeitstitel')->required(),
|
||||
Select::make('kind')->label('Art')->options([
|
||||
'film' => 'Film',
|
||||
'audio' => 'Audio',
|
||||
'bild' => 'Bild',
|
||||
'pdf' => 'PDF',
|
||||
'text' => 'Text',
|
||||
'aufgabe' => 'Aufgabe',
|
||||
])->required(),
|
||||
Select::make('output_class')->label('Ausgabeklasse')->options([
|
||||
'film' => 'Film',
|
||||
'audio' => 'Audio',
|
||||
'bild' => 'Bild',
|
||||
'pdf' => 'PDF',
|
||||
'text' => 'Text',
|
||||
])->required(),
|
||||
])
|
||||
->action(function (array $data): void {
|
||||
$this->report(function () use ($data): void {
|
||||
app(ContentService::class)->createElement($data['kind'], $data['output_class'], $data['working_title']);
|
||||
}, 'Das Inhaltselement ist angelegt.');
|
||||
}),
|
||||
Action::make('version')
|
||||
->label('Fassung veröffentlichen')
|
||||
->visible(fn (): bool => ContentElementResource::editor())
|
||||
->schema([
|
||||
Select::make('element_id')->label('Element')->options(fn (): array => CatalogOptions::elements())->required(),
|
||||
Textarea::make('body')->label('Text'),
|
||||
FileUpload::make('incoming')->label('Datei')->disk('cms_incoming')->directory('inhalte'),
|
||||
TextInput::make('change_note')->label('Änderungsnotiz'),
|
||||
])
|
||||
->action(function (array $data): void {
|
||||
$this->report(function () use ($data): void {
|
||||
$metadata = filled($data['incoming'] ?? null) ? ['incoming' => $data['incoming']] : [];
|
||||
app(ContentService::class)->publishElementVersion(
|
||||
ContentElement::query()->findOrFail($data['element_id']),
|
||||
$data['body'] ?? null,
|
||||
$metadata,
|
||||
$data['change_note'] ?? null,
|
||||
);
|
||||
}, 'Die Fassung ist gespeichert.');
|
||||
}),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\LicenseArticles;
|
||||
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Domain\Identity\StaffRole;
|
||||
use App\Filament\Resources\LicenseArticles\Pages\ListLicenseArticles;
|
||||
use App\Models\User;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class LicenseArticleResource extends Resource
|
||||
{
|
||||
protected static ?string $model = LicenseArticle::class;
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Katalog';
|
||||
|
||||
protected static ?string $navigationLabel = 'Lizenzartikel';
|
||||
|
||||
protected static ?string $modelLabel = 'Lizenzartikel';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Lizenzartikel';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'code';
|
||||
|
||||
public static function canViewAny(): bool
|
||||
{
|
||||
return self::keeper();
|
||||
}
|
||||
|
||||
public static function keeper(): bool
|
||||
{
|
||||
$user = Filament::auth()->user();
|
||||
|
||||
return $user instanceof User && $user->hasStaffRole(StaffRole::Katalogverwalter);
|
||||
}
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema;
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table->columns([
|
||||
TextColumn::make('code')->label('Kennung')->searchable(),
|
||||
TextColumn::make('product_line')->label('Produktlinie'),
|
||||
TextColumn::make('currentRelease.number')->label('Aktueller Stand'),
|
||||
])->recordUrl(null);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListLicenseArticles::route('/'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\LicenseArticles\Pages;
|
||||
|
||||
use App\Domain\Catalog\ArticleService;
|
||||
use App\Domain\Catalog\CompositionVersion;
|
||||
use App\Domain\Catalog\ContentElementVersion;
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Filament\Resources\LicenseArticles\LicenseArticleResource;
|
||||
use App\Filament\Support\CatalogOptions;
|
||||
use App\Filament\Support\ReportsDomainRules;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListLicenseArticles extends ListRecords
|
||||
{
|
||||
use ReportsDomainRules;
|
||||
|
||||
protected static string $resource = LicenseArticleResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('create')
|
||||
->label('Artikel anlegen')
|
||||
->schema([
|
||||
TextInput::make('code')->label('Kennung')->required(),
|
||||
TextInput::make('product_line')->label('Produktlinie'),
|
||||
])
|
||||
->action(function (array $data): void {
|
||||
$this->report(function () use ($data): void {
|
||||
app(ArticleService::class)->create($data['code'], $data['product_line'] ?? null);
|
||||
}, 'Der Lizenzartikel ist angelegt.');
|
||||
}),
|
||||
Action::make('release')
|
||||
->label('Stand veröffentlichen')
|
||||
->schema([
|
||||
Select::make('article_id')->label('Artikel')->options(fn (): array => CatalogOptions::articles())->required(),
|
||||
Select::make('root')->label('Wurzel')->options(fn (): array => CatalogOptions::readyTargets())->required(),
|
||||
Textarea::make('classification')->label('Einordnung')->required(),
|
||||
TextInput::make('change_note')->label('Änderungshinweis'),
|
||||
])
|
||||
->action(function (array $data): void {
|
||||
$this->report(function () use ($data): void {
|
||||
[$type, $id] = explode(':', $data['root'], 2);
|
||||
$root = $type === 'composition'
|
||||
? CompositionVersion::query()->findOrFail($id)
|
||||
: ContentElementVersion::query()->findOrFail($id);
|
||||
app(ArticleService::class)->publishRelease(
|
||||
LicenseArticle::query()->findOrFail($data['article_id']),
|
||||
$root,
|
||||
$data['classification'],
|
||||
$data['change_note'] ?? null,
|
||||
);
|
||||
}, 'Der Artikel-Stand ist veröffentlicht.');
|
||||
}),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Offers;
|
||||
|
||||
use App\Domain\Catalog\Offer;
|
||||
use App\Filament\Resources\LicenseArticles\LicenseArticleResource;
|
||||
use App\Filament\Resources\Offers\Pages\ListOffers;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class OfferResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Offer::class;
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Katalog';
|
||||
|
||||
protected static ?string $navigationLabel = 'Angebote';
|
||||
|
||||
protected static ?string $modelLabel = 'Angebot';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Angebote';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
public static function canViewAny(): bool
|
||||
{
|
||||
return LicenseArticleResource::keeper();
|
||||
}
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema;
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table->columns([
|
||||
TextColumn::make('name')->label('Name')->searchable(),
|
||||
TextColumn::make('versions.status')->label('Fassungen')->badge(),
|
||||
])->recordUrl(null);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListOffers::route('/'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Offers\Pages;
|
||||
|
||||
use App\Domain\Catalog\BundleVersion;
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Domain\Catalog\Offer;
|
||||
use App\Domain\Catalog\OfferService;
|
||||
use App\Domain\Catalog\RightsProfileVersion;
|
||||
use App\Filament\Resources\Offers\OfferResource;
|
||||
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;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
|
||||
class ListOffers extends ListRecords
|
||||
{
|
||||
use ReportsDomainRules;
|
||||
|
||||
protected static string $resource = OfferResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('create')->label('Angebot anlegen')->schema([
|
||||
TextInput::make('name')->label('Name')->required(),
|
||||
])->action(function (array $data): void {
|
||||
$this->report(function () use ($data): void {
|
||||
app(OfferService::class)->create($data['name']);
|
||||
}, 'Das Angebot ist angelegt.');
|
||||
}),
|
||||
Action::make('activate')->label('Fassung aktivieren')->schema([
|
||||
Select::make('offer_id')->label('Angebot')->options(fn (): array => CatalogOptions::offers())->required(),
|
||||
Select::make('grant_kind')->label('Vergabe')->options([
|
||||
'kauf' => 'Kauf',
|
||||
'auf_abruf' => 'Auf Abruf',
|
||||
'bei_registrierung' => 'Bei Registrierung',
|
||||
])->required(),
|
||||
TextInput::make('price_cents')->label('Preis in Cent')->numeric(),
|
||||
Repeater::make('lines')->label('Positionen')->schema([
|
||||
Select::make('kind')->label('Ziel')->options([
|
||||
'article' => 'Lizenzartikel',
|
||||
'bundle' => 'Paketfassung',
|
||||
])->required()->live(),
|
||||
Select::make('article_id')->label('Artikel')->options(fn (): array => CatalogOptions::articles())
|
||||
->visible(fn (Get $get): bool => $get('kind') === 'article'),
|
||||
Select::make('bundle_version_id')->label('Paketfassung')->options(fn (): array => CatalogOptions::bundleVersions())
|
||||
->visible(fn (Get $get): bool => $get('kind') === 'bundle'),
|
||||
Select::make('rights_id')->label('Rechte')->options(fn (): array => CatalogOptions::rights())->required(),
|
||||
])->minItems(1),
|
||||
])->action(function (array $data): void {
|
||||
$this->report(function () use ($data): void {
|
||||
$lines = [];
|
||||
|
||||
foreach ($data['lines'] as $line) {
|
||||
$target = $line['kind'] === 'bundle'
|
||||
? BundleVersion::query()->findOrFail($line['bundle_version_id'])
|
||||
: LicenseArticle::query()->findOrFail($line['article_id']);
|
||||
$lines[] = [
|
||||
'target' => $target,
|
||||
'rights' => RightsProfileVersion::query()->findOrFail($line['rights_id']),
|
||||
];
|
||||
}
|
||||
|
||||
app(OfferService::class)->activate(Offer::query()->findOrFail($data['offer_id']), $lines, [
|
||||
'grant_kind' => $data['grant_kind'],
|
||||
'price_cents' => $data['price_cents'] === null || $data['price_cents'] === '' ? null : (int) $data['price_cents'],
|
||||
'holder_kind' => 'person',
|
||||
]);
|
||||
}, 'Die Angebotsfassung ist aktiv.');
|
||||
}),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\RightsProfiles\Pages;
|
||||
|
||||
use App\Domain\Catalog\OfferService;
|
||||
use App\Filament\Resources\RightsProfiles\RightsProfileResource;
|
||||
use App\Filament\Support\ReportsDomainRules;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\CheckboxList;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListRightsProfiles extends ListRecords
|
||||
{
|
||||
use ReportsDomainRules;
|
||||
|
||||
protected static string $resource = RightsProfileResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('create')->label('Rechteprofil anlegen')->schema([
|
||||
TextInput::make('name')->label('Name')->required(),
|
||||
Select::make('purpose')->label('Zweck')->options([
|
||||
'ehrenamtlich' => 'Ehrenamtlich',
|
||||
'kommerziell' => 'Kommerziell',
|
||||
'institutionell' => 'Institutionell',
|
||||
])->required(),
|
||||
CheckboxList::make('capabilities')->label('Fähigkeiten')->options([
|
||||
'film:streamen' => 'Film streamen',
|
||||
'film:ansehen' => 'Film ansehen',
|
||||
'audio:streamen' => 'Audio streamen',
|
||||
'pdf:ansehen' => 'PDF ansehen',
|
||||
'pdf:laden' => 'PDF laden',
|
||||
'text:ansehen' => 'Text ansehen',
|
||||
'bild:ansehen' => 'Bild ansehen',
|
||||
])->required(),
|
||||
])->action(function (array $data): void {
|
||||
$this->report(function () use ($data): void {
|
||||
$capabilities = [];
|
||||
|
||||
foreach ($data['capabilities'] as $entry) {
|
||||
[$class, $action] = explode(':', $entry, 2);
|
||||
$capabilities[$class][] = $action;
|
||||
}
|
||||
|
||||
app(OfferService::class)->createRightsProfile($data['name'], $data['purpose'], $capabilities);
|
||||
}, 'Das Rechteprofil ist angelegt.');
|
||||
}),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\RightsProfiles;
|
||||
|
||||
use App\Domain\Catalog\RightsProfile;
|
||||
use App\Filament\Resources\LicenseArticles\LicenseArticleResource;
|
||||
use App\Filament\Resources\RightsProfiles\Pages\ListRightsProfiles;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class RightsProfileResource extends Resource
|
||||
{
|
||||
protected static ?string $model = RightsProfile::class;
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Katalog';
|
||||
|
||||
protected static ?string $navigationLabel = 'Rechteprofile';
|
||||
|
||||
protected static ?string $modelLabel = 'Rechteprofil';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Rechteprofile';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
public static function canViewAny(): bool
|
||||
{
|
||||
return LicenseArticleResource::keeper();
|
||||
}
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema;
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table->columns([
|
||||
TextColumn::make('name')->label('Name')->searchable(),
|
||||
TextColumn::make('versions.purpose')->label('Zwecke')->badge(),
|
||||
])->recordUrl(null);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListRightsProfiles::route('/'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -2,14 +2,53 @@
|
||||
|
||||
namespace App\Filament\Resources\Users\Pages;
|
||||
|
||||
use App\Domain\Catalog\Offer;
|
||||
use App\Domain\Entitlement\GrantIssuer;
|
||||
use App\Domain\Identity\StaffRole;
|
||||
use App\Filament\Resources\Users\UserResource;
|
||||
use App\Filament\Support\CatalogOptions;
|
||||
use App\Filament\Support\ReportsDomainRules;
|
||||
use App\Models\User;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class EditUser extends EditRecord
|
||||
{
|
||||
use ReportsDomainRules;
|
||||
|
||||
protected static string $resource = UserResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('grant')
|
||||
->label('Berechtigung vergeben')
|
||||
->visible(function (): bool {
|
||||
$actor = Filament::auth()->user();
|
||||
|
||||
return $actor instanceof User && $actor->hasStaffRole(StaffRole::Kundenbetreuung);
|
||||
})
|
||||
->schema([
|
||||
Select::make('offer_id')->label('Angebot')->options(fn (): array => CatalogOptions::offers())->required(),
|
||||
Textarea::make('reason')->label('Begründung')->required(),
|
||||
])
|
||||
->action(function (array $data): void {
|
||||
$this->report(function () use ($data): void {
|
||||
app(GrantIssuer::class)->grantManually(
|
||||
$this->record,
|
||||
Offer::query()->findOrFail($data['offer_id']),
|
||||
Filament::auth()->user(),
|
||||
$data['reason'],
|
||||
);
|
||||
}, 'Die Berechtigung ist vergeben.');
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $data
|
||||
* @return array<string, mixed>
|
||||
|
||||
Reference in new issue
Block a user