Zeige im Katalog, wie Inhalte, Pakete und Rechte zusammenhängen.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
fa706e5080
commit
cd79fb99d7
22 files changed
+1066
-200
No files matched your search
@@ -4,11 +4,17 @@
|
||||
|
||||
use App\Domain\Catalog\Bundle;
|
||||
use App\Filament\Resources\Bundles\Pages\ListBundles;
|
||||
use App\Filament\Resources\Bundles\Pages\ViewBundle;
|
||||
use App\Filament\Resources\LicenseArticles\LicenseArticleResource;
|
||||
use App\Filament\Support\CatalogReading;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Auth\Access\Response;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class BundleResource extends Resource
|
||||
{
|
||||
@@ -24,11 +30,32 @@ class BundleResource extends Resource
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
protected static ?int $navigationSort = 2;
|
||||
|
||||
public static function canViewAny(): bool
|
||||
{
|
||||
return LicenseArticleResource::keeper();
|
||||
}
|
||||
|
||||
public static function getViewAuthorizationResponse(Model $record): Response
|
||||
{
|
||||
return LicenseArticleResource::keeper() ? Response::allow() : Response::deny();
|
||||
}
|
||||
|
||||
public static function infolist(Schema $schema): Schema
|
||||
{
|
||||
return $schema->components([
|
||||
Section::make('Bestandteile')->description('Was diese Fassung direkt enthält.')->schema([
|
||||
TextEntry::make('parts')->hiddenLabel()->listWithLineBreaks()
|
||||
->state(fn (Bundle $record): array => app(CatalogReading::class)->bundleParts($record)),
|
||||
]),
|
||||
Section::make('Aufgelöste Lizenzartikel')->description('Darauf werden beim Erwerb die Berechtigungen vergeben.')->schema([
|
||||
TextEntry::make('articles')->hiddenLabel()->listWithLineBreaks()
|
||||
->state(fn (Bundle $record): array => app(CatalogReading::class)->bundleArticles($record)),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema;
|
||||
@@ -39,13 +66,14 @@ 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('/'),
|
||||
'view' => ViewBundle::route('/{record}'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -2,17 +2,13 @@
|
||||
|
||||
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;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
|
||||
class ListBundles extends ListRecords
|
||||
{
|
||||
@@ -20,6 +16,11 @@ class ListBundles extends ListRecords
|
||||
|
||||
protected static string $resource = BundleResource::class;
|
||||
|
||||
public function getSubheading(): string|Htmlable|null
|
||||
{
|
||||
return 'Ein Paket stellt Lizenzartikel und andere Pakete zusammen. Öffne es, um Bestandteile und die aufgelösten Artikel zu sehen.';
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
@@ -30,29 +31,6 @@ protected function getHeaderActions(): array
|
||||
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,57 @@
|
||||
<?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\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewBundle extends ViewRecord
|
||||
{
|
||||
use ReportsDomainRules;
|
||||
|
||||
protected static string $resource = BundleResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('publish')
|
||||
->label('Fassung veröffentlichen')
|
||||
->schema([
|
||||
CheckboxList::make('articles')->label('Lizenzartikel')->options(fn (): array => CatalogOptions::articles()),
|
||||
CheckboxList::make('bundles')->label('Enthaltene Pakete')
|
||||
->options(function (): array {
|
||||
$options = CatalogOptions::bundles();
|
||||
unset($options[$this->getRecord()->getKey()]);
|
||||
|
||||
return $options;
|
||||
}),
|
||||
])
|
||||
->action(function (array $data): void {
|
||||
$this->report(function () use ($data): void {
|
||||
/** @var Bundle $bundle */
|
||||
$bundle = $this->getRecord();
|
||||
$items = [];
|
||||
|
||||
foreach ($data['articles'] ?? [] as $id) {
|
||||
$items[] = LicenseArticle::query()->findOrFail($id);
|
||||
}
|
||||
|
||||
foreach ($data['bundles'] ?? [] as $id) {
|
||||
$items[] = Bundle::query()->findOrFail($id);
|
||||
}
|
||||
|
||||
app(BundleService::class)->publish($bundle, $items);
|
||||
}, 'Die Paketfassung ist veröffentlicht.');
|
||||
$this->getRecord()->unsetRelations();
|
||||
$this->getRecord()->refresh();
|
||||
}),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -4,17 +4,23 @@
|
||||
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Filament\Resources\Compositions\Pages\ListCompositions;
|
||||
use App\Filament\Resources\Compositions\Pages\ViewComposition;
|
||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||
use App\Filament\Support\CatalogReading;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Auth\Access\Response;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class CompositionResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Composition::class;
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Redaktion';
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Inhalte';
|
||||
|
||||
protected static ?string $navigationLabel = 'Kompositionen';
|
||||
|
||||
@@ -24,11 +30,32 @@ class CompositionResource extends Resource
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'designation';
|
||||
|
||||
protected static ?int $navigationSort = 2;
|
||||
|
||||
public static function canViewAny(): bool
|
||||
{
|
||||
return ContentElementResource::editor();
|
||||
}
|
||||
|
||||
public static function getViewAuthorizationResponse(Model $record): Response
|
||||
{
|
||||
return ContentElementResource::editor() ? Response::allow() : Response::deny();
|
||||
}
|
||||
|
||||
public static function infolist(Schema $schema): Schema
|
||||
{
|
||||
return $schema->components([
|
||||
Section::make('Mitglieder')->description('Geordnete Fassungen, keine Kopie der Dateien.')->schema([
|
||||
TextEntry::make('members')->hiddenLabel()->listWithLineBreaks()
|
||||
->state(fn (Composition $record): array => app(CatalogReading::class)->compositionMembers($record)),
|
||||
]),
|
||||
Section::make('Verwendung')->schema([
|
||||
TextEntry::make('usage')->hiddenLabel()->listWithLineBreaks()
|
||||
->state(fn (Composition $record): array => app(CatalogReading::class)->compositionUsage($record)),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema;
|
||||
@@ -39,13 +66,14 @@ 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('/'),
|
||||
'view' => ViewComposition::route('/{record}'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -2,19 +2,14 @@
|
||||
|
||||
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;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
|
||||
class ListCompositions extends ListRecords
|
||||
{
|
||||
@@ -22,6 +17,11 @@ class ListCompositions extends ListRecords
|
||||
|
||||
protected static string $resource = CompositionResource::class;
|
||||
|
||||
public function getSubheading(): string|Htmlable|null
|
||||
{
|
||||
return 'Eine freie Zusammenstellung fertiger Fassungen, zum Beispiel Übung oder Programm. Verkauf und Rechte entstehen erst am Lizenzartikel und am Angebot.';
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
@@ -36,37 +36,6 @@ protected function getHeaderActions(): array
|
||||
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\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\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\ViewRecord;
|
||||
|
||||
class ViewComposition extends ViewRecord
|
||||
{
|
||||
use ReportsDomainRules;
|
||||
|
||||
protected static string $resource = CompositionResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('publish')
|
||||
->label('Fassung veröffentlichen')
|
||||
->schema([
|
||||
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 {
|
||||
/** @var Composition $composition */
|
||||
$composition = $this->getRecord();
|
||||
$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,
|
||||
$members,
|
||||
auth()->user(),
|
||||
$data['note'] ?? null,
|
||||
);
|
||||
}, 'Die Kompositionsfassung ist bestätigt und bereit.');
|
||||
$this->getRecord()->unsetRelations();
|
||||
$this->getRecord()->refresh();
|
||||
}),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -5,18 +5,24 @@
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Identity\StaffRole;
|
||||
use App\Filament\Resources\ContentElements\Pages\ListContentElements;
|
||||
use App\Filament\Resources\ContentElements\Pages\ViewContentElement;
|
||||
use App\Filament\Support\CatalogReading;
|
||||
use App\Models\User;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Auth\Access\Response;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ContentElementResource extends Resource
|
||||
{
|
||||
protected static ?string $model = ContentElement::class;
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Redaktion';
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Inhalte';
|
||||
|
||||
protected static ?string $navigationLabel = 'Inhaltselemente';
|
||||
|
||||
@@ -26,6 +32,8 @@ class ContentElementResource extends Resource
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'working_title';
|
||||
|
||||
protected static ?int $navigationSort = 1;
|
||||
|
||||
public static function canViewAny(): bool
|
||||
{
|
||||
return self::editor();
|
||||
@@ -38,6 +46,25 @@ public static function editor(): bool
|
||||
return $user instanceof User && $user->hasStaffRole(StaffRole::Redakteur);
|
||||
}
|
||||
|
||||
public static function getViewAuthorizationResponse(Model $record): Response
|
||||
{
|
||||
return self::editor() ? Response::allow() : Response::deny();
|
||||
}
|
||||
|
||||
public static function infolist(Schema $schema): Schema
|
||||
{
|
||||
return $schema->components([
|
||||
Section::make('Fassungen')->schema([
|
||||
TextEntry::make('versions')->hiddenLabel()->listWithLineBreaks()
|
||||
->state(fn (ContentElement $record): array => app(CatalogReading::class)->elementVersions($record)),
|
||||
]),
|
||||
Section::make('Verwendung')->description('Kompositionen und Lizenzartikel, die auf dieses Material zeigen.')->schema([
|
||||
TextEntry::make('usage')->hiddenLabel()->listWithLineBreaks()
|
||||
->state(fn (ContentElement $record): array => app(CatalogReading::class)->elementUsage($record)),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema;
|
||||
@@ -50,13 +77,14 @@ public static function table(Table $table): Table
|
||||
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('/'),
|
||||
'view' => ViewContentElement::route('/{record}'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -2,17 +2,14 @@
|
||||
|
||||
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;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
|
||||
class ListContentElements extends ListRecords
|
||||
{
|
||||
@@ -20,6 +17,11 @@ class ListContentElements extends ListRecords
|
||||
|
||||
protected static string $resource = ContentElementResource::class;
|
||||
|
||||
public function getSubheading(): string|Htmlable|null
|
||||
{
|
||||
return 'Das Material selbst: Film, Text, PDF. Kompositionen und Lizenzartikel verweisen darauf.';
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
@@ -49,26 +51,6 @@ protected function getHeaderActions(): array
|
||||
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,48 @@
|
||||
<?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\ReportsDomainRules;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewContentElement extends ViewRecord
|
||||
{
|
||||
use ReportsDomainRules;
|
||||
|
||||
protected static string $resource = ContentElementResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('version')
|
||||
->label('Fassung veröffentlichen')
|
||||
->schema([
|
||||
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 {
|
||||
/** @var ContentElement $element */
|
||||
$element = $this->getRecord();
|
||||
$metadata = filled($data['incoming'] ?? null) ? ['incoming' => $data['incoming']] : [];
|
||||
app(ContentService::class)->publishElementVersion(
|
||||
$element,
|
||||
$data['body'] ?? null,
|
||||
$metadata,
|
||||
$data['change_note'] ?? null,
|
||||
);
|
||||
}, 'Die Fassung ist gespeichert.');
|
||||
$this->getRecord()->unsetRelations();
|
||||
$this->getRecord()->refresh();
|
||||
}),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -5,12 +5,18 @@
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Domain\Identity\StaffRole;
|
||||
use App\Filament\Resources\LicenseArticles\Pages\ListLicenseArticles;
|
||||
use App\Filament\Resources\LicenseArticles\Pages\ViewLicenseArticle;
|
||||
use App\Filament\Support\CatalogReading;
|
||||
use App\Models\User;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Auth\Access\Response;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class LicenseArticleResource extends Resource
|
||||
{
|
||||
@@ -26,6 +32,8 @@ class LicenseArticleResource extends Resource
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'code';
|
||||
|
||||
protected static ?int $navigationSort = 1;
|
||||
|
||||
public static function canViewAny(): bool
|
||||
{
|
||||
return self::keeper();
|
||||
@@ -38,6 +46,25 @@ public static function keeper(): bool
|
||||
return $user instanceof User && $user->hasStaffRole(StaffRole::Katalogverwalter);
|
||||
}
|
||||
|
||||
public static function getViewAuthorizationResponse(Model $record): Response
|
||||
{
|
||||
return self::keeper() ? Response::allow() : Response::deny();
|
||||
}
|
||||
|
||||
public static function infolist(Schema $schema): Schema
|
||||
{
|
||||
return $schema->components([
|
||||
Section::make('Aktueller Stand')->schema([
|
||||
TextEntry::make('stand')->hiddenLabel()->listWithLineBreaks()
|
||||
->state(fn (LicenseArticle $record): array => app(CatalogReading::class)->articleStand($record)),
|
||||
]),
|
||||
Section::make('Pakete und Angebote')->description('Wo dieser Artikel lizenziert wird.')->schema([
|
||||
TextEntry::make('context')->hiddenLabel()->listWithLineBreaks()
|
||||
->state(fn (LicenseArticle $record): array => app(CatalogReading::class)->articleContext($record)),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema;
|
||||
@@ -49,13 +76,14 @@ public static function table(Table $table): Table
|
||||
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('/'),
|
||||
'view' => ViewLicenseArticle::route('/{record}'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -3,17 +3,12 @@
|
||||
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;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
|
||||
class ListLicenseArticles extends ListRecords
|
||||
{
|
||||
@@ -21,6 +16,11 @@ class ListLicenseArticles extends ListRecords
|
||||
|
||||
protected static string $resource = LicenseArticleResource::class;
|
||||
|
||||
public function getSubheading(): string|Htmlable|null
|
||||
{
|
||||
return 'Kleinste lizenzierbare Einheit. Der Stand hält fest, welche Inhalte dazugehören. Pakete und Angebote verweisen auf den Artikel, sie kopieren ihn nicht.';
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
@@ -35,54 +35,6 @@ protected function getHeaderActions(): array
|
||||
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): string {
|
||||
[$type, $id] = explode(':', $data['root'], 2);
|
||||
$root = $type === 'composition'
|
||||
? CompositionVersion::query()->findOrFail($id)
|
||||
: ContentElementVersion::query()->findOrFail($id);
|
||||
$release = app(ArticleService::class)->publishRelease(
|
||||
LicenseArticle::query()->findOrFail($data['article_id']),
|
||||
$root,
|
||||
$data['classification'],
|
||||
$data['change_note'] ?? null,
|
||||
);
|
||||
$report = $release->impact_report ?? [];
|
||||
$offers = $report['offers'] ?? [];
|
||||
|
||||
return 'Stand '.$release->number.' ist veröffentlicht. Inhalte: '.($report['contents'] ?? 0)
|
||||
.', Inhaber: '.($report['holders'] ?? 0)
|
||||
.', Angebote: '.(implode(', ', $offers) !== '' ? implode(', ', $offers) : 'keins').'.';
|
||||
}, 'Der Artikel-Stand ist veröffentlicht.');
|
||||
}),
|
||||
Action::make('withdraw')
|
||||
->label('Stand zurückziehen')
|
||||
->schema([
|
||||
Select::make('article_id')->label('Artikel')->options(fn (): array => CatalogOptions::articles())->required(),
|
||||
Textarea::make('reason')->label('Begründung')->required(),
|
||||
])
|
||||
->action(function (array $data): void {
|
||||
$this->report(function () use ($data): string {
|
||||
$result = app(ArticleService::class)->withdraw(
|
||||
LicenseArticle::query()->findOrFail($data['article_id']),
|
||||
$data['reason'],
|
||||
);
|
||||
$current = $result['fallback_number'] === null
|
||||
? 'Es gibt keinen früheren Stand.'
|
||||
: 'Aktuell ist wieder Stand '.$result['fallback_number'].'.';
|
||||
$holders = $result['holders'] === [] ? 'niemand' : implode(', ', $result['holders']);
|
||||
|
||||
return 'Der Stand ist zurückgezogen. '.$current.' Betroffen: '.$holders.'.';
|
||||
}, 'Der Stand ist zurückgezogen.');
|
||||
}),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
<?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\ViewRecord;
|
||||
|
||||
class ViewLicenseArticle extends ViewRecord
|
||||
{
|
||||
use ReportsDomainRules;
|
||||
|
||||
protected static string $resource = LicenseArticleResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('release')
|
||||
->label('Stand veröffentlichen')
|
||||
->schema([
|
||||
Select::make('root')->label('Wurzel')->options(fn (): array => CatalogOptions::readyTargets())->required(),
|
||||
Textarea::make('classification')->label('Einordnung')->required()
|
||||
->helperText('Warum dies derselbe Lizenzartikel bleibt und kein neues Produkt ist.'),
|
||||
TextInput::make('change_note')->label('Änderungshinweis'),
|
||||
])
|
||||
->action(function (array $data): void {
|
||||
$this->report(function () use ($data): string {
|
||||
/** @var LicenseArticle $article */
|
||||
$article = $this->getRecord();
|
||||
[$type, $id] = explode(':', $data['root'], 2);
|
||||
$root = $type === 'composition'
|
||||
? CompositionVersion::query()->findOrFail($id)
|
||||
: ContentElementVersion::query()->findOrFail($id);
|
||||
$release = app(ArticleService::class)->publishRelease(
|
||||
$article,
|
||||
$root,
|
||||
$data['classification'],
|
||||
$data['change_note'] ?? null,
|
||||
);
|
||||
$report = $release->impact_report ?? [];
|
||||
$offers = $report['offers'] ?? [];
|
||||
|
||||
return 'Stand '.$release->number.' ist veröffentlicht. Inhalte: '.($report['contents'] ?? 0)
|
||||
.', Inhaber: '.($report['holders'] ?? 0)
|
||||
.', Angebote: '.(implode(', ', $offers) !== '' ? implode(', ', $offers) : 'keins').'.';
|
||||
}, 'Der Artikel-Stand ist veröffentlicht.');
|
||||
$this->refreshRecord();
|
||||
}),
|
||||
Action::make('withdraw')
|
||||
->label('Stand zurückziehen')
|
||||
->schema([
|
||||
Textarea::make('reason')->label('Begründung')->required(),
|
||||
])
|
||||
->action(function (array $data): void {
|
||||
$this->report(function () use ($data): string {
|
||||
$result = app(ArticleService::class)->withdraw($this->getRecord(), $data['reason']);
|
||||
$current = $result['fallback_number'] === null
|
||||
? 'Es gibt keinen früheren Stand.'
|
||||
: 'Aktuell ist wieder Stand '.$result['fallback_number'].'.';
|
||||
$holders = $result['holders'] === [] ? 'niemand' : implode(', ', $result['holders']);
|
||||
|
||||
return 'Der Stand ist zurückgezogen. '.$current.' Betroffen: '.$holders.'.';
|
||||
}, 'Der Stand ist zurückgezogen.');
|
||||
$this->refreshRecord();
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
private function refreshRecord(): void
|
||||
{
|
||||
$this->getRecord()->unsetRelations();
|
||||
$this->getRecord()->refresh();
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,16 @@
|
||||
use App\Domain\Catalog\Offer;
|
||||
use App\Filament\Resources\LicenseArticles\LicenseArticleResource;
|
||||
use App\Filament\Resources\Offers\Pages\ListOffers;
|
||||
use App\Filament\Resources\Offers\Pages\ViewOffer;
|
||||
use App\Filament\Support\CatalogReading;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Auth\Access\Response;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class OfferResource extends Resource
|
||||
{
|
||||
@@ -24,11 +30,32 @@ class OfferResource extends Resource
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
protected static ?int $navigationSort = 4;
|
||||
|
||||
public static function canViewAny(): bool
|
||||
{
|
||||
return LicenseArticleResource::keeper();
|
||||
}
|
||||
|
||||
public static function getViewAuthorizationResponse(Model $record): Response
|
||||
{
|
||||
return LicenseArticleResource::keeper() ? Response::allow() : Response::deny();
|
||||
}
|
||||
|
||||
public static function infolist(Schema $schema): Schema
|
||||
{
|
||||
return $schema->components([
|
||||
Section::make('Positionen')->description('Was angeboten wird, mit welchem Rechteprofil.')->schema([
|
||||
TextEntry::make('positions')->hiddenLabel()->listWithLineBreaks()
|
||||
->state(fn (Offer $record): array => app(CatalogReading::class)->offerPositions($record)),
|
||||
]),
|
||||
Section::make('Aufgelöste Berechtigungen')->description('Diese Artikel-Rechte entstehen beim Erwerb.')->schema([
|
||||
TextEntry::make('grants')->hiddenLabel()->listWithLineBreaks()
|
||||
->state(fn (Offer $record): array => app(CatalogReading::class)->offerGrants($record)),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema;
|
||||
@@ -39,13 +66,14 @@ 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('/'),
|
||||
'view' => ViewOffer::route('/{record}'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -2,20 +2,13 @@
|
||||
|
||||
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;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
|
||||
class ListOffers extends ListRecords
|
||||
{
|
||||
@@ -23,6 +16,11 @@ class ListOffers extends ListRecords
|
||||
|
||||
protected static string $resource = OfferResource::class;
|
||||
|
||||
public function getSubheading(): string|Htmlable|null
|
||||
{
|
||||
return 'Ein Angebot verbindet Artikel oder eine Paketfassung mit einem Rechteprofil. Die aufgelösten Berechtigungen stehen auf der Angebotsseite.';
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
@@ -33,46 +31,6 @@ protected function getHeaderActions(): array
|
||||
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,75 @@
|
||||
<?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\ViewRecord;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
|
||||
class ViewOffer extends ViewRecord
|
||||
{
|
||||
use ReportsDomainRules;
|
||||
|
||||
protected static string $resource = OfferResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('activate')->label('Fassung aktivieren')->schema([
|
||||
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()
|
||||
->helperText('Nur bei einem Kauf. 500 bedeutet 5,00 €.'),
|
||||
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 {
|
||||
/** @var Offer $offer */
|
||||
$offer = $this->getRecord();
|
||||
$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, $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.');
|
||||
$this->getRecord()->unsetRelations();
|
||||
$this->getRecord()->refresh();
|
||||
}),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
|
||||
class ListRightsProfiles extends ListRecords
|
||||
{
|
||||
@@ -17,6 +18,11 @@ class ListRightsProfiles extends ListRecords
|
||||
|
||||
protected static string $resource = RightsProfileResource::class;
|
||||
|
||||
public function getSubheading(): string|Htmlable|null
|
||||
{
|
||||
return 'Ein Rechteprofil beschreibt den Zweck und die erlaubten Handlungen. Es wird nicht verkauft; ein Angebot verbindet es mit Artikeln.';
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\RightsProfiles\Pages;
|
||||
|
||||
use App\Filament\Resources\RightsProfiles\RightsProfileResource;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewRightsProfile extends ViewRecord
|
||||
{
|
||||
protected static string $resource = RightsProfileResource::class;
|
||||
}
|
||||
@@ -5,10 +5,16 @@
|
||||
use App\Domain\Catalog\RightsProfile;
|
||||
use App\Filament\Resources\LicenseArticles\LicenseArticleResource;
|
||||
use App\Filament\Resources\RightsProfiles\Pages\ListRightsProfiles;
|
||||
use App\Filament\Resources\RightsProfiles\Pages\ViewRightsProfile;
|
||||
use App\Filament\Support\CatalogReading;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Auth\Access\Response;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class RightsProfileResource extends Resource
|
||||
{
|
||||
@@ -24,11 +30,28 @@ class RightsProfileResource extends Resource
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
protected static ?int $navigationSort = 3;
|
||||
|
||||
public static function canViewAny(): bool
|
||||
{
|
||||
return LicenseArticleResource::keeper();
|
||||
}
|
||||
|
||||
public static function getViewAuthorizationResponse(Model $record): Response
|
||||
{
|
||||
return LicenseArticleResource::keeper() ? Response::allow() : Response::deny();
|
||||
}
|
||||
|
||||
public static function infolist(Schema $schema): Schema
|
||||
{
|
||||
return $schema->components([
|
||||
Section::make('Fähigkeiten')->description('Zweck und erlaubte Handlungen. Angebote verwenden diese Fassung.')->schema([
|
||||
TextEntry::make('rights')->hiddenLabel()->listWithLineBreaks()
|
||||
->state(fn (RightsProfile $record): array => app(CatalogReading::class)->rights($record)),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema;
|
||||
@@ -39,13 +62,14 @@ 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('/'),
|
||||
'view' => ViewRightsProfile::route('/{record}'),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user