Ordne Paket, Rechteprofil, Säulen, Kombinationen und Benutzer in die gemeinsamen Muster ein.
- Gemeinsame Katalog-Objektseite (catalog/objekt): Kopf, Hauptabschnitte, Begleitinformation. Angebot, Paket und Rechteprofil nutzen sie; lesbare Bezeichnungen zentral in CatalogLabels. - Paket: eine Maske für erste und geänderte Fassung, bei einer Änderung mit der neuesten veröffentlichten Fassung vorbelegt; Wirkung unverändert BundleService::publish (frühere Fassungen bleiben veröffentlicht). - Rechteprofil: erlaubte Handlungen lesbar, Verwendung in Angeboten, Fassungen; der doppelte Titel „… ansehen ansehen“ entfällt. - Fachliche Säulen, Fachliche Kombinationen und Benutzer in der gemeinsamen Bestandsliste; Säulen mit Website-Zustand und Medienzahl, Konten mit Status und Rollen. - Gefüllte Filament-Hauptknöpfe überall im Verwaltungsgrün (auch Formularfuß, etwa „Speichern“ der Säule). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3aa1bad859
commit
51d58ac55c
14 files changed
+675
-198
No files matched your search
@@ -4,54 +4,194 @@
|
||||
|
||||
use App\Domain\Catalog\Bundle;
|
||||
use App\Domain\Catalog\BundleService;
|
||||
use App\Domain\Catalog\BundleStatus;
|
||||
use App\Domain\Catalog\BundleVersion;
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Domain\Catalog\StatusValue;
|
||||
use App\Filament\Resources\Bundles\BundleResource;
|
||||
use App\Filament\Support\CatalogOptions;
|
||||
use App\Filament\Support\CatalogReading;
|
||||
use App\Filament\Support\ReportsDomainRules;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\CheckboxList;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
use Filament\Schemas\Components\View;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Enums\Width;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
|
||||
/**
|
||||
* Paket in der gemeinsamen Katalog-Objektseite. Erste und geänderte Fassung nutzen dieselbe Maske; eine Änderung
|
||||
* ist mit der neuesten veröffentlichten Fassung vorbelegt. Wirkung unverändert BundleService::publish.
|
||||
*/
|
||||
class ViewBundle extends ViewRecord
|
||||
{
|
||||
use ReportsDomainRules;
|
||||
|
||||
protected static string $resource = BundleResource::class;
|
||||
|
||||
public function getTitle(): string|Htmlable
|
||||
{
|
||||
return (string) $this->getRecord()->name;
|
||||
}
|
||||
|
||||
public function getHeading(): string|Htmlable
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function getBreadcrumbs(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getMaxContentWidth(): Width|string|null
|
||||
{
|
||||
return Width::Full;
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function infolist(Schema $schema): Schema
|
||||
{
|
||||
return $schema->components([
|
||||
View::make('filament.catalog.objekt')->viewData(fn (): array => $this->paketDaten())->columnSpanFull(),
|
||||
])->columns(1);
|
||||
}
|
||||
|
||||
public function publishedVersion(): ?BundleVersion
|
||||
{
|
||||
/** @var Bundle $bundle */
|
||||
$bundle = $this->getRecord();
|
||||
|
||||
return $bundle->versions()
|
||||
->where('status', BundleStatus::Veroeffentlicht)
|
||||
->orderByDesc('number')
|
||||
->with(['items.article', 'items.nestedBundle'])
|
||||
->first();
|
||||
}
|
||||
|
||||
public function publishAction(): Action
|
||||
{
|
||||
return Action::make('publish')
|
||||
->label(fn (): string => $this->publishedVersion() !== null ? 'Geänderte Fassung veröffentlichen' : 'Fassung veröffentlichen')
|
||||
->modalHeading(fn (): string => $this->publishedVersion() !== null
|
||||
? 'Paket ändern: Fassung '.$this->nextNumber().' veröffentlichen'
|
||||
: 'Erste Fassung veröffentlichen')
|
||||
->modalDescription(fn (): string => ($published = $this->publishedVersion()) !== null
|
||||
? 'Die Maske ist mit Fassung '.$published->number.' vorbelegt. Fassung '.$published->number.' bleibt veröffentlicht und unverändert; Angebote verweisen weiter auf die Paketfassung, die sie nennen.'
|
||||
: 'Die gewählten Lizenzartikel und Pakete bilden die erste Fassung. Sie ist danach unveränderlich.')
|
||||
->modalSubmitActionLabel(fn (): string => 'Fassung '.$this->nextNumber().' veröffentlichen')
|
||||
->fillForm(fn (): array => $this->formFromPublished())
|
||||
->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): string {
|
||||
/** @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);
|
||||
}
|
||||
|
||||
$version = app(BundleService::class)->publish($bundle, $items);
|
||||
|
||||
return 'Fassung '.$version->number.' ist veröffentlicht.';
|
||||
}, 'Die Paketfassung ist veröffentlicht.');
|
||||
$this->getRecord()->unsetRelations();
|
||||
$this->getRecord()->refresh();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{articles: list<int>, bundles: list<int>}
|
||||
*/
|
||||
private function formFromPublished(): array
|
||||
{
|
||||
$published = $this->publishedVersion();
|
||||
|
||||
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()]);
|
||||
'articles' => $published?->items->pluck('license_article_id')->filter()->values()->all() ?? [],
|
||||
'bundles' => $published?->items->pluck('nested_bundle_id')->filter()->values()->all() ?? [],
|
||||
];
|
||||
}
|
||||
|
||||
return $options;
|
||||
}),
|
||||
])
|
||||
->action(function (array $data): void {
|
||||
$this->report(function () use ($data): void {
|
||||
/** @var Bundle $bundle */
|
||||
$bundle = $this->getRecord();
|
||||
$items = [];
|
||||
private function nextNumber(): int
|
||||
{
|
||||
return ((int) $this->getRecord()->versions()->max('number')) + 1;
|
||||
}
|
||||
|
||||
foreach ($data['articles'] ?? [] as $id) {
|
||||
$items[] = LicenseArticle::query()->findOrFail($id);
|
||||
}
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function paketDaten(): array
|
||||
{
|
||||
/** @var Bundle $bundle */
|
||||
$bundle = $this->getRecord();
|
||||
$published = $this->publishedVersion();
|
||||
$articles = $published !== null ? app(CatalogReading::class)->bundleArticles($bundle) : [];
|
||||
|
||||
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();
|
||||
}),
|
||||
return [
|
||||
'kopf' => [
|
||||
'brot' => [['label' => 'Pakete', 'href' => BundleResource::getUrl('index')], $bundle->name],
|
||||
'titel' => $bundle->name,
|
||||
'typ' => 'Paket',
|
||||
'status' => $published !== null
|
||||
? ['text' => 'Fassung '.$published->number.' veröffentlicht', 'ton' => 'gut']
|
||||
: ['text' => 'Noch keine veröffentlichte Fassung. Bestandteile werden mit der Fassung festgeschrieben.', 'ton' => 'offen'],
|
||||
'aktionen' => [[
|
||||
'label' => $published !== null ? 'Geänderte Fassung veröffentlichen' : 'Fassung veröffentlichen',
|
||||
'wire' => "mountAction('publish')",
|
||||
'art' => 'primary',
|
||||
]],
|
||||
],
|
||||
'haupt' => [
|
||||
[
|
||||
'titel' => 'Bestandteile',
|
||||
'zusatz' => $published !== null ? 'Fassung '.$published->number : null,
|
||||
'hilfe' => 'Was diese Fassung direkt enthält.',
|
||||
'zeilen' => $published === null ? [] : $published->items->sortBy('position')->map(fn ($item): array => [
|
||||
'text' => $item->article !== null ? 'Lizenzartikel '.$item->article->code : 'Paket '.($item->nestedBundle?->name ?? 'fehlt'),
|
||||
])->values()->all(),
|
||||
'leer' => ['titel' => 'Noch keine Bestandteile', 'text' => 'Mit „Fassung veröffentlichen“ wählst du Lizenzartikel und andere Pakete.'],
|
||||
],
|
||||
...($published !== null ? [[
|
||||
'titel' => 'Aufgelöste Lizenzartikel',
|
||||
'hilfe' => 'Darauf werden beim Erwerb die Berechtigungen vergeben.',
|
||||
'zeilen' => array_map(fn (string $code): array => ['text' => $code], $articles),
|
||||
]] : []),
|
||||
],
|
||||
'seite' => [[
|
||||
'titel' => 'Fassungen',
|
||||
'zeilen' => $bundle->versions()->withCount('items')->orderByDesc('number')->get()->map(fn (BundleVersion $version): array => [
|
||||
'text' => 'Fassung '.$version->number,
|
||||
'zustand' => StatusValue::of($version->status) === BundleStatus::Veroeffentlicht->value
|
||||
? ['label' => 'Veröffentlicht', 'ton' => 'gut']
|
||||
: ['label' => 'Entwurf', 'ton' => 'offen'],
|
||||
'neben' => $version->items_count === 1 ? '1 Bestandteil' : $version->items_count.' Bestandteile',
|
||||
])->all(),
|
||||
'leer' => 'Noch keine Fassung.',
|
||||
'hilfe' => 'Veröffentlichte Fassungen bleiben unverändert; ein Angebot nennt die Paketfassung, auf die es sich bezieht.',
|
||||
]],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -16,8 +16,8 @@
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
|
||||
/**
|
||||
* Listen „Module“ und „Programme“: dieselbe Bestandsliste wie der Arbeitsplatz, mit festem Typ. Fachliche
|
||||
* Kombinationen behalten vorerst ihre Tabelle (Teil B, Abschnitt 3).
|
||||
* Listen „Module“, „Programme“ und „Fachliche Kombinationen“: dieselbe Bestandsliste wie der Arbeitsplatz, mit festem
|
||||
* Typ. Module und Programme teilen den Anlegedialog des Arbeitsplatzes; Kombinationen behalten ihren.
|
||||
*/
|
||||
abstract class ListCompositionKind extends ListRecords
|
||||
{
|
||||
@@ -31,41 +31,39 @@ protected function fixedKind(): ?CompositionKind
|
||||
return $this->kind();
|
||||
}
|
||||
|
||||
private function usesBestand(): bool
|
||||
private function onDesk(): bool
|
||||
{
|
||||
return in_array($this->kind(), [CompositionKind::Kurs, CompositionKind::Uebung], true);
|
||||
}
|
||||
|
||||
public function getSubheading(): string|Htmlable|null
|
||||
{
|
||||
$desk = $this->usesBestand() ? ' Programme und Module stehen gemeinsam auch auf dem Arbeitsplatz.' : '';
|
||||
$desk = $this->onDesk() ? ' Programme und Module stehen gemeinsam auch auf dem Arbeitsplatz.' : '';
|
||||
|
||||
return $this->kind()->deskExplanation().$desk;
|
||||
}
|
||||
|
||||
public function getMaxContentWidth(): Width|string|null
|
||||
{
|
||||
return $this->usesBestand() ? Width::Full : parent::getMaxContentWidth();
|
||||
return Width::Full;
|
||||
}
|
||||
|
||||
public function content(Schema $schema): Schema
|
||||
{
|
||||
if (! $this->usesBestand()) {
|
||||
return parent::content($schema);
|
||||
}
|
||||
|
||||
return $schema->components([View::make('filament.verwaltung.bestand')]);
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
if ($this->usesBestand()) {
|
||||
if ($this->onDesk()) {
|
||||
return [$this->createCompositionAction($this->kind())];
|
||||
}
|
||||
|
||||
return [
|
||||
Action::make('create')
|
||||
->label($this->kind()->createLabel())
|
||||
->modalHeading('Neue '.$this->kind()->label())
|
||||
->modalSubmitActionLabel($this->kind()->createLabel())
|
||||
->visible(fn (): bool => ContentElementResource::editor())
|
||||
->schema([
|
||||
TextInput::make('designation')->label('Bezeichnung')->required(),
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
use App\Domain\Catalog\Offer;
|
||||
use App\Domain\Catalog\OfferService;
|
||||
use App\Domain\Catalog\OfferStatus;
|
||||
use App\Domain\Catalog\OfferVersion;
|
||||
use App\Domain\Catalog\StatusValue;
|
||||
use App\Filament\Resources\Offers\OfferResource;
|
||||
use App\Filament\Support\CatalogLabels;
|
||||
use App\Filament\Support\ListsCatalog;
|
||||
use App\Filament\Support\ReportsDomainRules;
|
||||
use Filament\Actions\Action;
|
||||
@@ -63,7 +63,7 @@ protected function catalogRows(): array
|
||||
|
||||
if ($active !== null) {
|
||||
$chips[] = ['label' => 'Fassung '.$active->number.' aktiv', 'ton' => 'gut'];
|
||||
$chips[] = ['label' => $this->vergabe($active), 'ton' => 'neutral'];
|
||||
$chips[] = ['label' => CatalogLabels::vergabe($active), 'ton' => 'neutral'];
|
||||
$zustand[] = 'aktiv';
|
||||
$text = $active->lines->map(fn ($line): string => ($line->article !== null
|
||||
? 'Lizenzartikel '.$line->article->code
|
||||
@@ -94,18 +94,6 @@ protected function catalogRows(): array
|
||||
return $rows;
|
||||
}
|
||||
|
||||
private function vergabe(OfferVersion $version): string
|
||||
{
|
||||
$kind = match ($version->grant_kind) {
|
||||
'kauf' => 'Kauf',
|
||||
'auf_abruf' => 'Auf Abruf',
|
||||
'bei_registrierung' => 'Bei Registrierung',
|
||||
default => (string) $version->grant_kind,
|
||||
};
|
||||
|
||||
return $version->price_cents === null ? $kind : $kind.' · '.number_format($version->price_cents / 100, 2, ',', '.').' €';
|
||||
}
|
||||
|
||||
protected function zustandOptionen(): array
|
||||
{
|
||||
return ['alle' => 'Jeder Zustand', 'aktiv' => 'Mit aktiver Fassung', 'ohne' => 'Ohne aktive Fassung'];
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
use App\Domain\Catalog\RightsProfileVersion;
|
||||
use App\Domain\Catalog\StatusValue;
|
||||
use App\Filament\Resources\Offers\OfferResource;
|
||||
use App\Filament\Resources\RightsProfiles\Pages\ListRightsProfiles;
|
||||
use App\Filament\Support\CatalogLabels;
|
||||
use App\Filament\Support\CatalogOptions;
|
||||
use App\Filament\Support\ReportsDomainRules;
|
||||
use Filament\Actions\Action;
|
||||
@@ -70,7 +70,7 @@ public function getBreadcrumbs(): array
|
||||
public function infolist(Schema $schema): Schema
|
||||
{
|
||||
return $schema->components([
|
||||
View::make('filament.catalog.angebot')->viewData(fn (): array => $this->angebotDaten())->columnSpanFull(),
|
||||
View::make('filament.catalog.objekt')->viewData(fn (): array => $this->angebotDaten())->columnSpanFull(),
|
||||
])->columns(1);
|
||||
}
|
||||
|
||||
@@ -192,6 +192,8 @@ private function nextNumber(): int
|
||||
}
|
||||
|
||||
/**
|
||||
* Daten der gemeinsamen Katalog-Objektseite.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function angebotDaten(): array
|
||||
@@ -199,64 +201,74 @@ private function angebotDaten(): array
|
||||
/** @var Offer $offer */
|
||||
$offer = $this->getRecord();
|
||||
$active = $this->activeVersion();
|
||||
$versions = $offer->versions()->orderByDesc('number')->get();
|
||||
$vergabe = $active !== null ? CatalogLabels::vergabe($active) : null;
|
||||
|
||||
return [
|
||||
'offer' => $offer,
|
||||
'active' => $active,
|
||||
'grants' => $active !== null ? $this->leistungsumfang($active) : [],
|
||||
'versions' => $versions->map(fn (OfferVersion $version): array => [
|
||||
'number' => $version->number,
|
||||
'status' => match (StatusValue::of($version->status)) {
|
||||
'aktiv' => 'Aktiv',
|
||||
'beendet' => 'Beendet',
|
||||
default => 'Entwurf',
|
||||
},
|
||||
'ton' => match (StatusValue::of($version->status)) {
|
||||
'aktiv' => 'gut',
|
||||
'beendet' => 'leise',
|
||||
default => 'offen',
|
||||
},
|
||||
'vergabe' => $this->vergabe($version),
|
||||
'wann' => $version->activated_at?->format('d.m.Y'),
|
||||
])->all(),
|
||||
'vergabe' => $active !== null ? $this->vergabe($active) : null,
|
||||
'kopf' => [
|
||||
'brot' => [['label' => 'Angebote', 'href' => OfferResource::getUrl('index')], $offer->name],
|
||||
'titel' => $offer->name,
|
||||
'typ' => 'Angebot',
|
||||
'status' => $active !== null
|
||||
? ['text' => 'Fassung '.$active->number.' aktiv · '.$vergabe, 'ton' => 'gut']
|
||||
: ['text' => 'Noch keine aktive Fassung. Ein Angebot ohne aktive Fassung kann niemand erwerben.', 'ton' => 'offen'],
|
||||
'aktionen' => [[
|
||||
'label' => $active !== null ? 'Geänderte Fassung aktivieren' : 'Fassung aktivieren',
|
||||
'wire' => "mountAction('activate')",
|
||||
'art' => 'primary',
|
||||
]],
|
||||
],
|
||||
'haupt' => [
|
||||
[
|
||||
'titel' => 'Positionen',
|
||||
'zusatz' => $active !== null ? 'Fassung '.$active->number : null,
|
||||
'hilfe' => $active !== null ? 'Vergabe: '.$vergabe.'. Diese Fassung ist unveränderlich; eine Änderung aktiviert die nächste Fassung.' : null,
|
||||
'zeilen' => $active === null ? [] : $active->lines->sortBy('position')->map(fn ($line): array => [
|
||||
'text' => $line->article !== null ? 'Lizenzartikel '.$line->article->code : 'Paket '.($line->bundleVersion?->bundle?->name ?? '–').' · Fassung '.($line->bundleVersion?->number ?? '–'),
|
||||
'neben' => 'Rechte: '.($line->rights?->profile?->name ?? '–'),
|
||||
])->values()->all(),
|
||||
'leer' => ['titel' => 'Noch keine Positionen', 'text' => 'Mit „Fassung aktivieren“ legst du fest, welche Lizenzartikel oder Paketfassungen mit welchem Rechteprofil angeboten werden, wie vergeben wird und zu welchem Preis.'],
|
||||
],
|
||||
...($active !== null ? [[
|
||||
'titel' => 'Aufgelöster Leistungsumfang',
|
||||
'hilfe' => 'Diese Artikel-Rechte entstehen beim Erwerb dieser Fassung.',
|
||||
'zeilen' => $this->leistungsumfang($active),
|
||||
'leer' => ['titel' => 'Kein Leistungsumfang', 'text' => 'Diese Fassung hat keinen aufgelösten Leistungsumfang.'],
|
||||
]] : []),
|
||||
],
|
||||
'seite' => [[
|
||||
'titel' => 'Fassungen',
|
||||
'zeilen' => $offer->versions()->orderByDesc('number')->get()->map(fn (OfferVersion $version): array => [
|
||||
'text' => 'Fassung '.$version->number,
|
||||
'zustand' => match (StatusValue::of($version->status)) {
|
||||
'aktiv' => ['label' => 'Aktiv', 'ton' => 'gut'],
|
||||
'beendet' => ['label' => 'Beendet', 'ton' => 'leise'],
|
||||
default => ['label' => 'Entwurf', 'ton' => 'offen'],
|
||||
},
|
||||
'neben' => CatalogLabels::vergabe($version).($version->activated_at ? ' · aktiviert am '.$version->activated_at->format('d.m.Y') : ''),
|
||||
])->all(),
|
||||
'leer' => 'Noch keine Fassung.',
|
||||
'hilfe' => 'Beendete Fassungen bleiben gespeichert; Erwerbe verweisen auf ihre Fassung. Ob ein Angebot künftig auch als Vorlage für ein weiteres dienen soll, ist fachlich noch offen (OFF-04).',
|
||||
]],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Aufgelöster Leistungsumfang in lesbaren Fähigkeiten (dieselben Bezeichnungen wie beim Rechteprofil).
|
||||
*
|
||||
* @return list<string>
|
||||
* @return list<array{text: string, neben: string}>
|
||||
*/
|
||||
private function leistungsumfang(OfferVersion $version): array
|
||||
{
|
||||
$zeilen = [];
|
||||
|
||||
foreach ($version->resolvedScopes()->with(['article', 'rights.profile'])->get() as $scope) {
|
||||
$faehigkeiten = [];
|
||||
|
||||
foreach ($scope->rights?->capabilities ?? [] as $class => $actions) {
|
||||
foreach ((array) $actions as $action) {
|
||||
$faehigkeiten[] = ListRightsProfiles::FAEHIGKEITEN[$class.':'.$action] ?? $class.': '.$action;
|
||||
}
|
||||
}
|
||||
|
||||
$zeilen[] = 'Lizenzartikel '.$scope->article?->code.' · '.($scope->rights?->profile?->name ?? '–').' · '.($faehigkeiten === [] ? 'keine Fähigkeiten' : implode(', ', $faehigkeiten));
|
||||
$faehigkeiten = CatalogLabels::faehigkeiten($scope->rights?->capabilities);
|
||||
$zeilen[] = [
|
||||
'text' => 'Lizenzartikel '.$scope->article?->code,
|
||||
'neben' => ($scope->rights?->profile?->name ?? '–').': '.($faehigkeiten === [] ? 'keine Fähigkeiten' : implode(', ', $faehigkeiten)),
|
||||
];
|
||||
}
|
||||
|
||||
return $zeilen === [] ? ['Diese Fassung hat keinen aufgelösten Leistungsumfang.'] : $zeilen;
|
||||
}
|
||||
|
||||
private function vergabe(OfferVersion $version): string
|
||||
{
|
||||
$kind = match ($version->grant_kind) {
|
||||
'kauf' => 'Kauf',
|
||||
'auf_abruf' => 'Auf Abruf',
|
||||
'bei_registrierung' => 'Bei Registrierung',
|
||||
default => (string) $version->grant_kind,
|
||||
};
|
||||
|
||||
return $version->price_cents === null ? $kind : $kind.' · '.number_format($version->price_cents / 100, 2, ',', '.').' €';
|
||||
return $zeilen;
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,11 @@
|
||||
|
||||
namespace App\Filament\Resources\Pillars\Pages;
|
||||
|
||||
use App\Domain\Catalog\Pillar;
|
||||
use App\Domain\Catalog\PillarService;
|
||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||
use App\Filament\Resources\Pillars\PillarResource;
|
||||
use App\Filament\Support\ListsCatalog;
|
||||
use App\Filament\Support\ReportsDomainRules;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
@@ -13,6 +15,7 @@
|
||||
|
||||
class ListPillars extends ListRecords
|
||||
{
|
||||
use ListsCatalog;
|
||||
use ReportsDomainRules;
|
||||
|
||||
protected static string $resource = PillarResource::class;
|
||||
@@ -27,6 +30,9 @@ protected function getHeaderActions(): array
|
||||
return [
|
||||
Action::make('create')
|
||||
->label('Säule anlegen')
|
||||
->modalHeading('Neue fachliche Säule')
|
||||
->modalDescription('Der Name genügt. Website-Text, Adresse und Veröffentlichung legst du danach fest.')
|
||||
->modalSubmitActionLabel('Säule anlegen')
|
||||
->visible(fn (): bool => ContentElementResource::editor())
|
||||
->schema([
|
||||
TextInput::make('name')->label('Name')->required(),
|
||||
@@ -43,4 +49,45 @@ protected function getHeaderActions(): array
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
protected function catalogRows(): array
|
||||
{
|
||||
$rows = [];
|
||||
|
||||
foreach (Pillar::query()->withCount('elements')->orderBy('sort_order')->orderBy('name')->get() as $pillar) {
|
||||
$public = $pillar->published_at !== null;
|
||||
$url = PillarResource::getUrl('edit', ['record' => $pillar]);
|
||||
$rows[] = [
|
||||
'schluessel' => 's'.$pillar->id,
|
||||
'titel' => $pillar->name,
|
||||
'meta' => 'Fachliche Säule'.(filled($pillar->slug) ? ' · /themen/'.$pillar->slug : ''),
|
||||
'text' => (string) ($pillar->public_summary ?? ''),
|
||||
'symbol' => 'modul',
|
||||
'url' => $url,
|
||||
'chips' => [
|
||||
$public ? ['label' => 'Auf der Website veröffentlicht', 'ton' => 'gut'] : ['label' => 'Intern', 'ton' => 'leise'],
|
||||
['label' => $pillar->elements_count === 1 ? '1 Medium' : $pillar->elements_count.' Medien', 'ton' => 'neutral'],
|
||||
],
|
||||
'zustand' => [$public ? 'oeffentlich' : 'intern'],
|
||||
'aktionen' => [['label' => 'Bearbeiten', 'href' => $url, 'icon' => 'stift']],
|
||||
];
|
||||
}
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
protected function zustandOptionen(): array
|
||||
{
|
||||
return ['alle' => 'Jeder Zustand', 'oeffentlich' => 'Auf der Website veröffentlicht', 'intern' => 'Intern'];
|
||||
}
|
||||
|
||||
protected function einheit(): array
|
||||
{
|
||||
return ['Fachliche Säule', 'Fachliche Säulen'];
|
||||
}
|
||||
|
||||
protected function leer(): array
|
||||
{
|
||||
return ['titel' => 'Noch keine Säulen', 'text' => 'Mit „Säule anlegen“ oben entsteht die erste Säule.'];
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@
|
||||
use App\Domain\Catalog\OfferService;
|
||||
use App\Domain\Catalog\RightsProfile;
|
||||
use App\Filament\Resources\RightsProfiles\RightsProfileResource;
|
||||
use App\Filament\Support\CatalogLabels;
|
||||
use App\Filament\Support\ListsCatalog;
|
||||
use App\Filament\Support\ReportsDomainRules;
|
||||
use Filament\Actions\Action;
|
||||
@@ -19,19 +20,6 @@ class ListRightsProfiles extends ListRecords
|
||||
use ListsCatalog;
|
||||
use ReportsDomainRules;
|
||||
|
||||
/** Lesbare Fähigkeiten; dieselben Werte wie im Anlegedialog. */
|
||||
public const FAEHIGKEITEN = [
|
||||
'film:streamen' => 'Film ansehen',
|
||||
'film:laden' => 'Film herunterladen',
|
||||
'audio:streamen' => 'Hörstück ansehen',
|
||||
'document:ansehen' => 'Dokument ansehen',
|
||||
'document:laden' => 'Dokument herunterladen',
|
||||
'pdf:ansehen' => 'PDF ansehen',
|
||||
'pdf:laden' => 'PDF herunterladen',
|
||||
'text:ansehen' => 'Text ansehen',
|
||||
'bild:ansehen' => 'Bild ansehen',
|
||||
];
|
||||
|
||||
protected static string $resource = RightsProfileResource::class;
|
||||
|
||||
public function getSubheading(): string|Htmlable|null
|
||||
@@ -53,7 +41,7 @@ protected function getHeaderActions(): array
|
||||
'kommerziell' => 'Kommerziell',
|
||||
'institutionell' => 'Institutionell',
|
||||
])->required(),
|
||||
CheckboxList::make('capabilities')->label('Fähigkeiten')->options(self::FAEHIGKEITEN)->required(),
|
||||
CheckboxList::make('capabilities')->label('Fähigkeiten')->options(CatalogLabels::FAEHIGKEITEN)->required(),
|
||||
])->action(function (array $data): void {
|
||||
$this->report(function () use ($data): void {
|
||||
$capabilities = [];
|
||||
@@ -75,20 +63,8 @@ protected function catalogRows(): array
|
||||
|
||||
foreach (RightsProfile::query()->with('versions')->orderBy('name')->get() as $profile) {
|
||||
$version = $profile->versions->sortByDesc('number')->first();
|
||||
$faehigkeiten = [];
|
||||
|
||||
foreach ($version?->capabilities ?? [] as $class => $actions) {
|
||||
foreach ((array) $actions as $action) {
|
||||
$faehigkeiten[] = self::FAEHIGKEITEN[$class.':'.$action] ?? $class.': '.$action;
|
||||
}
|
||||
}
|
||||
|
||||
$purpose = match ((string) $version?->purpose) {
|
||||
'ehrenamtlich' => 'Ehrenamtlich',
|
||||
'kommerziell' => 'Kommerziell',
|
||||
'institutionell' => 'Institutionell',
|
||||
default => (string) $version?->purpose,
|
||||
};
|
||||
$faehigkeiten = CatalogLabels::faehigkeiten($version?->capabilities);
|
||||
$purpose = CatalogLabels::zweck($version?->purpose);
|
||||
$chips = $version === null
|
||||
? [['label' => 'Noch keine Fassung', 'ton' => 'offen']]
|
||||
: [['label' => 'Fassung '.$version->number, 'ton' => 'neutral'], ['label' => $purpose, 'ton' => 'leise']];
|
||||
|
||||
@@ -2,10 +2,119 @@
|
||||
|
||||
namespace App\Filament\Resources\RightsProfiles\Pages;
|
||||
|
||||
use App\Domain\Catalog\OfferLine;
|
||||
use App\Domain\Catalog\OfferStatus;
|
||||
use App\Domain\Catalog\RightsProfile;
|
||||
use App\Domain\Catalog\RightsProfileVersion;
|
||||
use App\Domain\Catalog\StatusValue;
|
||||
use App\Filament\Resources\RightsProfiles\RightsProfileResource;
|
||||
use App\Filament\Support\CatalogLabels;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
use Filament\Schemas\Components\View;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Enums\Width;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
|
||||
/**
|
||||
* Rechteprofil in der gemeinsamen Katalog-Objektseite: Zweck, erlaubte Handlungen und Verwendung in Angeboten.
|
||||
* Ein Rechteprofil wird hier nur gelesen; es gibt keine Bearbeitung.
|
||||
*/
|
||||
class ViewRightsProfile extends ViewRecord
|
||||
{
|
||||
protected static string $resource = RightsProfileResource::class;
|
||||
|
||||
public function getTitle(): string|Htmlable
|
||||
{
|
||||
return (string) $this->getRecord()->name;
|
||||
}
|
||||
|
||||
public function getHeading(): string|Htmlable
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function getBreadcrumbs(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getMaxContentWidth(): Width|string|null
|
||||
{
|
||||
return Width::Full;
|
||||
}
|
||||
|
||||
public function infolist(Schema $schema): Schema
|
||||
{
|
||||
return $schema->components([
|
||||
View::make('filament.catalog.objekt')->viewData(fn (): array => $this->profilDaten())->columnSpanFull(),
|
||||
])->columns(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function profilDaten(): array
|
||||
{
|
||||
/** @var RightsProfile $profile */
|
||||
$profile = $this->getRecord();
|
||||
$versions = $profile->versions()->orderByDesc('number')->get();
|
||||
$current = $versions->first();
|
||||
$faehigkeiten = CatalogLabels::faehigkeiten($current?->capabilities);
|
||||
$optionen = collect($current?->options ?? [])->map(fn (mixed $wert, string $schluessel): array => [
|
||||
'text' => $schluessel,
|
||||
'neben' => is_scalar($wert) ? (string) $wert : json_encode($wert, JSON_UNESCAPED_UNICODE),
|
||||
])->values()->all();
|
||||
$verwendung = OfferLine::query()
|
||||
->whereIn('rights_profile_version_id', $versions->pluck('id'))
|
||||
->with(['offerVersion.offer', 'article', 'bundleVersion.bundle'])
|
||||
->get()
|
||||
->map(fn (OfferLine $line): array => [
|
||||
'text' => ($line->offerVersion?->offer?->name ?? 'Angebot').' · Fassung '.($line->offerVersion?->number ?? '–'),
|
||||
'zustand' => StatusValue::of($line->offerVersion?->status) === OfferStatus::Aktiv->value
|
||||
? ['label' => 'Aktiv', 'ton' => 'gut']
|
||||
: ['label' => StatusValue::of($line->offerVersion?->status) === OfferStatus::Beendet->value ? 'Beendet' : 'Entwurf', 'ton' => 'leise'],
|
||||
'neben' => $line->article !== null ? 'Lizenzartikel '.$line->article->code : 'Paket '.($line->bundleVersion?->bundle?->name ?? '–'),
|
||||
])->all();
|
||||
|
||||
return [
|
||||
'kopf' => [
|
||||
'brot' => [['label' => 'Rechteprofile', 'href' => RightsProfileResource::getUrl('index')], $profile->name],
|
||||
'titel' => $profile->name,
|
||||
'typ' => 'Rechteprofil',
|
||||
'status' => $current === null
|
||||
? ['text' => 'Noch keine Fassung', 'ton' => 'offen']
|
||||
: ['text' => 'Fassung '.$current->number.' · '.CatalogLabels::zweck($current->purpose).($current->locked_at !== null ? ' · festgeschrieben seit '.$current->locked_at->format('d.m.Y') : ''), 'ton' => 'neutral'],
|
||||
],
|
||||
'haupt' => [
|
||||
[
|
||||
'titel' => 'Erlaubte Handlungen',
|
||||
'zusatz' => $current !== null ? 'Fassung '.$current->number : null,
|
||||
'hilfe' => $current?->locked_at !== null
|
||||
? 'Diese Fassung wird in einem aktiven Angebot verwendet und ist deshalb unveränderlich.'
|
||||
: 'Zweck und erlaubte Handlungen. Angebote verbinden das Profil mit Lizenzartikeln.',
|
||||
'zeilen' => array_map(fn (string $label): array => ['text' => $label], $faehigkeiten),
|
||||
'leer' => ['titel' => 'Keine Handlungen', 'text' => 'Diese Fassung erlaubt keine Handlung.'],
|
||||
],
|
||||
...($optionen !== [] ? [['titel' => 'Optionen', 'zeilen' => $optionen]] : []),
|
||||
],
|
||||
'seite' => [
|
||||
[
|
||||
'titel' => 'In Angeboten',
|
||||
'zeilen' => $verwendung,
|
||||
'leer' => 'In keinem Angebot verwendet.',
|
||||
],
|
||||
[
|
||||
'titel' => 'Fassungen',
|
||||
'zeilen' => $versions->map(fn (RightsProfileVersion $version): array => [
|
||||
'text' => 'Fassung '.$version->number,
|
||||
'zustand' => $version->locked_at !== null ? ['label' => 'Festgeschrieben', 'ton' => 'leise'] : null,
|
||||
'neben' => CatalogLabels::zweck($version->purpose),
|
||||
])->all(),
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -2,18 +2,70 @@
|
||||
|
||||
namespace App\Filament\Resources\Users\Pages;
|
||||
|
||||
use App\Domain\Identity\AccountStatus;
|
||||
use App\Domain\Identity\StaffRole;
|
||||
use App\Filament\Resources\Users\UserResource;
|
||||
use App\Filament\Support\ListsCatalog;
|
||||
use App\Models\User;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListUsers extends ListRecords
|
||||
{
|
||||
use ListsCatalog;
|
||||
|
||||
protected static string $resource = UserResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
CreateAction::make()->label('Benutzer anlegen'),
|
||||
];
|
||||
}
|
||||
|
||||
protected function catalogRows(): array
|
||||
{
|
||||
$rows = [];
|
||||
|
||||
foreach (User::query()->with('staffRoles')->orderBy('name')->get() as $user) {
|
||||
$status = $user->status instanceof AccountStatus ? $user->status->label() : (string) $user->status;
|
||||
$rollen = $user->staffRoles->map(fn ($role): string => $role->role instanceof StaffRole ? $role->role->label() : StaffRole::from((string) $role->role)->label())->all();
|
||||
$url = UserResource::getUrl('edit', ['record' => $user]);
|
||||
$rows[] = [
|
||||
'schluessel' => 'u'.$user->id,
|
||||
'titel' => (string) $user->name,
|
||||
'meta' => (string) $user->email,
|
||||
'symbol' => 'schluessel',
|
||||
'url' => $url,
|
||||
'chips' => [
|
||||
['label' => $status !== '' ? $status : 'Ohne Status', 'ton' => 'neutral'],
|
||||
...array_map(fn (string $rolle): array => ['label' => $rolle, 'ton' => 'gut'], $rollen),
|
||||
],
|
||||
'zustand' => $rollen === [] ? ['ohne-rolle'] : ['mit-rolle'],
|
||||
'aktionen' => [['label' => 'Bearbeiten', 'href' => $url, 'icon' => 'stift']],
|
||||
];
|
||||
}
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
protected function zustandOptionen(): array
|
||||
{
|
||||
return ['alle' => 'Alle Konten', 'mit-rolle' => 'Mit Verwaltungsrolle', 'ohne-rolle' => 'Ohne Verwaltungsrolle'];
|
||||
}
|
||||
|
||||
protected function einheit(): array
|
||||
{
|
||||
return ['Konto', 'Konten'];
|
||||
}
|
||||
|
||||
protected function leer(): array
|
||||
{
|
||||
return ['titel' => 'Noch keine Konten', 'text' => 'Mit „Benutzer anlegen“ oben entsteht das erste Konto.'];
|
||||
}
|
||||
|
||||
protected function suchPlatzhalter(): string
|
||||
{
|
||||
return 'Name oder E-Mail';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Support;
|
||||
|
||||
use App\Domain\Catalog\OfferVersion;
|
||||
|
||||
/**
|
||||
* Lesbare Bezeichnungen für Katalogangaben, gemeinsam für Listen und Objektseiten (Rechteprofil, Angebot).
|
||||
*/
|
||||
final class CatalogLabels
|
||||
{
|
||||
/** Fähigkeiten eines Rechteprofils; dieselben Werte wie im Anlegedialog. */
|
||||
public const FAEHIGKEITEN = [
|
||||
'film:streamen' => 'Film ansehen',
|
||||
'film:laden' => 'Film herunterladen',
|
||||
'audio:streamen' => 'Hörstück ansehen',
|
||||
'document:ansehen' => 'Dokument ansehen',
|
||||
'document:laden' => 'Dokument herunterladen',
|
||||
'pdf:ansehen' => 'PDF ansehen',
|
||||
'pdf:laden' => 'PDF herunterladen',
|
||||
'text:ansehen' => 'Text ansehen',
|
||||
'bild:ansehen' => 'Bild ansehen',
|
||||
];
|
||||
|
||||
/**
|
||||
* @param array<string, mixed>|null $capabilities ['film' => ['streamen'], …]
|
||||
* @return list<string>
|
||||
*/
|
||||
public static function faehigkeiten(?array $capabilities): array
|
||||
{
|
||||
$labels = [];
|
||||
|
||||
foreach ($capabilities ?? [] as $class => $actions) {
|
||||
foreach ((array) $actions as $action) {
|
||||
$labels[] = self::FAEHIGKEITEN[$class.':'.$action] ?? $class.': '.$action;
|
||||
}
|
||||
}
|
||||
|
||||
return $labels;
|
||||
}
|
||||
|
||||
public static function zweck(?string $purpose): string
|
||||
{
|
||||
return match ((string) $purpose) {
|
||||
'ehrenamtlich' => 'Ehrenamtlich',
|
||||
'kommerziell' => 'Kommerziell',
|
||||
'institutionell' => 'Institutionell',
|
||||
default => (string) $purpose,
|
||||
};
|
||||
}
|
||||
|
||||
public static function vergabe(OfferVersion $version): string
|
||||
{
|
||||
$kind = match ($version->grant_kind) {
|
||||
'kauf' => 'Kauf',
|
||||
'auf_abruf' => 'Auf Abruf',
|
||||
'bei_registrierung' => 'Bei Registrierung',
|
||||
default => (string) $version->grant_kind,
|
||||
};
|
||||
|
||||
return $version->price_cents === null ? $kind : $kind.' · '.number_format($version->price_cents / 100, 2, ',', '.').' €';
|
||||
}
|
||||
}
|
||||
@@ -60,6 +60,7 @@ public function bestand(): array
|
||||
$einheit = match ($fixed) {
|
||||
CompositionKind::Kurs => ['Programm', 'Programme'],
|
||||
CompositionKind::Uebung => ['Modul', 'Module'],
|
||||
CompositionKind::Kombination => ['Fachliche Kombination', 'Fachliche Kombinationen'],
|
||||
default => ['Programm oder Modul', 'Programme und Module'],
|
||||
};
|
||||
$gruppen = [];
|
||||
@@ -90,8 +91,12 @@ public function bestand(): array
|
||||
'zeilen' => $this->entries(),
|
||||
'einheit' => $einheit,
|
||||
'leer' => [
|
||||
'titel' => 'Noch keine '.$einheit[1],
|
||||
'text' => 'Mit „'.($fixed === CompositionKind::Kurs ? 'Programm' : 'Modul').' anlegen“ oben entsteht der erste Eintrag. Der Name genügt.',
|
||||
'titel' => $fixed === CompositionKind::Kombination ? 'Noch keine fachlichen Kombinationen' : 'Noch keine '.$einheit[1],
|
||||
'text' => 'Mit „'.match ($fixed) {
|
||||
CompositionKind::Kurs => 'Programm anlegen',
|
||||
CompositionKind::Kombination => CompositionKind::Kombination->createLabel(),
|
||||
default => 'Modul anlegen',
|
||||
}.'“ oben entsteht der erste Eintrag. Der Name genügt.',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
{{-- Angebot im gemeinsamen Rahmen: Kopf, aktive Fassung (Positionen, Leistungsumfang), Fassungsverlauf. --}}
|
||||
@php
|
||||
$kopfStatus = $active !== null
|
||||
? ['text' => 'Fassung '.$active->number.' aktiv · '.$vergabe, 'ton' => 'gut']
|
||||
: ['text' => 'Noch keine aktive Fassung. Ein Angebot ohne aktive Fassung kann niemand erwerben.', 'ton' => 'offen'];
|
||||
$aktionen = [[
|
||||
'label' => $active !== null ? 'Geänderte Fassung aktivieren' : 'Fassung aktivieren',
|
||||
'wire' => "mountAction('activate')",
|
||||
'art' => 'primary',
|
||||
]];
|
||||
@endphp
|
||||
<div class="vw">
|
||||
@include('filament.verwaltung.kopf', [
|
||||
'brot' => [['label' => 'Angebote', 'href' => \App\Filament\Resources\Offers\OfferResource::getUrl('index')], $offer->name],
|
||||
'titel' => $offer->name,
|
||||
'typ' => 'Angebot',
|
||||
'status' => $kopfStatus,
|
||||
'aktionen' => $aktionen,
|
||||
])
|
||||
|
||||
<div class="vw-medien-raster" style="margin-top: 1.25rem;">
|
||||
<section class="vw-medien-haupt" aria-labelledby="positionen-titel">
|
||||
<h2 id="positionen-titel" class="vw-abschnitt-titel">Positionen @if ($active)<span class="vw-rolle-zahl">· Fassung {{ $active->number }}</span>@endif</h2>
|
||||
@if ($active === null)
|
||||
<div class="vw-leer">
|
||||
<strong>Noch keine Positionen</strong>
|
||||
<p>Mit „Fassung aktivieren“ legst du fest, welche Lizenzartikel oder Paketfassungen mit welchem Rechteprofil angeboten werden, wie vergeben wird und zu welchem Preis.</p>
|
||||
</div>
|
||||
@else
|
||||
<p class="vw-feld-hilfe">Vergabe: {{ $vergabe }}. Diese Fassung ist unveränderlich; eine Änderung aktiviert die nächste Fassung.</p>
|
||||
<ul class="vw-verwendungsliste">
|
||||
@foreach ($active->lines->sortBy('position') as $line)
|
||||
<li>
|
||||
<strong>{{ $line->article !== null ? 'Lizenzartikel '.$line->article->code : 'Paket '.($line->bundleVersion?->bundle?->name ?? '–').' · Fassung '.($line->bundleVersion?->number ?? '–') }}</strong>
|
||||
<span class="vw-feld-hilfe">Rechte: {{ $line->rights?->profile?->name ?? '–' }}</span>
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
<h3 class="vw-abschnitt-titel" style="font-size: 1.05rem; margin-top: 0.75rem;">Aufgelöster Leistungsumfang</h3>
|
||||
<p class="vw-feld-hilfe">Diese Artikel-Rechte entstehen beim Erwerb dieser Fassung.</p>
|
||||
<ul class="vw-verwendungsliste">
|
||||
@foreach ($grants as $grant)
|
||||
<li><span>{{ $grant }}</span></li>
|
||||
@endforeach
|
||||
</ul>
|
||||
@endif
|
||||
</section>
|
||||
|
||||
<aside class="vw-medien-seite" aria-labelledby="fassungen-titel">
|
||||
<h2 id="fassungen-titel" class="vw-abschnitt-titel">Fassungen</h2>
|
||||
@if ($versions === [])
|
||||
<p class="vw-feld-hilfe">Noch keine Fassung.</p>
|
||||
@else
|
||||
<ul class="vw-verwendungsliste">
|
||||
@foreach ($versions as $version)
|
||||
<li>
|
||||
<strong>Fassung {{ $version['number'] }}</strong>
|
||||
<span @class(['vw-zustand', 'is-'.$version['ton']])>{{ $version['status'] }}</span>
|
||||
<span class="vw-feld-hilfe">{{ $version['vergabe'] }}@if ($version['wann']) · aktiviert am {{ $version['wann'] }}@endif</span>
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
@endif
|
||||
<p class="vw-feld-hilfe">Beendete Fassungen bleiben gespeichert; Erwerbe verweisen auf ihre Fassung. Ob ein Angebot künftig auch als Vorlage für ein weiteres dienen soll, ist fachlich noch offen (OFF-04).</p>
|
||||
</aside>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,59 @@
|
||||
{{--
|
||||
Gemeinsame Katalog-Objektseite (Angebot, Paket, Rechteprofil): gemeinsamer Kopf, Hauptabschnitte links,
|
||||
Begleitinformation rechts. Parameter:
|
||||
kopf Parameter für filament.verwaltung.kopf
|
||||
haupt Liste ['titel', 'zusatz' => kleiner Titelzusatz, 'hilfe', 'zeilen' => [['text', 'neben']], 'leer' => ['titel', 'text']]
|
||||
seite Liste ['titel', 'zeilen' => [['text', 'zustand' => ['label', 'ton'], 'neben']], 'hilfe', 'leer' => Text]
|
||||
--}}
|
||||
<div class="vw">
|
||||
@include('filament.verwaltung.kopf', $kopf)
|
||||
|
||||
<div class="vw-medien-raster vw-katalogobjekt">
|
||||
<div class="vw-medien-haupt">
|
||||
@foreach ($haupt as $abschnitt)
|
||||
<section class="vw-katalog-abschnitt" aria-labelledby="abschnitt-{{ $loop->index }}">
|
||||
<h2 id="abschnitt-{{ $loop->index }}" class="vw-abschnitt-titel">{{ $abschnitt['titel'] }}@if (filled($abschnitt['zusatz'] ?? null)) <span class="vw-rolle-zahl">· {{ $abschnitt['zusatz'] }}</span>@endif</h2>
|
||||
@if (filled($abschnitt['hilfe'] ?? null))
|
||||
<p class="vw-feld-hilfe">{{ $abschnitt['hilfe'] }}</p>
|
||||
@endif
|
||||
@if (($abschnitt['zeilen'] ?? []) === [] && ! empty($abschnitt['leer']))
|
||||
<div class="vw-leer">
|
||||
<strong>{{ $abschnitt['leer']['titel'] }}</strong>
|
||||
<p>{{ $abschnitt['leer']['text'] }}</p>
|
||||
</div>
|
||||
@elseif (($abschnitt['zeilen'] ?? []) !== [])
|
||||
<ul class="vw-verwendungsliste">
|
||||
@foreach ($abschnitt['zeilen'] as $zeile)
|
||||
<li><strong>{{ $zeile['text'] }}</strong>@if (filled($zeile['neben'] ?? null)) <span class="vw-feld-hilfe">{{ $zeile['neben'] }}</span>@endif</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
@endif
|
||||
</section>
|
||||
@endforeach
|
||||
</div>
|
||||
|
||||
<aside class="vw-medien-seite">
|
||||
@foreach ($seite as $abschnitt)
|
||||
<section class="vw-katalog-abschnitt" aria-labelledby="seite-{{ $loop->index }}">
|
||||
<h2 id="seite-{{ $loop->index }}" class="vw-abschnitt-titel">{{ $abschnitt['titel'] }}</h2>
|
||||
@if (($abschnitt['zeilen'] ?? []) === [])
|
||||
@if (filled($abschnitt['leer'] ?? null))<p class="vw-feld-hilfe">{{ $abschnitt['leer'] }}</p>@endif
|
||||
@else
|
||||
<ul class="vw-verwendungsliste">
|
||||
@foreach ($abschnitt['zeilen'] as $zeile)
|
||||
<li>
|
||||
<strong>{{ $zeile['text'] }}</strong>
|
||||
@if (! empty($zeile['zustand']))<span @class(['vw-zustand', 'is-'.($zeile['zustand']['ton'] ?? 'neutral')])>{{ $zeile['zustand']['label'] }}</span>@endif
|
||||
@if (filled($zeile['neben'] ?? null))<span class="vw-feld-hilfe">{{ $zeile['neben'] }}</span>@endif
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
@endif
|
||||
@if (filled($abschnitt['hilfe'] ?? null))
|
||||
<p class="vw-feld-hilfe">{{ $abschnitt['hilfe'] }}</p>
|
||||
@endif
|
||||
</section>
|
||||
@endforeach
|
||||
</aside>
|
||||
</div>
|
||||
</div>
|
||||
@@ -451,9 +451,9 @@
|
||||
.vw-bestand-filter, .vw-bestand-suche { flex-basis: 100%; }
|
||||
.vw-bestand-ansicht { margin-left: 0; }
|
||||
}
|
||||
/* Filament-Kopfaktionen (z. B. „… anlegen“) wie .vw-btn.is-primary */
|
||||
.fi-header .fi-ac .fi-btn.fi-color-primary, .fi-header .fi-btn.fi-color-primary { background: var(--vw-pine); color: #fff; }
|
||||
.fi-header .fi-btn.fi-color-primary:hover { background: var(--vw-pine-dark); color: #fff; }
|
||||
/* Gefüllte Filament-Hauptknöpfe (Seitenkopf, Formularfuß) wie .vw-btn.is-primary */
|
||||
.fi-btn.fi-color-primary:not(.fi-outlined) { background: var(--vw-pine); color: #fff; }
|
||||
.fi-btn.fi-color-primary:not(.fi-outlined):hover { background: var(--vw-pine-dark); color: #fff; }
|
||||
|
||||
@container (max-width: 52rem) {
|
||||
.vw-zeile { grid-template-columns: 1.5rem var(--vw-thumb-small) minmax(0, 1fr); grid-template-areas: "griff bild text" "griff aktionen aktionen"; }
|
||||
|
||||
@@ -9,8 +9,11 @@
|
||||
use App\Domain\Catalog\ContentService;
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Domain\Catalog\OfferService;
|
||||
use App\Domain\Catalog\PillarService;
|
||||
use App\Filament\Pages\EditorialDesk;
|
||||
use App\Filament\Resources\Bundles\Pages\ListBundles;
|
||||
use App\Filament\Resources\Bundles\Pages\ViewBundle;
|
||||
use App\Filament\Resources\Combinations\Pages\ListCombinations;
|
||||
use App\Filament\Resources\ContentElements\Pages\ListContentElements;
|
||||
use App\Filament\Resources\Courses\Pages\ListCourses;
|
||||
use App\Filament\Resources\Exercises\ExerciseResource;
|
||||
@@ -20,7 +23,10 @@
|
||||
use App\Filament\Resources\Offers\OfferResource;
|
||||
use App\Filament\Resources\Offers\Pages\ListOffers;
|
||||
use App\Filament\Resources\Offers\Pages\ViewOffer;
|
||||
use App\Filament\Resources\Pillars\Pages\ListPillars;
|
||||
use App\Filament\Resources\RightsProfiles\Pages\ListRightsProfiles;
|
||||
use App\Filament\Resources\RightsProfiles\Pages\ViewRightsProfile;
|
||||
use App\Filament\Resources\Users\Pages\ListUsers;
|
||||
use App\Filament\Support\Bestand;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
@@ -266,6 +272,95 @@ public function test_one_offer_mask_activates_the_first_version_and_is_prefilled
|
||||
$this->assertSame(['beendet', 'aktiv'], $statuses);
|
||||
}
|
||||
|
||||
public function test_a_bundle_change_is_prefilled_and_keeps_the_published_version(): void
|
||||
{
|
||||
$content = app(ContentService::class);
|
||||
$articles = app(ArticleService::class);
|
||||
$sheet = $content->publishElementVersion($content->createElement('pdf', 'pdf', 'Merkblatt'), 'Hinweis');
|
||||
$first = $articles->create('demo-a', 'Erprobung');
|
||||
$articles->publishRelease($first, $sheet, 'A.');
|
||||
$second = $articles->create('demo-b', 'Erprobung');
|
||||
$articles->publishRelease($second, $sheet, 'B.');
|
||||
$bundle = app(BundleService::class)->create('Demo Basis');
|
||||
app(BundleService::class)->publish($bundle, [$first->fresh()]);
|
||||
|
||||
$component = Livewire::actingAs($this->keeper(), 'staff')
|
||||
->test(ViewBundle::class, ['record' => $bundle->getKey()])
|
||||
->assertSee('Fassung 1 veröffentlicht')
|
||||
->assertSee('Lizenzartikel demo-a')
|
||||
->assertSee('Geänderte Fassung veröffentlichen')
|
||||
->mountAction('publish');
|
||||
$this->assertSame('Paket ändern: Fassung 2 veröffentlichen', $component->instance()->getMountedAction()->getModalHeading());
|
||||
$this->assertSame([$first->id], array_map('intval', $component->get('mountedActions.0.data.articles')));
|
||||
|
||||
$component->fillForm(['articles' => [$first->id, $second->id]])
|
||||
->callMountedAction()
|
||||
->assertHasNoFormErrors()
|
||||
->assertSee('Fassung 2 veröffentlicht')
|
||||
->assertSee('Lizenzartikel demo-b');
|
||||
|
||||
$this->assertSame(2, $bundle->versions()->where('status', 'veroeffentlicht')->count());
|
||||
$this->assertSame(1, $bundle->versions()->where('number', 1)->firstOrFail()->items()->count());
|
||||
}
|
||||
|
||||
public function test_a_rights_profile_reads_as_allowed_actions_and_names_its_offers(): void
|
||||
{
|
||||
$offers = app(OfferService::class);
|
||||
$content = app(ContentService::class);
|
||||
$articles = app(ArticleService::class);
|
||||
$sheet = $content->publishElementVersion($content->createElement('pdf', 'pdf', 'Merkblatt'), 'Hinweis');
|
||||
$article = $articles->create('demo-merkblatt', 'Erprobung');
|
||||
$articles->publishRelease($article, $sheet, 'A.');
|
||||
$rights = $offers->createRightsProfile('Abstand ansehen', 'ehrenamtlich', ['pdf' => ['ansehen', 'laden']]);
|
||||
$offer = $offers->create('Kostenlos');
|
||||
$offers->activate($offer, [['target' => $article->fresh(), 'rights' => $rights]], ['grant_kind' => 'auf_abruf']);
|
||||
|
||||
Livewire::actingAs($this->keeper(), 'staff')
|
||||
->test(ViewRightsProfile::class, ['record' => $rights->rights_profile_id])
|
||||
->assertSee('Abstand ansehen')
|
||||
->assertDontSee('Abstand ansehen ansehen')
|
||||
->assertSee('PDF ansehen')
|
||||
->assertSee('PDF herunterladen')
|
||||
->assertDontSee('pdf: ansehen')
|
||||
->assertSee('Kostenlos · Fassung 1')
|
||||
->assertSee('festgeschrieben seit');
|
||||
}
|
||||
|
||||
public function test_pillars_combinations_and_accounts_use_the_same_list(): void
|
||||
{
|
||||
$content = app(ContentService::class);
|
||||
$content->createComposition('Materialsatz Alltag', CompositionKind::Kombination);
|
||||
$content->createComposition('Modul Abstand', CompositionKind::Uebung);
|
||||
app(PillarService::class)->create('Sicher handeln im Alltag');
|
||||
$editor = $this->editor();
|
||||
|
||||
Livewire::actingAs($editor, 'staff')
|
||||
->test(ListPillars::class)
|
||||
->assertSee('Sicher handeln im Alltag')
|
||||
->assertSee('Intern')
|
||||
->assertSee('0 Medien')
|
||||
->assertSeeHtml('wire:partial="action-modals"');
|
||||
|
||||
Livewire::actingAs($editor, 'staff')
|
||||
->test(ListCombinations::class)
|
||||
->assertSee('Materialsatz Alltag')
|
||||
->assertDontSee('Modul Abstand')
|
||||
->assertSeeHtml('wire:partial="action-modals"')
|
||||
->assertSee('Kombination anlegen');
|
||||
|
||||
$admin = User::factory()->systemverwalter()->create(['name' => 'Anna Admin', 'email' => 'anna@example.test']);
|
||||
$admin->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP');
|
||||
|
||||
Livewire::actingAs($admin, 'staff')
|
||||
->test(ListUsers::class)
|
||||
->assertSee('Anna Admin')
|
||||
->assertSee('anna@example.test')
|
||||
->assertSee('Benutzer anlegen')
|
||||
->set('suche', 'anna@')
|
||||
->assertSee('Anna Admin')
|
||||
->assertDontSee($editor->email);
|
||||
}
|
||||
|
||||
private function keeper(): User
|
||||
{
|
||||
$keeper = User::factory()->katalogverwalter()->create();
|
||||
|
||||
Reference in new issue
Block a user