Author SHA1 Message Date
Lars 4e0760db1e Add feature tests for shop functionality and organization purchases
Deploy Test / test (push) Successful in 1m38s
Deploy Test / deploy (push) Successful in 31s
- Implement OfferOptionAdminTest to validate offer option management, including price display, activation, and cancellation.
- Create OrganizationPurchaseTest to ensure correct handling of organization purchases, including access control and order processing.
- Add ShopProductPageTest to verify shop product listings, search functionality, and product page details.
- Introduce BuildsShop trait for seeding test data related to shop functionality.
- Implement MoneyTest to validate money parsing and formatting, ensuring correct handling of euro amounts.
2026-11-21 12:06:24 +01:00
Lars 6c8bbee363 Merge branch 'develop' of 192.168.2.144:Lars/laraundfelix into develop
Deploy Test / test (push) Successful in 1m29s
Deploy Test / deploy (push) Successful in 28s
2026-11-21 10:33:07 +01:00
Lars 7ad5929588 Refine product configuration and member area documentation; clarify MVP requirements, add details on licensing options, and enhance user interface guidelines. Update payment processes for organizations and clarify target audiences for the sales launch. Introduce new requirements for managing offers and discounts in the shop system, including the necessity of a shopping cart for multiple offers. 2026-11-21 10:33:05 +01:00
LarsandClaude Sonnet 5.5 ed1f706d46 Dokumentiere die Vereinheitlichung der fachlichen Säulen
CI Feature / test (push) Successful in 1m33s
Deploy Test / test (push) Successful in 1m30s
Deploy Test / deploy (push) Successful in 33s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-21 10:22:55 +01:00
LarsandClaude Sonnet 5.5 7c48a6480c Vereinheitliche die fachlichen Säulen auf die zentrale Säulenverwaltung
CI Feature / test (push) Successful in 1m34s
Deploy Test / test (push) Successful in 1m29s
Deploy Test / deploy (push) Successful in 29s
Module, Programme und Lizenzartikel verwenden wie Medien und Seiten die Tabelle
pillars; die Kopie „Fachliche Säule“ in den redaktionellen Dimensionen wird nirgends
mehr angeboten, geändert oder gefiltert und bleibt nur als Verlauf erhalten.

- Migration (nur Ergänzungen): composition_pillar und license_article_pillar mit
  restrictOnDelete, pillar_id an den alten Dimensionswerten als dokumentierte
  Abbildung, einmalige wiederholbare Übernahme (LegacyPillarAdoption).
- Übernahme nur über die gespeicherte Kennung pfeiler-<Nummer> und nur direkte
  Zuordnungen; mehrdeutige, abgeleitete und verwaiste Fälle werden gemeldet, nicht
  geraten. Medien bleiben bei ihrer Zuordnung. Alte Zeilen bleiben unverändert.
  Befehl: php artisan luf:saeulen-uebernehmen [--dry-run].
- Editoren von Modul, Programm und Lizenzartikel wählen Säulen aus der Säulenverwaltung;
  PillarService::assign gilt für alle Objektarten, Löschschutz zählt alle Objektarten.
- Filter: Module und Programme, Aufbau-Picker und Mitgliederbibliothek nach der
  Säulenzuordnung; alte Adressen mit einem Säulenwert der Einordnung folgen der Säule.
- Abgeleitete Säulen (aus enthaltenen Medien) bleiben getrennt von direkten.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-21 10:11:42 +01:00
LarsandClaude Opus 5.5 d5c2b34b9d Nimm die Brand-UI-Kit-Stände 1.2 bis 1.7 ohne Originalmotive auf.
CI Feature / test (push) Successful in 1m18s
Deploy Test / test (push) Successful in 1m39s
Deploy Test / deploy (push) Successful in 28s
Design-Tokens, SVG-Entwürfe, Cursor-Übergabe, Branding-Freigabe, freigegebene Logovarianten, Hero-,
Bild-und-Text- und Premium-Widgets (v1.6) sowie den Kartenentwurf v1.7 mit Ergänzungsdokumenten; die
Architektur- und Analysedokumente verweisen bereits auf diese Ordner.

Bewusst nicht aufgenommen: 01_originale/ und die Kopien der Originalmotive in 09_hero_widget/assets und
13_premium_karten_v1.7_entwurf/assets (zusammen etwa 30 MB, Veröffentlichung nicht freigegeben, bleiben
sonst dauerhaft in der Historie) sowie das Zip des Kartenentwurfs (Duplikat des Ordners). Die Vorschauen
dieser beiden Ordner zeigen deshalb im Repository keine Originalmotive.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 08:53:34 +01:00
LarsandClaude Opus 5.5 eb6192b067 Halte die Entscheidungen vom 20.11. zu Stammdaten und Warenkorb fest.
- 04-fachliche-anforderungen: FACH-56 bis FACH-59, Ergänzung redaktionelle Stammdatenpflege und
  Shopentscheidung Warenkorb (develop verweist bereits auf FACH-56 bis FACH-58).
- 16_MVP_Slice: Hinweis, dass der Warenkorb-Ausschluss für den neuen Shopauftrag aufgehoben ist.
- paket-manifest: Stand vom 20.11.; Prüfsummen gegen den jetzt committeten Inhalt neu berechnet
  (16-funktionszuordnung, abnahme/teil-a und tokens hatten sich auf develop seither geändert).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 08:53:33 +01:00
LarsandClaude Opus 5.5 061bc00564 Lasse nginx den App-Container zur Laufzeit auflösen
CI Feature / test (push) Successful in 1m21s
Deploy Test / test (push) Successful in 1m10s
Deploy Test / deploy (push) Successful in 28s
fastcgi_pass app:9000 legte die Adresse beim Start von nginx fest. Ein erneuter
Deploy-Lauf nach einer Env-Änderung erzeugte die App mit neuer Adresse neu, den
Web-Container nicht; Prod antwortete mit 502 (20.11.2026). Jetzt löst nginx den
Namen über Dockers DNS (127.0.0.11, 10 s) bei Bedarf auf. Test hält die
Konfiguration fest; DEPLOYMENT.md beschreibt das Ändern der Env-Datei.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 07:10:47 +01:00
LarsandClaude Opus 5.5 8a97d9c334 Filtere im Aufbau-Picker nach der Filterregel, nenne betroffene Objekte und tausche beim Sortieren nur Nachbarn
CI Feature / test (push) Successful in 1m13s
Deploy Test / test (push) Successful in 1m7s
Deploy Test / deploy (push) Successful in 24s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 21:39:25 +01:00
LarsandClaude Opus 5.5 e20f428a57 Dokumentiere die redaktionellen Stammdaten mit Prüfung auf luf-test
CI Feature / test (push) Successful in 1m9s
Deploy Test / test (push) Successful in 1m8s
Deploy Test / deploy (push) Successful in 31s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 21:34:00 +01:00
LarsandClaude Opus 5.5 70695db290 Lasse die Stammdatentabelle bei schmaleren Fenstern umbrechen statt scrollen
CI Feature / test (push) Successful in 1m13s
Deploy Test / test (push) Successful in 1m9s
Deploy Test / deploy (push) Successful in 22s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 21:29:47 +01:00
LarsandClaude Opus 5.5 f774d43647 Führe die zentrale Pflege redaktioneller Stammdaten ein
CI Feature / test (push) Successful in 1m12s
Deploy Test / test (push) Successful in 1m7s
Deploy Test / deploy (push) Successful in 23s
FACH-56 bis FACH-58: Arbeitsplatz „Redaktionelle Stammdaten“ für fachliche
Materialarten, Altersbereich und Zielgruppe, Einsatzbereiche und
Verwendungszwecke (bestehende Tabellen; Säulen bleiben in ihrer Verwaltung).

- Migration (nur Ergänzungen): aktiv/inaktiv für Materialarten und Werte,
  Reihenfolge der Werte, zulässige Objektkontexte der Materialarten, einmalig
  aus dem Bestand abgeleitet; jede vorhandene Zuordnung bleibt zulässig.
- EditorialVocabulary als eine Regelquelle für Redaktion (Medium, Modul,
  Programm, Lizenzartikel), Medien- und Kompositionsfilter, Picker und
  Mitgliederbibliothek: neu wählbar nur aktive, kontextgerechte Werte;
  vorhandene inaktive Zuordnungen sichtbar und beim Speichern erhalten;
  serverseitige Prüfung der Materialart.
- Kennung fest, Bezeichnung pflegbar; verwendete Werte nur deaktivierbar;
  Systemkennungen (programm, modul, traineranleitung) geschützt.
- „Inhaltsart“ heißt durchgängig „Fachliche Materialart“; der Picker trennt
  Medienart und fachliche Materialart und filtert danach.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 21:18:03 +01:00
LarsandClaude Opus 5.5 c84ae10809 Dokumentiere den CMS-Abschluss mit Prüfung auf luf-test
CI Feature / test (push) Successful in 1m10s
Deploy Test / test (push) Successful in 1m5s
Deploy Test / deploy (push) Successful in 23s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 17:02:05 +01:00
LarsandClaude Opus 5.5 f3eda56021 Zeige nach dem Speichern aus dem Baustein den neuen Speicherstand im Kopf
CI Feature / test (push) Successful in 1m10s
Deploy Test / test (push) Successful in 1m4s
Deploy Test / deploy (push) Successful in 23s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 16:55:50 +01:00
LarsandClaude Opus 5.5 4f3b7c351e Verdichte Webpräsenz-Kopf, Seitenliste und Menühinweise
CI Feature / test (push) Successful in 1m9s
Deploy Test / test (push) Successful in 1m4s
Deploy Test / deploy (push) Successful in 22s
Kompakter Kopf mit aufrufbarer Hilfe statt wiederholter Erläuterungen zu
Sortierung, Ausblenden, Speichern und Veröffentlichung. Seitenliste: Chip
„Veröffentlicht“, Revisionsnummer in der Detailzeile; Listenhinweis nur noch bei
offenen Menüänderungen. Menüs: kein Dauerband und keine Wiederholungen mehr im
Detailbereich. Funktionen und Zustände unverändert.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 16:49:09 +01:00
LarsandClaude Opus 5.5 75596bdaec Führe Bausteine ohne Zwischenschritt und wähle CMS-Bilder im gemeinsamen Picker
- Bausteindialog: „Zum Seitenaufbau“ kehrt an die Stelle zurück, „Entwurf
  speichern“ übernimmt und speichert direkt; Fehler erscheinen wie beim Kopf.
- Karten mit Fachobjekt: zentrale Angaben aus der Redaktion als Platzhalter,
  eigene Angaben als „Eigene Angabe für diese Karte“ markiert.
- Bildfelder des CMS (Bausteine und Abschnittshintergrund) öffnen den
  gemeinsamen visuellen Picker statt einer eigenen Auswahlliste. Der allgemeine
  Teil des Pickers liegt im Trait ChoosesMedia (aus der Redaktion herausgelöst,
  nicht kopiert); ChoosesWebsiteImages übernimmt nur Website-Bilder in genau
  das auslösende Feld, auch im Bausteindialog. Keine Freigabe durch Auswahl.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 16:46:29 +01:00
LarsandClaude Opus 5.5 5548106c31 Verdichte Seitenaufbau und Abschnittsgestaltung im CMS
- Seitenaufbau: Bausteine als Miniaturvorschau in Desktop-Proportion (verkleinert,
  Höhe begrenzt); Abschnittskopf „Abschnitt N“ mit knapper Angabe zu Raster und
  abweichender Gestaltung, vollständig im Titel; Plätze ohne eigenen Kopf, nur
  über Lage und Breite; Aktionen benennen Abschnitt oder Baustein.
- Seitenkopf kompakter; Erläuterungen als aufrufbare Hilfe; kein Rahmen
  „Inhalt der Seite“, keine leeren Abstände ausgeblendeter Teile.
- „Abschnitt gestalten“: knappe Leiste mit „Zum Seitenaufbau“ und Hilfe, keine
  wiederholte Zusammenfassung; Einstellungen in Raster und Breite, Hintergrund,
  Abstände und Trenner; Erklärungen als Hinweis. Rückkehr an den Abschnitt.
- Tests: Gruppen speichern gemeinsam; Texte bewusst angepasst.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 16:37:14 +01:00
LarsandClaude Opus 5.5 dd3ee39f69 Ergänze die Abnahme Teil C um Duplizieren und Esc im Kontext
CI Feature / test (push) Successful in 1m6s
Deploy Test / test (push) Successful in 1m1s
Deploy Test / deploy (push) Successful in 23s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 12:45:03 +01:00
LarsandClaude Opus 5.5 a7d369bab1 Dokumentiere die Abnahme von Teil C
Seiteneditor und Webpräsenz mit Prüfergebnissen auf luf-test, Messung,
gefundenen Fehlern, Abweichungen und 23 Belegbildern.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 12:42:58 +01:00
LarsandClaude Opus 5.5 d4110b1d51 Halte den Fuß des Bausteindialogs in schmalen Fenstern erreichbar
CI Feature / test (push) Successful in 1m6s
Deploy Test / test (push) Successful in 1m1s
Deploy Test / deploy (push) Successful in 33s
Der Inhaltsbereich des großen Dialogs wuchs über das Fenster hinaus; bei 900 px
(Vorschau unter dem Formular) lagen „Zur Seite“ und „Änderungen verwerfen“
außerhalb des sichtbaren Bereichs. Der Inhalt scrollt jetzt im Dialog.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 12:37:13 +01:00
LarsandClaude Opus 5.5 0c6519be28 Erkenne offene Dialoge für Strg+S und Esc richtig
CI Feature / test (push) Successful in 1m5s
Deploy Test / test (push) Successful in 1m1s
Deploy Test / deploy (push) Successful in 23s
Filament-Dialoge sind fest positioniert; offsetParent ist dort immer null, die
Prüfung hielt einen offenen Bausteindialog daher für geschlossen. Jetzt über
getClientRects(). Funktionszuordnung, CLAUDE.md und Cursor-Regel nennen die
CMS- und Webpräsenz-Bausteine.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 12:25:32 +01:00
LarsandClaude Opus 5.5 30dd0f9eb8 Schreibe beim Menüspeichern nur geänderte Einträge
CI Feature / test (push) Successful in 1m5s
Deploy Test / test (push) Successful in 59s
Deploy Test / deploy (push) Successful in 24s
Unveränderte Einträge erhalten höchstens eine neue Reihenfolge; ein bestehender
Gleichstand in Datenbankfolge bleibt unberührt, Texte werden nur bei Änderung
bereinigt. „Website ansehen“ nennt den gespeicherten Stand.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 12:16:27 +01:00
LarsandClaude Opus 5.5 07592f57bd Führe die Webpräsenz mit Seitenbestand und Menüeditor ein
Ein Arbeitsplatz für Seiten und Menüs (Dokument 13, Umbauauftrag Teil C):
- Seiten: gemeinsame Bestandsliste mit Veröffentlichungszustand, Menüzuordnung
  je Bereich, Filtern, Sortierung (beide Richtungen), Vorschau und Duplizieren.
- Menüs: Arbeitsstand aller Einträge, gespeichert in einem Schritt. Breit Liste
  mit festem Detailbereich, schmal genau ein aufgeklappter Eintrag. Umordnen
  per Ziehen, Knöpfen oder Alt+Pfeil nur innerhalb derselben Ebene.
- Prüfung nach den bisherigen Regeln der Navigationsverwaltung; Speichern
  verweigert bei zwischenzeitlicher Änderung an anderer Stelle.
- Ein Eintrag mit Untereinträgen bleibt im Hauptmenü, weil die öffentliche
  Navigation Untereinträge nur dort zeigt (Schutz vor Widerspruch, keine neue Regel).
- Bisherige Listen „Seiten“ und „Navigation“ leiten nach gleicher Rechteprüfung
  dorthin; Anlegen und Bearbeiten einer Seite bleiben unverändert.
- Tests der alten Listen auf die Webpräsenz übertragen (gleiche Erwartungen).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 12:08:56 +01:00
LarsandClaude Opus 5.5 bc6e4ec7ad Mache Gestaltungsfehler sichtbar und schließe stille Verlustwege im Baustein
- Bausteindialog ohne Schließen-Kreuz: Verlassen nur über „Zur Seite“ oder „Änderungen verwerfen“.
- Strg+S und Esc wirken nicht, solange ein Dialog offen ist.
- Ein Raster- oder Gestaltungsfehler öffnet den betroffenen Abschnitt (CMS-12).
- Nachtrag in Abnahme Teil B: Zeitfenster der Knopffarben-Regel berichtigt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 11:48:11 +01:00
LarsandClaude Opus 5.5 77ebb0c1d5 Mache „Baustein konfigurieren“ zum großen Kontext mit Vorschau.
CI Feature / test (push) Successful in 1m3s
Deploy Test / test (push) Successful in 1m0s
Deploy Test / deploy (push) Successful in 29s
Dokument 12, CMS-R03/R11: Der Bausteindialog öffnet im Vollbild, mit Titel
aus Bausteintyp, Abschnitt, Platz und Rastereinheiten; Inhalt, Medien und
Darstellung stehen auf breiten Schirmen neben der Bausteinvorschau. „Zur
Seite“ übernimmt die Eingaben in den Seitenentwurf, „Änderungen verwerfen“
ist eine ausdrückliche Handlung; Esc und Klick daneben verwerfen nichts mehr
still. Der Knopf am Baustein heißt sichtbar „Konfigurieren“ (bisher nur ein
Zahnrad ohne zugänglichen Namen).

Eine Bearbeitung direkt in der Seite ohne Übernahmeschritt wurde gemessen
(lokal, Seite mit 20 Abschnitten): Laden 11,3 s statt 3,9 s, Antworten
3,3 MB statt 2,2 MB. Deshalb bleibt der Übernahmeschritt, als „Zur Seite“.

Außerdem: Die Breitenwahl der Vorschau markiert beim Öffnen die tatsächlich
gezeigte Breite (der Wert fehlte beim Bearbeiten). Die Regel für grüne
Hauptknöpfe gilt nur noch in Seitenkopf, Dialogfuß und Aktionsleisten, damit
Knopfgruppen in Formularen ihre Auswahl zeigen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 11:35:15 +01:00
LarsandClaude Opus 5.5 4e00c4254b Führe „Abschnitt gestalten“ als eigenen Kontext im Seitenaufbau ein.
CI Feature / test (push) Successful in 1m3s
Deploy Test / test (push) Successful in 57s
Deploy Test / deploy (push) Successful in 24s
Dokument 12, CMS-R04/R11: Raster und Gestaltung stehen nicht mehr dauerhaft an
jedem Abschnitt. „Abschnitt gestalten“ am Abschnitt öffnet Raster, Breite,
Hintergrund (mit Bild, Fokus, Überlagerung), drei Abstände und Trenner dieses
Abschnitts; die Plätze darunter zeigen die Bausteine im Rasterverhältnis.
„Zur Seite“ (oder Esc) führt zurück. Der Kontext merkt sich die Position des
Abschnitts und übersteht das Speichern, bei dem die Repeater-Schlüssel neu
vergeben werden. Felder werden nur ausgeblendet und bleiben im
Formularzustand. Beim Anlegen einer Seite bleibt alles sichtbar.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 11:21:31 +01:00
LarsandClaude Opus 5.5 aaad2fa19b Gib dem Seiteneditor Kopf und Register des gemeinsamen Rahmens.
CI Feature / test (push) Successful in 1m2s
Deploy Test / test (push) Successful in 57s
Deploy Test / deploy (push) Successful in 24s
Dokument 12, CMS-R01: gemeinsamer Objektkopf mit getrennten Aussagen zu
Speicherzustand („Änderungen nicht gespeichert“, „Entwurf gespeichert
(Revision N)“, „Gespeicherter Stand ist veröffentlicht“) und öffentlicher
Revision; „Seitenvorschau“, „Entwurf speichern“ (auch Strg+S) und
„Veröffentlichen …“ im Kopf, „Live-Seite öffnen“ unter „Weitere Aktionen“.
Register Seiteninhalt, Seiteneinstellungen und Verlauf (Revisionen). Ausgeblendete
Register bleiben im Formularzustand und werden mitgespeichert; ein Fehler in
einem ausgeblendeten Register zeigt dieses Register. „Nicht gespeichert“
vergleicht den normalisierten Editorstand mit dem geladenen Stand. Die
Revisionsliste lädt sofort, weil das verzögerte Laden im ausgeblendeten
Register nie ausgelöst würde.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 11:16:55 +01:00
LarsandClaude Opus 5.5 b23b30e897 Vermerke den behobenen Rückschritt der Hauptknopf-Regel in der Abnahme Teil B.
CI Feature / test (push) Successful in 56s
Deploy Test / test (push) Successful in 54s
Deploy Test / deploy (push) Successful in 23s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 11:09:11 +01:00
LarsandClaude Opus 5.5 afe35fc11f Nimm Auswahlfelder von der grünen Hauptknopf-Regel aus.
CI Feature / test (push) Successful in 1m3s
Deploy Test / test (push) Successful in 58s
Deploy Test / deploy (push) Successful in 31s
Die Regel für gefüllte Filament-Hauptknöpfe traf auch ToggleButtons (etwa die
Rasterauswahl im Seiteneditor); gewählte und nicht gewählte Optionen sahen
gleich aus. Sie gilt jetzt nur für Knöpfe und Links.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 11:04:01 +01:00
LarsandClaude Opus 5.5 514eb46217 Ergänze die Abnahme Teil B um Tastatur, alle Anlegedialoge und Angebotsbedingungen.
CI Feature / test (push) Successful in 1m0s
Deploy Test / test (push) Successful in 56s
Deploy Test / deploy (push) Successful in 23s
Schreibt „Neue fachliche Kombination“ klein.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 09:16:21 +01:00
LarsandClaude Opus 5.5 71e71b4ef2 Übernimm verdeckte Angebotsbedingungen und halte die Listenlänge beim Anlegen.
CI Feature / test (push) Successful in 59s
Deploy Test / test (push) Successful in 56s
Deploy Test / deploy (push) Successful in 23s
- „Geänderte Fassung aktivieren“ übernimmt Inhaberart, Laufzeitregel,
  Steuerklasse und „dynamisch“ aus der aktiven Fassung. Bisher wurden sie still
  auf Person/dauerhaft zurückgesetzt, obwohl die Maske „vorbelegt“ sagte. Ohne
  aktive Fassung gilt wie bisher die Vorgabe.
- Nur Such- und Filteränderungen lassen die Liste wieder oben beginnen; Eingaben
  in einem geöffneten Anlegedialog klappen „Weitere anzeigen“ nicht mehr zu.
- Test: Kombinationen öffnen Aufbau und Redaktion aus der Liste.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 09:11:27 +01:00
LarsandClaude Opus 5.5 0a0e4edbc2 Schreibe die Abnahme für Teil B und führe Regeln und Funktionszuordnung nach.
CI Feature / test (push) Successful in 1m0s
Deploy Test / test (push) Successful in 56s
Deploy Test / deploy (push) Successful in 24s
abnahme/teil-b.md mit geprüftem Code-Stand, Abläufen auf luf-test bei
1440/900/760 px, mitgelieferter Korrektur von „Medium anlegen“, gefundenen
Fehlern, offenen Fachfragen und 22 Belegbildern. CLAUDE.md und die
Cursor-Regel nennen die gemeinsame Bestandsliste, den Eintrag und die
Katalog-Objektseite; Dokument 16 die neue Zuordnung.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 09:07:03 +01:00
LarsandClaude Opus 5.5 b60029431f Gib den Abschnitten der Katalog-Objektseite Abstand.
CI Feature / test (push) Successful in 59s
Deploy Test / test (push) Successful in 55s
Deploy Test / deploy (push) Successful in 23s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 09:00:06 +01:00
LarsandClaude Opus 5.5 f4376ae819 Benenne die Zustandsliste jeder Zeile eindeutig.
CI Feature / test (push) Successful in 59s
Deploy Test / test (push) Successful in 55s
Deploy Test / deploy (push) Successful in 24s
Das Filterfeld „Zustand“ und die Zustandsliste jeder Zeile trugen denselben
zugänglichen Namen; die Zeilenliste heißt jetzt „Zustand von …“.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 08:56:27 +01:00
LarsandClaude Opus 5.5 51d58ac55c Ordne Paket, Rechteprofil, Säulen, Kombinationen und Benutzer in die gemeinsamen Muster ein.
CI Feature / test (push) Successful in 1m0s
Deploy Test / test (push) Successful in 55s
Deploy Test / deploy (push) Successful in 23s
- 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>
2026-11-20 08:53:25 +01:00
LarsandClaude Opus 5.5 3aa1bad859 Zeige den Leistungsumfang eines Angebots lesbar und den Pfad nur einmal.
CI Feature / test (push) Successful in 59s
Deploy Test / test (push) Successful in 54s
Deploy Test / deploy (push) Successful in 23s
Die Fähigkeiten im aufgelösten Leistungsumfang tragen dieselben
Bezeichnungen wie beim Rechteprofil („Film ansehen“ statt „film: streamen“).
Filaments eigener Pfad entfällt auf der Angebotsseite wie bei Medien und
Aufbau. Der Art-Umschalter der Bestandsliste bricht nicht mehr um.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 08:35:50 +01:00
LarsandClaude Opus 5.5 660b50f418 Stelle die Kataloglisten und das Angebot auf die gemeinsamen Muster um.
CI Feature / test (push) Successful in 1m0s
Deploy Test / test (push) Successful in 54s
Deploy Test / deploy (push) Successful in 23s
- Lizenzartikel, Pakete, Rechteprofile und Angebote nutzen die gemeinsame
  Bestandsliste (ListsCatalog): Suche, Zustandsfilter, lesbare Zustände aus
  vorhandenen Daten statt „Aktueller Stand: 1“ oder „Fassungen: aktiv“
  (Stand veröffentlicht/in Arbeit/gesperrt, in aktivem Angebot, Fassung aktiv
  mit Vergabe und Preis, Bestandteile, Zweck und Fähigkeiten). Lizenzartikel
  zeigen ihr Titelbild.
- Anlegedialoge benennen Zweck und Bestätigung und öffnen danach den neuen
  Eintrag, statt in der Liste stehen zu bleiben.
- Angebot im gemeinsamen Rahmen (Kopf, Positionen, aufgelöster
  Leistungsumfang, Fassungsverlauf). Eine Maske für Anlegen und Ändern
  (FACH-20): „Fassung aktivieren“ bzw. „Geänderte Fassung aktivieren“, bei einer
  Änderung mit der aktiven Fassung vorbelegt (FACH-08). Wirkung unverändert
  OfferService::activate: die bisherige Fassung wird beendet und bleibt
  gespeichert. „Als Vorlage verwenden“ (FACH-09) bleibt offen (OFF-04).
- Entfernt: editorial/catalog-card (ersetzt).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 08:29:28 +01:00
LarsandClaude Opus 5.5 532979aa86 Führe die gemeinsame Bestandsliste für Arbeitsplatz, Module, Programme und Medien ein.
CI Feature / test (push) Successful in 59s
Deploy Test / test (push) Successful in 54s
Deploy Test / deploy (push) Successful in 23s
Dokument 14 §3 und §9: eine gepflegte Liste statt Kartenwand, Filterwand und
Filament-Tabellen.

- Gemeinsamer Eintrag x-vw.eintrag (Vorschau, Titel, Typzeile), genutzt vom
  Picker und von allen Listen.
- Ansicht verwaltung/bestand mit Trait ShowsBestand: Suche, wenige sichtbare
  Filter, „Weitere Filter“, aktive Filter als entfernbare Chips mit „Alle
  zurücksetzen“, Trefferzahl, Zeilen mit Zustand und benannten Aktionen,
  Kacheln als Option, „Weitere anzeigen“ in Schritten von 50, Leerzustand und
  eigener Dialogbereich (sonst öffnen „… anlegen“-Dialoge nicht).
- Arbeitsplatz, „Module“ und „Programme“ zeigen dieselben Zeilen
  (ListsCompositions); die Listen mit festem Typ. Ein Anlegedialog für Module
  und Programme statt Inline-Feldern und eines zweiten Filament-Dialogs; die
  Anlage nutzt wie bisher EditorialCatalog::create.
- Medien: Suche, Technische Art, Freigabe und Verwendung sichtbar, die übrigen
  acht Filter unter „Weitere Filter“; alle Adressnamen bleiben. Grundansicht ist
  jetzt die Liste (Dokument 14: kompakte Listen), Kacheln bleiben wählbar.
- Hauptknöpfe im Filament-Seitenkopf im Verwaltungsgrün.
- Entfernt: media/library, media/card, media/mark (ersetzt).

Tests bewusst angepasst: Die Medienliste öffnet als Liste; das Ersatzsymbol
nennt die Art über data-symbol.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 08:20:57 +01:00
LarsandClaude Opus 5.5 f846c0b2ee Zeige den Dialog „Medium anlegen“ in der Medienliste wieder an.
CI Feature / test (push) Successful in 1m0s
Deploy Test / test (push) Successful in 54s
Deploy Test / deploy (push) Successful in 23s
Filament gibt den Dialogbereich einer Listenseite über die Tabelle aus. Die
Medienliste ersetzt die Tabelle durch die eigene Kachel-/Listenansicht; damit
fehlte der Bereich, „Medium anlegen“ wurde zwar geöffnet, aber nie
angezeigt. Die Ansicht gibt den Dialogbereich jetzt selbst aus. Der Knopf im
Dialog heißt „Medium anlegen“ statt „Absenden“.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 07:58:48 +01:00
LarsandClaude Opus 5.5 335b09f40e Ergänze die Abnahme um die geprüften Dialog-Einstiege des Medieneditors.
CI Feature / test (push) Successful in 55s
Deploy Test / test (push) Successful in 53s
Deploy Test / deploy (push) Successful in 22s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 07:39:49 +01:00
LarsandClaude Opus 5.5 7b712e0c45 Nenne die Fassungsnummer im Titel der Dialoge Freigeben und Deaktivieren.
CI Feature / test (push) Successful in 59s
Deploy Test / test (push) Successful in 53s
Deploy Test / deploy (push) Successful in 24s
Freigeben ist jetzt an der Fassung, unter „Weitere Aktionen“ und im Kopf
erreichbar; der Titel „Fassung 3 freigeben“ bzw. „Fassung 2 deaktivieren“
zeigt, welche Fassung betroffen ist.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 07:36:38 +01:00
LarsandClaude Opus 5.5 4847303a6f Ersetze eine fremde Fassungsangabe in der Adresse beim Festhalten.
CI Feature / test (push) Successful in 58s
Deploy Test / test (push) Successful in 53s
Deploy Test / deploy (push) Successful in 23s
Mit `?fassung=` einer Fassung eines anderen Mediums blieb die Angabe stehen;
die Anzeige fiel auf die Vorgabe zurück und konnte nach einer Freigabe wieder
auf eine andere Fassung wandern. Die gezeigte Fassung wird jetzt immer aus
den eigenen Fassungen bestimmt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 07:29:51 +01:00
LarsandClaude Opus 5.5 608550b620 Schreibe die Abnahme für Aufbauarbeitsplatz und Medieneditor.
CI Feature / test (push) Successful in 54s
Deploy Test / test (push) Successful in 53s
Deploy Test / deploy (push) Successful in 33s
Abschnitte 2 und 3 in abnahme/teil-a.md mit geprüftem Code-Stand,
Abläufen auf luf-test (1440/900/760 px), gefundenen und behobenen Fehlern,
verbleibenden Abweichungen und 20 Belegbildern. Dokument 16 nennt die
neue Zuordnung von Aufbau und Medieneditor.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 07:27:05 +01:00
LarsandClaude Opus 5.5 0a8ff0761a Halte die gezeigte Fassung fest, damit kein Text auf eine andere Fassung rutscht.
CI Feature / test (push) Successful in 56s
Deploy Test / test (push) Successful in 54s
Deploy Test / deploy (push) Successful in 23s
Ohne ausdrückliche Auswahl zeigte der Medieneditor die neueste freigegebene
Fassung. Legte „Neue Fassung anlegen“ eine Fassung an oder gab „Freigeben“
einen Entwurf frei, wechselte die Anzeige still auf diese Fassung, während
das Textfeld noch den Wortlaut der bisherigen enthielt; „Text speichern“
hätte ihn in die neue Fassung geschrieben (auf luf-test beim Prüflauf am
Prüfmedium so geschehen). Die gezeigte Fassung wird beim Öffnen festgehalten,
und ob offener Text besteht, wird vor dem Anlegen geprüft.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 07:22:07 +01:00
LarsandClaude Opus 5.5 a994c875ee Beginne die Filmstellenwahl bei der Stelle des aktuellen Vorschaubilds.
CI Feature / test (push) Successful in 56s
Deploy Test / test (push) Successful in 53s
Deploy Test / deploy (push) Successful in 23s
Stammte das Vorschaubild aus Sekunde 41,5 der gezeigten Fassung, stand der
Regler trotzdem auf 0. Ohne eigene Wahl beginnen Regler und Zahl jetzt bei
der aktuellen Stelle.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 07:11:32 +01:00
LarsandClaude Opus 5.5 d33ce86ae3 Beschrifte den Dialog „Neue Fassung anlegen“ und gleiche Filament-Hauptknöpfe an.
CI Feature / test (push) Successful in 59s
Deploy Test / test (push) Successful in 58s
Deploy Test / deploy (push) Successful in 26s
Der Fassungsdialog hatte „Absenden“ ohne Erklärung. Er nennt jetzt Zweck und
Folgen und bestätigt mit „Fassung anlegen“. Hauptaktionen in Filament-Dialogen
(anlegen, freigeben, deaktivieren) erscheinen im Grün der Verwaltung mit
weißer Schrift statt in Filaments hellem Grün.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 07:06:20 +01:00
LarsandClaude Opus 5.5 d1b10ef11d Ordne den Medieneditor in den Rahmen des Aufbauarbeitsplatzes ein.
CI Feature / test (push) Successful in 59s
Deploy Test / test (push) Successful in 54s
Deploy Test / deploy (push) Successful in 23s
Dokument 14 §4: Medien nutzen denselben Rahmen wie Module und Programme.
Das Register „Inhalt und Fassungen“ zeigt die Fassungen links (gleiche
Bausteinzeilen, ohne Griff und Position, weil nicht sortierbar) und die
gewählte Fassung rechts mit Abspieler oder Lehrtext, Status, Änderungsnotiz,
Begründung einer Deaktivierung, Freigabehindernis, „Im eigenen Tab“,
Freigeben, Deaktivieren und den Modulen und Programmen, die genau diese
Fassung einbinden. Medien ohne Fassung zeigen statt einer leeren Liste den
Hinweis und „Erste Fassung anlegen“.

- Wechsel der Fassung verwirft keinen ungespeicherten Lehrtext mehr still,
  sondern fragt über den gemeinsamen Bestätigungsdialog. Offener Text steht im
  Kopfstatus und löst die Abgangswarnung aus.
- „Text speichern“ auf einer verwendeten Fassung legt die neue Fassung an und
  wählt sie aus; die Rückmeldung steht im Detailbereich. Nach „Neue Fassung
  anlegen“ wird die neue Fassung gezeigt, sofern kein offener Text verloren geht.
- Vorschaubild als eigenes Register wie „Didaktik und Katalogbild“: Bild,
  Alternativtext, Filmstelle (Regler und Zahl zeigen denselben Wert),
  Hochladen, Bilddatei, Bestand.
- Verwendung als Liste mit Verweisen, getrennt nach Modulen/Programmen und
  Lizenzartikeln, statt Doppelausgabe.
- „Fassung freigeben“ im Kopf wandert unter „Weitere Aktionen“, weil die
  Freigabe jetzt an der Fassung steht. „bereich=fassungen“ bleibt als Adresse
  gültig und öffnet das zusammengelegte Register.

Tests bewusst angepasst: Der Lehrtext steht nur noch im Bearbeitungsfeld
(assertSet statt assertSee), die Filmstelle im Register Vorschaubild, die
Verwendung als verlinkte Liste.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 06:59:59 +01:00
LarsandClaude Opus 5.5 60f5b8e6c0 Nenne im Stand-Chip die Fassung, die die Bibliothek zeigt.
Zeigt die Mitgliederbibliothek eine ältere Fassung, stand „In der
Mitgliederbibliothek“ neben „Fassung 2“ und las sich, als wäre Fassung 2
sichtbar. Der Chip heißt dann nur „Bibliothek zeigt Fassung 1“ (Arbeitsplatz-
karten und Register „Fassungen und Verwendung“). Das Menü im Detailbereich des
Aufbaus trägt einen eigenen zugänglichen Namen, damit es sich vom Seitenmenü
„Weitere Aktionen“ unterscheidet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 06:59:46 +01:00
LarsandClaude Opus 5.5 105d27f9c9 Halte Aufklappen an der Quelle fest und nenne die in der Bibliothek sichtbare Fassung richtig.
CI Feature / test (push) Successful in 1m2s
Deploy Test / test (push) Successful in 56s
Deploy Test / deploy (push) Successful in 26s
Aufgeklappte Module bleiben beim Verschieben aufgeklappt. Der Hinweis zur
Mitgliederbibliothek widersprach den Fassungsangaben, wenn eine ältere
Fassung sichtbar war.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 06:34:48 +01:00
LarsandClaude Opus 5.5 7eb3cd6230 Baue den Aufbauarbeitsplatz nach dem kombinierten Entwurf um.
CI Feature / test (push) Successful in 58s
Deploy Test / test (push) Successful in 52s
Deploy Test / deploy (push) Successful in 24s
Struktur links mit Position, Ziehgriff, aufklappbarem Quelleninhalt und
Auf/Ab für die ausgewählte Verwendung; rechts der Detailbereich mit „An
dieser Stelle“ (Rolle, Hinweis, Fassung), „Quelle“ und „Inhaltsvorschau“.
Didaktik und Katalogbild sowie Fassungen und Verwendung sind eigene
Bereiche statt Dialog und Seitenspalte. Freigabe- und Textdialog nutzen
den gemeinsamen Dialog.

Entfernt verdeckte Speicherungen: Hinzufügen eines Bestandteils speichert
den Entwurf nicht mehr nebenbei (Ausnahme: ausdrückliches „Zurück und
einbinden“), der Textwortlaut wird an der Quelle gespeichert, ohne den
Aufbau mitzuspeichern. Der Mediendialog „Angaben und Vorschaubild“ war
ein zweiter Editor für Medientexte und weicht „Quelle bearbeiten“.
Vorhandene Bilder als Katalogbild kommen über den gemeinsamen Picker.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 06:28:16 +01:00
LarsandClaude Opus 5.5 156cdd6976 Schreibe die Abnahme des Redaktionsmanagers auf den geprüften Endstand fort.
CI Feature / test (push) Successful in 52s
Deploy Test / test (push) Successful in 52s
Deploy Test / deploy (push) Successful in 23s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 23:47:08 +01:00
LarsandClaude Opus 5.5 baa7691ab5 Öffne „Neues Medium anlegen“ aus dem Picker erst nach dem Schließen des Pickers.
CI Feature / test (push) Successful in 56s
Deploy Test / test (push) Successful in 52s
Deploy Test / deploy (push) Successful in 23s
Filament rendert beim Öffnen einer Aktion nicht neu; der Dialog wird deshalb
nach der Antwort per $wire geöffnet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 23:36:03 +01:00
LarsandClaude Opus 5.5 494e9fa0fb Gib den Aufbau-Dialogen Fokusfalle und Esc und öffne „Medium anlegen“ ohne offenen Picker dahinter.
CI Feature / test (push) Successful in 58s
Deploy Test / test (push) Successful in 51s
Deploy Test / deploy (push) Successful in 37s
Dialoge zeigen beim Öffnen keine Meldung einer früheren Aktion mehr.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 23:28:54 +01:00
LarsandClaude Opus 5.5 e7b0932e54 Sichere den Redaktions-Arbeitsstand ab und entferne den Parallel-Editor.
CI Feature / test (push) Successful in 57s
Deploy Test / test (push) Successful in 51s
Deploy Test / deploy (push) Successful in 23s
- Speichern löst nur Zuordnungen, die beim Laden da waren; zwischenzeitlich
  anderswo ergänzte bleiben erhalten.
- Eine belegte Einzelrolle (Titelbild, Hero, Hover) wird im Picker
  ausdrücklich ausgetauscht, mit Banner und benanntem Ersatz.
- Gemeinsamer Bestätigungsdialog statt Browser-confirm(); Warnung beim
  Verlassen der Seite mit ungespeicherten Änderungen.
- „Ausgabe prüfen“ am Medium benennt, welche Angaben aktuell und welche
  gespeichert sind.
- Das frühere Gesamtformular für Medien leitet in die Redaktion; „Löschen“
  steht unter „Weitere Aktionen“, die Medienliste öffnet die Redaktion.
- Vorschaubild aus vorhandenem Bild wieder über den gemeinsamen Picker
  wählbar (Oberfläche war seit 72130d6 entfallen).
- Vorgemerkte Upload-Dateien bleiben sichtbar, Brotkrumen führen zur Liste,
  die Redaktion lässt sich über die Adresse nicht ohne Recht öffnen.
- Agentenregeln und CLAUDE.md verweisen auf die gemeinsamen Bausteine.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 23:22:44 +01:00
LarsandClaude Opus 5.5 872f156d7d Belege die Abnahme des Redaktionsmanagers und fange schmale Bausteinkarten ab.
CI Feature / test (push) Successful in 55s
Deploy Test / test (push) Successful in 50s
Deploy Test / deploy (push) Successful in 23s
Abnahme Teil A, Abschnitt 1 mit Prüfabläufen und Screenshots von luf-test.
Bausteinkarten im Aufbau umbrechen unter 861 px, statt Text abzuschneiden.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 23:07:03 +01:00
LarsandClaude Opus 5.5 2d63109553 Glätte Statuszeilen, Galeriestatus und Artikeltitel nach der Sichtprüfung.
CI Feature / test (push) Successful in 56s
Deploy Test / test (push) Successful in 52s
Deploy Test / deploy (push) Successful in 23s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 22:59:54 +01:00
LarsandClaude Opus 5.5 9dc4b4e64d Führe Browser-Zurück aus der Redaktion verlustfrei in den Ausgangseditor.
CI Feature / test (push) Successful in 55s
Deploy Test / test (push) Successful in 51s
Deploy Test / deploy (push) Successful in 28s
Der geöffnete Redaktionsmanager steht in der Adresse (redaktion=1). Zurück
und Vor im Browser wechseln innerhalb derselben Komponente; offene Eingaben
beider Seiten bleiben erhalten.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 22:52:25 +01:00
LarsandClaude Opus 5.5 1b271e0ce7 Zeige Programme ohne Fassung neutral und schreibe Tokens und Funktionszuordnung fort.
CI Feature / test (push) Successful in 50s
Deploy Test / test (push) Successful in 51s
Deploy Test / deploy (push) Successful in 23s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 22:49:14 +01:00
LarsandClaude Opus 5.5 e1fd59491c Baue den Redaktionsmanager auf gemeinsame Bausteine um.
CI Feature / test (push) Successful in 56s
Medium, Modul, Programm und Lizenzartikel nutzen denselben Objektkopf,
dieselben Register (Texte, Präsentationsmedien, Einordnung) und denselben
visuellen Picker. Präsentationsmedien, Abweichungen und Texte bilden einen
Arbeitsstand, den nur „Redaktion speichern“ schreibt; Austausch behält die
Position, Sortierung bleibt in der Rolle. Der Wechsel zur Redaktion und zurück
erhält offene Eingaben des Ausgangseditors.

Entfernt versteckte Mitspeicherungen: Der Didaktikdialog schreibt keine
Redaktionstexte mehr, die Website-Freigabe keine offenen Quellenzeilen,
Entwurf verwerfen setzt keine offenen Redaktionseingaben zurück. Tests, die
alte Orte oder CSS-Zeichenketten prüften, sind auf die neue Bedienung
umgestellt; neue Tests decken Arbeitsstand, Austausch, Abbrechen und
Rückweg ab. Datenmodell, Fassungen und Rechte bleiben unverändert.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 22:46:43 +01:00
Lars 41658d98dd Richte Redaktionskarten und Redaktionskopf am Zeilenlayout aus.
Deploy Test / test (push) Successful in 1m3s
Deploy Test / deploy (push) Successful in 23s
2026-11-19 21:31:39 +01:00
Lars b9fe0e3791 Richte die Redaktionsformulare an den Mockups aus.
Deploy Test / test (push) Successful in 55s
Deploy Test / deploy (push) Successful in 24s
Abschnitte, Medienkarten, Einordnung und Auswahl folgen der vorgegebenen Form. Datenmodell und Fassungen bleiben unverändert.
2026-11-19 15:28:22 +01:00
Lars 4c29ab2593 Führe den gemeinsamen Redaktionsarbeitsplatz ein.
Deploy Test / test (push) Successful in 55s
Deploy Test / deploy (push) Successful in 24s
Texte, Medienzuordnung und Einordnung teilen sich einen Arbeitsplatz. Fassungen, Rechte und das Datenmodell bleiben unverändert.
2026-11-19 14:43:15 +01:00
610 changed files with 29785 additions and 2999 deletions

No files matched your search

+19
View File
@@ -0,0 +1,19 @@
---
description: Gemeinsame verbindliche UX-Vorgaben für Verwaltungsänderungen bei Lara & Felix. Ergänzt die Betriebsregeln, ersetzt sie nicht.
alwaysApply: true
---
# Verwaltung – gemeinsame Designgrundlage
Betriebsregeln in `CLAUDE.md` und `.cursor/rules/luf-betrieb.mdc` bleiben verbindlich. Diese Datei ergänzt sie für die Verwaltungsoberfläche.
1. `CLAUDE.md`, vorhandene aktive Repository-Regeln und `docs/ux/verwaltung/README.md` lesen.
2. `docs/ux/verwaltung/14-verwaltungsstandard.md` ist die maßgebliche UX-Grundlage. `15-umbauauftrag.md` beschreibt Umsetzung und Nachweise. Keine erneute allgemeine Designfreigabe oder neue Mockups je Screen verlangen.
3. Gemeinsame Komponenten statt kopierter Masken: Rahmen, Listen, Picker, Redaktion, geordnete Zuordnung, Status/Aktionen und Vorschau. Fachlich zulässige Typen und Referenzen sind Kontext derselben Komponente. Vorhanden in `resources/views/filament/verwaltung/`: `kopf` (Objektkopf, Status, Aktionen, Weitere Aktionen), `redaktion` (Manager), `texte`/`textfeld`, `praesentation`/`zuordnung-menue`, `einordnung`, `varianten`, `picker` (auch Aufbau, Vorschaubild und CMS-Bilder; Logik im Trait `ChoosesMedia`), `bestand` (gemeinsame Bestandsliste mit Suche, Filtern, aktiven Filterchips, Zeilen/Kacheln, „Weitere anzeigen“ und Dialogbereich; Trait `ShowsBestand`), Komponente `<x-vw.eintrag>` (Vorschau, Titel, Typzeile; Picker und Listen), `aufbau` (Struktur links, Detail rechts; auch Fassungen eines Mediums), `catalog/objekt` (Angebot, Paket, Rechteprofil), `cms/seite-kopf` (Seiteneditor mit Registern und Kontexten), Webpräsenz `cms/menues` mit `menue-zeile`, `menue-detail`, `ziel-auswahl` (Menüs als Arbeitsstand, breit Liste mit Detail, schmal ein aufgeklappter Eintrag), `bestaetigung` (statt `wire:confirm`), `abgang` (Warnung bei ungespeicherten Änderungen), `styles` (Tokens, einmal je Seite über den Panel-Hook). Logik im Trait `App\Filament\Support\ManagesEditorialSurface`; neue Objektarten liefern nur Feldliste, Einordnungsgruppen und Kopfangaben.
4. Eindeutigen Speicherumfang, Zustand und Vorschau-Datenstand anzeigen. Keine pauschale neue Genehmigungskette. Produktbeschreibung, Lehrinhalt, kommerzielle Daten und technische Verwaltung gezielt gliedern.
5. Redaktion für Medien einschließlich Filmen, Module, Programme und Lizenzartikel gemeinsam nutzen. Zentrale Medien referenzieren, mehrere Medien je Rolle und reine Präsentationsmedien ohne Lehrfassung erhalten.
6. Rückkehr mit offenen Eingaben sicherstellen; kein Pflichtspeichern vor dem Redaktionswechsel, kein heimliches Mitspeichern und kein veraltetes Zurückschreiben.
7. Bestehende Erwerbe, Rechte, Historie und fachliche Fassungsregeln erhalten. Offene Fragen in Dokument 04 nicht selbst durch neue Geschäftsregeln entscheiden; nur tatsächlich abhängige Teile gezielt klären.
8. Bestehende Tokens und freigegebene Assets nutzen. Verwaltungsmaße: `docs/ux/verwaltung/tokens.md`. Bilder sind räumliche Referenzen, keine autoritative Farbquelle oder auszuliefernde UI-Grafik.
9. Betroffene Abläufe funktional und visuell prüfen: Rückkehr, relevante Fehler-/Leer-/Ladezustände, Tastatur, breite/schmalere Fenster und fachliche Regressionen. Bestehende Betriebs- und Testregeln erfüllen.
10. Tatsächliche Komponentenwiederverwendung, Prüfergebnisse, gerenderte Screenshots und konkrete Abweichungen liefern; `docs/ux/verwaltung/regeln/ux-abnahme-vorlage.md` verwenden. Keine unbewiesene Abnahme behaupten.
+13
View File
@@ -0,0 +1,13 @@
# Einstieg für Coding-Agenten
Betriebs-, Test-, Deployment- und Medienschutzregeln stehen in `CLAUDE.md` und in `.cursor/rules/luf-betrieb.mdc`. Sie gelten unverändert.
Für die Verwaltung zusätzlich:
- `docs/ux/verwaltung/14-verwaltungsstandard.md` ist die maßgebliche Designgrundlage, `docs/ux/verwaltung/15-umbauauftrag.md` der konkrete Auftrag. Keine neue allgemeine Designfreigabe oder Screenserie verlangen.
- `docs/ux/verwaltung/README.md` und Dokument 04 für Herkunft und offene Geschäftsfragen. Historische Entwürfe nach der Rangfolge in Dokument 14 lesen.
- Gleichartige Aufgaben mit den gemeinsamen Komponenten unter `resources/views/filament/verwaltung/` und `resources/views/filament/editorial/` lösen. Fachfunktionen, Datenbeziehungen, Rechte und Fassungsbindungen erhalten.
- Offene Eingaben beim Wechsel zur Redaktion und zurück erhalten. Speicherwirkung benennen. Maße in `docs/ux/verwaltung/tokens.md`.
- Hauptabläufe prüfen, bestehende Testpflichten erfüllen, Abweichungen konkret benennen. Keine ungeprüfte Abnahme behaupten.
Diese Datei ergänzt die Betriebsregeln und löst kein Deployment aus.
+7
View File
@@ -59,3 +59,10 @@ ## Entwicklung
- Commits: kurze, deutsche oder englische Betreffzeile im Imperativ, ein logischer Schritt pro Commit. - Commits: kurze, deutsche oder englische Betreffzeile im Imperativ, ein logischer Schritt pro Commit.
- Änderungen an `.gitea/workflows/`, `Dockerfile`, `docker-compose.yml` und `scripts/deploy.sh` wirken direkt auf Test und Prod. Sie werden nur gezielt und mit Begründung geändert und in `docs/betrieb/DEPLOYMENT.md` nachgeführt. - Änderungen an `.gitea/workflows/`, `Dockerfile`, `docker-compose.yml` und `scripts/deploy.sh` wirken direkt auf Test und Prod. Sie werden nur gezielt und mit Begründung geändert und in `docs/betrieb/DEPLOYMENT.md` nachgeführt.
- Nicht verifizierte Aussagen zu Servern oder Kapazitäten werden als solche gekennzeichnet. Nichts erfinden (Ports, Hostnamen, Pfade, Zugangsdaten). - Nicht verifizierte Aussagen zu Servern oder Kapazitäten werden als solche gekennzeichnet. Nichts erfinden (Ports, Hostnamen, Pfade, Zugangsdaten).
## Verwaltungsoberfläche
- Maßgeblich sind `docs/ux/verwaltung/14-verwaltungsstandard.md` (Design und Interaktion) und `15-umbauauftrag.md` (Auftrag, Nachweise). Keine neue allgemeine Designabstimmung verlangen. Einstieg für alle Agenten: `AGENTS.md`, `.cursor/rules/verwaltung-ux.mdc`.
- Gemeinsame Bausteine wiederverwenden statt neue Masken bauen: `resources/views/filament/verwaltung/` (`kopf`, `redaktion`, `texte`, `praesentation`, `einordnung`, `picker`, `bestaetigung`, `abgang`, `aufbau`, `bestand`) mit dem Trait `App\Filament\Support\ManagesEditorialSurface`. Listen nutzen `verwaltung/bestand` mit `ShowsBestand` (bzw. `ListsCompositions`, `ListsCatalog`) und den Eintrag `<x-vw.eintrag>`, den auch der Picker verwendet; Katalogobjekte die Seite `catalog/objekt`. CMS: Seitenkopf `cms/seite-kopf` (Register, Kontexte „Abschnitt gestalten“ und „Konfigurieren“); Seiten und Menüs in der Webpräsenz (`App\Filament\Pages\Webpraesenz`, Menüs als Arbeitsstand mit einer Speicherhandlung). Der Picker liegt im Trait `ChoosesMedia` (Redaktion über `ManagesEditorialSurface`, CMS-Bilder über `ChoosesWebsiteImages`); keine eigenen Auswahllisten für Medien bauen. Redaktionelle Auswahlwerte (Materialart, Einordnung) nur über `App\Domain\Catalog\EditorialVocabulary` anbieten und prüfen (aktiv, zulässiger Kontext, vorhandene Zuordnungen erhalten); gepflegt werden sie unter „Redaktionelle Stammdaten“. Fachliche Säulen gibt es nur in der Säulenverwaltung (`pillars`); Zuordnung über `PillarService::assign`, nie über eine Dimension. Ersetzt eine Seite die Filament-Tabelle, muss sie den Dialogbereich ausgeben (in `bestand` enthalten), sonst öffnen „… anlegen“-Dialoge nicht. Gestaltungswerte nur in `verwaltung/styles.blade.php` (Tokens `--vw-…`, dokumentiert in `docs/ux/verwaltung/tokens.md`).
- Die Redaktion ist ein Arbeitsstand: nur „Redaktion speichern“ schreibt Texte, Einordnung, Präsentationsmedien und Abweichungen. Kein verdecktes Mitspeichern aus anderen Dialogen, offene Eingaben bleiben beim Wechsel erhalten.
- Jede UI-Änderung in der echten Anwendung prüfen (luf-test, breite und schmale Fenster, Tastatur) und mit Screenshots in `docs/ux/verwaltung/abnahme/` belegen. Stand der Abnahme: `abnahme/teil-a.md`, `abnahme/teil-b.md`, `abnahme/teil-c.md`, `abnahme/stammdaten.md`.
@@ -0,0 +1,25 @@
<?php
namespace App\Console\Commands;
use App\Domain\Catalog\LegacyPillarAdoption;
use Illuminate\Console\Command;
class AdoptLegacyPillars extends Command
{
protected $signature = 'luf:saeulen-uebernehmen {--dry-run : Nur berichten, nichts schreiben}';
protected $description = 'Übernimmt die alte Dimension „Fachliche Säule“ in die zentrale Säulenverwaltung und berichtet ungeklärte Fälle';
public function handle(): int
{
$dryRun = (bool) $this->option('dry-run');
$report = (new LegacyPillarAdoption)->run($dryRun);
foreach (LegacyPillarAdoption::lines($report, $dryRun) as $line) {
$this->line($line);
}
return $report['unresolved'] === [] ? self::SUCCESS : self::FAILURE;
}
}
+1 -1
View File
@@ -67,7 +67,7 @@ private function createFixture(
$kind = EditorialContentKind::query()->where('slug', 'programm')->first(); $kind = EditorialContentKind::query()->where('slug', 'programm')->first();
if ($kind === null) { if ($kind === null) {
$this->error('Die Inhaltsart Programm fehlt.'); $this->error('Die fachliche Materialart Programm fehlt.');
return self::FAILURE; return self::FAILURE;
} }
+10
View File
@@ -4,6 +4,7 @@
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasMany;
class Composition extends Model class Composition extends Model
@@ -44,4 +45,13 @@ public function versions(): HasMany
{ {
return $this->hasMany(CompositionVersion::class); return $this->hasMany(CompositionVersion::class);
} }
/**
* Direkt zugeordnete fachliche Säulen (zentrale Säulenverwaltung). Die Säulen der enthaltenen Medien sind davon
* getrennt und werden zur Laufzeit abgeleitet (CatalogReading::memberPillars).
*/
public function pillars(): BelongsToMany
{
return $this->belongsToMany(Pillar::class)->orderBy('pillars.sort_order')->orderBy('pillars.name');
}
} }
+59 -1
View File
@@ -2,17 +2,49 @@
namespace App\Domain\Catalog; namespace App\Domain\Catalog;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasMany;
/**
* Fachliche Materialart (FACH-56 bis FACH-58). Die Bezeichnung ist pflegbar, die Kennung (slug) bleibt nach dem Anlegen
* fest. Zulässige Objektkontexte bestimmen, wo eine Materialart neu gewählt werden kann; vorhandene Zuordnungen bleiben
* immer erhalten (siehe EditorialVocabulary).
*/
class EditorialContentKind extends Model class EditorialContentKind extends Model
{ {
/** Objektkontexte aus dem Fachmodell: Medium (ContentElement), Modul und Programm (Composition), Lizenzartikel. */
public const CONTEXTS = [
'medium' => 'Medium',
'modul' => 'Modul',
'programm' => 'Programm',
'lizenzartikel' => 'Lizenzartikel',
];
/**
* Kennungen, auf die der Code fachlich verweist: öffentliche Programmseiten und das Anlegen von Programmen und
* Modulen (programm, modul), Vertraulichkeit von Traineranleitungen (traineranleitung). Ihre Bezeichnung bleibt
* pflegbar; deaktivieren, Kontexte ändern und löschen sind gesperrt.
*/
public const SYSTEM_SLUGS = ['programm', 'modul', 'traineranleitung'];
protected $fillable = [ protected $fillable = [
'slug', 'slug',
'label', 'label',
'sort_order', 'sort_order',
'is_active',
'contexts',
]; ];
protected function casts(): array
{
return [
'is_active' => 'boolean',
'contexts' => 'array',
'sort_order' => 'integer',
];
}
public function compositions(): HasMany public function compositions(): HasMany
{ {
return $this->hasMany(Composition::class); return $this->hasMany(Composition::class);
@@ -23,11 +55,37 @@ public function contentElements(): HasMany
return $this->hasMany(ContentElement::class); return $this->hasMany(ContentElement::class);
} }
public function licenseArticles(): HasMany
{
return $this->hasMany(LicenseArticle::class);
}
/** /**
* @param Builder<EditorialContentKind> $query
*/
public function scopeActive(Builder $query): void
{
$query->where('is_active', true);
}
public function allows(string $context): bool
{
return in_array($context, (array) ($this->contexts ?? []), true);
}
public function isSystem(): bool
{
return in_array($this->slug, self::SYSTEM_SLUGS, true);
}
/**
* Alle Materialarten in Pflegereihenfolge (ohne Kontext- oder Aktivfilter). Für Auswahlstellen gilt
* EditorialVocabulary.
*
* @return array<int, string> * @return array<int, string>
*/ */
public static function selectOptions(): array public static function selectOptions(): array
{ {
return static::query()->orderBy('sort_order')->pluck('label', 'id')->all(); return static::query()->orderBy('sort_order')->orderBy('id')->pluck('label', 'id')->all();
} }
} }
+9 -10
View File
@@ -8,28 +8,27 @@
class EditorialDimension extends Model class EditorialDimension extends Model
{ {
/** Gespiegelte Säulen; gepflegt werden Säulen über die Säulenverwaltung, nicht als Stammdaten. */
public const PILLAR_SLUG = 'saeule';
protected $fillable = ['slug', 'label']; protected $fillable = ['slug', 'label'];
/** Werte in Pflegereihenfolge. */
public function values(): HasMany public function values(): HasMany
{ {
return $this->hasMany(EditorialDimensionValue::class); return $this->hasMany(EditorialDimensionValue::class)->orderBy('sort_order')->orderBy('id');
} }
/** /**
* Inhaltselemente pflegen Themen über die Säulen, nicht noch einmal über die Dimension. * Fachliche Säulen werden für alle Objektarten über die zentrale Säulenverwaltung gewählt (`pillars`), nie über
* Module, Programme und Lizenzartikel haben keine Säulenauswahl und behalten die Dimension. * eine Dimension. Die alte Dimension „Fachliche Säule“ bleibt nur als Verlauf in der Datenbank und wird nirgends
* mehr angeboten, geändert oder gefiltert.
* *
* @return Collection<int, self> * @return Collection<int, self>
*/ */
public static function forSubject(Model $subject): Collection public static function forSubject(Model $subject): Collection
{ {
$query = static::query()->with('values')->orderBy('label'); return static::query()->with('values')->where('slug', '!=', self::PILLAR_SLUG)->orderBy('label')->get();
if ($subject instanceof ContentElement) {
$query->where('slug', '!=', 'saeule');
}
return $query->get();
} }
/** /**
@@ -7,7 +7,15 @@
class EditorialDimensionValue extends Model class EditorialDimensionValue extends Model
{ {
protected $fillable = ['editorial_dimension_id', 'slug', 'label']; protected $fillable = ['editorial_dimension_id', 'pillar_id', 'slug', 'label', 'sort_order', 'is_active'];
protected function casts(): array
{
return [
'is_active' => 'boolean',
'sort_order' => 'integer',
];
}
public function dimension(): BelongsTo public function dimension(): BelongsTo
{ {
+252
View File
@@ -0,0 +1,252 @@
<?php
namespace App\Domain\Catalog;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
/**
* Eine Regelquelle für redaktionelle Stammdaten (FACH-56 bis FACH-58): Welche fachlichen Materialarten und welche
* Einordnungswerte Editor, Filter und Picker anbieten.
*
* - Neu wählbar sind nur aktive Werte; Materialarten zusätzlich nur im zulässigen Objektkontext.
* - Vorhandene Zuordnungen bleiben sichtbar und erhalten, auch wenn der Wert inaktiv ist oder sein Kontext geändert
* wurde; sie sind gekennzeichnet.
* - Filter finden auch Objekte mit inaktiven Werten; ein gewählter Filter bleibt erhalten.
*/
final class EditorialVocabulary
{
public const INACTIVE_SUFFIX = ' (inaktiv)';
public const OUT_OF_CONTEXT_SUFFIX = ' (hier nicht vorgesehen)';
/**
* Objektkontext eines Fachobjekts nach dem Fachmodell, null wenn es keine Materialart trägt.
*/
public function contextOf(Model $subject): ?string
{
if ($subject instanceof ContentElement) {
return 'medium';
}
if ($subject instanceof LicenseArticle) {
return 'lizenzartikel';
}
if ($subject instanceof Composition) {
return self::compositionContext($subject->kind instanceof CompositionKind ? $subject->kind : CompositionKind::tryFrom((string) $subject->kind));
}
return null;
}
public static function compositionContext(?CompositionKind $kind): ?string
{
return match ($kind) {
CompositionKind::Kurs => 'programm',
CompositionKind::Uebung => 'modul',
default => null,
};
}
/**
* Auswahl der Materialart in einem Editor: aktive, im Kontext zulässige Arten in Pflegereihenfolge, dazu die
* bereits zugeordnete Art mit Kennzeichnung, falls sie inaktiv oder hier nicht vorgesehen ist.
*
* @return array<int, string>
*/
public function kindOptions(string $context, ?int $currentId = null): array
{
$options = [];
foreach (EditorialContentKind::query()->orderBy('sort_order')->orderBy('id')->get() as $kind) {
$offered = $kind->is_active && $kind->allows($context);
if ($offered) {
$options[$kind->id] = (string) $kind->label;
} elseif ($currentId !== null && $kind->id === $currentId) {
$options[$kind->id] = $this->kindLabel($kind, $context);
}
}
return $options;
}
/**
* Prüft eine neue Materialart serverseitig. Die bereits gespeicherte Art bleibt immer zulässig.
*/
public function kindError(string $context, ?int $newId, ?int $storedId): ?string
{
if ($newId === null || $newId === $storedId) {
return null;
}
$kind = EditorialContentKind::query()->find($newId);
if (! $kind instanceof EditorialContentKind) {
return 'Diese fachliche Materialart gibt es nicht mehr.';
}
if (! $kind->is_active) {
return 'Die fachliche Materialart „'.$kind->label.'“ ist deaktiviert und kann nicht neu gewählt werden.';
}
if (! $kind->allows($context)) {
return 'Die fachliche Materialart „'.$kind->label.'“ ist für '.(EditorialContentKind::CONTEXTS[$context] ?? $context).' nicht vorgesehen.';
}
return null;
}
/**
* Filteroptionen der Materialart für einen Bestand: im Kontext zulässige Arten und Arten, die dort tatsächlich
* vorkommen (gekennzeichnet), dazu ein bereits gewählter Filter.
*
* @return array<string, string>
*/
public function kindFilterOptions(string $context, string $selected = ''): array
{
$used = $this->usedKindIds($context);
$options = [];
foreach (EditorialContentKind::query()->orderBy('sort_order')->orderBy('id')->get() as $kind) {
$show = ($kind->allows($context) && $kind->is_active) || in_array($kind->id, $used, true) || (string) $kind->id === $selected;
if ($show) {
$options[(string) $kind->id] = $this->kindLabel($kind, $context);
}
}
return $options;
}
public function kindLabel(EditorialContentKind $kind, string $context): string
{
return (string) $kind->label
.(! $kind->is_active ? self::INACTIVE_SUFFIX : (! $kind->allows($context) ? self::OUT_OF_CONTEXT_SUFFIX : ''));
}
/**
* @return list<int>
*/
private function usedKindIds(string $context): array
{
$query = match ($context) {
'medium' => DB::table('content_elements'),
'lizenzartikel' => DB::table('license_articles'),
'programm' => DB::table('compositions')->where('kind', CompositionKind::Kurs->value),
'modul' => DB::table('compositions')->where('kind', CompositionKind::Uebung->value),
default => null,
};
return $query === null ? [] : $query->whereNotNull('editorial_content_kind_id')->distinct()
->pluck('editorial_content_kind_id')->map(fn ($id): int => (int) $id)->all();
}
/**
* Einordnung im Editor: je angebotener Dimension aktive Werte und bereits zugeordnete inaktive Werte (gekennzeichnet).
*
* @param list<int> $assignedIds
* @return list<array{label: string, values: list<array{id: int, label: string, inactive: bool}>}>
*/
public function dimensionGroups(Model $subject, array $assignedIds): array
{
$groups = [];
foreach (EditorialDimension::forSubject($subject) as $dimension) {
$values = [];
foreach ($dimension->values as $value) {
if ($value->is_active || in_array((int) $value->id, $assignedIds, true)) {
$values[] = [
'id' => (int) $value->id,
'label' => (string) $value->label.($value->is_active ? '' : self::INACTIVE_SUFFIX),
'inactive' => ! $value->is_active,
];
}
}
if ($values !== []) {
$groups[] = ['label' => (string) $dimension->label, 'values' => $values];
}
}
return $groups;
}
/**
* Filtergruppen der Einordnung: aktive Werte, verwendete inaktive Werte (gekennzeichnet) und gewählte Filter.
*
* @param list<int> $selectedIds
* @return list<array{label: string, values: list<array{id: int, label: string}>}>
*/
public function dimensionFilterGroups(array $selectedIds = []): array
{
$used = DB::table('identity_dimension_values')->distinct()->pluck('editorial_dimension_value_id')->map(fn ($id): int => (int) $id)->all();
$groups = [];
foreach (EditorialDimension::query()->with('values')->orderBy('label')->get() as $dimension) {
if ($dimension->slug === EditorialDimension::PILLAR_SLUG) {
continue;
}
$values = [];
foreach ($dimension->values as $value) {
$id = (int) $value->id;
if ($value->is_active || in_array($id, $used, true) || in_array($id, $selectedIds, true)) {
$values[] = ['id' => $id, 'label' => (string) $value->label.($value->is_active ? '' : self::INACTIVE_SUFFIX)];
}
}
if ($values !== []) {
$groups[] = ['label' => (string) $dimension->label, 'values' => $values];
}
}
return $groups;
}
/**
* Öffentliche Filter der Mitgliederbibliothek: nur aktive Werte, ein bereits gewählter Wert bleibt sichtbar.
*
* @param list<int> $selectedIds
* @return Collection<int, EditorialDimension>
*/
public function memberFilterDimensions(array $selectedIds = []): Collection
{
$dimensions = EditorialDimension::query()->with('values')->where('slug', '!=', EditorialDimension::PILLAR_SLUG)->orderBy('label')->get();
foreach ($dimensions as $dimension) {
$dimension->setRelation('values', $dimension->values
->filter(fn (EditorialDimensionValue $value): bool => $value->is_active || in_array((int) $value->id, $selectedIds, true))
->values());
}
return $dimensions->filter(fn (EditorialDimension $dimension): bool => $dimension->values->isNotEmpty())->values();
}
/**
* Für replaceOffered: Werte, die bei diesem Fachobjekt gesetzt oder entfernt werden dürfen. Aktive Werte der
* angebotenen Dimensionen und die bereits zugeordneten inaktiven (der Editor zeigt sie gekennzeichnet an).
*
* @param list<int> $assignedIds
* @return list<int>
*/
public function editableValueIds(Model $subject, array $assignedIds): array
{
$ids = [];
foreach (EditorialDimension::forSubject($subject) as $dimension) {
foreach ($dimension->values as $value) {
if ($value->is_active || in_array((int) $value->id, $assignedIds, true)) {
$ids[] = (int) $value->id;
}
}
}
return $ids;
}
}
+10 -1
View File
@@ -57,11 +57,20 @@ public function matches(Model $subject, array $valueIds): bool
* Ersetzt nur die Werte der Dimensionen, die dieses Fachobjekt anbietet. * Ersetzt nur die Werte der Dimensionen, die dieses Fachobjekt anbietet.
* Nicht angebotene Zuordnungen, etwa gespiegelte Säulen am Inhaltselement, bleiben. * Nicht angebotene Zuordnungen, etwa gespiegelte Säulen am Inhaltselement, bleiben.
* *
* Inaktive Werte (Stammdatenpflege) sind nicht neu wählbar. Bereits zugeordnete inaktive Werte zeigt der Editor
* gekennzeichnet an; sie bleiben, solange sie mitgeschickt werden, und werden nur bei ausdrücklicher Abwahl entfernt.
*
* @param list<int> $valueIds * @param list<int> $valueIds
*/ */
public function replaceOffered(Model $subject, array $valueIds): void public function replaceOffered(Model $subject, array $valueIds): void
{ {
$offeredIds = EditorialDimension::offeredValueIds($subject); $assigned = IdentityDimensionValue::query()
->where('subject_type', $subject->getMorphClass())
->where('subject_id', $subject->getKey())
->pluck('editorial_dimension_value_id')
->map(fn ($id): int => (int) $id)
->all();
$offeredIds = app(EditorialVocabulary::class)->editableValueIds($subject, $assigned);
$ids = array_values(array_intersect( $ids = array_values(array_intersect(
array_values(array_unique(array_map(intval(...), $valueIds))), array_values(array_unique(array_map(intval(...), $valueIds))),
$offeredIds, $offeredIds,
+270
View File
@@ -0,0 +1,270 @@
<?php
namespace App\Domain\Catalog;
use Illuminate\Support\Facades\DB;
/**
* Übernimmt die frühere Kopie „Fachliche Säule“ (Dimension `saeule`) in die zentrale Säulenverwaltung (Tabelle
* `pillars`). Verlustfrei, wiederholbar und ohne Raten:
*
* - **Zuordnung Wert → Säule** nur über die gespeicherte Kennung `pfeiler-{Säulenkennung}`, die die Migration
* vom 16.11.2026 beim Spiegeln geschrieben hat, und nur, wenn die Säule existiert und nicht jünger als der Wert ist
* (sonst kann die Kennung nicht aus ihr entstanden sein). Eine abweichende Bezeichnung ist nach einem Umbenennen
* erwartet und wird nur berichtet. Die Verknüpfung steht in `editorial_dimension_values.pillar_id`.
* - **Übernommen** werden nur direkte Zuordnungen von Modulen, Programmen und Lizenzartikeln in `composition_pillar`
* und `license_article_pillar` (insert-or-ignore, daher beliebig oft ausführbar).
* - **Nicht übernommen, sondern gemeldet:** Werte ohne belastbare Kennung, Zuordnungen zu fehlenden Objekten,
* abgeleitete Zuordnungen und unbekannte Objektarten. Abgeleitete Säulen eines Programms oder Moduls entstehen zur
* Laufzeit aus den enthaltenen Medien und werden nie als direkte Zuordnung gespeichert.
* - **Medien:** Die gespiegelten Zeilen sind eine veraltete Kopie; maßgeblich ist `content_element_pillar`. Sie werden
* nicht zurückgemischt, nur gezählt.
* - Alte Zeilen werden weder geändert noch gelöscht.
*
* Nur die Datenbankfassade, damit spätere Änderungen an Modellen die Migration nicht berühren.
*/
final class LegacyPillarAdoption
{
/** @var array<string, array{table: string, column: string, subjects: string}> */
private const TARGETS = [
'composition' => ['table' => 'composition_pillar', 'column' => 'composition_id', 'subjects' => 'compositions'],
'license_article' => ['table' => 'license_article_pillar', 'column' => 'license_article_id', 'subjects' => 'license_articles'],
];
/**
* @return array{
* mapping: list<array<string, mixed>>,
* unresolved: list<array<string, mixed>>,
* copied: array<string, int>,
* already: array<string, int>,
* before: array<string, int>,
* after: array<string, int>,
* mirror: array<string, int>
* }
*/
public function run(bool $dryRun = false): array
{
$report = [
'mapping' => [],
'unresolved' => [],
'copied' => ['composition' => 0, 'license_article' => 0],
'already' => ['composition' => 0, 'license_article' => 0],
'before' => $this->counts(),
'after' => [],
'mirror' => ['element_rows' => 0, 'missing_in_pivot' => 0, 'only_in_pivot' => 0],
];
$dimension = DB::table('editorial_dimensions')->where('slug', 'saeule')->first();
if ($dimension === null) {
$report['after'] = $report['before'];
return $report;
}
$resolved = [];
foreach (DB::table('editorial_dimension_values')->where('editorial_dimension_id', $dimension->id)->orderBy('id')->get() as $value) {
$pillar = $this->pillarFor($value);
if (is_string($pillar)) {
$report['unresolved'][] = ['art' => 'Wert', 'wert_id' => (int) $value->id, 'wert' => $value->label, 'kennung' => $value->slug, 'grund' => $pillar];
$report['mapping'][] = ['wert_id' => (int) $value->id, 'wert' => $value->label, 'saeule_id' => null, 'status' => 'offen'];
continue;
}
$resolved[(int) $value->id] = (int) $pillar->id;
$status = $value->pillar_id === null ? 'zugeordnet' : 'bereits zugeordnet';
$hint = $value->label !== $pillar->name ? 'über Kennung zugeordnet, Bezeichnung weicht ab („'.$pillar->name.'“)' : null;
$report['mapping'][] = ['wert_id' => (int) $value->id, 'wert' => $value->label, 'saeule_id' => (int) $pillar->id, 'saeule' => $pillar->name, 'status' => $status, 'hinweis' => $hint];
if ($value->pillar_id === null && ! $dryRun) {
DB::table('editorial_dimension_values')->where('id', $value->id)->update(['pillar_id' => $pillar->id]);
}
}
$subjectTypes = $this->subjectTypes();
foreach (DB::table('identity_dimension_values')
->whereIn('editorial_dimension_value_id', DB::table('editorial_dimension_values')->where('editorial_dimension_id', $dimension->id)->select('id'))
->orderBy('id')->get() as $row) {
$valueId = (int) $row->editorial_dimension_value_id;
$label = DB::table('editorial_dimension_values')->where('id', $valueId)->value('label');
$target = $subjectTypes[$row->subject_type] ?? null;
if ($target === 'content_element') {
$report['mirror']['element_rows']++;
continue;
}
$where = ['art' => 'Zuordnung', 'zuordnung_id' => (int) $row->id, 'wert_id' => $valueId, 'wert' => $label, 'objektart' => $row->subject_type, 'objekt_id' => (int) $row->subject_id, 'herkunft' => $row->origin];
if ($target === null) {
$report['unresolved'][] = $where + ['grund' => 'unbekannte Objektart'];
continue;
}
if ($row->origin !== 'direkt') {
$report['unresolved'][] = $where + ['grund' => 'abgeleitete Zuordnung (wird nicht als direkte übernommen)'];
continue;
}
if (! isset($resolved[$valueId])) {
$report['unresolved'][] = $where + ['grund' => 'Wert ohne belastbare Säule'];
continue;
}
$config = self::TARGETS[$target];
if (! DB::table($config['subjects'])->where('id', $row->subject_id)->exists()) {
$report['unresolved'][] = $where + ['grund' => 'Objekt nicht mehr vorhanden'];
continue;
}
$present = DB::table($config['table'])->where($config['column'], $row->subject_id)->where('pillar_id', $resolved[$valueId])->exists();
if ($present) {
$report['already'][$target]++;
continue;
}
if (! $dryRun) {
DB::table($config['table'])->insertOrIgnore([$config['column'] => $row->subject_id, 'pillar_id' => $resolved[$valueId]]);
}
$report['copied'][$target]++;
}
$report['mirror'] = array_merge($report['mirror'], $this->mirrorDivergence($dimension->id, $resolved));
$report['after'] = $dryRun ? $report['before'] : $this->counts();
return $report;
}
/**
* @param array<string, mixed> $report
* @return list<string>
*/
public static function lines(array $report, bool $dryRun = false): array
{
$names = ['composition' => 'Module und Programme', 'license_article' => 'Lizenzartikel'];
$lines = [$dryRun ? 'Probelauf, es wird nichts geschrieben.' : 'Übernahme abgeschlossen.', ''];
foreach ($report['mapping'] as $row) {
$lines[] = sprintf('Wert %d „%s“ → %s%s', $row['wert_id'], $row['wert'], $row['saeule_id'] === null ? 'keine Säule (offen)' : 'Säule '.$row['saeule_id'].' „'.($row['saeule'] ?? '').'“ ('.$row['status'].')', ! empty($row['hinweis']) ? ' – '.$row['hinweis'] : '');
}
$lines[] = '';
foreach ($names as $key => $label) {
$lines[] = sprintf('%s: %d übernommen, %d bereits vorhanden, Zuordnungen vorher %d, nachher %d', $label, $report['copied'][$key], $report['already'][$key], $report['before'][$key], $report['after'][$key]);
}
$lines[] = sprintf('Medien (nur Information): %d gespiegelte Zeilen, %d nicht mehr in der Medienzuordnung, %d nur dort. Maßgeblich bleibt die Medienzuordnung.', $report['mirror']['element_rows'], $report['mirror']['missing_in_pivot'], $report['mirror']['only_in_pivot']);
if ($report['unresolved'] === []) {
$lines[] = 'Keine ungeklärten Fälle.';
} else {
$lines[] = '';
$lines[] = 'Ungeklärt, bitte entscheiden (nichts wurde geändert):';
foreach ($report['unresolved'] as $row) {
$lines[] = '- '.json_encode($row, JSON_UNESCAPED_UNICODE);
}
}
return $lines;
}
/**
* Die Säule zu einem alten Wert, oder der Grund, warum es keine belastbare gibt.
*/
private function pillarFor(object $value): object|string
{
if (preg_match('/^pfeiler-(\d+)$/', (string) $value->slug, $match) !== 1) {
return 'Kennung ist nicht „pfeiler-<Nummer>“, keine belastbare Verknüpfung';
}
$pillar = DB::table('pillars')->where('id', (int) $match[1])->first();
if ($pillar === null) {
return 'Die Säule zur Kennung existiert nicht mehr';
}
if ($value->pillar_id !== null && (int) $value->pillar_id !== (int) $pillar->id) {
return 'Gespeicherte Verknüpfung (Säule '.$value->pillar_id.') und Kennung (Säule '.$pillar->id.') widersprechen sich';
}
if ($pillar->created_at !== null && $value->created_at !== null && $pillar->created_at > $value->created_at) {
return 'Die Säule ist jünger als der Wert; die Kennung kann nicht aus ihr entstanden sein';
}
return $pillar;
}
/**
* @return array<string, string> Objektart wie gespeichert => Ziel
*/
private function subjectTypes(): array
{
$types = [];
foreach ([
'composition' => [Composition::class],
'license_article' => [LicenseArticle::class],
'content_element' => [ContentElement::class],
] as $target => $classes) {
foreach ($classes as $class) {
$types[$class] = $target;
$types[(new $class)->getMorphClass()] = $target;
}
}
return $types;
}
/**
* @return array<string, int>
*/
private function counts(): array
{
return [
'composition' => DB::table('composition_pillar')->count(),
'license_article' => DB::table('license_article_pillar')->count(),
];
}
/**
* @param array<int, int> $resolved
* @return array{missing_in_pivot: int, only_in_pivot: int}
*/
private function mirrorDivergence(int $dimensionId, array $resolved): array
{
$mirrored = [];
foreach (DB::table('identity_dimension_values')
->whereIn('subject_type', array_unique([ContentElement::class, (new ContentElement)->getMorphClass()]))
->whereIn('editorial_dimension_value_id', array_keys($resolved) ?: [0])
->get() as $row) {
$mirrored[$row->subject_id.':'.$resolved[(int) $row->editorial_dimension_value_id]] = true;
}
$pivot = [];
foreach (DB::table('content_element_pillar')->get() as $row) {
$pivot[$row->content_element_id.':'.$row->pillar_id] = true;
}
return [
'missing_in_pivot' => count(array_diff_key($mirrored, $pivot)),
'only_in_pivot' => count(array_diff_key($pivot, $mirrored)),
];
}
}
+7
View File
@@ -4,6 +4,7 @@
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasMany;
class LicenseArticle extends Model class LicenseArticle extends Model
@@ -49,4 +50,10 @@ public function editorialContentKind(): BelongsTo
{ {
return $this->belongsTo(EditorialContentKind::class); return $this->belongsTo(EditorialContentKind::class);
} }
/** Direkt zugeordnete fachliche Säulen (zentrale Säulenverwaltung). */
public function pillars(): BelongsToMany
{
return $this->belongsToMany(Pillar::class)->orderBy('pillars.sort_order')->orderBy('pillars.name');
}
} }
+15
View File
@@ -3,14 +3,29 @@
namespace App\Domain\Catalog; namespace App\Domain\Catalog;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasMany;
class Offer extends Model class Offer extends Model
{ {
protected $fillable = [ protected $fillable = [
'name', 'name',
'composition_id',
'option_label',
]; ];
/** Komposition, deren öffentliche Seite die Produktseite dieser Lizenzoption ist. */
public function composition(): BelongsTo
{
return $this->belongsTo(Composition::class);
}
/** Bezeichnung der Option auf der Produktseite. */
public function optionName(): string
{
return filled($this->option_label) ? (string) $this->option_label : (string) $this->name;
}
public function versions(): HasMany public function versions(): HasMany
{ {
return $this->hasMany(OfferVersion::class); return $this->hasMany(OfferVersion::class);
+51
View File
@@ -22,6 +22,23 @@ public function currentActiveVersion(Offer $offer): OfferVersion
return $version; return $version;
} }
/**
* Die aktive, als Kauf angebotene Fassung mit Preis; sonst null (nicht kaufbar, zurückgezogen oder kostenlos).
*/
public function purchasableVersion(Offer $offer): ?OfferVersion
{
$version = $offer->versions()
->where('status', OfferStatus::Aktiv)
->orderByDesc('number')
->first();
if ($version === null || $version->grant_kind !== 'kauf' || $version->price_cents === null) {
return null;
}
return $version;
}
/** /**
* @param array<string, mixed> $capabilities * @param array<string, mixed> $capabilities
* @param array<string, mixed> $options * @param array<string, mixed> $options
@@ -138,6 +155,40 @@ public function activate(Offer $offer, array $lines, array $attributes = []): Of
}); });
} }
/**
* Zieht die Option aus dem Verkauf zurück: Die aktive Fassung wird beendet und bleibt gespeichert. Bereits
* begründete Berechtigungen und Bestellungen ändern sich nicht; offene Warenkörbe zeigen die Position als
* zurückgezogen und blockieren den Abschluss, bis der Käufer sie entfernt.
*/
public function end(Offer $offer): OfferVersion
{
return DB::transaction(function () use ($offer): OfferVersion {
$offer = Offer::query()->lockForUpdate()->findOrFail($offer->id);
$version = $this->currentActiveVersion($offer);
$version->status = OfferStatus::Beendet;
$version->save();
return $version;
});
}
/**
* Produktzuordnung der Option: Die Komposition bestimmt die öffentliche Produktseite und die Alternativgruppe,
* die Bezeichnung benennt die Option auf dieser Seite. Beides sind keine bindenden Konditionen.
*/
public function assignProduct(Offer $offer, ?int $compositionId, ?string $optionLabel): Offer
{
if ($compositionId !== null) {
Composition::query()->findOrFail($compositionId);
}
$offer->composition_id = $compositionId;
$offer->option_label = filled($optionLabel) ? trim((string) $optionLabel) : null;
$offer->save();
return $offer;
}
/** /**
* @return list<int> * @return list<int>
*/ */
+10
View File
@@ -34,6 +34,16 @@ public function pages(): BelongsToMany
return $this->belongsToMany(Page::class); return $this->belongsToMany(Page::class);
} }
public function compositions(): BelongsToMany
{
return $this->belongsToMany(Composition::class);
}
public function licenseArticles(): BelongsToMany
{
return $this->belongsToMany(LicenseArticle::class);
}
/** /**
* @param Builder<Pillar> $query * @param Builder<Pillar> $query
* @return Builder<Pillar> * @return Builder<Pillar>
+31
View File
@@ -0,0 +1,31 @@
<?php
namespace App\Domain\Catalog;
use Illuminate\Support\Facades\DB;
/**
* Alte Filteradressen: Vor der Vereinheitlichung war „Fachliche Säule“ ein Wert der redaktionellen Einordnung
* (`?einordnung=…`, `?pillar=…`, `dimension[]=…`). Verweist ein solcher Wert über `pillar_id` auf eine zentrale Säule,
* gilt der Filter jetzt für diese Säule, statt stillschweigend zu entfallen.
*/
final class PillarFilterCompat
{
/**
* @return int|null|false Kennung der Säule; null: alter Säulenwert ohne belastbare Verknüpfung; false: kein Säulenwert
*/
public static function pillarOfLegacyValue(int $valueId): int|false|null
{
$row = DB::table('editorial_dimension_values')
->join('editorial_dimensions', 'editorial_dimensions.id', '=', 'editorial_dimension_values.editorial_dimension_id')
->where('editorial_dimension_values.id', $valueId)
->where('editorial_dimensions.slug', EditorialDimension::PILLAR_SLUG)
->first(['editorial_dimension_values.pillar_id']);
if ($row === null) {
return false;
}
return $row->pillar_id === null ? null : (int) $row->pillar_id;
}
}
+42 -6
View File
@@ -40,19 +40,55 @@ public function present(Pillar $pillar, string $name, string $slug, ?string $sum
public function delete(Pillar $pillar): void public function delete(Pillar $pillar): void
{ {
if ($pillar->elements()->exists() || $pillar->pages()->exists()) { $usage = $this->usage($pillar);
throw new DomainRuleException('Eine Säule mit zugeordneten Medien oder Seiten wird nicht gelöscht.');
if (array_sum($usage) > 0) {
throw new DomainRuleException('Eine Säule mit zugeordneten Objekten wird nicht gelöscht ('.$this->usageText($usage).'). Ordnen Sie sie zuerst anders zu.');
} }
$pillar->delete(); $pillar->delete();
} }
/** /**
* @param list<int> $pillarIds * Zuordnungen je Objektart: Medien, Module und Programme, Lizenzartikel, Seiten.
*
* @return array{medien: int, zusammenstellungen: int, lizenzartikel: int, seiten: int}
*/ */
public function assign(ContentElement $element, array $pillarIds): void public function usage(Pillar $pillar): array
{ {
$element->pillars()->sync($this->ids($pillarIds)); return [
'medien' => $pillar->elements()->count(),
'zusammenstellungen' => $pillar->compositions()->count(),
'lizenzartikel' => $pillar->licenseArticles()->count(),
'seiten' => $pillar->pages()->count(),
];
}
/**
* @param array{medien: int, zusammenstellungen: int, lizenzartikel: int, seiten: int} $usage
*/
public function usageText(array $usage): string
{
$parts = [];
foreach (['medien' => ['Medium', 'Medien'], 'zusammenstellungen' => ['Modul oder Programm', 'Module und Programme'], 'lizenzartikel' => ['Lizenzartikel', 'Lizenzartikel'], 'seiten' => ['Seite', 'Seiten']] as $key => [$one, $many]) {
if ($usage[$key] > 0) {
$parts[] = $usage[$key].' '.($usage[$key] === 1 ? $one : $many);
}
}
return $parts === [] ? 'nirgends zugeordnet' : implode(', ', $parts);
}
/**
* Ordnet einem Medium, Modul, Programm, Lizenzartikel oder einer Seite Säulen zu. Alle Objektarten verwenden
* dieselbe zentrale Säule und dieselbe Speicherregel; die Zuordnung ersetzt die bisherige vollständig.
*
* @param list<int|string> $pillarIds
*/
public function assign(ContentElement|Composition|LicenseArticle|Page $subject, array $pillarIds): void
{
$subject->pillars()->sync($this->ids($pillarIds));
} }
/** /**
@@ -60,7 +96,7 @@ public function assign(ContentElement $element, array $pillarIds): void
*/ */
public function assignPages(Page $page, array $pillarIds): void public function assignPages(Page $page, array $pillarIds): void
{ {
$page->pillars()->sync($this->ids($pillarIds)); $this->assign($page, $pillarIds);
} }
/** /**
+247 -1
View File
@@ -2,9 +2,11 @@
namespace App\Domain\Catalog; namespace App\Domain\Catalog;
use App\Domain\Media\ThumbnailRef;
use App\Domain\Media\WebsiteMedia; use App\Domain\Media\WebsiteMedia;
use App\Models\User; use App\Models\User;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
/** /**
* Präsentationsmedien sind Referenzen auf Inhaltselemente. * Präsentationsmedien sind Referenzen auf Inhaltselemente.
@@ -45,6 +47,9 @@ public function rows(Model $subject): array
'title' => $element instanceof ContentElement 'title' => $element instanceof ContentElement
? (string) ($element->display_title ?: $element->working_title) ? (string) ($element->display_title ?: $element->working_title)
: 'Medium fehlt', : 'Medium fehlt',
'image' => $element instanceof ContentElement
? ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path)
: null,
'kind' => $element?->editorialContentKind?->label, 'kind' => $element?->editorialContentKind?->label,
'output' => $element instanceof ContentElement ? (string) $element->output_class : '', 'output' => $element instanceof ContentElement ? (string) $element->output_class : '',
'released' => $released, 'released' => $released,
@@ -56,6 +61,240 @@ public function rows(Model $subject): array
return $rows; return $rows;
} }
/**
* Gespeicherte Zuordnungen als bearbeitbarer Arbeitsstand, nach Rolle und Position geordnet.
*
* @return list<array{key: string, id: int|null, role: string, element_id: int, source: int|null}>
*/
public function staged(Model $subject): array
{
$assignments = PresentationAssignment::query()
->with('role')
->where('subject_type', $subject->getMorphClass())
->where('subject_id', $subject->getKey())
->get()
->sortBy(fn (PresentationAssignment $row): string => sprintf('%05d-%05d-%08d', (int) $row->role?->sort_order, (int) $row->position, (int) $row->id))
->values();
$rows = [];
foreach ($assignments as $assignment) {
$rows[] = [
'key' => 'a'.$assignment->id,
'id' => (int) $assignment->id,
'role' => (string) $assignment->role?->slug,
'element_id' => (int) $assignment->content_element_id,
'source' => $assignment->source_version_id !== null ? (int) $assignment->source_version_id : null,
];
}
return $rows;
}
/**
* Anzeigezeilen für einen Arbeitsstand, gruppiert nach Rolle. Liest nur, schreibt nichts.
*
* @param list<array{key: string, id: int|null, role: string, element_id: int, source: int|null}> $staged
* @return list<array{role: string, label: string, multiple: bool, ordered: bool, rows: list<array<string, mixed>>}>
*/
public function describe(array $staged): array
{
$roles = PresentationRole::query()->orderBy('sort_order')->get()->keyBy('slug');
$elements = ContentElement::query()
->with('editorialContentKind')
->whereIn('id', array_values(array_unique(array_map(fn (array $row): int => (int) $row['element_id'], $staged))))
->get()
->keyBy('id');
$sources = ContentElementVersion::query()
->whereIn('id', array_values(array_filter(array_map(fn (array $row): ?int => $row['source'] ?? null, $staged))))
->get()
->keyBy('id');
$groups = [];
foreach ($roles as $slug => $role) {
$rows = array_values(array_filter($staged, fn (array $row): bool => $row['role'] === $slug));
if ($rows === []) {
continue;
}
$described = [];
foreach ($rows as $row) {
$element = $elements->get((int) $row['element_id']);
$released = $element instanceof ContentElement && $this->website->present($element) !== null;
$source = $row['source'] !== null ? $sources->get((int) $row['source']) : null;
$described[] = [
'key' => $row['key'],
'id' => $row['id'],
'element_id' => (int) $row['element_id'],
'title' => $element instanceof ContentElement
? (string) ($element->display_title ?: $element->working_title)
: 'Medium fehlt',
'image' => $element instanceof ContentElement
? ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path)
: null,
'kind' => $element?->editorialContentKind?->label,
'output' => $element instanceof ContentElement ? (string) $element->output_class : '',
'released' => $released,
'release_label' => $released ? 'Für die Website freigegeben' : 'Nicht für die Website freigegeben',
'binding' => $source instanceof ContentElementVersion ? $this->bindingFor($source) : null,
'new' => $row['id'] === null,
];
}
$groups[] = [
'role' => (string) $slug,
'label' => PresentationRole::displayLabel((string) $slug, (string) $role->label),
'multiple' => (bool) $role->multiple,
'ordered' => (bool) $role->ordered,
'rows' => $described,
];
}
return $groups;
}
/**
* Prüft, ob ein Medium im Arbeitsstand einer Rolle zugeordnet werden darf. Liefert den Ablehnungsgrund oder null.
*/
public function refusal(Model $subject, string $roleSlug, int $elementId): ?string
{
$role = PresentationRole::query()->where('slug', $roleSlug)->first();
$element = ContentElement::query()->find($elementId);
if (! $role instanceof PresentationRole || ! $element instanceof ContentElement) {
return 'Rolle oder Medium fehlt.';
}
if ($element->archived_at !== null) {
return 'Ein archiviertes Medium wird nicht zugeordnet.';
}
if ($subject instanceof ContentElement && (int) $subject->getKey() === (int) $element->id) {
return 'Ein Medium kann nicht seine eigene Präsentation sein.';
}
return null;
}
/**
* Schreibt einen Arbeitsstand: entfernte Zuordnungen lösen, neue anlegen, Bindung und Reihenfolge je Rolle setzen.
* Medien, Fassungen und Website-Freigaben bleiben unberührt.
*
* Mit $baseline (dem beim Laden gelesenen Stand) werden nur Zuordnungen gelöst, die dort standen und im
* Arbeitsstand fehlen. Was inzwischen an anderer Stelle hinzugekommen ist, bleibt erhalten.
*
* @param list<array{key: string, id: int|null, role: string, element_id: int, source: int|null}> $staged
* @param list<array{key: string, id: int|null, role: string, element_id: int, source: int|null}>|null $baseline
*/
public function commit(Model $subject, array $staged, ?User $actor = null, ?array $baseline = null): void
{
$roles = PresentationRole::query()->get()->keyBy('slug');
$seen = [];
foreach ($staged as $row) {
$role = $roles->get($row['role']);
if (! $role instanceof PresentationRole) {
throw new DomainRuleException('Diese Rolle gibt es nicht.');
}
$refusal = $this->refusal($subject, $row['role'], (int) $row['element_id']);
if ($refusal !== null) {
throw new DomainRuleException($refusal);
}
$pair = $row['role'].':'.$row['element_id'];
if (isset($seen[$pair])) {
throw new DomainRuleException('Ein Medium steht in derselben Rolle nur einmal.');
}
$seen[$pair] = true;
$count = count(array_filter($staged, fn (array $other): bool => $other['role'] === $row['role']));
if (! $role->multiple && $count > 1) {
throw new DomainRuleException($role->label.' hat nur eine Zuordnung.');
}
$element = ContentElement::query()->findOrFail((int) $row['element_id']);
$this->checkedSource($subject, $element, $row['source']);
}
DB::transaction(function () use ($subject, $staged, $roles, $actor, $baseline): void {
$existing = PresentationAssignment::query()
->with(['role', 'element'])
->where('subject_type', $subject->getMorphClass())
->where('subject_id', $subject->getKey())
->get()
->keyBy('id');
$kept = array_filter(array_map(fn (array $row): ?int => $row['id'], $staged));
$known = $baseline === null ? null : array_filter(array_map(fn (array $row): ?int => $row['id'], $baseline));
foreach ($existing as $id => $assignment) {
$wasLoaded = $known === null || in_array((int) $id, $known, true);
$replacedSingle = ! (bool) $assignment->role?->multiple
&& ! in_array((int) $id, $kept, true)
&& array_filter($staged, fn (array $row): bool => $row['role'] === $assignment->role?->slug) !== [];
if (! in_array((int) $id, $kept, true) && ($wasLoaded || $replacedSingle)) {
$this->record($subject, ($assignment->role?->label ?? 'Präsentation').': '.($assignment->element?->working_title ?? ''), null, $actor);
$assignment->delete();
}
}
$positions = [];
foreach ($staged as $row) {
$role = $roles->get($row['role']);
$position = $positions[$row['role']] = ($positions[$row['role']] ?? 0) + 1;
$assignment = $row['id'] !== null ? $existing->get($row['id']) : null;
if ($assignment instanceof PresentationAssignment) {
$changed = (int) $assignment->position !== $position
|| (int) ($assignment->source_version_id ?? 0) !== (int) ($row['source'] ?? 0);
$assignment->position = $position;
$assignment->source_version_id = $row['source'];
if ($changed) {
$assignment->save();
}
continue;
}
$element = ContentElement::query()->findOrFail((int) $row['element_id']);
$same = PresentationAssignment::query()
->where('subject_type', $subject->getMorphClass())
->where('subject_id', $subject->getKey())
->where('presentation_role_id', $role->id)
->where('content_element_id', $element->id)
->first();
if ($same instanceof PresentationAssignment) {
$same->position = $position;
$same->source_version_id = $row['source'];
$same->save();
continue;
}
PresentationAssignment::query()->create([
'subject_type' => $subject->getMorphClass(),
'subject_id' => $subject->getKey(),
'content_element_id' => $element->id,
'presentation_role_id' => $role->id,
'position' => $position,
'source_version_id' => $row['source'],
]);
$this->record($subject, null, $role->label.': '.$element->working_title, $actor);
}
});
}
public function assign(Model $subject, string $roleSlug, int $elementId, ?int $sourceVersionId, ?User $actor = null): string public function assign(Model $subject, string $roleSlug, int $elementId, ?int $sourceVersionId, ?User $actor = null): string
{ {
$role = PresentationRole::query()->where('slug', $roleSlug)->first(); $role = PresentationRole::query()->where('slug', $roleSlug)->first();
@@ -238,7 +477,14 @@ private function binding(PresentationAssignment $assignment): ?array
return null; return null;
} }
$version = $assignment->sourceVersion; return $this->bindingFor($assignment->sourceVersion);
}
/**
* @return array{label: string, stale: bool}
*/
private function bindingFor(ContentElementVersion $version): array
{
$latestId = ContentElementVersion::query() $latestId = ContentElementVersion::query()
->where('content_element_id', $version->content_element_id) ->where('content_element_id', $version->content_element_id)
->where('status', ContentVersionStatus::Bereit) ->where('status', ContentVersionStatus::Bereit)
+16
View File
@@ -41,4 +41,20 @@ public static function selectOptions(): array
{ {
return static::query()->orderBy('sort_order')->pluck('label', 'slug')->all(); return static::query()->orderBy('sort_order')->pluck('label', 'slug')->all();
} }
/**
* Kurze Bezeichnung für Überschriften und Auswahl in der Verwaltung.
*/
public static function displayLabel(string $slug, string $label): string
{
return match ($slug) {
'titelbild' => 'Titelbild',
'titelbild_alternativ' => 'Alternative Titelbilder',
'trailer' => 'Trailer',
'vorschauclip' => 'Vorschauclips',
'interview' => 'Interviews',
'galerie' => 'Galerie',
default => $label,
};
}
} }
@@ -6,7 +6,7 @@
use Filament\Forms\Components\Field; use Filament\Forms\Components\Field;
use Filament\Forms\Components\FileUpload; use Filament\Forms\Components\FileUpload;
use Filament\Forms\Components\Placeholder; use Filament\Forms\Components\Placeholder;
use Filament\Forms\Components\Select; use Filament\Forms\Components\ViewField;
use Filament\Notifications\Notification; use Filament\Notifications\Notification;
use Filament\Schemas\Components\Utilities\Get; use Filament\Schemas\Components\Utilities\Get;
use Filament\Schemas\Components\Utilities\Set; use Filament\Schemas\Components\Utilities\Set;
@@ -34,16 +34,12 @@ final class ImageRefFields
public static function fields(string $label = 'Bild', bool $live = false, string $key = 'image', ?string $altField = null): array public static function fields(string $label = 'Bild', bool $live = false, string $key = 'image', ?string $altField = null): array
{ {
return [ return [
Select::make($key) // Auswahl über den gemeinsamen visuellen Picker (Suche, Vorschau, Website-Freigabe im Detail).
ViewField::make($key)
->live() ->live()
->label($label.' aus dem Medienmanager') ->label($label.' aus dem Medienmanager')
->searchable() ->view('filament.cms.bild-feld')
->allowHtml() ->helperText('Öffentlich erscheint ein Bild nur mit Website-Freigabe; die Auswahl gibt es nicht frei.'),
->options(fn (): array => app(WebsiteImage::class)->options())
->getSearchResultsUsing(fn (?string $search): array => app(WebsiteImage::class)->options($search))
->getOptionLabelUsing(fn (mixed $value): ?string => app(WebsiteImage::class)->optionHtml($value))
->placeholder('Kein Bild')
->helperText('Alle Bilder des Medienmanagers. Öffentlich erscheint ein Bild nur mit Website-Freigabe.'),
FileUpload::make('_upload') FileUpload::make('_upload')
->live() ->live()
->label($label.': neues Bild hochladen') ->label($label.': neues Bild hochladen')
@@ -13,6 +13,8 @@
use Filament\Forms\Components\Select; use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput; use Filament\Forms\Components\TextInput;
use Filament\Schemas\Components\Group; use Filament\Schemas\Components\Group;
use Filament\Schemas\Components\Utilities\Get;
use Illuminate\Support\Str;
/** /**
* Gemeinsame Basis der Premium-Karten (Brand-UI-Kit v1.7, Entwurf zur visuellen Freigabe): * Gemeinsame Basis der Premium-Karten (Brand-UI-Kit v1.7, Entwurf zur visuellen Freigabe):
@@ -183,17 +185,22 @@ public function editorSchema(): array
Group::make([ Group::make([
$action, $action,
$note, $note,
// Zentrale Angaben aus der Redaktion als Platzhalter; eine eigene Eintragung ist als solche markiert.
TextInput::make('heading') TextInput::make('heading')
->label('Anzeigename nur für diese Karte') ->label('Anzeigename nur für diese Karte')
->maxLength(200) ->maxLength(200)
->live(onBlur: true) ->live(onBlur: true)
->placeholder('Zentraler Anzeigename') ->placeholder(fn (Get $get): string => $this->centralText($get('../refs.'.$this->refKey()), 'title') ?? 'Zentraler Anzeigename')
->hint(fn (?string $state): string => filled($state) ? 'Eigene Angabe für diese Karte' : 'Aus der Redaktion')
->hintColor(fn (?string $state): string => filled($state) ? 'warning' : 'gray')
->helperText('Leer übernimmt den Anzeigenamen des Fachobjekts. Eine Eintragung gilt nur für diese Karte und ändert die Quelle nicht.'), ->helperText('Leer übernimmt den Anzeigenamen des Fachobjekts. Eine Eintragung gilt nur für diese Karte und ändert die Quelle nicht.'),
TextInput::make('summary') TextInput::make('summary')
->label('Teaser nur für diese Karte') ->label('Teaser nur für diese Karte')
->maxLength(500) ->maxLength(500)
->live(onBlur: true) ->live(onBlur: true)
->placeholder('Zentraler Teaser oder Kurzbeschreibung') ->placeholder(fn (Get $get): string => $this->centralText($get('../refs.'.$this->refKey()), 'summary') ?? 'Zentraler Teaser oder Kurzbeschreibung')
->hint(fn (?string $state): string => filled($state) ? 'Eigene Angabe für diese Karte' : 'Aus der Redaktion')
->hintColor(fn (?string $state): string => filled($state) ? 'warning' : 'gray')
->helperText('Leer übernimmt Teaser oder Kurzbeschreibung. Lehrinhalt, Rechte und Preise bleiben unberührt.'), ->helperText('Leer übernimmt Teaser oder Kurzbeschreibung. Lehrinhalt, Rechte und Preise bleiben unberührt.'),
])->statePath('data'), ])->statePath('data'),
]; ];
@@ -292,6 +299,26 @@ protected function centralCoverId(mixed $id): ?int
return null; return null;
} }
/**
* Zentraler Anzeigename oder Teaser des gewählten Objekts (Redaktionsstand) für Platzhalter im Editor.
*/
private function centralText(mixed $id, string $field): ?string
{
if (blank($id)) {
return null;
}
try {
$subject = $this->subject($id, RenderContext::preview());
} catch (\Throwable) {
return null;
}
$text = $subject?->{$field};
return is_string($text) && trim($text) !== '' ? Str::limit(trim($text), 120) : null;
}
private function subjectField(): Select private function subjectField(): Select
{ {
return Select::make($this->refKey()) return Select::make($this->refKey())
+244
View File
@@ -0,0 +1,244 @@
<?php
namespace App\Domain\Commerce;
use App\Domain\Catalog\DomainRuleException;
use App\Domain\Catalog\Offer;
use App\Domain\Catalog\OfferService;
use App\Domain\Catalog\OfferVersion;
use App\Domain\Identity\Party;
use App\Domain\Identity\PartyType;
use App\Models\User;
/**
* Sitzungsgebundener Mehrangebotswarenkorb (Etappe 1). Er bleibt in derselben Browsersitzung über Anmeldung,
* Registrierung und E-Mail-Bestätigung erhalten. Je Option gibt es genau eine Position. Optionen derselben Produktseite
* (gleiche Komposition) sind Alternativen und werden nur nach ausdrücklichem Wechsel ersetzt.
* Der Warenkorb reserviert weder Preis noch Konditionen; er merkt sich, was der Käufer gesehen hat.
*/
class Cart
{
public const KEY = 'shop.cart';
public const ADDED = 'added';
public const PRESENT = 'present';
public const ALTERNATIVE = 'alternative';
public const UNAVAILABLE = 'unavailable';
public function __construct(
private readonly OwnershipCheck $ownership,
private readonly OrderHolders $holders,
private readonly OfferService $offers,
) {}
/**
* @return array<int, array{version_id: int, price_cents: int}>
*/
public function items(): array
{
return (array) session()->get(self::KEY, []);
}
public function count(): int
{
return count($this->items());
}
public function has(Offer $offer): bool
{
return isset($this->items()[$offer->id]);
}
/**
* Die bereits enthaltene Alternative derselben Produktseite, falls vorhanden.
*/
public function alternativeTo(Offer $offer): ?Offer
{
if ($offer->composition_id === null) {
return null;
}
$ids = array_diff(array_keys($this->items()), [$offer->id]);
return $ids === [] ? null : Offer::query()
->whereIn('id', $ids)
->where('composition_id', $offer->composition_id)
->first();
}
public function add(Offer $offer): string
{
$version = $this->purchasable($offer);
if ($version === null) {
return self::UNAVAILABLE;
}
if ($this->has($offer)) {
return self::PRESENT;
}
if ($this->alternativeTo($offer) !== null) {
return self::ALTERNATIVE;
}
$this->put($offer, $version);
return self::ADDED;
}
/**
* Ausdrücklicher Wechsel: die Alternative wird durch die gewählte Option ersetzt.
*/
public function switchTo(Offer $offer): bool
{
$version = $this->purchasable($offer);
if ($version === null) {
return false;
}
$alternative = $this->alternativeTo($offer);
if ($alternative !== null) {
$this->remove($alternative);
}
$this->put($offer, $version);
return true;
}
public function remove(Offer $offer): void
{
$items = $this->items();
unset($items[$offer->id]);
session()->put(self::KEY, $items);
}
/**
* Der Käufer übernimmt Preis und Fassung, die der Shop jetzt zeigt.
*/
public function acceptCurrent(Offer $offer): void
{
$version = $this->purchasable($offer);
if ($version !== null && $this->has($offer)) {
$this->put($offer, $version);
}
}
public function clear(): void
{
session()->forget(self::KEY);
}
/**
* Serverseitige Prüfung: aktuelle Fassung, Preis, Kaufbarkeit, passende Inhaberart, vorhandene Rechte.
*/
public function review(?User $user = null, ?int $holderPartyId = null): CartReview
{
$offers = Offer::query()
->whereIn('id', array_keys($this->items()))
->with('composition')
->get()
->keyBy('id');
$versions = [];
foreach ($this->items() as $offerId => $item) {
$offer = $offers->get($offerId);
if ($offer !== null) {
$versions[$offerId] = $this->purchasable($offer);
}
}
$holder = $user === null ? null : $this->holderFor($user, $holderPartyId, $versions);
$lines = [];
foreach ($this->items() as $offerId => $item) {
$offer = $offers->get($offerId);
if ($offer === null) {
continue;
}
$version = $versions[$offerId] ?? null;
$seen = (int) $item['price_cents'];
if ($version === null) {
$lines[] = new CartLine($offer, null, CartLine::WITHDRAWN, $seen, null,
'Diese Option ist nicht mehr erhältlich. Entferne sie, um mit den übrigen Positionen fortzufahren.');
continue;
}
$current = (int) $version->price_cents;
if ($holder !== null && ! $this->suitsHolder($version, $holder)) {
$lines[] = new CartLine($offer, $version, CartLine::WRONG_HOLDER, $seen, $current,
$version->holder_kind === 'organisation'
? 'Diese Option ist für Organisationen. Bestelle als Verein oder entferne sie.'
: 'Diese Option ist für Privatpersonen. Bestelle als Privatperson oder entferne sie.');
continue;
}
if ($holder !== null && $this->ownership->covers($holder, $version)) {
$lines[] = new CartLine($offer, $version, CartLine::OWNED, $seen, $current);
continue;
}
if ($current !== $seen) {
$lines[] = new CartLine($offer, $version, CartLine::PRICE_CHANGED, $seen, $current);
} elseif ((int) $item['version_id'] !== $version->id) {
$lines[] = new CartLine($offer, $version, CartLine::TERMS_CHANGED, $seen, $current,
'Die Bedingungen dieser Option wurden aktualisiert. Bitte prüfe die Übersicht.');
} else {
$lines[] = new CartLine($offer, $version, CartLine::OK, $seen, $current);
}
}
return new CartReview($lines, $holder);
}
/**
* Die aktive, als Kauf angebotene Fassung der Option; sonst null (nicht kaufbar oder zurückgezogen).
*/
public function purchasable(Offer $offer): ?OfferVersion
{
return $this->offers->purchasableVersion($offer);
}
private function put(Offer $offer, OfferVersion $version): void
{
$items = $this->items();
$items[$offer->id] = ['version_id' => $version->id, 'price_cents' => (int) $version->price_cents];
session()->put(self::KEY, $items);
}
/**
* @param array<int, OfferVersion|null> $versions
*/
private function holderFor(User $user, ?int $partyId, array $versions): ?Party
{
$onlyOrganisations = $versions !== [] && collect($versions)
->filter()
->every(fn (OfferVersion $version): bool => $version->holder_kind === 'organisation');
try {
return $this->holders->resolve($user, $partyId, $onlyOrganisations);
} catch (DomainRuleException) {
return null;
}
}
private function suitsHolder(OfferVersion $version, Party $holder): bool
{
return ($version->holder_kind === 'organisation') === ($holder->type === PartyType::Organisation);
}
}
+54
View File
@@ -0,0 +1,54 @@
<?php
namespace App\Domain\Commerce;
use App\Domain\Catalog\Offer;
use App\Domain\Catalog\OfferVersion;
/**
* Eine Position des Warenkorbs mit dem Ergebnis der serverseitigen Prüfung.
*/
final class CartLine
{
public const OK = 'ok';
public const PRICE_CHANGED = 'preis_geaendert';
public const TERMS_CHANGED = 'bedingungen_geaendert';
public const WITHDRAWN = 'zurueckgezogen';
public const OWNED = 'bereits_erworben';
public const WRONG_HOLDER = 'falscher_inhaber';
public function __construct(
public readonly Offer $offer,
public readonly ?OfferVersion $version,
public readonly string $state,
public readonly int $seenPriceCents,
public readonly ?int $currentPriceCents,
public readonly ?string $note = null,
) {}
/** Geht in Summe und Bestellung ein. */
public function orderable(): bool
{
return in_array($this->state, [self::OK, self::PRICE_CHANGED, self::TERMS_CHANGED], true);
}
/** Verhindert den Abschluss, bis der Käufer die Position selbst entfernt oder den Inhaber wechselt. */
public function blocks(): bool
{
return in_array($this->state, [self::WITHDRAWN, self::WRONG_HOLDER], true);
}
public function title(): string
{
$composition = $this->offer->composition;
return $composition !== null
? (string) ($composition->display_title ?: $composition->designation)
: (string) $this->offer->name;
}
}
+65
View File
@@ -0,0 +1,65 @@
<?php
namespace App\Domain\Commerce;
use App\Domain\Identity\Party;
/**
* Prüfergebnis des Warenkorbs für einen vorgesehenen Lizenzinhaber. Die Prüfsumme bindet die Bestellung an genau
* diese Übersicht: Inhaber, Fassung und Preis jeder Position samt Zustand, auch der ausgeschlossenen.
*/
final class CartReview
{
/**
* @param list<CartLine> $lines
*/
public function __construct(
public readonly array $lines,
public readonly ?Party $holder,
) {}
/** @return list<CartLine> */
public function orderable(): array
{
return array_values(array_filter($this->lines, fn (CartLine $line): bool => $line->orderable()));
}
public function totalCents(): int
{
return array_sum(array_map(fn (CartLine $line): int => (int) $line->currentPriceCents, $this->orderable()));
}
public function blocked(): bool
{
foreach ($this->lines as $line) {
if ($line->blocks()) {
return true;
}
}
return false;
}
public function empty(): bool
{
return $this->orderable() === [];
}
public function canOrder(): bool
{
return $this->holder !== null && ! $this->blocked() && ! $this->empty();
}
public function digest(): string
{
$parts = [];
foreach ($this->lines as $line) {
$parts[] = $line->offer->id.':'.($line->version?->id ?? 0).':'.$line->currentPriceCents.':'.$line->state;
}
sort($parts);
return hash('sha256', ($this->holder?->id ?? 0).'|'.implode(',', $parts));
}
}
+102 -28
View File
@@ -5,11 +5,13 @@
use App\Domain\Catalog\DomainRuleException; use App\Domain\Catalog\DomainRuleException;
use App\Domain\Catalog\Offer; use App\Domain\Catalog\Offer;
use App\Domain\Catalog\OfferService; use App\Domain\Catalog\OfferService;
use App\Domain\Catalog\OfferVersion;
use App\Domain\Entitlement\Acquisition; use App\Domain\Entitlement\Acquisition;
use App\Domain\Entitlement\AcquisitionType; use App\Domain\Entitlement\AcquisitionType;
use App\Domain\Entitlement\GrantIssuer; use App\Domain\Entitlement\GrantIssuer;
use App\Domain\Entitlement\GrantStatus; use App\Domain\Entitlement\GrantStatus;
use App\Domain\Identity\AccountStatus; use App\Domain\Identity\AccountStatus;
use App\Domain\Identity\Party;
use App\Mail\OrderConfirmed; use App\Mail\OrderConfirmed;
use App\Models\User; use App\Models\User;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
@@ -20,13 +22,15 @@ class Checkout
public function __construct( public function __construct(
private readonly GrantIssuer $grants, private readonly GrantIssuer $grants,
private readonly OfferService $offers, private readonly OfferService $offers,
private readonly OrderHolders $holders,
) {} ) {}
/**
* Einzelkauf einer Option als Person (bestehender Weg, ohne Warenkorb).
*/
public function place(User $user, Offer $offer): Order public function place(User $user, Offer $offer): Order
{ {
if ($user->status !== AccountStatus::Aktiv || $user->party_id === null) { $this->assertActive($user);
throw new DomainRuleException('Nur ein aktives Mitglied kann kaufen.');
}
$version = $this->offers->currentActiveVersion($offer); $version = $this->offers->currentActiveVersion($offer);
@@ -38,20 +42,78 @@ public function place(User $user, Offer $offer): Order
throw new DomainRuleException('Der Kauf braucht einen Preis an der Angebotsfassung.'); throw new DomainRuleException('Der Kauf braucht einen Preis an der Angebotsfassung.');
} }
return DB::transaction(function () use ($user, $offer, $version): Order { $holder = $this->holders->resolve($user, null);
$order = Order::query()->create([
'user_id' => $user->id, return DB::transaction(fn (): Order => $this->createOrder($user, $holder, [[$offer, $version]]));
'party_id' => $user->party_id, }
'status' => 'offen',
'holder_kind' => 'person', /**
]); * Bestellung aus dem Warenkorb, erst nach serverseitiger Prüfung. Die Prüfsumme bindet die Bestellung an die
* Übersicht, die der Käufer gesehen hat: Hat sich Preis, Fassung oder Bedingung seither geändert, entsteht keine
* Bestellung und der Käufer sieht zuerst die aktualisierte Übersicht. Positionen, deren Umfang der Inhaber bereits
* mit denselben Rechten besitzt, erzeugen keine Bestellposition.
*/
public function placeFromCart(User $user, Cart $cart, ?int $holderPartyId, string $digest): Order
{
$this->assertActive($user);
$order = DB::transaction(function () use ($user, $cart, $holderPartyId, $digest): Order {
// Optionen sperren, damit eine gleichzeitige Aktivierung die Prüfung nicht unterläuft.
Offer::query()->whereIn('id', array_keys($cart->items()))->orderBy('id')->lockForUpdate()->get();
$review = $cart->review($user, $holderPartyId);
if ($review->holder === null) {
throw new DomainRuleException('Für diesen Lizenzinhaber ist das Konto nicht bestellberechtigt.');
}
if (! hash_equals($review->digest(), $digest)) {
throw new StaleOverview('Die Übersicht hat sich geändert. Bitte prüfe die aktualisierte Bestellübersicht.');
}
if ($review->blocked()) {
throw new DomainRuleException('Entferne zuerst die Positionen, die nicht bestellt werden können.');
}
if ($review->empty()) {
throw new DomainRuleException('Es gibt nichts zu bestellen. Alle Positionen sind bereits erworben.');
}
$pairs = array_map(fn (CartLine $line): array => [$line->offer, $line->version], $review->orderable());
return $this->createOrder($user, $review->holder, $pairs);
});
$cart->clear();
return $order;
}
/**
* @param list<array{0: Offer, 1: OfferVersion}> $pairs
*/
private function createOrder(User $user, Party $holder, array $pairs): Order
{
$order = Order::query()->create([
'user_id' => $user->id,
'party_id' => $holder->id,
'status' => 'offen',
'holder_kind' => $holder->type->value,
'total_cents' => array_sum(array_map(fn (array $pair): int => (int) $pair[1]->price_cents, $pairs)),
'currency' => 'EUR',
]);
foreach ($pairs as [$offer, $version]) {
$line = $order->lines()->create([ $line = $order->lines()->create([
'offer_version_id' => $version->id, 'offer_version_id' => $version->id,
'offer_name' => $offer->name, 'offer_name' => $offer->name,
'price_cents' => $version->price_cents, 'price_cents' => $version->price_cents,
'currency' => 'EUR',
'term_rule' => $version->term_rule, 'term_rule' => $version->term_rule,
'update_promise' => $version->update_promise, 'update_promise' => $version->update_promise,
'holder_kind' => $version->holder_kind, 'holder_kind' => $version->holder_kind,
'tax_class' => $version->tax_class,
'grant_kind' => $version->grant_kind,
'holder_party_id' => $holder->id,
]); ]);
$version->load('resolvedScopes.rights'); $version->load('resolvedScopes.rights');
@@ -66,11 +128,15 @@ public function place(User $user, Offer $offer): Order
], ],
]); ]);
} }
}
return $order->load('lines.scopeItems'); return $order->load('lines.scopeItems');
});
} }
/**
* Freischaltung nach bestätigter Testzahlung: alle Bestellpositionen aus ihrem festgehaltenen Umfang, in einer
* Transaktion. Wiederholte Bestätigung ist wirkungslos; ein Fehler hinterlässt weder Zahlung noch Rechte.
*/
public function confirmTestPayment(Order $order, string $reference): Order public function confirmTestPayment(Order $order, string $reference): Order
{ {
$this->assertTestDriver(); $this->assertTestDriver();
@@ -100,14 +166,12 @@ public function confirmTestPayment(Order $order, string $reference): Order
$order->status = 'bezahlt'; $order->status = 'bezahlt';
$order->save(); $order->save();
$paidNow = true; $paidNow = true;
$line = $order->lines()->firstOrFail(); $actor = User::query()->findOrFail($order->user_id);
$this->grants->issue(
$order->user, foreach ($order->lines()->orderBy('id')->get() as $line) {
$line->offerVersion, $holder = Party::query()->findOrFail($line->holder_party_id ?? $order->party_id);
AcquisitionType::Bestellposition, $this->grants->issueFromOrderLine($line, $holder, $actor);
'order_line', }
$line->id,
);
return $order->load('lines', 'payments'); return $order->load('lines', 'payments');
}); });
@@ -142,6 +206,10 @@ public function failTestPayment(Order $order, string $reference): Order
}); });
} }
/**
* Vollerstattung: widerruft die Berechtigungen aller Positionen dieser Bestellung. Andere Erwerbsquellen
* (kostenlose Vergabe, frühere Käufe) bleiben unberührt.
*/
public function refund(Order $order, string $reason): Order public function refund(Order $order, string $reason): Order
{ {
$reason = trim($reason); $reason = trim($reason);
@@ -157,15 +225,14 @@ public function refund(Order $order, string $reason): Order
throw new DomainRuleException('Nur eine bezahlte Bestellung kann erstattet werden.'); throw new DomainRuleException('Nur eine bezahlte Bestellung kann erstattet werden.');
} }
$line = $order->lines()->firstOrFail(); foreach ($order->lines()->orderBy('id')->get() as $line) {
$acquisition = Acquisition::query()->where([ $acquisition = Acquisition::query()->where([
'type' => AcquisitionType::Bestellposition, 'type' => AcquisitionType::Bestellposition,
'reference_type' => 'order_line', 'reference_type' => 'order_line',
'reference_id' => $line->id, 'reference_id' => $line->id,
])->first(); ])->first();
if ($acquisition !== null) { foreach ($acquisition?->grants ?? [] as $grant) {
foreach ($acquisition->grants as $grant) {
if ($grant->status === GrantStatus::Aktiv) { if ($grant->status === GrantStatus::Aktiv) {
$grant->status = GrantStatus::Widerrufen; $grant->status = GrantStatus::Widerrufen;
$grant->status_reason = $reason; $grant->status_reason = $reason;
@@ -182,6 +249,13 @@ public function refund(Order $order, string $reason): Order
}); });
} }
private function assertActive(User $user): void
{
if ($user->status !== AccountStatus::Aktiv || $user->party_id === null) {
throw new DomainRuleException('Nur ein aktives Mitglied kann kaufen.');
}
}
private function assertTestDriver(): void private function assertTestDriver(): void
{ {
if (app()->isProduction() || config('services.payment.driver') !== 'test') { if (app()->isProduction() || config('services.payment.driver') !== 'test') {
+56
View File
@@ -0,0 +1,56 @@
<?php
namespace App\Domain\Commerce;
use App\Domain\Catalog\DomainRuleException;
/**
* Beträge werden als ganze Cent gespeichert und in Euro angezeigt und eingegeben (deutsches Format).
*/
final class Money
{
/** Obergrenze eines Preises (1.000.000 €), weit unter dem Wertebereich der Datenbank. */
public const MAX_CENTS = 100_000_000;
public static function format(?int $cents): string
{
return $cents === null ? '–' : number_format($cents / 100, 2, ',', '.').' €';
}
/**
* Euro-Eingabe („12,50“, „1.299“, „5“) als Cent. Leere Eingabe ergibt null.
*/
public static function parse(string|int|float|null $input): ?int
{
if ($input === null) {
return null;
}
$text = trim((string) $input);
if ($text === '') {
return null;
}
$text = str_replace([' ', '€'], '', $text);
if (str_contains($text, ',')) {
$text = str_replace('.', '', $text);
$text = str_replace(',', '.', $text);
} elseif (preg_match('/^\d{1,3}(\.\d{3})+$/', $text) === 1) {
$text = str_replace('.', '', $text);
}
if (preg_match('/^\d+(\.\d{1,2})?$/', $text) !== 1) {
throw new DomainRuleException('Der Preis ist kein gültiger Eurobetrag, zum Beispiel 12,50.');
}
$cents = (int) round(((float) $text) * 100);
if ($cents > self::MAX_CENTS) {
throw new DomainRuleException('Der Preis ist zu hoch. Zulässig sind höchstens '.self::format(self::MAX_CENTS).'.');
}
return $cents;
}
}
+2
View File
@@ -15,6 +15,8 @@ class Order extends Model
'party_id', 'party_id',
'status', 'status',
'holder_kind', 'holder_kind',
'total_cents',
'currency',
]; ];
public function user(): BelongsTo public function user(): BelongsTo
+75
View File
@@ -0,0 +1,75 @@
<?php
namespace App\Domain\Commerce;
use App\Domain\Catalog\DomainRuleException;
use App\Domain\Identity\Membership;
use App\Domain\Identity\Party;
use App\Domain\Identity\PartyType;
use App\Models\User;
use Illuminate\Support\Collection;
/**
* Für wen ein Konto bestellen darf: für sich selbst (Person) und für Organisationen, bei denen es eine aktive
* Mitgliedschaft mit Bestellberechtigung hat. Eine Bestellung hat genau einen Lizenzinhaber.
*/
class OrderHolders
{
/**
* @return Collection<int, Party>
*/
public function for(User $user): Collection
{
$holders = collect();
if ($user->party_id !== null) {
$person = Party::query()->find($user->party_id);
if ($person !== null) {
$holders->push($person);
}
}
$organisations = Membership::query()
->active()
->where('user_id', $user->id)
->where('may_order', true)
->with('organisation')
->orderBy('id')
->get()
->map(fn (Membership $membership): ?Party => $membership->organisation)
->filter(fn (?Party $party): bool => $party !== null && $party->type === PartyType::Organisation);
return $holders->concat($organisations)->values();
}
/**
* Der gewählte Inhaber; ohne Wahl die Person, bei Angeboten nur für Organisationen die erste Organisation.
*/
public function resolve(User $user, ?int $partyId, bool $preferOrganisation = false): Party
{
$holders = $this->for($user);
if ($partyId !== null) {
$chosen = $holders->first(fn (Party $party): bool => $party->id === $partyId);
if ($chosen === null) {
throw new DomainRuleException('Für diesen Lizenzinhaber ist das Konto nicht bestellberechtigt.');
}
return $chosen;
}
if ($preferOrganisation) {
$organisation = $holders->first(fn (Party $party): bool => $party->type === PartyType::Organisation);
if ($organisation !== null) {
return $organisation;
}
}
$person = $holders->first(fn (Party $party): bool => $party->type === PartyType::Person);
return $person ?? throw new DomainRuleException('Nur ein aktives Mitglied kann kaufen.');
}
}
+10
View File
@@ -3,6 +3,7 @@
namespace App\Domain\Commerce; namespace App\Domain\Commerce;
use App\Domain\Catalog\OfferVersion; use App\Domain\Catalog\OfferVersion;
use App\Domain\Identity\Party;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasMany;
@@ -17,6 +18,10 @@ class OrderLine extends Model
'term_rule', 'term_rule',
'update_promise', 'update_promise',
'holder_kind', 'holder_kind',
'currency',
'tax_class',
'grant_kind',
'holder_party_id',
]; ];
public function order(): BelongsTo public function order(): BelongsTo
@@ -24,6 +29,11 @@ public function order(): BelongsTo
return $this->belongsTo(Order::class); return $this->belongsTo(Order::class);
} }
public function holder(): BelongsTo
{
return $this->belongsTo(Party::class, 'holder_party_id');
}
public function offerVersion(): BelongsTo public function offerVersion(): BelongsTo
{ {
return $this->belongsTo(OfferVersion::class); return $this->belongsTo(OfferVersion::class);
+94
View File
@@ -0,0 +1,94 @@
<?php
namespace App\Domain\Commerce;
use App\Domain\Catalog\OfferVersion;
use App\Domain\Entitlement\Grant;
use App\Domain\Entitlement\GrantStatus;
use App\Domain\Identity\Party;
/**
* „Bereits erworben“ (FACH-59): Der vorgesehene Lizenzinhaber hat bereits eine gültige Lizenz mit demselben Umfang
* und denselben Nutzungsrechten. Maßgeblich ist genau ein Erwerb, der jeden Umfangsposten der Angebotsfassung mit
* gleichem Zweck, gleichen Fähigkeiten und gleichen Optionen trägt. Rechte mehrerer Erwerbe werden nicht zu einer
* neuen Lizenz kombiniert. Alle Erwerbsarten zählen (Kauf, freier Abruf, manuelle Vergabe), sofern aktiv und gültig.
*/
class OwnershipCheck
{
public function covers(Party $holder, OfferVersion $version): bool
{
$needed = $this->needed($version);
if ($needed === []) {
return false;
}
$now = now();
$byAcquisition = Grant::query()
->where('status', GrantStatus::Aktiv)
->whereHas('acquisition', fn ($query) => $query->where('party_id', $holder->id))
->get()
->filter(fn (Grant $grant): bool => ($grant->valid_from === null || ! $grant->valid_from->greaterThan($now))
&& ($grant->valid_until === null || $grant->valid_until->greaterThan($now)))
->groupBy('acquisition_id');
foreach ($byAcquisition as $grants) {
$have = [];
foreach ($grants as $grant) {
$have[$grant->license_article_id.'|'.$this->fingerprint($grant->rights_snapshot ?? [])] = true;
}
if (array_diff_key($needed, $have) === []) {
return true;
}
}
return false;
}
/**
* @return array<string, true>
*/
private function needed(OfferVersion $version): array
{
$needed = [];
$version->loadMissing('resolvedScopes.rights');
foreach ($version->resolvedScopes as $scope) {
$needed[$scope->license_article_id.'|'.$this->fingerprint([
'purpose' => $scope->rights->purpose,
'capabilities' => $scope->rights->capabilities,
'options' => $scope->rights->options ?? [],
])] = true;
}
return $needed;
}
/**
* Reihenfolge von Schlüsseln und Aktionen spielt keine Rolle.
*
* @param array<string, mixed> $rights
*/
private function fingerprint(array $rights): string
{
$capabilities = [];
foreach ((array) ($rights['capabilities'] ?? []) as $class => $actions) {
$actions = array_values(array_unique((array) $actions));
sort($actions);
$capabilities[(string) $class] = $actions;
}
ksort($capabilities);
$options = (array) ($rights['options'] ?? []);
ksort($options);
return md5(json_encode([
'purpose' => (string) ($rights['purpose'] ?? ''),
'capabilities' => $capabilities,
'options' => $options,
], JSON_THROW_ON_ERROR));
}
}
+114
View File
@@ -0,0 +1,114 @@
<?php
namespace App\Domain\Commerce;
use App\Domain\Catalog\Composition;
use App\Domain\Catalog\LicenseArticle;
use App\Domain\Catalog\Offer;
use App\Domain\Catalog\OfferService;
use App\Domain\Catalog\OfferVersion;
use App\Filament\Support\CatalogLabels;
/**
* Kaufbare Lizenzoptionen einer Produktseite aus dem veröffentlichten Katalog: aktive Angebotsfassungen mit Preis,
* Eignung, Laufzeit, Umfang und Nutzungsrechten. Die Seite selbst (Titel, Beschreibung, Struktur) kommt aus der
* zur Anzeige freigegebenen Komposition; hier entsteht kein zweiter Text.
*/
class ProductOptions
{
public function __construct(private readonly OfferService $offers) {}
/**
* @return list<array<string, mixed>>
*/
public function forComposition(Composition $composition): array
{
$options = [];
foreach (Offer::query()->where('composition_id', $composition->id)->orderBy('id')->get() as $offer) {
$version = $this->offers->purchasableVersion($offer);
if ($version !== null) {
$options[] = $this->describe($offer, $version);
}
}
return $options;
}
/**
* Zeilen für Shop-Suche und Kacheln: je Komposition die günstigste Option.
*
* @return array<int, array{from_cents: int, count: int}>
*/
public function summaries(): array
{
$summary = [];
foreach (Offer::query()->whereNotNull('composition_id')->orderBy('id')->get() as $offer) {
$version = $this->offers->purchasableVersion($offer);
if ($version === null) {
continue;
}
$current = $summary[$offer->composition_id] ?? ['from_cents' => PHP_INT_MAX, 'count' => 0];
$summary[$offer->composition_id] = [
'from_cents' => min($current['from_cents'], (int) $version->price_cents),
'count' => $current['count'] + 1,
];
}
return $summary;
}
/**
* @return array<string, mixed>
*/
public function describe(Offer $offer, OfferVersion $version): array
{
$version->loadMissing('resolvedScopes.article', 'resolvedScopes.rights');
$scope = [];
foreach ($version->resolvedScopes as $item) {
$faehigkeiten = CatalogLabels::faehigkeiten($item->rights?->capabilities);
$scope[] = [
'article' => $this->articleTitle($item->article),
'purpose' => CatalogLabels::zweck($item->rights?->purpose),
'rights' => $faehigkeiten,
];
}
return [
'offer' => $offer,
'version' => $version,
'name' => $offer->optionName(),
'price_cents' => (int) $version->price_cents,
'price' => Money::format((int) $version->price_cents),
'for' => $version->holder_kind === 'organisation' ? 'Organisationen und Vereine' : 'Privatpersonen',
'holder_kind' => $version->holder_kind,
'term' => self::termLabel($version),
'scope' => $scope,
];
}
public static function termLabel(OfferVersion $version): string
{
return match ($version->term_rule) {
'dauerhaft' => 'Dauerhaft nutzbar',
'befristet' => 'Befristet',
'solange_angebot_aktiv' => 'Solange das Angebot aktiv ist',
'periodisch' => 'Laufend, periodisch',
default => (string) $version->term_rule,
};
}
public function articleTitle(?LicenseArticle $article): string
{
if ($article === null) {
return '–';
}
return (string) ($article->display_title ?: $article->working_title ?: $article->code);
}
}
+16
View File
@@ -0,0 +1,16 @@
<?php
namespace App\Domain\Commerce;
/**
* Etappe 1 verwendet ausschließlich Testzahlung und erteilt keine Produktivfreigabe. Der Shop (Warenkorb, Kasse,
* Kopflink) ist deshalb nur aktiv, wenn die Umgebung nicht Produktion ist und der Zahlungstreiber „test“ gilt.
* Dieselbe Bedingung gilt für die Testzahlung der Bestellseite.
*/
final class Shop
{
public static function enabled(): bool
{
return ! app()->isProduction() && config('services.payment.driver') === 'test';
}
}
+11
View File
@@ -0,0 +1,11 @@
<?php
namespace App\Domain\Commerce;
use App\Domain\Catalog\DomainRuleException;
/**
* Preis oder bindende Bedingungen haben sich nach Anzeige der Bestellübersicht geändert. Es entsteht keine
* Bestellung; der Käufer sieht zuerst die aktualisierte Übersicht (FACH-59).
*/
class StaleOverview extends DomainRuleException {}
+1
View File
@@ -19,6 +19,7 @@ class Acquisition extends Model
'reference_type', 'reference_type',
'reference_id', 'reference_id',
'conditions', 'conditions',
'acting_user_id',
]; ];
protected function casts(): array protected function casts(): array
+1 -1
View File
@@ -47,7 +47,7 @@ public function __invoke(
$candidates = Grant::query() $candidates = Grant::query()
->where('license_article_id', $article->id) ->where('license_article_id', $article->id)
->where('status', GrantStatus::Aktiv) ->where('status', GrantStatus::Aktiv)
->whereHas('acquisition', fn ($query) => $query->where('party_id', $user->party_id)) ->usableBy($user)
->get() ->get()
->filter(function (Grant $grant) use ($now): bool { ->filter(function (Grant $grant) use ($now): bool {
if ($grant->valid_from !== null && $grant->valid_from->greaterThan($now)) { if ($grant->valid_from !== null && $grant->valid_from->greaterThan($now)) {
+29
View File
@@ -5,6 +5,9 @@
use App\Domain\Catalog\ArticleRelease; use App\Domain\Catalog\ArticleRelease;
use App\Domain\Catalog\LicenseArticle; use App\Domain\Catalog\LicenseArticle;
use App\Domain\Catalog\RightsProfileVersion; use App\Domain\Catalog\RightsProfileVersion;
use App\Domain\Identity\Membership;
use App\Models\User;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\BelongsTo;
@@ -32,6 +35,32 @@ protected function casts(): array
]; ];
} }
/**
* Berechtigungen, die ein Konto nutzen darf (zentrale Regel für Entscheidung, Bibliothek und Vorschaubilder):
* - persönliche Erwerbe: Inhaber ist die Person des Kontos;
* - Erwerbe einer Organisation: nur das auslösende Konto und nur, solange seine Mitgliedschaft mit
* Bestellberechtigung besteht (Etappe 1, Domänenmodell 04; Sitzpools folgen mit A4).
*
* @param Builder<Grant> $query
* @return Builder<Grant>
*/
public function scopeUsableBy(Builder $query, User $user): Builder
{
return $query->whereHas('acquisition', function (Builder $acquisition) use ($user): void {
$acquisition->where(function (Builder $either) use ($user): void {
$either->where('party_id', $user->party_id)
->orWhere(function (Builder $organisation) use ($user): void {
$organisation->where('acting_user_id', $user->id)
->whereIn('party_id', Membership::query()
->active()
->where('user_id', $user->id)
->where('may_order', true)
->select('party_id'));
});
});
});
}
public function acquisition(): BelongsTo public function acquisition(): BelongsTo
{ {
return $this->belongsTo(Acquisition::class); return $this->belongsTo(Acquisition::class);
+52
View File
@@ -7,6 +7,8 @@
use App\Domain\Catalog\OfferService; use App\Domain\Catalog\OfferService;
use App\Domain\Catalog\OfferStatus; use App\Domain\Catalog\OfferStatus;
use App\Domain\Catalog\OfferVersion; use App\Domain\Catalog\OfferVersion;
use App\Domain\Commerce\OrderLine;
use App\Domain\Identity\Party;
use App\Models\User; use App\Models\User;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
@@ -69,6 +71,56 @@ public function grantManually(User $user, Offer $offer, User $actor, string $rea
}); });
} }
/**
* Freischaltung einer bezahlten Bestellposition aus deren festgehaltenem Umfang (Umfangskopie und Bedingungen der
* Position, nicht aus der Angebotsfassung). Inhaber ist der Lizenzinhaber der Position, das auslösende Konto wird
* am Erwerb festgehalten. Wiederholsicher: je Bestellposition genau ein Erwerb.
*/
public function issueFromOrderLine(OrderLine $line, Party $holder, User $actor): Acquisition
{
return DB::transaction(function () use ($line, $holder, $actor): Acquisition {
$existing = Acquisition::query()->where([
'party_id' => $holder->id,
'type' => AcquisitionType::Bestellposition,
'reference_type' => 'order_line',
'reference_id' => $line->id,
])->first();
if ($existing !== null) {
return $existing->load('grants');
}
$acquisition = Acquisition::query()->create([
'party_id' => $holder->id,
'type' => AcquisitionType::Bestellposition,
'reference_type' => 'order_line',
'reference_id' => $line->id,
'acting_user_id' => $actor->id,
'conditions' => [
'term_rule' => $line->term_rule,
'update_promise' => $line->update_promise,
'holder_kind' => $line->holder_kind,
'offer_version_id' => $line->offer_version_id,
],
]);
$line->loadMissing('scopeItems.article');
foreach ($line->scopeItems as $item) {
$acquisition->grants()->create([
'license_article_id' => $item->license_article_id,
'rights_profile_version_id' => $item->rights_profile_version_id,
'rights_snapshot' => $item->rights_snapshot,
'release_at_grant_id' => $item->article?->current_release_id,
'status' => GrantStatus::Aktiv,
'valid_from' => now(),
]);
}
return $acquisition->load('grants');
});
}
public function issue( public function issue(
User $user, User $user,
OfferVersion $version, OfferVersion $version,
+52
View File
@@ -0,0 +1,52 @@
<?php
namespace App\Domain\Identity;
use App\Models\User;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* Mitgliedschaft eines Kontos in einer Organisation (Domänenmodell 04, MEMBERSHIP). Etappe 1 nutzt sie für die
* Bestellberechtigung: Ein Konto bestellt nur für eine Organisation, bei der eine aktive Mitgliedschaft mit
* `may_order` besteht. Sitzpools und Selbstverwaltung folgen mit A4.
*/
class Membership extends Model
{
protected $fillable = [
'user_id',
'party_id',
'role',
'may_order',
'valid_from',
'valid_until',
];
protected function casts(): array
{
return [
'may_order' => 'boolean',
'valid_from' => 'date',
'valid_until' => 'date',
];
}
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
public function organisation(): BelongsTo
{
return $this->belongsTo(Party::class, 'party_id');
}
/** Mitgliedschaften, die heute gelten. */
public function scopeActive(Builder $query): Builder
{
return $query
->where(fn (Builder $inner) => $inner->whereNull('valid_from')->orWhereDate('valid_from', '<=', now()))
->where(fn (Builder $inner) => $inner->whereNull('valid_until')->orWhereDate('valid_until', '>=', now()));
}
}
+13 -204
View File
@@ -2,20 +2,21 @@
namespace App\Filament\Pages; namespace App\Filament\Pages;
use App\Domain\Catalog\Composition;
use App\Domain\Catalog\CompositionKind; use App\Domain\Catalog\CompositionKind;
use App\Domain\Catalog\ContentVersionStatus;
use App\Domain\Catalog\EditorialDimension;
use App\Domain\Catalog\IdentityDimensionValue;
use App\Filament\Resources\ContentElements\ContentElementResource; use App\Filament\Resources\ContentElements\ContentElementResource;
use App\Filament\Support\EditorialCatalog; use App\Filament\Support\ListsCompositions;
use Filament\Pages\Page; use Filament\Pages\Page;
use Filament\Support\Enums\Width; use Filament\Support\Enums\Width;
use Illuminate\Contracts\Support\Htmlable; use Illuminate\Contracts\Support\Htmlable;
use Livewire\Attributes\Url;
/**
* Arbeitsplatz: Programme und Module in der gemeinsamen Bestandsliste. Die Listen „Module“ und „Programme“ zeigen
* dieselben Zeilen mit festem Typ (ListsCompositions).
*/
class EditorialDesk extends Page class EditorialDesk extends Page
{ {
use ListsCompositions;
protected static string|\UnitEnum|null $navigationGroup = 'Inhalte'; protected static string|\UnitEnum|null $navigationGroup = 'Inhalte';
protected static ?string $navigationLabel = 'Arbeitsplatz'; protected static ?string $navigationLabel = 'Arbeitsplatz';
@@ -28,24 +29,6 @@ class EditorialDesk extends Page
protected string $view = 'filament.editorial.desk-page'; protected string $view = 'filament.editorial.desk-page';
#[Url]
public string $query = '';
#[Url]
public string $kindFilter = 'alle';
#[Url]
public string $pillar = '';
#[Url]
public string $visibility = 'alle';
public string $programName = '';
public string $moduleName = '';
public string $feedback = '';
public function getHeading(): string|Htmlable|null public function getHeading(): string|Htmlable|null
{ {
return 'Programme und Module'; return 'Programme und Module';
@@ -53,7 +36,7 @@ public function getHeading(): string|Htmlable|null
public function getSubheading(): string|Htmlable|null public function getSubheading(): string|Htmlable|null
{ {
return 'Vorhandene Einträge öffnen oder einen neuen anlegen. Technische Kennungen sind dafür nicht nötig.'; return 'Vorhandene Einträge öffnen oder einen neuen anlegen. Ein Programm ordnet Module; ein Modul ordnet Medien und Texte.';
} }
public function getMaxContentWidth(): Width|string|null public function getMaxContentWidth(): Width|string|null
@@ -66,185 +49,11 @@ public static function canAccess(): bool
return ContentElementResource::editor(); return ContentElementResource::editor();
} }
/** protected function getHeaderActions(): array
* @return list<array{label: string, values: list<array{id: int, label: string}>}>
*/
public function dimensionFilters(): array
{ {
$groups = []; return [
$this->createCompositionAction(CompositionKind::Uebung),
foreach (EditorialDimension::query()->with('values')->orderBy('label')->get() as $dimension) { $this->createCompositionAction(CompositionKind::Kurs),
$values = []; ];
foreach ($dimension->values as $value) {
$values[] = ['id' => $value->id, 'label' => $value->label];
}
if ($values !== []) {
$groups[] = ['label' => $dimension->label, 'values' => $values];
}
}
return $groups;
}
public function resetFilters(): void
{
$this->query = '';
$this->kindFilter = 'alle';
$this->pillar = '';
$this->visibility = 'alle';
}
public function hasActiveFilters(): bool
{
return trim($this->query) !== '' || $this->kindFilter !== 'alle' || $this->pillar !== '' || $this->visibility !== 'alle';
}
/**
* @return list<array<string, mixed>>
*/
public function entries(): array
{
$query = trim($this->query);
$needle = mb_strtolower($query);
$catalog = app(EditorialCatalog::class);
$offered = $catalog->offeredCompositionIds();
$pillarIds = $this->pillar === '' ? null : $this->pillarSubjects((int) $this->pillar);
$rows = [];
$compositions = Composition::query()
->whereIn('kind', [CompositionKind::Kurs, CompositionKind::Uebung])
->with(['editorialContentKind', 'versions.members.contentElementVersion.element'])
->orderBy('designation')
->get();
foreach ($compositions as $composition) {
$kind = $composition->kind instanceof CompositionKind
? $composition->kind
: CompositionKind::from((string) $composition->kind);
if ($this->kindFilter === 'programm' && $kind !== CompositionKind::Kurs) {
continue;
}
if ($this->kindFilter === 'modul' && $kind !== CompositionKind::Uebung) {
continue;
}
if ($pillarIds !== null && ! in_array($composition->id, $pillarIds, true)) {
continue;
}
$stand = $catalog->stand($composition);
if (! $this->matchesVisibility($stand)) {
continue;
}
$title = $catalog->compositionTitle($composition);
$summary = (string) ($composition->summary ?? '');
$haystack = mb_strtolower($title.' '.$composition->designation.' '.$summary.' '.(string) $composition->description);
if ($needle !== '' && ! str_contains($haystack, $needle)) {
continue;
}
$cover = $catalog->cover($composition, $this->coverMembers($composition));
$rows[] = [
'title' => $title,
'kind' => $kind->deskLabel(),
'tone' => $kind === CompositionKind::Kurs ? 'programm' : 'modul',
'summary' => $summary,
'url' => EditorialCatalog::editUrl($composition),
'image' => $cover['url'],
'image_note' => $cover['note'],
'chips' => $catalog->statusChips($composition, in_array($composition->id, $offered, true)),
];
}
return $rows;
}
/**
* @return list<array{target: string}>
*/
private function coverMembers(Composition $composition): array
{
$draft = $composition->working_draft;
if (is_array($draft) && is_array($draft['members'] ?? null) && $draft['members'] !== []) {
return $draft['members'];
}
$version = $composition->versions
->filter(fn ($item): bool => $item->status === ContentVersionStatus::Bereit)
->sortByDesc('number')
->first();
if ($version === null) {
return [];
}
$members = [];
foreach ($version->members as $member) {
$target = $member->content_element_version_id
? 'element:'.$member->content_element_version_id
: 'composition:'.$member->nested_composition_version_id;
$members[] = ['target' => $target];
}
return $members;
}
/**
* @return list<int>
*/
private function pillarSubjects(int $valueId): array
{
return IdentityDimensionValue::query()
->where('subject_type', (new Composition)->getMorphClass())
->where('editorial_dimension_value_id', $valueId)
->pluck('subject_id')
->map(fn (mixed $id): int => (int) $id)
->all();
}
/**
* @param array{text: string, number: int|null, released_number: int|null} $stand
*/
private function matchesVisibility(array $stand): bool
{
return match ($this->visibility) {
'bibliothek' => $stand['released_number'] !== null,
'verborgen' => $stand['number'] !== null && $stand['released_number'] === null,
'entwurf' => $stand['number'] === null,
default => true,
};
}
public function createProgram(): void
{
$this->create(CompositionKind::Kurs, $this->programName);
}
public function createModule(): void
{
$this->create(CompositionKind::Uebung, $this->moduleName);
}
private function create(CompositionKind $kind, string $name): void
{
$name = trim($name);
if ($name === '') {
$this->feedback = 'Der Name fehlt.';
return;
}
$composition = app(EditorialCatalog::class)->create($name, $kind);
$this->redirect(EditorialCatalog::editUrl($composition), navigate: false);
} }
} }
@@ -0,0 +1,693 @@
<?php
namespace App\Filament\Pages;
use App\Domain\Catalog\Composition;
use App\Domain\Catalog\CompositionKind;
use App\Domain\Catalog\ContentElement;
use App\Domain\Catalog\EditorialContentKind;
use App\Domain\Catalog\EditorialDimension;
use App\Domain\Catalog\EditorialDimensionValue;
use App\Domain\Catalog\EditorialVocabulary;
use App\Domain\Catalog\LicenseArticle;
use App\Filament\Resources\ContentElements\ContentElementResource;
use App\Filament\Resources\LicenseArticles\LicenseArticleResource;
use App\Filament\Resources\Pillars\PillarResource;
use App\Filament\Support\EditorialCatalog;
use Filament\Actions\Action;
use Filament\Actions\ActionGroup;
use Filament\Forms\Components\Checkbox;
use Filament\Forms\Components\CheckboxList;
use Filament\Forms\Components\Placeholder;
use Filament\Forms\Components\TextInput;
use Filament\Notifications\Notification;
use Filament\Pages\Page;
use Filament\Schemas\Components\Utilities\Get;
use Filament\Support\Enums\Width;
use Filament\Support\Exceptions\Halt;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Concerns\InteractsWithTable;
use Filament\Tables\Contracts\HasTable;
use Filament\Tables\Filters\SelectFilter;
use Filament\Tables\Table;
use Illuminate\Contracts\Support\Htmlable;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\HtmlString;
use Illuminate\Support\Str;
use Livewire\Attributes\Url;
/**
* Redaktionelle Stammdaten (FACH-56 bis FACH-58): fachliche Materialarten und die Werte der Einordnung (Altersbereich
* und Zielgruppe, Einsatzbereiche, Verwendungszwecke) zentral pflegen. Bestehende Tabellen, keine Kopien.
*
* - Bezeichnung pflegbar, Kennung fest; Zuordnungen hängen an der Kennung des Datensatzes und bleiben beim Umbenennen.
* - Verwendete Werte werden deaktiviert statt gelöscht; Löschen nur ohne jede Zuordnung.
* - Materialarten haben zulässige Objektkontexte; vorhandene Zuordnungen bleiben bei einer Änderung erhalten.
* - Säulen werden in der vorhandenen Säulenverwaltung gepflegt (verlinkt), nicht hier.
*/
class RedaktionelleStammdaten extends Page implements HasTable
{
use InteractsWithTable;
protected static string|\UnitEnum|null $navigationGroup = 'Inhalte';
protected static ?string $navigationLabel = 'Redaktionelle Stammdaten';
protected static ?int $navigationSort = 6;
protected static ?string $slug = 'stammdaten';
protected static ?string $title = 'Redaktionelle Stammdaten';
protected string $view = 'filament.stammdaten';
/** Bevorzugte Reihenfolge der Einordnungsgruppen; weitere Dimensionen folgen nach Bezeichnung. */
private const DIMENSION_ORDER = ['zielgruppe', 'einsatzbereich', 'verwendungszweck'];
#[Url(as: 'gruppe', except: 'materialart')]
public string $gruppe = 'materialart';
/** @var array<int, array<string, int>>|null */
private ?array $verwendungCache = null;
public static function canAccess(): bool
{
return self::darfPflegen();
}
public static function darfPflegen(): bool
{
return ContentElementResource::editor();
}
public function mount(): void
{
if (! array_key_exists($this->gruppe, $this->gruppen())) {
$this->gruppe = 'materialart';
}
}
public function getSubheading(): string|Htmlable|null
{
return 'Auswahlwerte für Redaktion, Filter und Picker. Bezeichnungen sind änderbar, Zuordnungen bleiben erhalten; verwendete Werte werden deaktiviert statt gelöscht.';
}
public function getMaxContentWidth(): Width|string|null
{
return Width::Full;
}
/**
* @return array<string, string> Schlüssel => Bezeichnung
*/
public function gruppen(): array
{
$gruppen = ['materialart' => 'Fachliche Materialarten'];
$dimensionen = EditorialDimension::query()->where('slug', '!=', EditorialDimension::PILLAR_SLUG)->get()
->sortBy(fn (EditorialDimension $d): string => sprintf('%02d', array_search($d->slug, self::DIMENSION_ORDER, true) === false ? 99 : array_search($d->slug, self::DIMENSION_ORDER, true)).$d->label);
foreach ($dimensionen as $dimension) {
$gruppen[$dimension->slug] = (string) $dimension->label;
}
return $gruppen;
}
public function zeigeGruppe(string $gruppe): void
{
if (array_key_exists($gruppe, $this->gruppen())) {
$this->gruppe = $gruppe;
$this->verwendungCache = null;
$this->resetTable();
}
}
public function saeulenUrl(): string
{
return PillarResource::getUrl('index');
}
private function istMaterialart(): bool
{
return $this->gruppe === 'materialart';
}
private function dimension(): ?EditorialDimension
{
return $this->istMaterialart() ? null : EditorialDimension::query()->where('slug', $this->gruppe)->first();
}
// ---------------------------------------------------------------------------------------------------------------
// Tabelle
// ---------------------------------------------------------------------------------------------------------------
public function table(Table $table): Table
{
$materialart = $this->istMaterialart();
return $table
->query(function (): Builder {
if ($this->istMaterialart()) {
return EditorialContentKind::query();
}
return EditorialDimensionValue::query()->where('editorial_dimension_id', $this->dimension()?->id ?? 0);
})
->defaultSort('sort_order')
->reorderable('sort_order')
->reorderRecordsTriggerAction(fn (Action $action, bool $isReordering): Action => $action
->button()
->label($isReordering ? 'Sortieren beenden' : 'Per Ziehen sortieren'))
->paginated(false)
->searchPlaceholder('Bezeichnung oder Kennung')
->columns(array_values(array_filter([
TextColumn::make('label')
->label('Bezeichnung')
->searchable(['label', 'slug'])
->weight('semibold')
->wrap()
->description(fn (Model $record): string => 'Kennung: '.$record->slug
.($record instanceof EditorialContentKind && $record->isSystem() ? ' · vom System verwendet' : '')),
$materialart ? TextColumn::make('contexts')
->label('Zulässig für')
->state(fn (EditorialContentKind $record): array => array_values(array_map(
fn (string $context): string => EditorialContentKind::CONTEXTS[$context] ?? $context,
(array) ($record->contexts ?? []),
)))
->badge()
->color('gray')
->wrap() : null,
TextColumn::make('is_active')
->label('Status')
->formatStateUsing(fn (bool $state): string => $state ? 'Aktiv' : 'Inaktiv')
->badge()
->color(fn (bool $state): string => $state ? 'success' : 'gray'),
TextColumn::make('verwendung')
->label('Verwendung')
->state(fn (Model $record): string => $this->verwendungText($record))
->wrap()
->action($this->verwendungAction()->name('verwendungZeigen')),
])))
->filters([
SelectFilter::make('is_active')
->label('Status')
->options(['1' => 'Aktiv', '0' => 'Inaktiv']),
])
->recordActions([
Action::make('hoch')
->label('Nach oben')
->icon('heroicon-m-arrow-up')
->iconButton()
->color('gray')
->authorize(fn (): bool => self::darfPflegen())
->disabled(fn (Model $record): bool => $this->nachbar($record, -1) === null)
->action(fn (Model $record) => $this->verschiebe($record, -1)),
Action::make('runter')
->label('Nach unten')
->icon('heroicon-m-arrow-down')
->iconButton()
->color('gray')
->authorize(fn (): bool => self::darfPflegen())
->disabled(fn (Model $record): bool => $this->nachbar($record, 1) === null)
->action(fn (Model $record) => $this->verschiebe($record, 1)),
$this->bearbeitenAction(),
ActionGroup::make([
$this->verwendungAction(),
$this->umschaltenAction(),
$this->loeschenAction(),
])->label('Weitere')->icon('heroicon-m-chevron-down')->button()->size('sm')->color('gray'),
])
->emptyStateHeading('Noch keine Werte')
->emptyStateDescription('Mit „Wert anlegen“ entsteht der erste Wert dieser Gruppe.');
}
protected function getHeaderActions(): array
{
return [
Action::make('anlegen')
->label('Wert anlegen')
->icon('heroicon-o-plus')
->authorize(fn (): bool => self::darfPflegen())
->modalHeading(fn (): string => 'Neuer Wert: '.($this->gruppen()[$this->gruppe] ?? ''))
->schema(fn (): array => $this->formular(null))
->fillForm(fn (): array => ['contexts' => ['medium']])
->modalSubmitActionLabel('Anlegen')
->action(function (array $data): void {
$this->anlegen($data);
}),
];
}
// ---------------------------------------------------------------------------------------------------------------
// Formular, Anlegen, Bearbeiten
// ---------------------------------------------------------------------------------------------------------------
/**
* @return list<mixed>
*/
private function formular(?Model $record): array
{
$felder = [
TextInput::make('label')
->label('Bezeichnung')
->required()
->maxLength(120)
->helperText($record !== null
? 'Die Kennung „'.$record->slug.'“ bleibt; vorhandene Zuordnungen behalten den Wert und zeigen die neue Bezeichnung.'
: 'Die Kennung entsteht aus der Bezeichnung und bleibt danach fest.'),
];
if ($this->istMaterialart()) {
$system = $record instanceof EditorialContentKind && $record->isSystem();
$felder[] = CheckboxList::make('contexts')
->label('Zulässig für')
->options(EditorialContentKind::CONTEXTS)
->required()
->live()
->columns(['default' => 2, 'md' => 4])
->disabled($system)
->dehydrated(! $system)
->helperText($system
? 'Diese Materialart verwendet das System; ihre Kontexte bleiben fest.'
: 'Nur hier wird die Materialart neu angeboten. Programm und Modul gehören zu den Objektarten Programm und Modul, nicht zu Medien.');
if ($record instanceof EditorialContentKind) {
$felder[] = Placeholder::make('konflikt')
->label('Bestehende Zuordnungen')
->visible(fn (Get $get): bool => $this->kontextKonflikte($record, (array) $get('contexts')) !== [])
->content(fn (Get $get): HtmlString => new HtmlString('<span style="color: #9a5b00">'
.e(implode(' ', $this->kontextKonflikte($record, (array) $get('contexts'))))
.' Diese Zuordnungen bleiben erhalten und werden dort als „hier nicht vorgesehen“ gekennzeichnet; neu wählbar ist die Materialart dort nicht mehr.</span>'));
$felder[] = Checkbox::make('konflikt_bestaetigt')
->label('Ich habe die bestehenden Zuordnungen geprüft.')
->accepted()
->visible(fn (Get $get): bool => $this->kontextKonflikte($record, (array) $get('contexts')) !== []);
}
}
return $felder;
}
/**
* @return list<string> Meldungen je entferntem Kontext mit Verwendung
*/
private function kontextKonflikte(EditorialContentKind $kind, array $neu): array
{
$verwendung = $this->verwendung($kind);
$meldungen = [];
$zeilen = null;
foreach ((array) ($kind->contexts ?? []) as $context) {
if (! in_array($context, $neu, true) && ($verwendung[$context] ?? 0) > 0) {
$zeilen ??= $this->verwendungListe($kind)['zeilen'];
$titel = array_slice(array_column(array_filter($zeilen, fn (array $z): bool => $z['art'] === (EditorialContentKind::CONTEXTS[$context] ?? '')), 'titel'), 0, 5);
$meldungen[] = (EditorialContentKind::CONTEXTS[$context] ?? $context).': '.$verwendung[$context].' '.($verwendung[$context] === 1 ? 'Zuordnung' : 'Zuordnungen')
.($titel !== [] ? ' („'.implode('“, „', $titel).'“'.($verwendung[$context] > count($titel) ? ' und weitere' : '').')' : '').'.';
}
}
return $meldungen;
}
private function bearbeitenAction(): Action
{
return Action::make('bearbeiten')
->label('Bearbeiten')
->icon('heroicon-o-pencil-square')
->button()
->size('sm')
->color('gray')
->authorize(fn (): bool => self::darfPflegen())
->modalHeading(fn (Model $record): string => '„'.$record->label.'“ bearbeiten')
->schema(fn (Model $record): array => $this->formular($record))
->fillForm(fn (Model $record): array => [
'label' => $record->label,
'contexts' => $record instanceof EditorialContentKind ? (array) ($record->contexts ?? []) : [],
])
->modalSubmitActionLabel('Speichern')
->action(function (Model $record, array $data): void {
$label = trim((string) $data['label']);
$this->pruefeBezeichnung($label, $record);
$record->label = $label;
if ($record instanceof EditorialContentKind && ! $record->isSystem() && isset($data['contexts'])) {
$record->contexts = $this->kontexte((array) $data['contexts']);
}
$record->save();
Notification::make()->success()->title('Gespeichert')->body('Die neue Bezeichnung gilt sofort in Redaktion, Filtern und Picker.')->send();
});
}
private function anlegen(array $data): void
{
$label = trim((string) $data['label']);
$this->pruefeBezeichnung($label, null);
if ($this->istMaterialart()) {
EditorialContentKind::query()->create([
'label' => $label,
'slug' => $this->freieKennung($label, EditorialContentKind::query()),
'sort_order' => (int) EditorialContentKind::query()->max('sort_order') + 10,
'is_active' => true,
'contexts' => $this->kontexte((array) ($data['contexts'] ?? [])),
]);
} else {
$dimension = $this->dimension();
abort_if($dimension === null, 404);
$werte = EditorialDimensionValue::query()->where('editorial_dimension_id', $dimension->id);
EditorialDimensionValue::query()->create([
'editorial_dimension_id' => $dimension->id,
'label' => $label,
'slug' => $this->freieKennung($label, clone $werte),
'sort_order' => (int) (clone $werte)->max('sort_order') + 10,
'is_active' => true,
]);
}
$this->verwendungCache = null;
Notification::make()->success()->title('Angelegt: „'.$label.'“')->body('Der Wert ist sofort in der passenden Redaktion wählbar.')->send();
}
private function pruefeBezeichnung(string $label, ?Model $ausser): void
{
$query = $this->istMaterialart()
? EditorialContentKind::query()
: EditorialDimensionValue::query()->where('editorial_dimension_id', $this->dimension()?->id ?? 0);
$doppelt = $query->whereRaw('LOWER(label) = ?', [mb_strtolower($label)])
->when($ausser !== null, fn (Builder $q) => $q->whereKeyNot($ausser->getKey()))
->exists();
if ($label === '' || $doppelt) {
Notification::make()->danger()->title($label === '' ? 'Die Bezeichnung fehlt.' : 'Diese Bezeichnung gibt es in der Gruppe schon.')->send();
throw new Halt;
}
}
/**
* @return list<string>
*/
private function kontexte(array $kontexte): array
{
$erlaubt = array_keys(EditorialContentKind::CONTEXTS);
return array_values(array_filter($erlaubt, fn (string $context): bool => in_array($context, $kontexte, true)));
}
private function freieKennung(string $label, Builder $query): string
{
$basis = Str::slug($label) ?: 'wert';
$kennung = $basis;
$nummer = 2;
while ((clone $query)->where('slug', $kennung)->exists()) {
$kennung = $basis.'-'.$nummer++;
}
return $kennung;
}
// ---------------------------------------------------------------------------------------------------------------
// Aktiv, Löschen, Reihenfolge
// ---------------------------------------------------------------------------------------------------------------
private function umschaltenAction(): Action
{
return Action::make('umschalten')
->label(fn (Model $record): string => $record->is_active ? 'Deaktivieren' : 'Reaktivieren')
->icon(fn (Model $record): string => $record->is_active ? 'heroicon-o-eye-slash' : 'heroicon-o-eye')
->authorize(fn (): bool => self::darfPflegen())
->hidden(fn (Model $record): bool => $record instanceof EditorialContentKind && $record->isSystem())
->requiresConfirmation()
->modalHeading(fn (Model $record): string => '„'.$record->label.'“ '.($record->is_active ? 'deaktivieren?' : 'reaktivieren?'))
->modalDescription(fn (Model $record): string => $record->is_active
? 'Der Wert wird für neue Zuordnungen nicht mehr angeboten. '.$this->verwendungSatz($record).' Filter finden diese Objekte weiterhin.'
: 'Der Wert wird wieder für neue Zuordnungen angeboten.')
->modalSubmitActionLabel(fn (Model $record): string => $record->is_active ? 'Deaktivieren' : 'Reaktivieren')
->action(function (Model $record): void {
abort_if($record instanceof EditorialContentKind && $record->isSystem(), 403);
$record->is_active = ! $record->is_active;
$record->save();
});
}
private function loeschenAction(): Action
{
return Action::make('loeschen')
->label('Löschen')
->icon('heroicon-o-trash')
->color('danger')
->authorize(fn (): bool => self::darfPflegen())
->visible(fn (Model $record): bool => $this->loeschbar($record))
->requiresConfirmation()
->modalHeading(fn (Model $record): string => '„'.$record->label.'“ löschen?')
->modalDescription('Der Wert ist nirgends zugeordnet und wird endgültig entfernt.')
->modalSubmitActionLabel('Löschen')
->action(function (Model $record): void {
// Erneut prüfen: Zwischenzeitlich entstandene Zuordnungen würden die Datenbank sonst still lösen.
if (! $this->loeschbar($record)) {
Notification::make()->danger()->title('Nicht gelöscht: Der Wert ist inzwischen zugeordnet. Deaktivieren Sie ihn stattdessen.')->send();
return;
}
$record->delete();
$this->verwendungCache = null;
});
}
private function loeschbar(Model $record): bool
{
if ($record instanceof EditorialContentKind && $record->isSystem()) {
return false;
}
return array_sum($this->verwendung($record, frisch: true)) === 0;
}
private function nachbar(Model $record, int $richtung): ?Model
{
$liste = $this->geordnet();
$index = $liste->search(fn (Model $m): bool => $m->is($record));
return $index === false ? null : $liste->get($index + $richtung);
}
private function verschiebe(Model $record, int $richtung): void
{
$liste = $this->geordnet()->values();
$index = $liste->search(fn (Model $m): bool => $m->is($record));
if ($index === false || $liste->get($index + $richtung) === null) {
return;
}
$nachbar = $liste->get($index + $richtung);
// Nur die beiden Einträge tauschen; neu nummeriert wird nur bei gleicher Reihenfolgezahl.
if ((int) $record->sort_order !== (int) $nachbar->sort_order) {
DB::transaction(function () use ($record, $nachbar): void {
[$a, $b] = [(int) $record->sort_order, (int) $nachbar->sort_order];
$record->sort_order = $b;
$record->save();
$nachbar->sort_order = $a;
$nachbar->save();
});
return;
}
$neu = $liste->all();
[$neu[$index], $neu[$index + $richtung]] = [$neu[$index + $richtung], $neu[$index]];
DB::transaction(function () use ($neu): void {
foreach (array_values($neu) as $position => $eintrag) {
if ((int) $eintrag->sort_order !== ($position + 1) * 10) {
$eintrag->sort_order = ($position + 1) * 10;
$eintrag->save();
}
}
});
}
/**
* @return Collection<int, Model>
*/
private function geordnet(): Collection
{
$query = $this->istMaterialart()
? EditorialContentKind::query()
: EditorialDimensionValue::query()->where('editorial_dimension_id', $this->dimension()?->id ?? 0);
return $query->orderBy('sort_order')->orderBy('id')->get()->values();
}
// ---------------------------------------------------------------------------------------------------------------
// Verwendung
// ---------------------------------------------------------------------------------------------------------------
/**
* Zuordnungen je Objektkontext.
*
* @return array<string, int>
*/
public function verwendung(Model $record, bool $frisch = false): array
{
if ($frisch || $this->verwendungCache === null) {
$this->verwendungCache = $this->istMaterialart() ? $this->materialartVerwendung() : $this->einordnungVerwendung();
}
return $this->verwendungCache[(int) $record->getKey()] ?? [];
}
private function verwendungText(Model $record): string
{
$teile = [];
foreach ($this->verwendung($record) as $context => $anzahl) {
if ($anzahl > 0) {
$teile[] = $anzahl.' '.$this->einheit($context, $anzahl);
}
}
return $teile === [] ? 'Nicht verwendet' : implode(' · ', $teile);
}
private function verwendungSatz(Model $record): string
{
$text = $this->verwendungText($record);
return $text === 'Nicht verwendet'
? 'Er ist derzeit nirgends zugeordnet.'
: 'Bestehende Zuordnungen ('.$text.') bleiben erhalten und sichtbar.';
}
private function einheit(string $context, int $anzahl): string
{
return match ($context) {
'medium' => $anzahl === 1 ? 'Medium' : 'Medien',
'modul' => $anzahl === 1 ? 'Modul' : 'Module',
'programm' => $anzahl === 1 ? 'Programm' : 'Programme',
'lizenzartikel' => 'Lizenzartikel',
default => $anzahl === 1 ? 'Kombination' : 'Kombinationen',
};
}
/**
* @return array<int, array<string, int>>
*/
private function materialartVerwendung(): array
{
$ergebnis = [];
foreach (DB::table('content_elements')->whereNotNull('editorial_content_kind_id')->groupBy('editorial_content_kind_id')->selectRaw('editorial_content_kind_id as id, count(*) as anzahl')->get() as $zeile) {
$ergebnis[(int) $zeile->id]['medium'] = (int) $zeile->anzahl;
}
foreach (DB::table('compositions')->whereNotNull('editorial_content_kind_id')->groupBy('editorial_content_kind_id', 'kind')->selectRaw('editorial_content_kind_id as id, kind, count(*) as anzahl')->get() as $zeile) {
$context = EditorialVocabulary::compositionContext(CompositionKind::tryFrom((string) $zeile->kind)) ?? 'kombination';
$ergebnis[(int) $zeile->id][$context] = ($ergebnis[(int) $zeile->id][$context] ?? 0) + (int) $zeile->anzahl;
}
foreach (DB::table('license_articles')->whereNotNull('editorial_content_kind_id')->groupBy('editorial_content_kind_id')->selectRaw('editorial_content_kind_id as id, count(*) as anzahl')->get() as $zeile) {
$ergebnis[(int) $zeile->id]['lizenzartikel'] = (int) $zeile->anzahl;
}
return $ergebnis;
}
/**
* @return array<int, array<string, int>>
*/
private function einordnungVerwendung(): array
{
$ergebnis = [];
$zeilen = DB::table('identity_dimension_values')
->leftJoin('compositions', function ($join): void {
$join->on('compositions.id', '=', 'identity_dimension_values.subject_id')
->where('identity_dimension_values.subject_type', (new Composition)->getMorphClass());
})
->groupBy('identity_dimension_values.editorial_dimension_value_id', 'identity_dimension_values.subject_type', 'compositions.kind')
->selectRaw('identity_dimension_values.editorial_dimension_value_id as id, identity_dimension_values.subject_type as typ, compositions.kind as kind, count(*) as anzahl')
->get();
foreach ($zeilen as $zeile) {
$context = match ($zeile->typ) {
(new ContentElement)->getMorphClass() => 'medium',
(new LicenseArticle)->getMorphClass() => 'lizenzartikel',
default => EditorialVocabulary::compositionContext(CompositionKind::tryFrom((string) $zeile->kind)) ?? 'kombination',
};
$ergebnis[(int) $zeile->id][$context] = ($ergebnis[(int) $zeile->id][$context] ?? 0) + (int) $zeile->anzahl;
}
return $ergebnis;
}
private function verwendungAction(): Action
{
return Action::make('verwendung')
->label('Verwendung')
->icon('heroicon-m-list-bullet')
->authorize(fn (): bool => self::darfPflegen())
->modalHeading(fn (Model $record): string => 'Verwendung von „'.$record->label.'“')
->modalContent(fn (Model $record) => view('filament.stammdaten-verwendung', $this->verwendungListe($record)))
->modalSubmitAction(false)
->modalCancelActionLabel('Schließen');
}
/**
* Zugeordnete Objekte mit Links in ihre Bearbeitung und gefilterte Bestandslisten.
*
* @return array{zeilen: list<array{art: string, titel: string, url: string}>, mehr: int, filter: list<array{label: string, url: string}>}
*/
public function verwendungListe(Model $record): array
{
$grenze = 40;
$zeilen = [];
$filter = [];
if ($record instanceof EditorialContentKind) {
$medien = ContentElement::query()->where('editorial_content_kind_id', $record->id);
$kompositionen = Composition::query()->where('editorial_content_kind_id', $record->id);
$artikel = LicenseArticle::query()->where('editorial_content_kind_id', $record->id);
if ((clone $medien)->exists()) {
$filter[] = ['label' => 'Im Medienmanager filtern', 'url' => ContentElementResource::getUrl('index', ['inhaltsart' => $record->id])];
}
} else {
$zuordnung = fn (string $klasse) => DB::table('identity_dimension_values')
->where('editorial_dimension_value_id', $record->getKey())
->where('subject_type', (new $klasse)->getMorphClass())
->pluck('subject_id');
$medien = ContentElement::query()->whereKey($zuordnung(ContentElement::class));
$kompositionen = Composition::query()->whereKey($zuordnung(Composition::class));
$artikel = LicenseArticle::query()->whereKey($zuordnung(LicenseArticle::class));
if ((clone $medien)->exists()) {
$filter[] = ['label' => 'Im Medienmanager filtern', 'url' => ContentElementResource::getUrl('index', ['einordnung' => $record->getKey()])];
}
if ((clone $kompositionen)->exists()) {
$filter[] = ['label' => 'Programme und Module filtern', 'url' => EditorialDesk::getUrl(['pillar' => $record->getKey()])];
}
}
$gesamt = (clone $medien)->count() + (clone $kompositionen)->count() + (clone $artikel)->count();
foreach ($medien->orderBy('working_title')->limit($grenze)->get() as $element) {
$zeilen[] = ['art' => 'Medium', 'titel' => (string) ($element->display_title ?: $element->working_title), 'url' => ContentElementResource::getUrl('view', ['record' => $element])];
}
foreach ($kompositionen->orderBy('designation')->limit($grenze)->get() as $composition) {
$context = EditorialVocabulary::compositionContext($composition->kind instanceof CompositionKind ? $composition->kind : CompositionKind::tryFrom((string) $composition->kind));
$zeilen[] = ['art' => EditorialContentKind::CONTEXTS[$context ?? ''] ?? 'Kombination', 'titel' => (string) ($composition->display_title ?: $composition->designation), 'url' => EditorialCatalog::editUrl($composition)];
}
foreach ($artikel->orderBy('code')->limit($grenze)->get() as $article) {
$zeilen[] = ['art' => 'Lizenzartikel', 'titel' => trim($article->code.' '.($article->display_title ?: $article->working_title)), 'url' => LicenseArticleResource::getUrl('view', ['record' => $article])];
}
return ['zeilen' => $zeilen, 'mehr' => max(0, $gesamt - count($zeilen)), 'filter' => $filter];
}
}
File diff suppressed because it is too large. Load diff
@@ -2,8 +2,12 @@
namespace App\Filament\Resources\Bundles\Pages; namespace App\Filament\Resources\Bundles\Pages;
use App\Domain\Catalog\Bundle;
use App\Domain\Catalog\BundleService; use App\Domain\Catalog\BundleService;
use App\Domain\Catalog\BundleStatus;
use App\Domain\Catalog\StatusValue;
use App\Filament\Resources\Bundles\BundleResource; use App\Filament\Resources\Bundles\BundleResource;
use App\Filament\Support\ListsCatalog;
use App\Filament\Support\ReportsDomainRules; use App\Filament\Support\ReportsDomainRules;
use Filament\Actions\Action; use Filament\Actions\Action;
use Filament\Forms\Components\TextInput; use Filament\Forms\Components\TextInput;
@@ -12,6 +16,7 @@
class ListBundles extends ListRecords class ListBundles extends ListRecords
{ {
use ListsCatalog;
use ReportsDomainRules; use ReportsDomainRules;
protected static string $resource = BundleResource::class; protected static string $resource = BundleResource::class;
@@ -24,13 +29,83 @@ public function getSubheading(): string|Htmlable|null
protected function getHeaderActions(): array protected function getHeaderActions(): array
{ {
return [ return [
Action::make('create')->label('Paket anlegen')->schema([ Action::make('create')->label('Paket anlegen')
TextInput::make('name')->label('Name')->required(), ->modalHeading('Neues Paket')
])->action(function (array $data): void { ->modalDescription('Der Name genügt. Bestandteile stellst du danach am Paket zusammen.')
$this->report(function () use ($data): void { ->modalSubmitActionLabel('Paket anlegen')
app(BundleService::class)->create($data['name']); ->schema([
}, 'Das Paket ist angelegt.'); TextInput::make('name')->label('Name')->required(),
}), ])->action(function (array $data): void {
$bundle = null;
$this->report(function () use ($data, &$bundle): void {
$bundle = app(BundleService::class)->create($data['name']);
}, 'Das Paket ist angelegt.');
if ($bundle instanceof Bundle) {
$this->redirect(BundleResource::getUrl('view', ['record' => $bundle]));
}
}),
]; ];
} }
protected function catalogRows(): array
{
$rows = [];
foreach (Bundle::query()->with(['versions.items'])->orderBy('name')->get() as $bundle) {
$versions = $bundle->versions->sortByDesc('number');
$published = $versions->first(fn ($version): bool => StatusValue::of($version->status) === BundleStatus::Veroeffentlicht->value);
$draft = $versions->first(fn ($version): bool => StatusValue::of($version->status) === BundleStatus::Entwurf->value);
$chips = [];
$zustand = [];
if ($published !== null) {
$chips[] = ['label' => 'Fassung '.$published->number.' veröffentlicht', 'ton' => 'gut'];
$chips[] = ['label' => $published->items->count() === 1 ? '1 Bestandteil' : $published->items->count().' Bestandteile', 'ton' => 'leise'];
$zustand[] = 'veroeffentlicht';
} else {
$chips[] = ['label' => $versions->isEmpty() ? 'Noch keine Fassung' : 'Noch nicht veröffentlicht', 'ton' => 'offen'];
$zustand[] = 'ohne';
}
if ($draft !== null) {
$chips[] = ['label' => 'Fassung '.$draft->number.' in Arbeit', 'ton' => 'offen'];
$zustand[] = 'entwurf';
}
if ($bundle->archived_at !== null) {
$chips[] = ['label' => 'Archiviert', 'ton' => 'leise'];
$zustand[] = 'archiviert';
}
$url = BundleResource::getUrl('view', ['record' => $bundle]);
$rows[] = [
'schluessel' => 'p'.$bundle->id,
'titel' => $bundle->name,
'meta' => 'Paket',
'symbol' => 'modul',
'url' => $url,
'chips' => $chips,
'zustand' => $zustand,
'aktionen' => [['label' => 'Öffnen', 'href' => $url]],
];
}
return $rows;
}
protected function zustandOptionen(): array
{
return ['alle' => 'Jeder Zustand', 'veroeffentlicht' => 'Veröffentlicht', 'ohne' => 'Noch nicht veröffentlicht', 'entwurf' => 'Fassung in Arbeit', 'archiviert' => 'Archiviert'];
}
protected function einheit(): array
{
return ['Paket', 'Pakete'];
}
protected function leer(): array
{
return ['titel' => 'Noch keine Pakete', 'text' => 'Mit „Paket anlegen“ oben entsteht das erste Paket.'];
}
} }
@@ -4,54 +4,194 @@
use App\Domain\Catalog\Bundle; use App\Domain\Catalog\Bundle;
use App\Domain\Catalog\BundleService; use App\Domain\Catalog\BundleService;
use App\Domain\Catalog\BundleStatus;
use App\Domain\Catalog\BundleVersion;
use App\Domain\Catalog\LicenseArticle; use App\Domain\Catalog\LicenseArticle;
use App\Domain\Catalog\StatusValue;
use App\Filament\Resources\Bundles\BundleResource; use App\Filament\Resources\Bundles\BundleResource;
use App\Filament\Support\CatalogOptions; use App\Filament\Support\CatalogOptions;
use App\Filament\Support\CatalogReading;
use App\Filament\Support\ReportsDomainRules; use App\Filament\Support\ReportsDomainRules;
use Filament\Actions\Action; use Filament\Actions\Action;
use Filament\Forms\Components\CheckboxList; use Filament\Forms\Components\CheckboxList;
use Filament\Resources\Pages\ViewRecord; 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 class ViewBundle extends ViewRecord
{ {
use ReportsDomainRules; use ReportsDomainRules;
protected static string $resource = BundleResource::class; 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 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 [ return [
Action::make('publish') 'articles' => $published?->items->pluck('license_article_id')->filter()->values()->all() ?? [],
->label('Fassung veröffentlichen') 'bundles' => $published?->items->pluck('nested_bundle_id')->filter()->values()->all() ?? [],
->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; private function nextNumber(): int
}), {
]) return ((int) $this->getRecord()->versions()->max('number')) + 1;
->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); * @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) { return [
$items[] = Bundle::query()->findOrFail($id); 'kopf' => [
} 'brot' => [['label' => 'Pakete', 'href' => BundleResource::getUrl('index')], $bundle->name],
'titel' => $bundle->name,
app(BundleService::class)->publish($bundle, $items); 'typ' => 'Paket',
}, 'Die Paketfassung ist veröffentlicht.'); 'status' => $published !== null
$this->getRecord()->unsetRelations(); ? ['text' => 'Fassung '.$published->number.' veröffentlicht', 'ton' => 'gut']
$this->getRecord()->refresh(); : ['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.',
]],
]; ];
} }
} }
File diff suppressed because it is too large. Load diff
@@ -4,38 +4,66 @@
use App\Domain\Catalog\CompositionKind; use App\Domain\Catalog\CompositionKind;
use App\Domain\Catalog\ContentService; use App\Domain\Catalog\ContentService;
use App\Domain\Catalog\EditorialContentKind;
use App\Filament\Resources\ContentElements\ContentElementResource; use App\Filament\Resources\ContentElements\ContentElementResource;
use App\Filament\Support\ListsCompositions;
use App\Filament\Support\ReportsDomainRules; use App\Filament\Support\ReportsDomainRules;
use Filament\Actions\Action; use Filament\Actions\Action;
use Filament\Forms\Components\TextInput; use Filament\Forms\Components\TextInput;
use Filament\Resources\Pages\ListRecords; use Filament\Resources\Pages\ListRecords;
use Filament\Schemas\Components\View;
use Filament\Schemas\Schema;
use Filament\Support\Enums\Width;
use Illuminate\Contracts\Support\Htmlable; use Illuminate\Contracts\Support\Htmlable;
/**
* 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 abstract class ListCompositionKind extends ListRecords
{ {
use ListsCompositions;
use ReportsDomainRules; use ReportsDomainRules;
abstract protected function kind(): CompositionKind; abstract protected function kind(): CompositionKind;
protected function fixedKind(): ?CompositionKind
{
return $this->kind();
}
private function onDesk(): bool
{
return in_array($this->kind(), [CompositionKind::Kurs, CompositionKind::Uebung], true);
}
public function getSubheading(): string|Htmlable|null public function getSubheading(): string|Htmlable|null
{ {
$desk = in_array($this->kind(), [CompositionKind::Kurs, CompositionKind::Uebung], true) $desk = $this->onDesk() ? ' Programme und Module stehen gemeinsam auch auf dem Arbeitsplatz.' : '';
? ' Programme und Module liegen gemeinsam auf dem Arbeitsplatz.'
: '';
return $this->kind()->deskExplanation().$desk; return $this->kind()->deskExplanation().$desk;
} }
public function getMaxContentWidth(): Width|string|null
{
return Width::Full;
}
public function content(Schema $schema): Schema
{
return $schema->components([View::make('filament.verwaltung.bestand')]);
}
protected function getHeaderActions(): array protected function getHeaderActions(): array
{ {
if ($this->onDesk()) {
return [$this->createCompositionAction($this->kind())];
}
return [ return [
Action::make('create') Action::make('create')
->label(match ($this->kind()) { ->label($this->kind()->createLabel())
CompositionKind::Kurs => 'Programm anlegen', ->modalHeading('Neue '.lcfirst($this->kind()->label()))
CompositionKind::Uebung => 'Modul anlegen', ->modalSubmitActionLabel($this->kind()->createLabel())
default => $this->kind()->createLabel(),
})
->visible(fn (): bool => ContentElementResource::editor()) ->visible(fn (): bool => ContentElementResource::editor())
->schema([ ->schema([
TextInput::make('designation')->label('Bezeichnung')->required(), TextInput::make('designation')->label('Bezeichnung')->required(),
@@ -44,16 +72,6 @@ protected function getHeaderActions(): array
$composition = null; $composition = null;
$this->report(function () use ($data, &$composition): void { $this->report(function () use ($data, &$composition): void {
$composition = app(ContentService::class)->createComposition($data['designation'], $this->kind()); $composition = app(ContentService::class)->createComposition($data['designation'], $this->kind());
$slug = match ($this->kind()) {
CompositionKind::Kurs => 'programm',
CompositionKind::Uebung => 'modul',
default => null,
};
$editorial = $slug === null ? null : EditorialContentKind::query()->where('slug', $slug)->first();
if ($editorial !== null) {
$composition->editorial_content_kind_id = $editorial->id;
$composition->save();
}
}, $this->kind()->label().' ist angelegt.'); }, $this->kind()->label().' ist angelegt.');
if ($composition !== null) { if ($composition !== null) {
@@ -7,8 +7,7 @@
use App\Domain\Catalog\ContentElementVersion; use App\Domain\Catalog\ContentElementVersion;
use App\Domain\Catalog\ContentService; use App\Domain\Catalog\ContentService;
use App\Domain\Catalog\DomainRuleException; use App\Domain\Catalog\DomainRuleException;
use App\Domain\Catalog\EditorialContentKind; use App\Domain\Catalog\EditorialVocabulary;
use App\Domain\Catalog\EditorialDimension;
use App\Domain\Catalog\IdentityDimension; use App\Domain\Catalog\IdentityDimension;
use App\Domain\Catalog\IdentityDimensionValue; use App\Domain\Catalog\IdentityDimensionValue;
use App\Domain\Catalog\IdentityProfile; use App\Domain\Catalog\IdentityProfile;
@@ -36,12 +35,23 @@
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\HtmlString; use Illuminate\Support\HtmlString;
/**
* Früheres Gesamtformular. Texte und Einordnung bearbeitet die gemeinsame Redaktion, Datei und Fassungen der
* Medieneditor; ein zweiter Editor für dieselben Felder ist nach Dokument 14 nicht zulässig. Die Adresse bleibt
* für alte Lesezeichen erhalten und führt nach der Rechteprüfung in die Redaktion des Mediums.
*/
class EditContentElement extends EditRecord class EditContentElement extends EditRecord
{ {
use ReportsDomainRules; use ReportsDomainRules;
protected static string $resource = ContentElementResource::class; protected static string $resource = ContentElementResource::class;
public function mount(int|string $record): void
{
parent::mount($record);
$this->redirect(ContentElementResource::getUrl('view', ['record' => $this->getRecord(), 'redaktion' => 1]));
}
public function getSubheading(): string|Htmlable|null public function getSubheading(): string|Htmlable|null
{ {
return 'Titel, Beschreibung, Hinweise und Vorschaubild gehören zum Medium. Ein Text bleibt dieselbe Fassung, solange er nicht freigegeben und verwendet wird.'; return 'Titel, Beschreibung, Hinweise und Vorschaubild gehören zum Medium. Ein Text bleibt dieselbe Fassung, solange er nicht freigegeben und verwendet wird.';
@@ -63,8 +73,8 @@ public function form(Schema $schema): Schema
->helperText('Erscheint in der Bibliothek. Leer lässt den Arbeitstitel stehen. Speichern legt keine Fassung an.'), ->helperText('Erscheint in der Bibliothek. Leer lässt den Arbeitstitel stehen. Speichern legt keine Fassung an.'),
Textarea::make('summary')->label('Kurzbeschreibung')->rows(3), Textarea::make('summary')->label('Kurzbeschreibung')->rows(3),
Select::make('editorial_content_kind_id') Select::make('editorial_content_kind_id')
->label('Inhaltsart') ->label('Fachliche Materialart')
->options(fn (): array => EditorialContentKind::selectOptions()) ->options(fn (): array => app(EditorialVocabulary::class)->kindOptions('medium', $this->getRecord()->editorial_content_kind_id !== null ? (int) $this->getRecord()->editorial_content_kind_id : null))
->nullable() ->nullable()
->helperText('Optional für Bibliothek und Website. Ändert weder die Ausgabeart noch eine Fassung.'), ->helperText('Optional für Bibliothek und Website. Ändert weder die Ausgabeart noch eine Fassung.'),
Placeholder::make('usage')->label('Verwendung')->content(function (): HtmlString { Placeholder::make('usage')->label('Verwendung')->content(function (): HtmlString {
@@ -92,9 +102,12 @@ public function form(Schema $schema): Schema
CheckboxList::make('dimension_ids')->label('Fachliche Einordnung') CheckboxList::make('dimension_ids')->label('Fachliche Einordnung')
->options(function (): array { ->options(function (): array {
$options = []; $options = [];
foreach (EditorialDimension::forSubject($this->getRecord()) as $dimension) { foreach (app(EditorialVocabulary::class)->dimensionGroups($this->getRecord(), IdentityDimensionValue::query()
foreach ($dimension->values as $value) { ->where('subject_type', $this->getRecord()->getMorphClass())
$options[$value->id] = $dimension->label.': '.$value->label; ->where('subject_id', $this->getRecord()->getKey())
->pluck('editorial_dimension_value_id')->map(fn ($id): int => (int) $id)->all()) as $dimension) {
foreach ($dimension['values'] as $value) {
$options[$value['id']] = $dimension['label'].': '.$value['label'];
} }
} }
@@ -2,11 +2,14 @@
namespace App\Filament\Resources\ContentElements\Pages; namespace App\Filament\Resources\ContentElements\Pages;
use App\Domain\Catalog\EditorialContentKind; use App\Domain\Catalog\EditorialVocabulary;
use App\Domain\Catalog\PillarFilterCompat;
use App\Filament\Resources\ContentElements\ContentElementResource; use App\Filament\Resources\ContentElements\ContentElementResource;
use App\Filament\Support\Bestand;
use App\Filament\Support\MediaLibrary; use App\Filament\Support\MediaLibrary;
use App\Filament\Support\MediumForm; use App\Filament\Support\MediumForm;
use App\Filament\Support\ReportsDomainRules; use App\Filament\Support\ReportsDomainRules;
use App\Filament\Support\ShowsBestand;
use Filament\Actions\Action; use Filament\Actions\Action;
use Filament\Resources\Pages\ListRecords; use Filament\Resources\Pages\ListRecords;
use Filament\Schemas\Components\RenderHook; use Filament\Schemas\Components\RenderHook;
@@ -20,14 +23,16 @@
class ListContentElements extends ListRecords class ListContentElements extends ListRecords
{ {
use ReportsDomainRules; use ReportsDomainRules;
use ShowsBestand;
protected static string $resource = ContentElementResource::class; protected static string $resource = ContentElementResource::class;
#[Url(as: 'suche', except: '')] #[Url(as: 'suche', except: '')]
public string $suche = ''; public string $suche = '';
#[Url(as: 'ansicht', except: 'kacheln')] /** Dokument 14 §3: kompakte Liste als Grundansicht; Kacheln bleiben wählbar. */
public string $ansicht = 'kacheln'; #[Url(as: 'ansicht', except: 'liste')]
public string $ansicht = 'liste';
#[Url(as: 'art', except: '')] #[Url(as: 'art', except: '')]
public string $art = ''; public string $art = '';
@@ -72,13 +77,17 @@ public function getMaxContentWidth(): Width|string|null
public function content(Schema $schema): Schema public function content(Schema $schema): Schema
{ {
return $schema->components([ return $schema->components([
$this->getTabsContentComponent(),
RenderHook::make(PanelsRenderHook::RESOURCE_PAGES_LIST_RECORDS_TABLE_BEFORE), RenderHook::make(PanelsRenderHook::RESOURCE_PAGES_LIST_RECORDS_TABLE_BEFORE),
View::make('filament.media.library'), View::make('filament.verwaltung.bestand'),
RenderHook::make(PanelsRenderHook::RESOURCE_PAGES_LIST_RECORDS_TABLE_AFTER), RenderHook::make(PanelsRenderHook::RESOURCE_PAGES_LIST_RECORDS_TABLE_AFTER),
]); ]);
} }
protected function bestandFilterEigenschaften(): array
{
return ['suche', 'art', 'freigabe', 'entwurf', 'fassung', 'nutzung', 'saeule', 'inhaltsart', 'einordnung', 'verarbeitung', 'archiv'];
}
public function showingList(): bool public function showingList(): bool
{ {
return $this->ansicht === 'liste'; return $this->ansicht === 'liste';
@@ -113,7 +122,7 @@ public function pillarOptions(): array
*/ */
public function classificationOptions(): array public function classificationOptions(): array
{ {
return app(MediaLibrary::class)->classifications(); return app(MediaLibrary::class)->classifications(ctype_digit($this->einordnung) ? [(int) $this->einordnung] : []);
} }
/** /**
@@ -121,7 +130,7 @@ public function classificationOptions(): array
*/ */
public function contentKindOptions(): array public function contentKindOptions(): array
{ {
return EditorialContentKind::selectOptions(); return app(EditorialVocabulary::class)->kindFilterOptions('medium', $this->inhaltsart);
} }
public function filtersActive(): bool public function filtersActive(): bool
@@ -152,6 +161,106 @@ public function resetFilters(): void
$this->inhaltsart = ''; $this->inhaltsart = '';
$this->verarbeitung = ''; $this->verarbeitung = '';
$this->archiv = 'aktiv'; $this->archiv = 'aktiv';
$this->bestandGrenze = Bestand::SCHRITT;
}
/**
* Gemeinsame Bestandsliste: Suche und häufige Filter sichtbar, die übrigen unter „Weitere Filter“.
*
* @return array<string, mixed>
*/
public function bestand(): array
{
// Alte Adressen mit einem Säulenwert der Einordnung gelten für die zentrale Säule.
if (ctype_digit($this->einordnung) && $this->saeule === '' && is_int($pillar = PillarFilterCompat::pillarOfLegacyValue((int) $this->einordnung))) {
[$this->saeule, $this->einordnung] = [(string) $pillar, ''];
}
$optionen = fn (array $liste, string $wert, string $label): array => collect($liste)
->mapWithKeys(fn (array $eintrag): array => [(string) $eintrag[$wert] => $eintrag[$label]])
->all();
$weitere = [
['eigenschaft' => 'inhaltsart', 'label' => 'Fachliche Materialart', 'vorgabe' => '', 'alle' => 'Alle Materialarten', 'optionen' => $this->contentKindOptions()],
['eigenschaft' => 'entwurf', 'label' => 'Entwurf', 'vorgabe' => '', 'alle' => 'Entwurf egal', 'optionen' => ['offen' => 'Offener Entwurf', 'keiner' => 'Kein offener Entwurf']],
['eigenschaft' => 'fassung', 'label' => 'Deaktivierte Fassungen', 'vorgabe' => '', 'alle' => 'Regulärer Bestand', 'optionen' => ['mit' => 'Mit deaktivierter Fassung', 'nur' => 'Nur deaktivierte Fassungen']],
];
if (($pillars = $this->pillarOptions()) !== []) {
$weitere[] = ['eigenschaft' => 'saeule', 'label' => 'Fachliche Säule', 'vorgabe' => '', 'alle' => 'Alle Säulen', 'optionen' => $optionen($pillars, 'id', 'name')];
}
if (($classes = $this->classificationOptions()) !== []) {
$weitere[] = ['eigenschaft' => 'einordnung', 'label' => 'Einordnung', 'vorgabe' => '', 'alle' => 'Alle Einordnungen', 'optionen' => $optionen($classes, 'id', 'label')];
}
$weitere[] = ['eigenschaft' => 'verarbeitung', 'label' => 'Verarbeitung', 'vorgabe' => '', 'alle' => 'Verarbeitung egal', 'optionen' => ['fehler' => 'Verarbeitungsfehler', 'uebernahme' => 'Datei wird übernommen']];
$weitere[] = ['eigenschaft' => 'archiv', 'label' => 'Archiv', 'vorgabe' => 'aktiv', 'optionen' => ['aktiv' => 'Aktive Medien', 'archiviert' => 'Archivierte Medien', 'alle' => 'Auch archivierte']];
return [
'suche' => ['eigenschaft' => 'suche', 'label' => 'Suche', 'platzhalter' => 'Titel, Beschreibung oder Suchbegriff'],
'filter' => [
['eigenschaft' => 'art', 'label' => 'Technische Art', 'vorgabe' => '', 'alle' => 'Alle Arten', 'optionen' => $optionen($this->typeOptions(), 'value', 'label')],
['eigenschaft' => 'freigabe', 'label' => 'Freigabe', 'vorgabe' => '', 'alle' => 'Alle Freigaben', 'optionen' => ['freigegeben' => 'Freigegebene Fassung', 'entwurf' => 'Nur offener Entwurf', 'ohne' => 'Keine freigegebene Fassung']],
['eigenschaft' => 'nutzung', 'label' => 'Verwendung', 'vorgabe' => '', 'alle' => 'Verwendung egal', 'optionen' => ['verwendet' => 'Verwendet', 'unbenutzt' => 'Nicht verwendet']],
],
'weitere' => $weitere,
'hinweis' => 'Freigabe meint die Fassung des Mediums, nicht die Website und keinen Zugriff. Materialart und Einordnung sind die redaktionelle Klassifikation; Verwendung zeigt, wo das Medium tatsächlich eingebunden ist. Deaktivierte und archivierte Medien bleiben über „Weitere Filter“ auffindbar.',
'zeilen' => array_map($this->zeile(...), $this->cards()),
'einheit' => ['Medium', 'Medien'],
'leer' => ['titel' => 'Noch keine Medien', 'text' => 'Mit „Medium anlegen“ oben lädst du eine Datei hoch oder schreibst einen Text.'],
'ansicht' => 'ansicht',
];
}
/**
* @param array<string, mixed> $card
* @return array<string, mixed>
*/
private function zeile(array $card): array
{
$chips = [['label' => $card['stand'], 'ton' => match ($card['standTone']) {
'ready' => 'gut',
'draft' => 'offen',
'blocked' => 'achtung',
default => 'leise',
}]];
foreach ([['draftNote', 'offen'], ['blockedNote', 'achtung'], ['processing', 'offen'], ['versionLabel', 'leise']] as [$feld, $ton]) {
if (filled($card[$feld] ?? null)) {
$chips[] = ['label' => (string) $card[$feld], 'ton' => $ton];
}
}
if ($card['archived']) {
$chips[] = ['label' => 'Archiviert', 'ton' => 'leise'];
}
return [
'schluessel' => 'm'.$card['id'],
'titel' => $card['title'],
'meta' => $card['type'].(filled($card['editorialKind'] ?? null) ? ' · '.$card['editorialKind'] : ''),
'text' => $card['description'],
'bild' => $card['image'],
'bildAlt' => $card['imageAlt'],
'symbol' => match ($card['typeKey']) {
'film' => 'film',
'bild' => 'bild',
'audio' => 'audio',
default => 'dokument',
},
'url' => $card['url'],
'chips' => $chips,
'hinweise' => array_values(array_filter([
$card['imageNote'] ? 'Vorschaubild: '.$card['imageNote'] : null,
$card['usageNote'] ? 'Einsatz: '.$card['usageNote'] : null,
$card['licenseNote'] ? 'Interner Lizenzvermerk: '.$card['licenseNote'] : null,
])),
'zusatz' => ['view' => 'filament.media.usages', 'daten' => ['card' => $card]],
'aktionen' => array_values(array_filter([
['label' => 'Ansehen', 'href' => $card['url'], 'icon' => 'auge'],
$card['editUrl'] ? ['label' => 'Redaktion', 'href' => $card['editUrl'], 'icon' => 'stift'] : null,
])),
];
} }
/** /**
@@ -179,6 +288,7 @@ protected function getHeaderActions(): array
return [ return [
Action::make('create') Action::make('create')
->label('Medium anlegen') ->label('Medium anlegen')
->modalSubmitActionLabel('Medium anlegen')
->visible(fn (): bool => ContentElementResource::editor()) ->visible(fn (): bool => ContentElementResource::editor())
->modalDescription('Dieselbe Maske gilt im Medienbestand, im Modul und im Programm. Der Upload zeigt seinen Fortschritt. Beschreibung, Hinweise und Vorschaubild gehören dazu.') ->modalDescription('Dieselbe Maske gilt im Medienbestand, im Modul und im Programm. Der Upload zeigt seinen Fortschritt. Beschreibung, Hinweise und Vorschaubild gehören dazu.')
->schema(fn (): array => MediumForm::fields(creating: true)) ->schema(fn (): array => MediumForm::fields(creating: true))
@@ -6,10 +6,13 @@
use App\Domain\Catalog\ContentElementVersion; use App\Domain\Catalog\ContentElementVersion;
use App\Domain\Catalog\ContentService; use App\Domain\Catalog\ContentService;
use App\Domain\Catalog\ContentVersionStatus; use App\Domain\Catalog\ContentVersionStatus;
use App\Domain\Catalog\DomainRuleException;
use App\Domain\Catalog\EditorialVocabulary;
use App\Domain\Catalog\IdentityChange; use App\Domain\Catalog\IdentityChange;
use App\Domain\Catalog\IdentityDimension; use App\Domain\Catalog\IdentityDimension;
use App\Domain\Catalog\IdentityDimensionValue; use App\Domain\Catalog\IdentityDimensionValue;
use App\Domain\Catalog\IdentityProfile; use App\Domain\Catalog\IdentityProfile;
use App\Domain\Catalog\Pillar;
use App\Domain\Catalog\PillarService; use App\Domain\Catalog\PillarService;
use App\Domain\Cms\Catalog\PublicMaterialReader; use App\Domain\Cms\Catalog\PublicMaterialReader;
use App\Domain\Cms\WebsiteImageUsage; use App\Domain\Cms\WebsiteImageUsage;
@@ -55,6 +58,14 @@ class ViewContentElement extends ViewRecord
public string $pictureFeedback = ''; public string $pictureFeedback = '';
/** Rückmeldung zur ausgewählten Fassung, direkt im Detailbereich. */
public string $fassungFeedback = '';
public bool $fassungFeedbackError = false;
/** Gewählte Quelle für ein neues Vorschaubild: film oder upload. */
public string $bildQuelle = '';
public mixed $previewUpload = null; public mixed $previewUpload = null;
public string $bereich = 'inhalt'; public string $bereich = 'inhalt';
@@ -91,18 +102,16 @@ class ViewContentElement extends ViewRecord
public string $editorialFeedback = ''; public string $editorialFeedback = '';
public int $versionsBeforeSave = 0;
public string $previewWidth = '640'; public string $previewWidth = '640';
public string $previewSurface = 'website'; public string $previewSurface = 'website';
public string $pickerQuery = '';
public string $pickerContext = 'modul'; public string $pickerContext = 'modul';
public string $pickerLayout = 'kacheln'; public string $pickerLayout = 'kacheln';
public string $pickerSelected = '';
public function mount(int|string $record): void public function mount(int|string $record): void
{ {
parent::mount($record); parent::mount($record);
@@ -113,25 +122,47 @@ public function mount(int|string $record): void
$this->fassung = $requested; $this->fassung = $requested;
} }
$bereich = (string) request()->query('bereich', 'beschreibung'); $bereich = (string) request()->query('bereich', 'inhalt');
$this->bereich = in_array($bereich, ['beschreibung', 'inhalt', 'fassungen', 'praesentation', 'verwendung', 'vorschau'], true) $this->bereich = $this->normalBereich($bereich);
? $bereich
: 'beschreibung';
$this->thumbnailAlt = (string) ($this->getRecord()->thumbnail_alt ?? ''); $this->thumbnailAlt = (string) ($this->getRecord()->thumbnail_alt ?? '');
$this->bildQuelle = $this->getRecord()->output_class === 'film' ? 'film' : 'upload';
$this->fillEditorial(); $this->fillEditorial();
// Die gezeigte Fassung wird festgehalten. Sonst wechselte die Anzeige still auf eine andere Fassung, sobald
// eine Freigabe oder neue Fassung die Vorgabe „neueste freigegebene“ ändert, während das Textfeld noch den
// Wortlaut der bisherigen enthält. Eine fremde oder ungültige Angabe in der Adresse wird dabei ersetzt.
$this->fassung = $this->shownVersion()?->id;
$this->syncBodyDraft(); $this->syncBodyDraft();
if (in_array($bereich, ['praesentation', 'redaktion'], true) && $this->canEditEditorial()) {
$this->openRedaktion($bereich === 'praesentation' ? 'medien' : 'texte');
}
} }
public function getHeading(): string|Htmlable public function updatedBereich(string $value): void
{
$this->bereich = $this->normalBereich($value);
}
/**
* Bereiche des Medieneditors. Fassungen und Inhalt bilden einen Bereich (Fassungen links, ausgewählte Fassung rechts);
* „fassungen“ bleibt als Adresse gültig. Die früheren Werte „beschreibung“ und „praesentation“ führen zur
* Website-Ansicht, weil Texte und Präsentationsmedien in der gemeinsamen Redaktion bearbeitet werden.
*/
public function normalBereich(string $value): string
{
return match ($value) {
'inhalt', 'vorschaubild', 'verwendung', 'vorschau', 'website' => $value,
'fassungen' => 'inhalt',
'beschreibung', 'praesentation', 'redaktion' => 'website',
default => 'inhalt',
};
}
public function getTitle(): string|Htmlable
{ {
return (string) $this->getRecord()->working_title; return (string) $this->getRecord()->working_title;
} }
public function getSubheading(): string|Htmlable|null
{
return 'Texte und Vorschaubild ändern keine Fassung. Eine neue Datei oder ein geänderter Lehrtext braucht eine neue Fassung.';
}
public function getMaxContentWidth(): Width|string|null public function getMaxContentWidth(): Width|string|null
{ {
return Width::Full; return Width::Full;
@@ -140,14 +171,54 @@ public function getMaxContentWidth(): Width|string|null
public function infolist(Schema $schema): Schema public function infolist(Schema $schema): Schema
{ {
return $schema->components([ return $schema->components([
View::make('filament.media.viewer')->viewData(fn (): array => $this->viewerData()), View::make('filament.media.viewer')->viewData(fn (): array => $this->viewerData())->columnSpanFull(),
]); ])->columns(1);
} }
/**
* Wählt eine Fassung. Ein geänderter, noch nicht gespeicherter Text geht dabei nicht stillschweigend verloren.
*/
public function showVersion(int $version): void public function showVersion(int $version): void
{ {
abort_unless($this->ownedVersion($version) instanceof ContentElementVersion, 404); abort_unless($this->ownedVersion($version) instanceof ContentElementVersion, 404);
$this->bereich = 'inhalt';
if ($this->shownVersion()?->id === $version) {
return;
}
if ($this->textUnsaved()) {
$this->askConfirmation('showVersion', $version);
return;
}
$this->selectVersion($version);
}
/**
* Der Text der gezeigten Fassung weicht vom gespeicherten Stand ab.
*/
public function textUnsaved(): bool
{
$shown = $this->shownVersion();
return $shown instanceof ContentElementVersion
&& $this->getRecord()->output_class === 'text'
&& $shown->status !== ContentVersionStatus::Gesperrt
&& trim($this->bodyDraft) !== trim((string) $shown->body);
}
public function discardShownText(): void
{
$this->syncBodyDraft();
$this->fassungFeedback = '';
}
private function selectVersion(int $version): void
{
$this->fassung = $version; $this->fassung = $version;
$this->fassungFeedback = '';
$this->syncBodyDraft(); $this->syncBodyDraft();
} }
@@ -159,12 +230,28 @@ public function saveShownText(): void
return; return;
} }
$created = app(ContentService::class)->isCommitted($shown); if (! $this->textUnsaved()) {
$this->report(function () use ($shown): void { $this->fassungFeedback = 'Der Text ist unverändert. Es gibt nichts zu speichern.';
app(ContentService::class)->reviseElementContent($shown, $this->bodyDraft); $this->fassungFeedbackError = false;
}, $created
? 'Die neue Fassung ist angelegt. Die bisherige bleibt erhalten.' return;
: 'Der Text ist in derselben Fassung gespeichert.'); }
try {
$saved = app(ContentService::class)->reviseElementContent($shown, $this->bodyDraft);
} catch (DomainRuleException $exception) {
$this->fassungFeedback = $exception->getMessage();
$this->fassungFeedbackError = true;
return;
}
// Eine freigegebene Fassung bleibt unverändert; die Auswahl folgt der neu angelegten Fassung.
$this->fassungFeedback = $saved->id !== $shown->id
? 'Fassung '.$saved->number.' ist angelegt. Fassung '.$shown->number.' bleibt erhalten.'
: 'Der Text ist in Fassung '.$saved->number.' gespeichert. Es entsteht keine neue Fassung.';
$this->fassungFeedbackError = false;
$this->fassung = $saved->id;
$this->getRecord()->unsetRelation('versions'); $this->getRecord()->unsetRelation('versions');
$this->syncBodyDraft(); $this->syncBodyDraft();
} }
@@ -292,7 +379,7 @@ public function deactivateAction(): Action
{ {
return Action::make('deactivate') return Action::make('deactivate')
->label('Deaktivieren') ->label('Deaktivieren')
->modalHeading('Fassung deaktivieren') ->modalHeading(fn (array $arguments): string => 'Fassung '.($this->ownedVersion((int) ($arguments['version'] ?? 0))?->number ?? '').' deaktivieren')
->modalDescription('Die Fassung bleibt hier einsehbar. Sie wird nicht mehr ausgeliefert und kann nicht in eine neue Übung oder einen neuen Kurs übernommen werden.') ->modalDescription('Die Fassung bleibt hier einsehbar. Sie wird nicht mehr ausgeliefert und kann nicht in eine neue Übung oder einen neuen Kurs übernommen werden.')
->modalSubmitActionLabel('Deaktivieren') ->modalSubmitActionLabel('Deaktivieren')
->visible(fn (): bool => ContentElementResource::editor()) ->visible(fn (): bool => ContentElementResource::editor())
@@ -312,49 +399,141 @@ public function deactivateAction(): Action
protected function getHeaderActions(): array protected function getHeaderActions(): array
{ {
return [ return [];
Action::make('releaseVersion') }
->label('Fassung freigeben')
->modalHeading('Fassung freigeben') public function releaseVersionAction(): Action
->modalDescription('Diese Fassung wird freigegeben. Sie erscheint dadurch nicht in der Mitgliederbibliothek, nicht auf der Website und nicht in einem Angebot. Eine deaktivierte Fassung bleibt unverändert.') {
->modalSubmitActionLabel('Freigeben') return Action::make('releaseVersion')
->visible(function (): bool { ->label('Fassung freigeben')
->modalHeading(function (array $arguments): string {
$versionId = (int) ($arguments['version'] ?? 0);
$version = $versionId > 0
? $this->ownedVersion($versionId)
: $this->getRecord()->versions()->where('status', ContentVersionStatus::Entwurf)->orderByDesc('number')->first();
return $version instanceof ContentElementVersion ? 'Fassung '.$version->number.' freigeben' : 'Fassung freigeben';
})
->modalDescription('Diese Fassung wird freigegeben. Sie erscheint dadurch nicht in der Mitgliederbibliothek, nicht auf der Website und nicht in einem Angebot. Eine deaktivierte Fassung bleibt unverändert.')
->modalSubmitActionLabel('Freigeben')
->visible(function (): bool {
/** @var ContentElement $element */
$element = $this->getRecord();
return ContentElementResource::editor()
&& $element->versions()->where('status', ContentVersionStatus::Entwurf)->exists();
})
->action(function (array $arguments): void {
abort_unless(ContentElementResource::editor(), 403);
$this->report(function () use ($arguments): string {
/** @var ContentElement $element */
$element = $this->getRecord();
$versionId = (int) ($arguments['version'] ?? 0);
$version = $versionId > 0
? $this->ownedVersion($versionId)
: $element->versions()->where('status', ContentVersionStatus::Entwurf)->orderByDesc('number')->first();
abort_unless($version instanceof ContentElementVersion, 404);
$released = app(ContentService::class)->releaseElementVersion($version);
return 'Fassung '.$released->number.' ist freigegeben.';
}, 'Die Fassung ist freigegeben.');
$this->getRecord()->unsetRelation('versions');
});
}
public function reviseAction(): Action
{
return Action::make('revise')
->label('Neue Fassung anlegen')
->modalHeading('Neue Fassung anlegen')
->modalDescription('Für eine neue Datei oder einen geänderten Lehrtext. Die bisherigen Fassungen bleiben unverändert. Redaktion, Vorschaubild und Website-Angaben gehören nicht zur Fassung.')
->modalSubmitActionLabel('Fassung anlegen')
->visible(fn (): bool => ContentElementResource::editor())
->schema(fn (): array => ElementRevision::fields($this->getRecord()))
->action(function (array $data): void {
// Vor dem Anlegen prüfen: danach gäbe es eine andere neueste Fassung.
$textOffen = $this->textUnsaved();
$this->report(function () use ($data): string {
/** @var ContentElement $element */ /** @var ContentElement $element */
$element = $this->getRecord(); $element = $this->getRecord();
return ContentElementResource::editor() return ElementRevision::publish($element, $data);
&& $element->versions()->where('status', ContentVersionStatus::Entwurf)->exists(); }, 'Die neue Fassung ist angelegt.');
}) $this->getRecord()->unsetRelation('versions');
->action(function (array $arguments): void {
abort_unless(ContentElementResource::editor(), 403);
$this->report(function () use ($arguments): string {
/** @var ContentElement $element */
$element = $this->getRecord();
$versionId = (int) ($arguments['version'] ?? 0);
$version = $versionId > 0
? $this->ownedVersion($versionId)
: $element->versions()->where('status', ContentVersionStatus::Entwurf)->orderByDesc('number')->first();
abort_unless($version instanceof ContentElementVersion, 404);
$released = app(ContentService::class)->releaseElementVersion($version);
return 'Fassung '.$released->number.' ist freigegeben.'; // Die neue Fassung wird gezeigt, sofern dabei kein offener Text verloren geht.
}, 'Die Fassung ist freigegeben.'); if (! $textOffen) {
$this->getRecord()->unsetRelation('versions'); $neueste = $this->getRecord()->versions()->orderByDesc('number')->value('id');
}), $this->fassung = $neueste !== null ? (int) $neueste : $this->fassung;
Action::make('revise') $this->fassungFeedback = '';
->label('Neue Fassung anlegen') $this->syncBodyDraft();
->visible(fn (): bool => ContentElementResource::editor()) }
->schema(fn (): array => ElementRevision::fields($this->getRecord())) });
->action(function (array $data): void { }
$this->report(function () use ($data): string {
/** @var ContentElement $element */
$element = $this->getRecord();
return ElementRevision::publish($element, $data); /**
}, 'Die neue Fassung ist angelegt.'); * Löschen bleibt Medien ohne Fassung vorbehalten. Bisher nur im separaten Formular, jetzt unter „Weitere Aktionen“.
$this->getRecord()->unsetRelation('versions'); */
}), public function deleteAction(): Action
]; {
return Action::make('delete')
->label('Medium löschen')
->color('danger')
->requiresConfirmation()
->modalHeading('Medium löschen')
->modalDescription('Das Medium hat keine Fassung und wird endgültig gelöscht. Zuordnungen als Präsentationsmedium entfallen.')
->modalSubmitActionLabel('Löschen')
->visible(fn (): bool => ContentElementResource::editor() && $this->getRecord()->versions()->doesntExist())
->action(function (): void {
abort_unless(ContentElementResource::editor() && $this->getRecord()->versions()->doesntExist(), 403);
$this->getRecord()->delete();
$this->redirect(ContentElementResource::getUrl('index'));
});
}
public function openThumbnailPicker(): void
{
abort_unless(ContentElementResource::editor(), 403);
$this->resetPicker('vorschaubild');
$this->pickerKind = 'bild';
}
protected function adoptThumbnailFromPicker(string $target): void
{
$this->pickerSelected = $target;
$this->adoptLibraryImage();
$this->pickerSelected = '';
}
/**
* @return array{aktion: string, argument: int|string|null, titel: string, text: string, label: string, gefahr: bool}|null
*/
protected function extraConfirmation(string $aktion, int|string|null $argument): ?array
{
$gezeigt = $this->shownVersion();
return match ($aktion) {
'withdrawWebsite' => ['aktion' => $aktion, 'argument' => null, 'titel' => 'Website-Freigabe zurücknehmen?', 'text' => 'Das Medium verschwindet sofort von allen öffentlichen Seiten. Zuordnungen und Fassungen bleiben erhalten.', 'label' => 'Freigabe zurücknehmen', 'gefahr' => true],
'showVersion' => ['aktion' => $aktion, 'argument' => $argument, 'titel' => 'Ungespeicherten Text verwerfen?', 'text' => 'Der geänderte Text von Fassung '.($gezeigt?->number ?? '').' ist noch nicht gespeichert und geht beim Wechsel verloren. Gespeicherte Fassungen bleiben unverändert.', 'label' => 'Verwerfen und wechseln', 'gefahr' => true],
default => null,
};
}
protected function runExtraConfirmation(string $aktion, int|string|null $argument): void
{
match ($aktion) {
'withdrawWebsite' => $this->withdrawWebsite(),
'showVersion' => $this->ownedVersion((int) $argument) instanceof ContentElementVersion ? $this->selectVersion((int) $argument) : null,
default => null,
};
}
public function hasDraftVersion(): bool
{
/** @var ContentElement $element */
$element = $this->getRecord();
return $element->versions()->where('status', ContentVersionStatus::Entwurf)->exists();
} }
/** /**
@@ -445,7 +624,15 @@ private function ownedVersion(int $id): ?ContentElementVersion
return $element->versions()->whereKey($id)->first(); return $element->versions()->whereKey($id)->first();
} }
/**
* Speichert die Redaktion: Texte, Einordnung, Präsentationsmedien und Abweichungen. Datei und Fassungen bleiben.
*/
public function saveEditorial(): void public function saveEditorial(): void
{
$this->saveRedaktion();
}
protected function saveRedaktionTexte(): bool
{ {
abort_unless(ContentElementResource::editor(), 403); abort_unless(ContentElementResource::editor(), 403);
@@ -454,12 +641,26 @@ public function saveEditorial(): void
$title = trim($this->workingTitle); $title = trim($this->workingTitle);
if ($title === '') { if ($title === '') {
$this->editorialFeedback = 'Der Arbeitstitel fehlt.'; $this->deskFeedback = 'Der Arbeitstitel fehlt. Er bezeichnet das Medium in der Verwaltung.';
$this->redaktionFehlerFeld = 'workingTitle';
return; return false;
} }
$versions = $element->versions()->count(); $kindError = app(EditorialVocabulary::class)->kindError(
'medium',
filled($this->kindId) ? (int) $this->kindId : null,
$element->editorial_content_kind_id !== null ? (int) $element->editorial_content_kind_id : null,
);
if ($kindError !== null) {
$this->deskFeedback = $kindError;
$this->redaktionFehlerFeld = 'kindId';
return false;
}
$this->versionsBeforeSave = $element->versions()->count();
app(IdentityProfile::class)->fill($element, [ app(IdentityProfile::class)->fill($element, [
'working_title' => $title, 'working_title' => $title,
'display_title' => $this->displayTitle, 'display_title' => $this->displayTitle,
@@ -471,7 +672,6 @@ public function saveEditorial(): void
'license_note' => $this->licenseNote, 'license_note' => $this->licenseNote,
'website_credit' => $this->websiteCredit, 'website_credit' => $this->websiteCredit,
'website_alt' => $this->websiteAlt, 'website_alt' => $this->websiteAlt,
'thumbnail_alt' => $this->thumbnailAlt,
'editorial_content_kind_id' => filled($this->kindId) ? (int) $this->kindId : null, 'editorial_content_kind_id' => filled($this->kindId) ? (int) $this->kindId : null,
], auth()->user()); ], auth()->user());
app(PillarService::class)->assign($element, array_map(intval(...), $this->pillarIds)); app(PillarService::class)->assign($element, array_map(intval(...), $this->pillarIds));
@@ -479,25 +679,169 @@ public function saveEditorial(): void
$element->refresh(); $element->refresh();
$this->fillEditorial(); $this->fillEditorial();
$this->editorialFeedback = $element->versions()->count() === $versions
? 'Gespeichert. Es gibt keine neue Fassung.' return true;
: 'Gespeichert. Prüfe die Fassungen, ihre Zahl hat sich geändert.';
} }
protected function redaktionSavedMessage(): string
{
/** @var ContentElement $element */
$element = $this->getRecord();
$this->editorialFeedback = $element->versions()->count() === $this->versionsBeforeSave
? 'Gespeichert. Es gibt keine neue Fassung.'
: 'Gespeichert. Prüfe die Fassungen, ihre Zahl hat sich geändert.';
return $this->editorialFeedback.' Datei, Inhaltsfassung und Website-Freigabe bleiben unverändert.';
}
protected function resetRedaktionTexte(): void
{
$this->fillEditorial();
}
public function einordnungUnsaved(): bool
{
/** @var ContentElement $element */
$element = $this->getRecord()->fresh() ?? $this->getRecord();
$kind = filled($this->kindId) ? (int) $this->kindId : null;
$storedKind = $element->editorial_content_kind_id !== null ? (int) $element->editorial_content_kind_id : null;
if ($kind !== $storedKind) {
return true;
}
$pillars = $element->pillars()->pluck('pillars.id')->map(fn ($id): int => (int) $id)->all();
$currentPillars = array_map(intval(...), $this->pillarIds);
sort($pillars);
sort($currentPillars);
if ($pillars !== $currentPillars) {
return true;
}
$stored = IdentityDimensionValue::query()
->where('subject_type', $element->getMorphClass())
->where('subject_id', $element->getKey())
->where('origin', 'direkt')
->pluck('editorial_dimension_value_id')
->map(fn ($id): int => (int) $id)
->all();
$current = array_map(intval(...), $this->dimensionIds);
sort($stored);
sort($current);
return $stored !== $current;
}
/**
* @return array{art: string, fuer: string, liste: string, zurueck: string, typ: ?string, umfang: string}
*/
public function redaktionKopf(): array
{
/** @var ContentElement $element */
$element = $this->getRecord();
return [
'art' => 'Medium',
'fuer' => 'das Medium',
'liste' => 'Medien',
'zurueck' => 'Zurück zur Medienbearbeitung',
'typ' => $element->editorialContentKind?->label ?? PublicMaterialReader::outputLabel((string) $element->output_class),
'umfang' => '„Redaktion speichern“ sichert Texte, Präsentationsmedien und Einordnung dieses Mediums. Verwendende Ansichten übernehmen die Angaben. Datei, Inhaltsfassung und Website-Freigabe bleiben unverändert.',
];
}
public function redaktionTitel(): string
{
$title = trim($this->displayTitle) !== '' ? trim($this->displayTitle) : trim($this->workingTitle);
return $title !== '' ? $title : (string) $this->getRecord()->working_title;
}
/**
* @return list<array<string, mixed>>
*/
public function redaktionFelder(): array
{
/** @var ContentElement $element */
$element = $this->getRecord();
$stored = fn (string $column): string => (string) ($element->getAttribute($column) ?? '');
return [
['id' => 'arbeitstitel', 'label' => 'Arbeitstitel', 'model' => 'workingTitle', 'kind' => 'text', 'stored' => $stored('working_title'), 'required' => true, 'hilfe' => 'Bezeichnung in der Verwaltung. Pflichtangabe.'],
['id' => 'anzeigename', 'label' => 'Anzeigename', 'model' => 'displayTitle', 'kind' => 'text', 'stored' => $stored('display_title'), 'hilfe' => 'Erscheint auf Karten und in der Bibliothek. Leer zeigt den Arbeitstitel.'],
['id' => 'teaser', 'label' => 'Teaser', 'model' => 'teaser', 'kind' => 'textarea', 'rows' => 2, 'stored' => $stored('teaser')],
['id' => 'kurz', 'label' => 'Kurzbeschreibung', 'model' => 'summary', 'kind' => 'textarea', 'rows' => 3, 'stored' => $stored('summary'), 'hilfe' => 'Erscheint auf Website- und Bibliothekskarten.'],
['id' => 'beschreibung', 'label' => 'Ausführliche Beschreibung', 'model' => 'descriptionText', 'kind' => 'textarea', 'rows' => 8, 'stored' => $stored('description'), 'hilfe' => 'Bleibt in der Verwaltung und in Detailansichten. Kein Lehrtext.'],
['id' => 'suche', 'label' => 'Suchbegriffe', 'model' => 'searchTerms', 'kind' => 'text', 'gruppe' => 'weitere', 'stored' => $stored('search_terms'), 'placeholder' => 'Begriffe, durch Komma getrennt'],
['id' => 'einsatz', 'label' => 'Hinweise für den Einsatz', 'model' => 'usageNote', 'kind' => 'textarea', 'rows' => 3, 'gruppe' => 'weitere', 'stored' => $stored('usage_note')],
['id' => 'lizenz', 'label' => 'Interner Lizenzvermerk', 'model' => 'licenseNote', 'kind' => 'textarea', 'rows' => 3, 'gruppe' => 'weitere', 'stored' => $stored('license_note'), 'hilfe' => 'Nur intern sichtbar.'],
['id' => 'quelle', 'label' => 'Quellenzeile für die Website', 'model' => 'websiteCredit', 'kind' => 'textarea', 'rows' => 2, 'gruppe' => 'weitere', 'stored' => $stored('website_credit')],
['id' => 'alt', 'label' => 'Alternativtext für die Website', 'model' => 'websiteAlt', 'kind' => 'text', 'gruppe' => 'weitere', 'stored' => $stored('website_alt'), 'hilfe' => 'Beschreibt das Bild für Menschen, die es nicht sehen.'],
];
}
/**
* @return array{model: string, options: array<int|string, string>, hilfe: string}
*/
public function einordnungArt(): array
{
return [
'model' => 'kindId',
'options' => app(EditorialVocabulary::class)->kindOptions('medium', $this->getRecord()->editorial_content_kind_id !== null ? (int) $this->getRecord()->editorial_content_kind_id : null),
'hilfe' => 'Fachliche Materialart, unabhängig von der technischen Medienart.',
];
}
/**
* @return list<array{legend: string, model: string, values: list<array{id: int, label: string}>}>
*/
public function einordnungGruppen(): array
{
$groups = [[
'legend' => 'Fachliche Säulen',
'model' => 'pillarIds',
'values' => Pillar::query()->orderBy('name')->get(['id', 'name'])
->map(fn (Pillar $pillar): array => ['id' => (int) $pillar->id, 'label' => (string) $pillar->name])->all(),
]];
foreach (app(EditorialVocabulary::class)->dimensionGroups($this->getRecord(), IdentityDimensionValue::query()
->where('subject_type', $this->getRecord()->getMorphClass())
->where('subject_id', $this->getRecord()->getKey())
->pluck('editorial_dimension_value_id')->map(fn ($id): int => (int) $id)->all()) as $dimension) {
$groups[] = [
'legend' => $dimension['label'],
'model' => 'dimensionIds',
'values' => $dimension['values'],
];
}
return array_values(array_filter($groups, fn (array $group): bool => $group['values'] !== []));
}
/**
* @return array{view: string, stand: string}
*/
public function redaktionAusgabe(): ?array
{
return [
'view' => 'filament.media.preview-frame',
'stand' => 'Arbeitstitel, Anzeigename und Kurzbeschreibung zeigen deine aktuellen Eingaben, auch ungespeicherte. Bild und übrige Angaben zeigen den gespeicherten Stand.',
];
}
/**
* Gibt das Medium für die Website frei. Quellenzeile und Alternativtext gelten im gespeicherten Stand der Redaktion;
* offene Eingaben in der Redaktion werden dabei weder gespeichert noch zurückgesetzt.
*/
public function releaseForWebsite(): void public function releaseForWebsite(): void
{ {
abort_unless(ContentElementResource::editor(), 403); abort_unless(ContentElementResource::editor(), 403);
/** @var ContentElement $element */ /** @var ContentElement $element */
$element = $this->getRecord(); $element = $this->getRecord();
app(IdentityProfile::class)->fill($element, [
'website_credit' => $this->websiteCredit,
'website_alt' => $this->websiteAlt,
], auth()->user());
$element->refresh();
$this->websiteFeedback = app(WebsiteRelease::class)->release($element, auth()->user()); $this->websiteFeedback = app(WebsiteRelease::class)->release($element, auth()->user());
$element->refresh(); $element->refresh();
$this->fillEditorial();
} }
public function withdrawWebsite(): void public function withdrawWebsite(): void
@@ -508,7 +852,18 @@ public function withdrawWebsite(): void
$element = $this->getRecord(); $element = $this->getRecord();
$this->websiteFeedback = app(WebsiteRelease::class)->withdraw($element, auth()->user()); $this->websiteFeedback = app(WebsiteRelease::class)->withdraw($element, auth()->user());
$element->refresh(); $element->refresh();
$this->fillEditorial(); }
public function saveThumbnailAlt(): void
{
abort_unless(ContentElementResource::editor(), 403);
/** @var ContentElement $element */
$element = $this->getRecord();
app(IdentityProfile::class)->fill($element, ['thumbnail_alt' => trim($this->thumbnailAlt)], auth()->user());
$element->refresh();
$this->thumbnailAlt = (string) ($element->thumbnail_alt ?? '');
$this->pictureFeedback = 'Der Alternativtext des Vorschaubilds ist gespeichert. Die Fassung bleibt unverändert.';
} }
/** /**
@@ -674,7 +1029,7 @@ public function editorialHistory(): array
'thumbnail_alt' => 'Alternativtext', 'thumbnail_alt' => 'Alternativtext',
'thumbnail_path' => 'Vorschaubild', 'thumbnail_path' => 'Vorschaubild',
'thumbnail_source' => 'Herkunft des Vorschaubilds', 'thumbnail_source' => 'Herkunft des Vorschaubilds',
'editorial_content_kind_id' => 'Inhaltsart', 'editorial_content_kind_id' => 'Fachliche Materialart',
]; ];
return IdentityChange::query() return IdentityChange::query()
@@ -9,9 +9,7 @@
use App\Filament\Support\CatalogReading; use App\Filament\Support\CatalogReading;
use App\Models\User; use App\Models\User;
use Filament\Facades\Filament; use Filament\Facades\Filament;
use Filament\Infolists\Components\TextEntry;
use Filament\Resources\Resource; use Filament\Resources\Resource;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Components\View; use Filament\Schemas\Components\View;
use Filament\Schemas\Schema; use Filament\Schemas\Schema;
use Filament\Tables\Columns\TextColumn; use Filament\Tables\Columns\TextColumn;
@@ -54,16 +52,13 @@ public static function getViewAuthorizationResponse(Model $record): Response
public static function infolist(Schema $schema): Schema public static function infolist(Schema $schema): Schema
{ {
return $schema->components([ return $schema->columns(1)->components([
Section::make('Aktueller Stand')->schema([ View::make('filament.editorial.license-desk')
TextEntry::make('stand')->hiddenLabel()->listWithLineBreaks() ->viewData(fn (LicenseArticle $record): array => [
->state(fn (LicenseArticle $record): array => app(CatalogReading::class)->articleStand($record)), 'stand' => app(CatalogReading::class)->articleStand($record),
]), 'kontext' => app(CatalogReading::class)->articleContext($record),
Section::make('Pakete und Angebote')->description('Wo dieser Artikel lizenziert wird.')->schema([ ])
TextEntry::make('context')->hiddenLabel()->listWithLineBreaks() ->columnSpanFull(),
->state(fn (LicenseArticle $record): array => app(CatalogReading::class)->articleContext($record)),
]),
View::make('filament.editorial.license-desk'),
]); ]);
} }
@@ -3,15 +3,24 @@
namespace App\Filament\Resources\LicenseArticles\Pages; namespace App\Filament\Resources\LicenseArticles\Pages;
use App\Domain\Catalog\ArticleService; use App\Domain\Catalog\ArticleService;
use App\Domain\Catalog\ContentElement;
use App\Domain\Catalog\LicenseArticle;
use App\Domain\Catalog\PresentationMedia;
use App\Domain\Catalog\ReleaseStatus;
use App\Domain\Catalog\StatusValue;
use App\Domain\Media\ThumbnailRef;
use App\Filament\Resources\LicenseArticles\LicenseArticleResource; use App\Filament\Resources\LicenseArticles\LicenseArticleResource;
use App\Filament\Support\ListsCatalog;
use App\Filament\Support\ReportsDomainRules; use App\Filament\Support\ReportsDomainRules;
use Filament\Actions\Action; use Filament\Actions\Action;
use Filament\Forms\Components\TextInput; use Filament\Forms\Components\TextInput;
use Filament\Resources\Pages\ListRecords; use Filament\Resources\Pages\ListRecords;
use Illuminate\Contracts\Support\Htmlable; use Illuminate\Contracts\Support\Htmlable;
use Illuminate\Support\Facades\DB;
class ListLicenseArticles extends ListRecords class ListLicenseArticles extends ListRecords
{ {
use ListsCatalog;
use ReportsDomainRules; use ReportsDomainRules;
protected static string $resource = LicenseArticleResource::class; protected static string $resource = LicenseArticleResource::class;
@@ -26,15 +35,118 @@ protected function getHeaderActions(): array
return [ return [
Action::make('create') Action::make('create')
->label('Artikel anlegen') ->label('Artikel anlegen')
->modalHeading('Neuer Lizenzartikel')
->modalDescription('Kennung und Produktlinie genügen. Titel, Texte und Stand pflegst du danach am Artikel.')
->modalSubmitActionLabel('Artikel anlegen')
->schema([ ->schema([
TextInput::make('code')->label('Kennung')->required(), TextInput::make('code')->label('Kennung')->required(),
TextInput::make('product_line')->label('Produktlinie'), TextInput::make('product_line')->label('Produktlinie'),
]) ])
->action(function (array $data): void { ->action(function (array $data): void {
$this->report(function () use ($data): void { $article = null;
app(ArticleService::class)->create($data['code'], $data['product_line'] ?? null); $this->report(function () use ($data, &$article): void {
$article = app(ArticleService::class)->create($data['code'], $data['product_line'] ?? null);
}, 'Der Lizenzartikel ist angelegt.'); }, 'Der Lizenzartikel ist angelegt.');
if ($article instanceof LicenseArticle) {
$this->redirect(LicenseArticleResource::getUrl('view', ['record' => $article]));
}
}), }),
]; ];
} }
protected function catalogRows(): array
{
$offered = DB::table('resolved_scopes')
->join('offer_versions', 'offer_versions.id', '=', 'resolved_scopes.offer_version_id')
->where('offer_versions.status', 'aktiv')
->distinct()
->pluck('resolved_scopes.license_article_id')
->map(fn (mixed $id): int => (int) $id)
->all();
$presentation = app(PresentationMedia::class);
$rows = [];
foreach (LicenseArticle::query()->with(['currentRelease', 'releases'])->orderBy('code')->get() as $article) {
$current = $article->currentRelease;
$currentStatus = $current !== null ? StatusValue::of($current->status) : null;
$draft = $article->releases->first(fn ($release): bool => StatusValue::of($release->status) === ReleaseStatus::Entwurf->value);
$chips = [];
$zustand = [];
if ($current === null) {
$chips[] = ['label' => 'Noch kein Stand', 'ton' => 'offen'];
$zustand[] = 'ohne';
} elseif ($currentStatus === ReleaseStatus::Gesperrt->value) {
$chips[] = ['label' => 'Stand '.$current->number.' gesperrt', 'ton' => 'achtung'];
$zustand[] = 'gesperrt';
} else {
$chips[] = ['label' => 'Stand '.$current->number.' veröffentlicht', 'ton' => 'gut'];
$zustand[] = 'stand';
}
if ($draft !== null) {
$chips[] = ['label' => 'Stand '.$draft->number.' in Arbeit', 'ton' => 'offen'];
$zustand[] = 'entwurf';
}
$inOffer = in_array($article->id, $offered, true);
$chips[] = $inOffer ? ['label' => 'In einem aktiven Angebot', 'ton' => 'gut'] : ['label' => 'In keinem aktiven Angebot', 'ton' => 'leise'];
$zustand[] = $inOffer ? 'angebot' : 'ohne-angebot';
if ($article->archived_at !== null) {
$chips[] = ['label' => 'Archiviert', 'ton' => 'leise'];
$zustand[] = 'archiviert';
}
$coverId = $presentation->coverElementId($article);
$cover = $coverId !== null ? ContentElement::query()->find($coverId) : null;
$title = trim((string) ($article->display_title ?: $article->working_title)) ?: $article->code;
$url = LicenseArticleResource::getUrl('view', ['record' => $article]);
$rows[] = [
'schluessel' => 'a'.$article->id,
'titel' => $title,
'meta' => 'Lizenzartikel · '.$article->code.(filled($article->product_line) ? ' · '.$article->product_line : ''),
'text' => trim((string) ($article->teaser ?: $article->summary)),
'bild' => $cover !== null ? ThumbnailRef::url('editorial.card', 'element', $cover->id, $cover->thumbnail_path) : null,
'symbol' => 'dokument',
'url' => $url,
'chips' => $chips,
'zustand' => $zustand,
'suchtext' => implode(' ', array_filter([$article->code, $article->working_title, $article->display_title, $article->summary, $article->product_line, $article->search_terms])),
'aktionen' => [['label' => 'Öffnen', 'href' => $url]],
];
}
return $rows;
}
protected function zustandOptionen(): array
{
return [
'alle' => 'Jeder Zustand',
'stand' => 'Mit veröffentlichtem Stand',
'ohne' => 'Noch ohne Stand',
'entwurf' => 'Stand in Arbeit',
'gesperrt' => 'Gesperrter Stand',
'angebot' => 'In einem aktiven Angebot',
'ohne-angebot' => 'In keinem aktiven Angebot',
'archiviert' => 'Archiviert',
];
}
protected function einheit(): array
{
return ['Lizenzartikel', 'Lizenzartikel'];
}
protected function leer(): array
{
return ['titel' => 'Noch keine Lizenzartikel', 'text' => 'Mit „Artikel anlegen“ oben entsteht der erste Artikel.'];
}
protected function suchPlatzhalter(): string
{
return 'Kennung, Titel oder Produktlinie';
}
} }
@@ -3,15 +3,22 @@
namespace App\Filament\Resources\LicenseArticles\Pages; namespace App\Filament\Resources\LicenseArticles\Pages;
use App\Domain\Catalog\ArticleService; use App\Domain\Catalog\ArticleService;
use App\Domain\Catalog\Composition;
use App\Domain\Catalog\CompositionKind;
use App\Domain\Catalog\CompositionVersion; use App\Domain\Catalog\CompositionVersion;
use App\Domain\Catalog\ContentElement;
use App\Domain\Catalog\ContentElementVersion; use App\Domain\Catalog\ContentElementVersion;
use App\Domain\Catalog\EditorialDimension; use App\Domain\Catalog\EditorialProfileReader;
use App\Domain\Catalog\EditorialVocabulary;
use App\Domain\Catalog\IdentityDimension; use App\Domain\Catalog\IdentityDimension;
use App\Domain\Catalog\IdentityDimensionValue; use App\Domain\Catalog\IdentityDimensionValue;
use App\Domain\Catalog\IdentityProfile; use App\Domain\Catalog\IdentityProfile;
use App\Domain\Catalog\LicenseArticle; use App\Domain\Catalog\LicenseArticle;
use App\Filament\Resources\ContentElements\ContentElementResource;
use App\Filament\Resources\LicenseArticles\LicenseArticleResource; use App\Filament\Resources\LicenseArticles\LicenseArticleResource;
use App\Filament\Support\AssignsPillars;
use App\Filament\Support\CatalogOptions; use App\Filament\Support\CatalogOptions;
use App\Filament\Support\EditorialCatalog;
use App\Filament\Support\ManagesEditorialSurface; use App\Filament\Support\ManagesEditorialSurface;
use App\Filament\Support\ReportsDomainRules; use App\Filament\Support\ReportsDomainRules;
use Filament\Actions\Action; use Filament\Actions\Action;
@@ -19,9 +26,12 @@
use Filament\Forms\Components\Textarea; use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput; use Filament\Forms\Components\TextInput;
use Filament\Resources\Pages\ViewRecord; use Filament\Resources\Pages\ViewRecord;
use Illuminate\Contracts\Support\Htmlable;
use Illuminate\Database\Eloquent\Model;
class ViewLicenseArticle extends ViewRecord class ViewLicenseArticle extends ViewRecord
{ {
use AssignsPillars;
use ManagesEditorialSurface; use ManagesEditorialSurface;
use ReportsDomainRules; use ReportsDomainRules;
@@ -41,6 +51,10 @@ class ViewLicenseArticle extends ViewRecord
public int|string|null $kindId = null; public int|string|null $kindId = null;
public ?int $releaseBeforeSave = null;
public int $releaseCountBeforeSave = 0;
/** @var list<int|string> */ /** @var list<int|string> */
public array $dimensionIds = []; public array $dimensionIds = [];
@@ -55,14 +69,42 @@ public function canEditEditorial(): bool
return LicenseArticleResource::keeper(); return LicenseArticleResource::keeper();
} }
public function canViewEditorial(): bool
{
return LicenseArticleResource::keeper();
}
public function getTitle(): string|Htmlable
{
return $this->redaktionTitel();
}
public function saveLicenseEditorial(): void public function saveLicenseEditorial(): void
{
$this->saveRedaktion();
}
protected function saveRedaktionTexte(): bool
{ {
$this->guardEditorial(); $this->guardEditorial();
/** @var LicenseArticle $article */ /** @var LicenseArticle $article */
$article = $this->getRecord(); $article = $this->getRecord();
$releaseId = $article->current_release_id; $this->releaseBeforeSave = $article->current_release_id;
$releases = $article->releases()->count(); $this->releaseCountBeforeSave = $article->releases()->count();
$kindError = app(EditorialVocabulary::class)->kindError(
'lizenzartikel',
filled($this->kindId) ? (int) $this->kindId : null,
$article->editorial_content_kind_id !== null ? (int) $article->editorial_content_kind_id : null,
);
if ($kindError !== null) {
$this->deskFeedback = $kindError;
$this->redaktionFehlerFeld = 'kindId';
return false;
}
app(IdentityProfile::class)->fill($article, [ app(IdentityProfile::class)->fill($article, [
'working_title' => $this->workingTitle, 'working_title' => $this->workingTitle,
@@ -75,34 +117,189 @@ public function saveLicenseEditorial(): void
], auth()->user()); ], auth()->user());
app(IdentityDimension::class)->replaceOffered($article, array_map(intval(...), $this->dimensionIds)); app(IdentityDimension::class)->replaceOffered($article, array_map(intval(...), $this->dimensionIds));
$this->persistPillarIds($article);
$article->refresh(); $article->refresh();
$this->fillLicenseEditorial(); $this->fillLicenseEditorial();
$this->deskFeedback = $article->current_release_id === $releaseId && $article->releases()->count() === $releases
return true;
}
protected function redaktionSavedMessage(): string
{
/** @var LicenseArticle $article */
$article = $this->getRecord();
return $article->current_release_id === $this->releaseBeforeSave && $article->releases()->count() === $this->releaseCountBeforeSave
? 'Gespeichert. Stand, Preis und Rechte bleiben unverändert.' ? 'Gespeichert. Stand, Preis und Rechte bleiben unverändert.'
: 'Gespeichert. Prüfe den Artikelstand, er hat sich geändert.'; : 'Gespeichert. Prüfe den Artikelstand, er hat sich geändert.';
} }
protected function resetRedaktionTexte(): void
{
$this->fillLicenseEditorial();
}
public function einordnungUnsaved(): bool
{
/** @var LicenseArticle $article */
$article = $this->getRecord()->fresh() ?? $this->getRecord();
$kind = filled($this->kindId) ? (int) $this->kindId : null;
$storedKind = $article->editorial_content_kind_id !== null ? (int) $article->editorial_content_kind_id : null;
if ($kind !== $storedKind) {
return true;
}
$stored = IdentityDimensionValue::query()
->where('subject_type', $article->getMorphClass())
->where('subject_id', $article->getKey())
->where('origin', 'direkt')
->pluck('editorial_dimension_value_id')
->map(fn ($id): int => (int) $id)
->all();
$current = array_map(intval(...), $this->dimensionIds);
sort($stored);
sort($current);
return $stored !== $current || $this->pillarsUnsaved($article);
}
/**
* @return array{art: string, fuer: string, liste: string, zurueck: string, typ: ?string, umfang: string}
*/
public function redaktionKopf(): array
{
return [
'art' => 'Lizenzartikel',
'fuer' => 'den Lizenzartikel',
'liste' => 'Lizenzartikel',
'zurueck' => 'Zurück zum Lizenzartikel',
'typ' => null,
'umfang' => '„Redaktion speichern“ sichert die eigenen Texte, Präsentationsmedien und Einordnung dieses Lizenzartikels. Leere Angaben übernehmen weiter die fachliche Quelle. Stand, Preis und Rechte bleiben unverändert.',
];
}
public function redaktionTitel(): string
{
foreach ([$this->displayTitle, $this->workingTitle] as $title) {
if (trim($title) !== '') {
return trim($title);
}
}
$profile = $this->editorialProfile('artikel');
if ($profile->value('display_title') !== null) {
return (string) $profile->value('display_title');
}
$source = $profile->source;
return $source !== null ? $this->sourceTitle($source) : (string) $this->getRecord()->code;
}
/**
* @return list<array<string, mixed>>
*/
public function redaktionFelder(): array
{
/** @var LicenseArticle $article */
$article = $this->getRecord();
$source = app(EditorialProfileReader::class)->sourceOf($article);
$sourceTitle = $source !== null ? $this->sourceTitle($source) : null;
$stored = fn (string $column): string => (string) ($article->getAttribute($column) ?? '');
$quelle = fn (string $column): ?array => $sourceTitle === null ? null : [
'titel' => $sourceTitle,
'wert' => (string) ($source->getAttribute($column) ?? ''),
];
return [
['id' => 'arbeitstitel', 'label' => 'Interner Arbeitstitel', 'model' => 'workingTitle', 'kind' => 'text', 'stored' => $stored('working_title'), 'hilfe' => 'Nur in der Verwaltung sichtbar.'],
['id' => 'anzeigename', 'label' => 'Name', 'model' => 'displayTitle', 'kind' => 'text', 'stored' => $stored('display_title'), 'quelle' => $quelle('display_title')],
['id' => 'teaser', 'label' => 'Teaser', 'model' => 'teaser', 'kind' => 'textarea', 'rows' => 2, 'stored' => $stored('teaser'), 'quelle' => $quelle('teaser')],
['id' => 'kurz', 'label' => 'Kurzbeschreibung', 'model' => 'summary', 'kind' => 'textarea', 'rows' => 4, 'stored' => $stored('summary'), 'quelle' => $quelle('summary')],
['id' => 'beschreibung', 'label' => 'Beschreibung', 'model' => 'descriptionText', 'kind' => 'textarea', 'rows' => 6, 'stored' => $stored('description'), 'quelle' => $quelle('description')],
['id' => 'suche', 'label' => 'Suchbegriffe', 'model' => 'searchTerms', 'kind' => 'text', 'gruppe' => 'weitere', 'stored' => $stored('search_terms'), 'quelle' => $quelle('search_terms')],
];
}
/**
* @return array{titel: string, art: string, fuer: string, url: ?string}|null
*/
public function redaktionQuelle(): ?array
{
/** @var LicenseArticle $article */
$article = $this->getRecord();
$source = app(EditorialProfileReader::class)->sourceOf($article);
if ($source === null) {
return null;
}
$url = match (true) {
$source instanceof Composition => EditorialCatalog::editUrl($source),
$source instanceof ContentElement => ContentElementResource::getUrl('view', ['record' => $source]),
default => null,
};
return [
'titel' => $this->sourceTitle($source),
'art' => $source instanceof ContentElement ? 'Medium' : ($source instanceof Composition && $source->kind === CompositionKind::Kurs ? 'Programm' : 'Modul'),
'fuer' => 'diesen Lizenzartikel',
'url' => $url,
];
}
public function redaktionOhneQuelle(): string
{
return 'Keine eindeutige fachliche Quelle. Es wird nichts aus einem Modul, Programm oder Medium übernommen.';
}
/**
* @return array{model: string, options: array<int|string, string>, hilfe: string}
*/
public function einordnungArt(): array
{
return [
'model' => 'kindId',
'options' => app(EditorialVocabulary::class)->kindOptions('lizenzartikel', $this->getRecord()->editorial_content_kind_id !== null ? (int) $this->getRecord()->editorial_content_kind_id : null),
'hilfe' => 'Die Einordnung des Artikels ändert weder die Quelle noch den Preis.',
];
}
/**
* @return list<array{legend: string, model: string, values: list<array{id: int, label: string}>}>
*/
public function einordnungGruppen(): array
{
$groups = array_map(fn (array $group): array => [
'legend' => $group['label'],
'model' => 'dimensionIds',
'values' => $group['values'],
], $this->licenseDimensionGroups());
$pillars = $this->pillarGroup();
return $pillars === null ? $groups : [$pillars, ...$groups];
}
private function sourceTitle(Model $source): string
{
$title = $source->getAttribute('display_title') ?: ($source->getAttribute('working_title') ?? $source->getAttribute('designation'));
return (string) $title;
}
/** /**
* @return list<array{label: string, values: list<array{id: int, label: string}>}> * @return list<array{label: string, values: list<array{id: int, label: string}>}>
*/ */
public function licenseDimensionGroups(): array public function licenseDimensionGroups(): array
{ {
$groups = []; return app(EditorialVocabulary::class)->dimensionGroups($this->getRecord(), IdentityDimensionValue::query()
->where('subject_type', $this->getRecord()->getMorphClass())
foreach (EditorialDimension::forSubject($this->getRecord()) as $dimension) { ->where('subject_id', $this->getRecord()->getKey())
$values = []; ->pluck('editorial_dimension_value_id')->map(fn ($id): int => (int) $id)->all());
foreach ($dimension->values as $value) {
$values[] = ['id' => $value->id, 'label' => $value->label];
}
if ($values !== []) {
$groups[] = ['label' => $dimension->label, 'values' => $values];
}
}
return $groups;
} }
private function fillLicenseEditorial(): void private function fillLicenseEditorial(): void
@@ -122,60 +319,68 @@ private function fillLicenseEditorial(): void
->where('origin', 'direkt') ->where('origin', 'direkt')
->pluck('editorial_dimension_value_id') ->pluck('editorial_dimension_value_id')
->all(); ->all();
$this->loadPillarIds($article);
} }
protected function getHeaderActions(): array protected function getHeaderActions(): array
{ {
return [ 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) public function releaseAction(): Action
.', Inhaber: '.($report['holders'] ?? 0) {
.', Angebote: '.(implode(', ', $offers) !== '' ? implode(', ', $offers) : 'keins').'.'; return Action::make('release')
}, 'Der Artikel-Stand ist veröffentlicht.'); ->label('Stand veröffentlichen')
$this->refreshRecord(); ->schema([
}), Select::make('root')->label('Wurzel')->options(fn (): array => CatalogOptions::readyTargets())->required(),
Action::make('withdraw') Textarea::make('classification')->label('Einordnung')->required()
->label('Stand zurückziehen') ->helperText('Warum dies derselbe Lizenzartikel bleibt und kein neues Produkt ist.'),
->schema([ TextInput::make('change_note')->label('Änderungshinweis'),
Textarea::make('reason')->label('Begründung')->required(), ])
]) ->action(function (array $data): void {
->action(function (array $data): void { $this->report(function () use ($data): string {
$this->report(function () use ($data): string { /** @var LicenseArticle $article */
$result = app(ArticleService::class)->withdraw($this->getRecord(), $data['reason']); $article = $this->getRecord();
$current = $result['fallback_number'] === null [$type, $id] = explode(':', $data['root'], 2);
? 'Es gibt keinen früheren Stand.' $root = $type === 'composition'
: 'Aktuell ist wieder Stand '.$result['fallback_number'].'.'; ? CompositionVersion::query()->findOrFail($id)
$holders = $result['holders'] === [] ? 'niemand' : implode(', ', $result['holders']); : 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 'Der Stand ist zurückgezogen. '.$current.' Betroffen: '.$holders.'.'; return 'Stand '.$release->number.' ist veröffentlicht. Inhalte: '.($report['contents'] ?? 0)
}, 'Der Stand ist zurückgezogen.'); .', Inhaber: '.($report['holders'] ?? 0)
$this->refreshRecord(); .', Angebote: '.(implode(', ', $offers) !== '' ? implode(', ', $offers) : 'keins').'.';
}), }, 'Der Artikel-Stand ist veröffentlicht.');
]; $this->refreshRecord();
});
}
public function withdrawAction(): Action
{
return 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 private function refreshRecord(): void
@@ -28,6 +28,9 @@ class NavigationItemResource extends Resource
protected static ?string $navigationLabel = 'Navigation'; protected static ?string $navigationLabel = 'Navigation';
/** Menüs werden in der Webpräsenz bearbeitet. */
protected static bool $shouldRegisterNavigation = false;
protected static ?string $modelLabel = 'Navigationspunkt'; protected static ?string $modelLabel = 'Navigationspunkt';
protected static ?string $pluralModelLabel = 'Navigation'; protected static ?string $pluralModelLabel = 'Navigation';
@@ -2,18 +2,22 @@
namespace App\Filament\Resources\NavigationItems\Pages; namespace App\Filament\Resources\NavigationItems\Pages;
use App\Filament\Pages\Webpraesenz;
use App\Filament\Resources\NavigationItems\NavigationItemResource; use App\Filament\Resources\NavigationItems\NavigationItemResource;
use Filament\Actions\CreateAction;
use Filament\Resources\Pages\ManageRecords; use Filament\Resources\Pages\ManageRecords;
/**
* Die Menüs werden in der Webpräsenz bearbeitet (Dokument 13). Die bisherige Adresse führt dorthin, nach derselben
* Rechteprüfung wie bisher.
*/
class ManageNavigationItems extends ManageRecords class ManageNavigationItems extends ManageRecords
{ {
protected static string $resource = NavigationItemResource::class; protected static string $resource = NavigationItemResource::class;
protected function getHeaderActions(): array public function mount(): void
{ {
return [ parent::mount();
CreateAction::make(),
]; $this->redirect(Webpraesenz::getUrl(['bereich' => 'menues']));
} }
} }
@@ -2,8 +2,13 @@
namespace App\Filament\Resources\Offers\Pages; namespace App\Filament\Resources\Offers\Pages;
use App\Domain\Catalog\Offer;
use App\Domain\Catalog\OfferService; use App\Domain\Catalog\OfferService;
use App\Domain\Catalog\OfferStatus;
use App\Domain\Catalog\StatusValue;
use App\Filament\Resources\Offers\OfferResource; use App\Filament\Resources\Offers\OfferResource;
use App\Filament\Support\CatalogLabels;
use App\Filament\Support\ListsCatalog;
use App\Filament\Support\ReportsDomainRules; use App\Filament\Support\ReportsDomainRules;
use Filament\Actions\Action; use Filament\Actions\Action;
use Filament\Forms\Components\TextInput; use Filament\Forms\Components\TextInput;
@@ -12,6 +17,7 @@
class ListOffers extends ListRecords class ListOffers extends ListRecords
{ {
use ListsCatalog;
use ReportsDomainRules; use ReportsDomainRules;
protected static string $resource = OfferResource::class; protected static string $resource = OfferResource::class;
@@ -24,13 +30,83 @@ public function getSubheading(): string|Htmlable|null
protected function getHeaderActions(): array protected function getHeaderActions(): array
{ {
return [ return [
Action::make('create')->label('Angebot anlegen')->schema([ Action::make('create')->label('Angebot anlegen')
TextInput::make('name')->label('Name')->required(), ->modalHeading('Neues Angebot')
])->action(function (array $data): void { ->modalDescription('Der Name genügt. Positionen, Vergabe und Preis legst du danach am Angebot fest.')
$this->report(function () use ($data): void { ->modalSubmitActionLabel('Angebot anlegen')
app(OfferService::class)->create($data['name']); ->schema([
}, 'Das Angebot ist angelegt.'); TextInput::make('name')->label('Name')->required(),
}), ])->action(function (array $data): void {
$offer = null;
$this->report(function () use ($data, &$offer): void {
$offer = app(OfferService::class)->create($data['name']);
}, 'Das Angebot ist angelegt.');
if ($offer instanceof Offer) {
$this->redirect(OfferResource::getUrl('view', ['record' => $offer]));
}
}),
]; ];
} }
protected function catalogRows(): array
{
$rows = [];
foreach (Offer::query()->with(['versions.lines.article', 'versions.lines.bundleVersion.bundle', 'versions.lines.rights.profile'])->orderBy('name')->get() as $offer) {
$versions = $offer->versions->sortByDesc('number');
$active = $versions->first(fn ($version): bool => StatusValue::of($version->status) === OfferStatus::Aktiv->value);
$ended = $versions->filter(fn ($version): bool => StatusValue::of($version->status) === OfferStatus::Beendet->value)->count();
$chips = [];
$zustand = [];
$text = '';
if ($active !== null) {
$chips[] = ['label' => 'Fassung '.$active->number.' aktiv', 'ton' => 'gut'];
$chips[] = ['label' => CatalogLabels::vergabe($active), 'ton' => 'neutral'];
$chips[] = ['label' => $active->holder_kind === 'organisation' ? 'Für Organisationen' : 'Für Privatpersonen', 'ton' => 'neutral'];
$zustand[] = 'aktiv';
$text = $active->lines->map(fn ($line): string => ($line->article !== null
? 'Lizenzartikel '.$line->article->code
: 'Paket '.($line->bundleVersion?->bundle?->name ?? '–')).' · '.($line->rights?->profile?->name ?? ''))->implode('; ');
} else {
$chips[] = ['label' => 'Keine aktive Fassung', 'ton' => 'offen'];
$zustand[] = 'ohne';
}
if ($ended > 0) {
$chips[] = ['label' => $ended === 1 ? '1 beendete Fassung' : $ended.' beendete Fassungen', 'ton' => 'leise'];
}
$url = OfferResource::getUrl('view', ['record' => $offer]);
$rows[] = [
'schluessel' => 'o'.$offer->id,
'titel' => $offer->name,
'meta' => 'Angebot',
'text' => $text,
'symbol' => 'etikett',
'url' => $url,
'chips' => $chips,
'zustand' => $zustand,
'aktionen' => [['label' => 'Öffnen', 'href' => $url]],
];
}
return $rows;
}
protected function zustandOptionen(): array
{
return ['alle' => 'Jeder Zustand', 'aktiv' => 'Mit aktiver Fassung', 'ohne' => 'Ohne aktive Fassung'];
}
protected function einheit(): array
{
return ['Angebot', 'Angebote'];
}
protected function leer(): array
{
return ['titel' => 'Noch keine Angebote', 'text' => 'Mit „Angebot anlegen“ oben entsteht das erste Angebot.'];
}
} }
+334 -14
View File
@@ -3,12 +3,20 @@
namespace App\Filament\Resources\Offers\Pages; namespace App\Filament\Resources\Offers\Pages;
use App\Domain\Catalog\BundleVersion; use App\Domain\Catalog\BundleVersion;
use App\Domain\Catalog\Composition;
use App\Domain\Catalog\CompositionVersion; use App\Domain\Catalog\CompositionVersion;
use App\Domain\Catalog\DomainRuleException;
use App\Domain\Catalog\LicenseArticle; use App\Domain\Catalog\LicenseArticle;
use App\Domain\Catalog\Offer; use App\Domain\Catalog\Offer;
use App\Domain\Catalog\OfferService; use App\Domain\Catalog\OfferService;
use App\Domain\Catalog\OfferStatus;
use App\Domain\Catalog\OfferVersion;
use App\Domain\Catalog\RightsProfileVersion; use App\Domain\Catalog\RightsProfileVersion;
use App\Domain\Catalog\StatusValue;
use App\Domain\Commerce\Money;
use App\Domain\Commerce\ProductOptions;
use App\Filament\Resources\Offers\OfferResource; use App\Filament\Resources\Offers\OfferResource;
use App\Filament\Support\CatalogLabels;
use App\Filament\Support\CatalogOptions; use App\Filament\Support\CatalogOptions;
use App\Filament\Support\ReportsDomainRules; use App\Filament\Support\ReportsDomainRules;
use Filament\Actions\Action; use Filament\Actions\Action;
@@ -17,24 +25,105 @@
use Filament\Forms\Components\TextInput; use Filament\Forms\Components\TextInput;
use Filament\Resources\Pages\ViewRecord; use Filament\Resources\Pages\ViewRecord;
use Filament\Schemas\Components\Utilities\Get; use Filament\Schemas\Components\Utilities\Get;
use Filament\Schemas\Components\View;
use Filament\Schemas\Schema;
use Filament\Support\Enums\Width;
use Illuminate\Contracts\Support\Htmlable;
use Illuminate\Support\Facades\DB;
/**
* Angebot im gemeinsamen Rahmen. Anlegen und Ändern nutzen dieselbe Maske (FACH-20): „Fassung aktivieren“ legt die
* nächste, danach unveränderliche Angebotsfassung an; bei einer Änderung ist die Maske mit der aktiven Fassung
* vorbelegt (FACH-08). Die Wirkung bleibt die bestehende von OfferService::activate.
*/
class ViewOffer extends ViewRecord class ViewOffer extends ViewRecord
{ {
use ReportsDomainRules; use ReportsDomainRules;
protected static string $resource = OfferResource::class; protected static string $resource = OfferResource::class;
public function getTitle(): string|Htmlable
{
return (string) $this->getRecord()->name;
}
public function getHeading(): string|Htmlable
{
return '';
}
public function getMaxContentWidth(): Width|string|null
{
return Width::Full;
}
protected function getHeaderActions(): array protected function getHeaderActions(): array
{ {
return [ return [];
Action::make('activate')->label('Fassung aktivieren')->schema([ }
/**
* Der gemeinsame Objektkopf zeigt den Pfad; Filaments eigener Pfad entfällt wie bei Medien und Aufbau.
*
* @return array<string, string>
*/
public function getBreadcrumbs(): array
{
return [];
}
public function infolist(Schema $schema): Schema
{
return $schema->components([
View::make('filament.catalog.objekt')->viewData(fn (): array => $this->angebotDaten())->columnSpanFull(),
])->columns(1);
}
public function activeVersion(): ?OfferVersion
{
/** @var Offer $offer */
$offer = $this->getRecord();
return $offer->versions()
->where('status', OfferStatus::Aktiv)
->orderByDesc('number')
->with(['lines.article', 'lines.bundleVersion.bundle', 'lines.rights.profile'])
->first();
}
public function activateAction(): Action
{
return Action::make('activate')
->label(fn (): string => $this->activeVersion() !== null ? 'Geänderte Fassung aktivieren' : 'Fassung aktivieren')
->modalHeading(fn (): string => $this->activeVersion() !== null
? 'Option „'.$this->getRecord()->optionName().'“ ändern: Fassung '.$this->nextNumber().' aktivieren'
: 'Option „'.$this->getRecord()->optionName().'“: erste Fassung aktivieren')
->modalDescription(fn (): string => ($active = $this->activeVersion()) !== null
? 'Betroffen ist nur die Option „'.$this->getRecord()->optionName().'“'.$this->productPageSuffix().'. Die Maske ist mit Fassung '.$active->number.' vorbelegt. Erst „Fassung '.$this->nextNumber().' aktivieren“ schaltet die Änderung öffentlich (auch Bezeichnung und Produktseite, sie erzeugen ebenfalls eine neue Fassung und zeigen offenen Warenkörben „Bedingungen aktualisiert“): Fassung '.$active->number.' wird beendet und bleibt gespeichert, neue Käufe nutzen Fassung '.$this->nextNumber().'. Bereits begründete Berechtigungen und Bestellungen ändern sich nicht. Andere Optionen derselben Produktseite bleiben unverändert kaufbar. „Abbrechen“ verwirft die Eingaben.'
: 'Positionen, Vergabe, Eignung und Preis bilden die erste Fassung dieser Option. Erst das Aktivieren macht sie öffentlich; danach ist sie unveränderlich, Änderungen ergeben eine weitere Fassung.')
->modalSubmitActionLabel(fn (): string => 'Fassung '.$this->nextNumber().' aktivieren')
->modalWidth('4xl')
->fillForm(fn (): array => $this->formFromActive())
->schema([
TextInput::make('option_label')->label('Bezeichnung der Option')
->helperText('So heißt die Option auf der Produktseite, zum Beispiel „Einzellizenz für Privatpersonen“. Sie ist keine bindende Bedingung, wird aber wie die übrigen Angaben erst mit „Fassung aktivieren“ übernommen.')
->maxLength(120),
Select::make('composition_id')->label('Produktseite')
->options(fn (): array => $this->productPages())
->searchable()
->helperText('Optionen derselben Produktseite sind Alternativen; im Warenkorb liegt nur eine davon. Die Beschreibung der Seite wird zentral an der Komposition gepflegt. Die Zuordnung wird mit „Fassung aktivieren“ übernommen.'),
Select::make('holder_kind')->label('Geeignet für')->options([
'person' => 'Privatpersonen',
'organisation' => 'Organisationen und Vereine',
])->required()
->helperText('Wähle die Eignung passend zu den Rechten: Organisationslizenzen brauchen institutionelle Rechte. Das System erzwingt diese Kopplung nicht.'),
Select::make('grant_kind')->label('Vergabe')->options([ Select::make('grant_kind')->label('Vergabe')->options([
'kauf' => 'Kauf', 'kauf' => 'Kauf',
'auf_abruf' => 'Auf Abruf', 'auf_abruf' => 'Auf Abruf',
'bei_registrierung' => 'Bei Registrierung', 'bei_registrierung' => 'Bei Registrierung',
])->required(), ])->required(),
TextInput::make('price_cents')->label('Preis in Cent')->numeric() TextInput::make('price_euro')->label('Preis in Euro')->suffix('€')
->helperText('Nur bei einem Kauf. 500 bedeutet 5,00 €.'), ->helperText('Nur bei einem Kauf, zum Beispiel 49,00.'),
Select::make('composition_version_id')->label('Programmfassung, die abgedeckt sein muss') Select::make('composition_version_id')->label('Programmfassung, die abgedeckt sein muss')
->options(function (): array { ->options(function (): array {
return CompositionVersion::query() return CompositionVersion::query()
@@ -57,9 +146,10 @@ protected function getHeaderActions(): array
Select::make('bundle_version_id')->label('Paketfassung')->options(fn (): array => CatalogOptions::bundleVersions()) Select::make('bundle_version_id')->label('Paketfassung')->options(fn (): array => CatalogOptions::bundleVersions())
->visible(fn (Get $get): bool => $get('kind') === 'bundle'), ->visible(fn (Get $get): bool => $get('kind') === 'bundle'),
Select::make('rights_id')->label('Rechte')->options(fn (): array => CatalogOptions::rights())->required(), Select::make('rights_id')->label('Rechte')->options(fn (): array => CatalogOptions::rights())->required(),
])->minItems(1), ])->minItems(1)->addActionLabel('Position hinzufügen'),
])->action(function (array $data): void { ])
$this->report(function () use ($data): void { ->action(function (array $data): void {
$this->report(function () use ($data): string {
/** @var Offer $offer */ /** @var Offer $offer */
$offer = $this->getRecord(); $offer = $this->getRecord();
$lines = []; $lines = [];
@@ -74,16 +164,246 @@ protected function getHeaderActions(): array
]; ];
} }
app(OfferService::class)->activate($offer, $lines, [ // Bedingungen, die die Maske nicht zeigt, bleiben bei einer Änderung die der aktiven Fassung.
'grant_kind' => $data['grant_kind'], $active = $this->activeVersion();
'price_cents' => $data['price_cents'] === null || $data['price_cents'] === '' ? null : (int) $data['price_cents'], $kept = $active === null ? [] : [
'holder_kind' => 'person', 'term_rule' => $active->term_rule,
'composition_version_id' => filled($data['composition_version_id'] ?? null) ? (int) $data['composition_version_id'] : null, 'tax_class' => $active->tax_class,
]); 'dynamic' => (bool) $active->dynamic,
];
$price = Money::parse($data['price_euro'] ?? null);
if ($data['grant_kind'] === 'kauf' && ($price === null || $price <= 0)) {
throw new DomainRuleException('Ein Kauf braucht einen Preis über 0,00 €.');
}
$service = app(OfferService::class);
$version = DB::transaction(function () use ($service, $offer, $data, $lines, $kept, $price) {
$service->assignProduct(
$offer,
filled($data['composition_id'] ?? null) ? (int) $data['composition_id'] : null,
$data['option_label'] ?? null,
);
return $service->activate($offer, $lines, [
...$kept,
'holder_kind' => $data['holder_kind'],
'grant_kind' => $data['grant_kind'],
'price_cents' => $price,
'composition_version_id' => filled($data['composition_version_id'] ?? null) ? (int) $data['composition_version_id'] : null,
]);
});
return 'Fassung '.$version->number.' ist aktiv. Die Option ist in dieser Fassung öffentlich kaufbar.';
}, 'Die Angebotsfassung ist aktiv.'); }, 'Die Angebotsfassung ist aktiv.');
$this->getRecord()->unsetRelations(); $this->getRecord()->unsetRelations();
$this->getRecord()->refresh(); $this->getRecord()->refresh();
}), });
}
/**
* Option aus dem Verkauf nehmen: nur die aktive Fassung dieser Option wird beendet.
*/
public function endAction(): Action
{
return Action::make('end')
->label('Aus dem Verkauf nehmen')
->color('danger')
->requiresConfirmation()
->modalHeading(fn (): string => 'Option „'.$this->getRecord()->optionName().'“ aus dem Verkauf nehmen?')
->modalDescription(fn (): string => 'Betroffen ist nur die Option „'.$this->getRecord()->optionName().'“'.$this->productPageSuffix().'. Die aktive Fassung wird beendet und bleibt gespeichert. Die Option ist danach nicht mehr kaufbar; in vorhandenen Warenkörben bleibt sie mit Hinweis sichtbar und blockiert den Abschluss, bis der Käufer sie entfernt. Bestehende Berechtigungen und Bestellungen ändern sich nicht. Andere Optionen derselben Produktseite bleiben kaufbar.')
->modalSubmitActionLabel('Aus dem Verkauf nehmen')
->visible(fn (): bool => $this->activeVersion() !== null)
->action(function (): void {
$this->report(function (): string {
$version = app(OfferService::class)->end($this->getRecord());
return 'Fassung '.$version->number.' ist beendet. Die Option ist nicht mehr kaufbar.';
}, 'Die Option ist aus dem Verkauf genommen.');
$this->getRecord()->unsetRelations();
$this->getRecord()->refresh();
});
}
/** „ der Produktseite „Titel““ oder leer, wenn die Option noch keiner Produktseite zugeordnet ist. */
private function productPageSuffix(): string
{
$page = $this->getRecord()->composition;
return $page === null ? '' : ' der Produktseite „'.($page->display_title ?: $page->designation).'“';
}
/**
* Produktseiten, die als Ziel wählbar sind: Kompositionen mit Bezeichnung und Art.
*
* @return array<int, string>
*/
private function productPages(): array
{
return Composition::query()
->with('editorialContentKind')
->whereNull('archived_at')
->orderBy('designation')
->get()
->mapWithKeys(fn (Composition $composition): array => [
$composition->id => ($composition->display_title ?: $composition->designation)
.' ('.($composition->editorialContentKind?->label ?? 'Zusammenstellung').')',
])
->all();
}
/**
* Vorbelegung aus der aktiven Fassung; ohne aktive Fassung eine leere Position.
*
* @return array<string, mixed>
*/
private function formFromActive(): array
{
$active = $this->activeVersion();
/** @var Offer $offer */
$offer = $this->getRecord();
$option = ['option_label' => $offer->option_label, 'composition_id' => $offer->composition_id];
if ($active === null) {
return [...$option, 'holder_kind' => 'person', 'grant_kind' => 'kauf', 'lines' => [['kind' => 'article']]];
}
return [
...$option,
'holder_kind' => $active->holder_kind,
'grant_kind' => $active->grant_kind,
'price_euro' => $active->price_cents === null ? null : number_format($active->price_cents / 100, 2, ',', ''),
'lines' => $active->lines->sortBy('position')->map(fn ($line): array => [
'kind' => $line->license_article_id !== null ? 'article' : 'bundle',
'article_id' => $line->license_article_id,
'bundle_version_id' => $line->bundle_version_id,
'rights_id' => $line->rights_profile_version_id,
])->values()->all(),
]; ];
} }
private function nextNumber(): int
{
return ((int) $this->getRecord()->versions()->max('number')) + 1;
}
/**
* Daten der gemeinsamen Katalog-Objektseite.
*
* @return array<string, mixed>
*/
private function angebotDaten(): array
{
/** @var Offer $offer */
$offer = $this->getRecord();
$active = $this->activeVersion();
$vergabe = $active !== null ? CatalogLabels::vergabe($active) : null;
return [
'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',
],
...($active !== null ? [[
'label' => 'Aus dem Verkauf nehmen',
'wire' => "mountAction('end')",
'art' => 'line',
]] : []),
],
],
'haupt' => [
...($active !== null ? [$this->optionAbschnitt($offer, $active)] : []),
[
'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).',
]],
];
}
/**
* Die Option auf einen Blick: Preis in Euro, Eignung, Rechte, zugrunde liegender Inhalt, Status und Produktseite.
*
* @return array<string, mixed>
*/
private function optionAbschnitt(Offer $offer, OfferVersion $active): array
{
$option = app(ProductOptions::class)->describe($offer, $active);
$inhalt = collect($option['scope'])->pluck('article')->unique()->implode(', ');
$rechte = collect($option['scope'])
->map(fn (array $item): string => $item['purpose'].($item['rights'] === [] ? '' : ': '.implode(', ', $item['rights'])))
->unique()
->implode('; ');
$seite = $offer->composition;
$kaufbar = app(OfferService::class)->purchasableVersion($offer) !== null;
return [
'titel' => 'Die Option auf einen Blick',
'zusatz' => 'Fassung '.$active->number,
'hilfe' => 'So erscheint die Option auf der öffentlichen Produktseite und im Warenkorb. Die Angaben dieser Fassung sind unveränderlich.',
'zeilen' => [
['text' => 'Preis: '.$option['price'], 'neben' => $active->grant_kind === 'kauf' ? 'Kauf mit Testzahlung' : CatalogLabels::vergabe($active)],
['text' => 'Geeignet für: '.$option['for'], 'neben' => $option['term']],
['text' => 'Rechte: '.($rechte !== '' ? $rechte : 'keine'), 'neben' => null],
['text' => 'Zugrunde liegender Inhalt: '.($inhalt !== '' ? $inhalt : '–'), 'neben' => null],
['text' => 'Status: '.($kaufbar ? 'Öffentlich kaufbar' : 'Nicht als Kauf angeboten'), 'neben' => $kaufbar ? 'Aktive Fassung '.$active->number : null],
['text' => 'Produktseite: '.($seite !== null ? ($seite->display_title ?: $seite->designation) : 'noch nicht zugeordnet'), 'neben' => $seite !== null ? 'Option „'.$offer->optionName().'“' : 'Mit „Geänderte Fassung aktivieren“ zuordnen.'],
],
];
}
/**
* Aufgelöster Leistungsumfang in lesbaren Fähigkeiten (dieselben Bezeichnungen wie beim Rechteprofil).
*
* @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 = CatalogLabels::faehigkeiten($scope->rights?->capabilities);
$zeilen[] = [
'text' => 'Lizenzartikel '.$scope->article?->code,
'neben' => ($scope->rights?->profile?->name ?? '–').': '.($faehigkeiten === [] ? 'keine Fähigkeiten' : implode(', ', $faehigkeiten)),
];
}
return $zeilen;
}
} }
+17 -5
View File
@@ -27,6 +27,9 @@ class PageResource extends Resource
protected static ?string $navigationLabel = 'Seiten'; protected static ?string $navigationLabel = 'Seiten';
/** Der Seitenbestand steht in der Webpräsenz; Anlegen und Bearbeiten bleiben hier. */
protected static bool $shouldRegisterNavigation = false;
protected static ?string $modelLabel = 'Seite'; protected static ?string $modelLabel = 'Seite';
protected static ?string $pluralModelLabel = 'Seiten'; protected static ?string $pluralModelLabel = 'Seiten';
@@ -38,11 +41,9 @@ public static function form(Schema $schema): Schema
return $schema->components([ return $schema->components([
Section::make('Seite und Suchmaschinen') Section::make('Seite und Suchmaschinen')
->description('Adresse, Titel für Suchmaschinen und Zuordnung zu Themenbereichen.') ->description('Adresse, Titel für Suchmaschinen und Zuordnung zu Themenbereichen.')
->collapsible()
->collapsed(fn (string $operation): bool => $operation === 'edit')
->persistCollapsed()
->columns(2) ->columns(2)
->columnSpanFull() ->columnSpanFull()
->extraAttributes(fn ($livewire): array => ['class' => self::registerClass($livewire, 'einstellungen')])
->schema([ ->schema([
TextInput::make('path') TextInput::make('path')
->label('Pfad') ->label('Pfad')
@@ -63,15 +64,26 @@ public static function form(Schema $schema): Schema
->columns(['default' => 1, 'lg' => 2]), ->columns(['default' => 1, 'lg' => 2]),
]), ]),
Section::make('Inhalt der Seite') Section::make('Inhalt der Seite')
->description('Abschnitt hinzufügen, Raster wählen, Widgets in die Plätze einsetzen. Ein Klick auf die Vorschau eines Widgets öffnet seinen Dialog; Hintergrund, Breite, Abstand und Trenner stehen unter „Gestaltung des Abschnitts“. Speichern legt einen Entwurf an; veröffentlicht wird erst über „Veröffentlichen“.') ->description(fn ($livewire): string => is_object($livewire) && method_exists($livewire, 'openAbschnitt')
? 'Seitenaufbau: Plätze und Bausteine im Rasterverhältnis der Website. „Abschnitt gestalten“ öffnet Raster, Breite, Hintergrund, Abstände und Trenner; ein Klick auf einen Baustein öffnet seine Konfiguration. Gesichert wird mit „Entwurf speichern“, veröffentlicht erst über „Veröffentlichen …“.'
: 'Abschnitt hinzufügen, Raster wählen, Widgets in die Plätze einsetzen. Ein Klick auf die Vorschau eines Widgets öffnet seinen Dialog; Hintergrund, Breite, Abstand und Trenner stehen unter „Gestaltung des Abschnitts“. Speichern legt einen Entwurf an; veröffentlicht wird erst über „Veröffentlichen“.')
->columnSpanFull() ->columnSpanFull()
->extraAttributes(['class' => 'luf-page-content']) ->extraAttributes(fn ($livewire): array => ['class' => 'luf-page-content '.self::registerClass($livewire, 'inhalt')])
->schema([ ->schema([
SectionEditor::repeater('sections'), SectionEditor::repeater('sections'),
]), ]),
]); ]);
} }
/**
* Im Seiten-Arbeitsplatz (EditPage) zeigt jedes Register nur seinen Teil; ausgeblendete Felder bleiben im
* Formularzustand und werden mitgespeichert. Beim Anlegen ist alles sichtbar.
*/
public static function registerClass(mixed $livewire, string $register): string
{
return is_object($livewire) && property_exists($livewire, 'register') && $livewire->register !== $register ? 'vw-ausgeblendet' : '';
}
public static function table(Table $table): Table public static function table(Table $table): Table
{ {
return $table return $table
@@ -6,16 +6,19 @@
use App\Domain\Cms\Page; use App\Domain\Cms\Page;
use App\Domain\Cms\PageService; use App\Domain\Cms\PageService;
use App\Filament\Resources\Pages\PageResource; use App\Filament\Resources\Pages\PageResource;
use App\Filament\Support\ChoosesWebsiteImages;
use App\Filament\Support\ReportsSectionErrors; use App\Filament\Support\ReportsSectionErrors;
use App\Filament\Support\SectionEditor; use App\Filament\Support\SectionEditor;
use Filament\Resources\Pages\CreateRecord; use Filament\Resources\Pages\CreateRecord;
use Filament\Support\Enums\Width; use Filament\Support\Enums\Width;
use Illuminate\Contracts\View\View;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Validation\ValidationException; use Illuminate\Validation\ValidationException;
class CreatePage extends CreateRecord class CreatePage extends CreateRecord
{ {
use ChoosesWebsiteImages;
use ReportsSectionErrors; use ReportsSectionErrors;
protected static string $resource = PageResource::class; protected static string $resource = PageResource::class;
@@ -28,6 +31,12 @@ class CreatePage extends CreateRecord
protected static bool $canCreateAnother = false; protected static bool $canCreateAnother = false;
/** Gemeinsamer Bild-Picker über dem Formular und dem Bausteindialog. */
public function getFooter(): ?View
{
return view('filament.cms.bild-picker');
}
/** /**
* @param array<string, mixed> $data * @param array<string, mixed> $data
*/ */
+229 -39
View File
@@ -6,17 +6,23 @@
use App\Domain\Cms\Page; use App\Domain\Cms\Page;
use App\Domain\Cms\PageService; use App\Domain\Cms\PageService;
use App\Filament\Resources\Pages\PageResource; use App\Filament\Resources\Pages\PageResource;
use App\Filament\Support\ChoosesWebsiteImages;
use App\Filament\Support\ReportsSectionErrors; use App\Filament\Support\ReportsSectionErrors;
use App\Filament\Support\SectionEditor; use App\Filament\Support\SectionEditor;
use Filament\Actions\Action; use Filament\Actions\Action;
use Filament\Notifications\Notification; use Filament\Notifications\Notification;
use Filament\Resources\Pages\EditRecord; use Filament\Resources\Pages\EditRecord;
use Filament\Schemas\Components\Group;
use Filament\Schemas\Schema;
use Filament\Support\Enums\Width; use Filament\Support\Enums\Width;
use Illuminate\Contracts\View\View;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Validation\ValidationException; use Illuminate\Validation\ValidationException;
use Livewire\Attributes\Url;
class EditPage extends EditRecord class EditPage extends EditRecord
{ {
use ChoosesWebsiteImages;
use ReportsSectionErrors; use ReportsSectionErrors;
protected static string $resource = PageResource::class; protected static string $resource = PageResource::class;
@@ -27,50 +33,234 @@ class EditPage extends EditRecord
/** Warnt vor dem Verlassen oder Neuladen, wenn Änderungen noch nicht gespeichert sind. */ /** Warnt vor dem Verlassen oder Neuladen, wenn Änderungen noch nicht gespeichert sind. */
protected ?bool $hasUnsavedDataChangesAlert = true; protected ?bool $hasUnsavedDataChangesAlert = true;
/** Register des Seiten-Arbeitsplatzes: inhalt, einstellungen, verlauf (Dokument 12, CMS-R01). */
#[Url(as: 'bereich', except: 'inhalt')]
public string $register = 'inhalt';
/**
* Kontext „Abschnitt gestalten“: Position des Abschnitts (die Repeater-Schlüssel wechseln beim Speichern,
* die Reihenfolge nicht). null ist der Seitenaufbau.
*/
#[Url(as: 'abschnitt', except: null)]
public ?int $abschnitt = null;
/** Fingerabdruck des zuletzt geladenen oder gespeicherten Stands; Grundlage für „nicht gespeichert“. */
public string $gespeicherterStand = '';
public function showRegister(string $register): void
{
$this->register = in_array($register, ['inhalt', 'einstellungen', 'verlauf'], true) ? $register : 'inhalt';
$this->abschnitt = null;
}
public function openAbschnitt(string $key): void
{
$index = array_search($key, array_map('strval', array_keys($this->data['sections'] ?? [])), true);
if ($index === false) {
return;
}
$this->register = 'inhalt';
$this->abschnitt = (int) $index;
$this->js('window.scrollTo({ top: 0 })');
}
/**
* Zurück zum Seitenaufbau, an die Stelle des gestalteten Abschnitts (Fokus auf „Abschnitt gestalten“).
*/
public function closeAbschnitt(): void
{
$key = $this->abschnittSchluessel();
$this->abschnitt = null;
if ($key !== null) {
$selector = json_encode('.luf-sections [x-sortable-item="'.$key.'"]');
$this->js("requestAnimationFrame(() => requestAnimationFrame(() => { const el = document.querySelector($selector); if (! el) return; window.scrollTo({ top: el.getBoundingClientRect().top + window.scrollY - 96 }); [...el.querySelectorAll('button')].find((b) => b.textContent.includes('Abschnitt gestalten'))?.focus({ preventScroll: true }); }))");
}
}
/**
* Repeater-Schlüssel des gestalteten Abschnitts, aufgelöst zur Laufzeit.
*/
public function abschnittSchluessel(): ?string
{
if ($this->abschnitt === null) {
return null;
}
$keys = array_map('strval', array_keys($this->data['sections'] ?? []));
return $keys[$this->abschnitt] ?? null;
}
/**
* Gemeinsamer Objektkopf statt Filaments Titel, Pfad und Kopfaktionen.
*/
public function getHeader(): ?View
{
return view('filament.cms.seite-kopf', ['seite' => $this->record, 'ungespeichert' => $this->hasUnsavedEditorChanges()]);
}
/**
* Weicht der Editorstand vom geladenen oder gespeicherten Stand ab? Verglichen wird derselbe normalisierte
* Zustand, der auch gespeichert würde; Vorschaubreiten zählen nicht.
*/
public function hasUnsavedEditorChanges(): bool
{
return $this->gespeicherterStand !== '' && $this->editorFingerprint() !== $this->gespeicherterStand;
}
protected function afterFill(): void
{
$this->gespeicherterStand = $this->editorFingerprint();
}
private function editorFingerprint(): string
{
$data = is_array($this->data ?? null) ? $this->data : [];
$pillars = array_map('intval', (array) ($data['pillars'] ?? []));
sort($pillars);
return md5(json_encode([
self::withoutPreviewKeys(SectionEditor::fromEditorState(is_array($data['sections'] ?? null) ? $data['sections'] : [])),
(string) ($data['path'] ?? ''),
(string) ($data['seo_title'] ?? ''),
(string) ($data['seo_description'] ?? ''),
$pillars,
], JSON_UNESCAPED_UNICODE) ?: '');
}
private static function withoutPreviewKeys(mixed $value): mixed
{
if (! is_array($value)) {
return $value;
}
unset($value['_preview_width']);
return array_map(self::withoutPreviewKeys(...), $value);
}
/**
* Formular und Verlauf (Revisionen) als Register; ausgeblendete Teile bleiben im Formularzustand.
*/
public function content(Schema $schema): Schema
{
return $schema->components([
$this->getFormContentComponent(),
Group::make([$this->getRelationManagersContentComponent()])
->extraAttributes(fn (): array => ['class' => $this->register === 'verlauf' ? '' : 'vw-ausgeblendet']),
]);
}
/**
* Speichern steht im Kopf; die Leiste unter dem Formular entfällt.
*/
protected function getFormActions(): array
{
return [];
}
/**
* Ein Fehler in einem gerade ausgeblendeten Register oder Abschnittsteil wird sichtbar gemacht (CMS-12).
*/
public function save(bool $shouldRedirect = true, bool $shouldSendSavedNotification = true): void
{
try {
parent::save($shouldRedirect, $shouldSendSavedNotification);
} catch (ValidationException $exception) {
$keys = implode(' ', array_keys($exception->errors()));
$this->register = str_contains($keys, 'data.sections') ? 'inhalt' : (preg_match('/data\.(path|seo_|pillars)/', $keys) === 1 ? 'einstellungen' : $this->register);
$this->showFailingSection(array_keys($exception->errors()));
throw $exception;
}
}
/**
* Raster und Gestaltung stehen nur im Kontext „Abschnitt gestalten“, andere Abschnitte sind dort ausgeblendet.
* Liegt der Fehler im gestalteten Abschnitt, bleibt der Kontext. Ein Raster- oder Gestaltungsfehler öffnet den
* betroffenen Abschnitt; jeder andere Abschnittsfehler (etwa die Platzübersicht) steht im Seitenaufbau.
*
* @param list<string> $errorKeys
*/
private function showFailingSection(array $errorKeys): void
{
$sectionKeys = array_map('strval', array_keys($this->data['sections'] ?? []));
$failing = [];
$design = null;
foreach ($errorKeys as $key) {
if (preg_match('/^data\.sections\.([^.]+)(?:\.(.*))?$/', $key, $match) !== 1) {
continue;
}
$index = array_search($match[1], $sectionKeys, true);
if ($index === false) {
continue;
}
$failing[] = $index;
if ($design === null && preg_match('/^(layout|style)(\.|$)/', $match[2] ?? '') === 1) {
$design = $index;
}
}
if ($failing === [] || ($this->abschnitt !== null && in_array($this->abschnitt, $failing, true))) {
return;
}
$this->abschnitt = $design;
}
/**
* „Entwurf speichern“ aus dem Bausteindialog: Der Baustein ist bereits übernommen, der Dialog schließt. Ein Fehler
* wird wie beim Speichern im Kopf gezeigt (Register, Abschnitt, Meldung), ohne den Baustein erneut zu öffnen.
*/
public function saveFromBlock(): void
{
// Nach einer Dialogaktion rendert Filament sonst nur den Dialog neu; der Kopf zeigte den alten Speicherstand.
$this->forceRender();
try {
$this->save(shouldRedirect: false);
} catch (ValidationException $exception) {
foreach ($exception->errors() as $key => $messages) {
foreach ((array) $messages as $message) {
$this->addError($key, $message);
}
}
}
}
protected function getHeaderActions(): array protected function getHeaderActions(): array
{ {
return [ return [];
Action::make('preview') }
->label('Vorschau')
->icon('heroicon-o-device-phone-mobile')
->color('gray')
->tooltip('Zuletzt gespeicherten Entwurf in Smartphone-, Tablet- und Desktopbreite ansehen')
->url(function (): string {
$revision = $this->record->latestRevision;
return $revision === null public function publishAction(): Action
? '#' {
: route('pages.preview.devices', $revision); return Action::make('publish')
}) ->label('Veröffentlichen')
->openUrlInNewTab(), ->icon('heroicon-o-globe-alt')
Action::make('publish') ->requiresConfirmation()
->label('Veröffentlichen') ->modalHeading('Seite veröffentlichen?')
->icon('heroicon-o-globe-alt') ->modalDescription('Der aktuelle Stand im Editor wird als Entwurf gespeichert und genau dieser Stand wird veröffentlicht. Enthält er Fehler, wird nichts veröffentlicht.')
->requiresConfirmation() ->modalSubmitActionLabel('Speichern und veröffentlichen')
->modalHeading('Seite veröffentlichen?') ->visible(fn (): bool => auth()->user()?->can('publish', $this->record) ?? false)
->modalDescription('Der aktuelle Stand im Editor wird als Entwurf gespeichert und genau dieser Stand wird veröffentlicht. Enthält er Fehler, wird nichts veröffentlicht.') ->action(function (PageService $service): void {
->modalSubmitActionLabel('Speichern und veröffentlichen') // Ungespeicherte Änderungen (zum Beispiel ein eben gewähltes Bild) gingen sonst beim Veröffentlichen verloren.
->visible(fn (): bool => auth()->user()?->can('publish', $this->record) ?? false) $this->save(shouldRedirect: false, shouldSendSavedNotification: false);
->action(function (PageService $service): void {
// Ungespeicherte Änderungen (zum Beispiel ein eben gewähltes Bild) gingen sonst beim Veröffentlichen verloren.
$this->save(shouldRedirect: false, shouldSendSavedNotification: false);
$this->record->unsetRelation('latestRevision'); $this->record->unsetRelation('latestRevision');
$revision = $this->record->latestRevision; $revision = $this->record->latestRevision;
abort_if($revision === null, 404); abort_if($revision === null, 404);
$service->publish($this->record, $revision); $service->publish($this->record, $revision);
$this->record->refresh(); $this->record->refresh();
Notification::make()->title('Seite veröffentlicht')->success()->send(); Notification::make()->title('Seite veröffentlicht')->success()->send();
}), });
Action::make('open')
->label('Live-Seite')
->icon('heroicon-o-arrow-top-right-on-square')
->color('gray')
->visible(fn (): bool => $this->record->isPublished())
->url(fn (): string => $this->record->publicUrl())
->openUrlInNewTab(),
];
} }
protected function getSaveFormAction(): Action protected function getSaveFormAction(): Action
@@ -2,18 +2,22 @@
namespace App\Filament\Resources\Pages\Pages; namespace App\Filament\Resources\Pages\Pages;
use App\Filament\Pages\Webpraesenz;
use App\Filament\Resources\Pages\PageResource; use App\Filament\Resources\Pages\PageResource;
use Filament\Actions\CreateAction;
use Filament\Resources\Pages\ListRecords; use Filament\Resources\Pages\ListRecords;
/**
* Der Seitenbestand steht in der Webpräsenz (Dokument 13). Die bisherige Adresse führt dorthin, nach derselben
* Rechteprüfung wie bisher.
*/
class ListPages extends ListRecords class ListPages extends ListRecords
{ {
protected static string $resource = PageResource::class; protected static string $resource = PageResource::class;
protected function getHeaderActions(): array public function mount(): void
{ {
return [ parent::mount();
CreateAction::make(),
]; $this->redirect(Webpraesenz::getUrl());
} }
} }
@@ -17,6 +17,9 @@ class RevisionsRelationManager extends RelationManager
protected static ?string $title = 'Revisionen'; protected static ?string $title = 'Revisionen';
/** Steht im Register „Verlauf“ zunächst ausgeblendet; verzögertes Laden würde dort nie ausgelöst. */
protected static ?bool $isLazyLoaded = false;
public function table(Table $table): Table public function table(Table $table): Table
{ {
return $table return $table
@@ -2,9 +2,11 @@
namespace App\Filament\Resources\Pillars\Pages; namespace App\Filament\Resources\Pillars\Pages;
use App\Domain\Catalog\Pillar;
use App\Domain\Catalog\PillarService; use App\Domain\Catalog\PillarService;
use App\Filament\Resources\ContentElements\ContentElementResource; use App\Filament\Resources\ContentElements\ContentElementResource;
use App\Filament\Resources\Pillars\PillarResource; use App\Filament\Resources\Pillars\PillarResource;
use App\Filament\Support\ListsCatalog;
use App\Filament\Support\ReportsDomainRules; use App\Filament\Support\ReportsDomainRules;
use Filament\Actions\Action; use Filament\Actions\Action;
use Filament\Forms\Components\TextInput; use Filament\Forms\Components\TextInput;
@@ -13,13 +15,14 @@
class ListPillars extends ListRecords class ListPillars extends ListRecords
{ {
use ListsCatalog;
use ReportsDomainRules; use ReportsDomainRules;
protected static string $resource = PillarResource::class; protected static string $resource = PillarResource::class;
public function getSubheading(): string|Htmlable|null public function getSubheading(): string|Htmlable|null
{ {
return 'Die fachlichen Säulen des Materials. Eine veröffentlichte Säule ist ein Themenbereich der Website. Ein Medium und eine Seite können mehreren Säulen zugeordnet sein.'; return 'Die fachlichen Säulen des Materials. Eine veröffentlichte Säule ist ein Themenbereich der Website. Medien, Module, Programme, Lizenzartikel und Seiten können mehreren Säulen zugeordnet sein. Hier ist die einzige Pflegestelle der Säulen.';
} }
protected function getHeaderActions(): array protected function getHeaderActions(): array
@@ -27,6 +30,9 @@ protected function getHeaderActions(): array
return [ return [
Action::make('create') Action::make('create')
->label('Säule anlegen') ->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()) ->visible(fn (): bool => ContentElementResource::editor())
->schema([ ->schema([
TextInput::make('name')->label('Name')->required(), TextInput::make('name')->label('Name')->required(),
@@ -43,4 +49,62 @@ protected function getHeaderActions(): array
}), }),
]; ];
} }
/**
* Zuordnungen aller Objektarten; ohne Zuordnung wie bisher „0 Medien“.
*/
private function usageLabel(PillarService $service, Pillar $pillar): string
{
$usage = [
'medien' => (int) $pillar->elements_count,
'zusammenstellungen' => (int) $pillar->compositions_count,
'lizenzartikel' => (int) $pillar->license_articles_count,
'seiten' => (int) $pillar->pages_count,
];
return array_sum($usage) === 0 ? '0 Medien' : $service->usageText($usage);
}
protected function catalogRows(): array
{
$rows = [];
$service = app(PillarService::class);
foreach (Pillar::query()->withCount(['elements', 'compositions', 'licenseArticles', 'pages'])->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' => $this->usageLabel($service, $pillar), '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.'];
}
} }
@@ -3,7 +3,10 @@
namespace App\Filament\Resources\RightsProfiles\Pages; namespace App\Filament\Resources\RightsProfiles\Pages;
use App\Domain\Catalog\OfferService; use App\Domain\Catalog\OfferService;
use App\Domain\Catalog\RightsProfile;
use App\Filament\Resources\RightsProfiles\RightsProfileResource; use App\Filament\Resources\RightsProfiles\RightsProfileResource;
use App\Filament\Support\CatalogLabels;
use App\Filament\Support\ListsCatalog;
use App\Filament\Support\ReportsDomainRules; use App\Filament\Support\ReportsDomainRules;
use Filament\Actions\Action; use Filament\Actions\Action;
use Filament\Forms\Components\CheckboxList; use Filament\Forms\Components\CheckboxList;
@@ -14,6 +17,7 @@
class ListRightsProfiles extends ListRecords class ListRightsProfiles extends ListRecords
{ {
use ListsCatalog;
use ReportsDomainRules; use ReportsDomainRules;
protected static string $resource = RightsProfileResource::class; protected static string $resource = RightsProfileResource::class;
@@ -26,36 +30,78 @@ public function getSubheading(): string|Htmlable|null
protected function getHeaderActions(): array protected function getHeaderActions(): array
{ {
return [ return [
Action::make('create')->label('Rechteprofil anlegen')->schema([ Action::make('create')->label('Rechteprofil anlegen')
TextInput::make('name')->label('Name')->required(), ->modalHeading('Neues Rechteprofil')
Select::make('purpose')->label('Zweck')->options([ ->modalDescription('Zweck und erlaubte Handlungen. Ein Angebot verbindet das Profil später mit Artikeln.')
'ehrenamtlich' => 'Ehrenamtlich', ->modalSubmitActionLabel('Rechteprofil anlegen')
'kommerziell' => 'Kommerziell', ->schema([
'institutionell' => 'Institutionell', TextInput::make('name')->label('Name')->required(),
])->required(), Select::make('purpose')->label('Zweck')->options([
CheckboxList::make('capabilities')->label('Fähigkeiten')->options([ 'ehrenamtlich' => 'Ehrenamtlich',
'film:streamen' => 'Film ansehen', 'kommerziell' => 'Kommerziell',
'film:laden' => 'Film herunterladen', 'institutionell' => 'Institutionell',
'audio:streamen' => 'Hörstück ansehen', ])->required(),
'document:ansehen' => 'Dokument ansehen', CheckboxList::make('capabilities')->label('Fähigkeiten')->options(CatalogLabels::FAEHIGKEITEN)->required(),
'document:laden' => 'Dokument herunterladen', ])->action(function (array $data): void {
'pdf:ansehen' => 'PDF ansehen', $this->report(function () use ($data): void {
'pdf:laden' => 'PDF herunterladen', $capabilities = [];
'text:ansehen' => 'Text ansehen',
'bild:ansehen' => 'Bild ansehen',
])->required(),
])->action(function (array $data): void {
$this->report(function () use ($data): void {
$capabilities = [];
foreach ($data['capabilities'] as $entry) { foreach ($data['capabilities'] as $entry) {
[$class, $action] = explode(':', $entry, 2); [$class, $action] = explode(':', $entry, 2);
$capabilities[$class][] = $action; $capabilities[$class][] = $action;
} }
app(OfferService::class)->createRightsProfile($data['name'], $data['purpose'], $capabilities); app(OfferService::class)->createRightsProfile($data['name'], $data['purpose'], $capabilities);
}, 'Das Rechteprofil ist angelegt.'); }, 'Das Rechteprofil ist angelegt.');
}), }),
]; ];
} }
protected function catalogRows(): array
{
$rows = [];
foreach (RightsProfile::query()->with('versions')->orderBy('name')->get() as $profile) {
$version = $profile->versions->sortByDesc('number')->first();
$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']];
if ($version?->locked_at !== null) {
$chips[] = ['label' => 'Festgeschrieben', 'ton' => 'leise'];
}
$url = RightsProfileResource::getUrl('view', ['record' => $profile]);
$rows[] = [
'schluessel' => 'r'.$profile->id,
'titel' => $profile->name,
'meta' => 'Rechteprofil',
'text' => $faehigkeiten === [] ? 'Keine Fähigkeiten' : implode(', ', $faehigkeiten),
'symbol' => 'schluessel',
'url' => $url,
'chips' => $chips,
'zustand' => [(string) $version?->purpose],
'aktionen' => [['label' => 'Öffnen', 'href' => $url]],
];
}
return $rows;
}
protected function zustandOptionen(): array
{
return ['alle' => 'Jeder Zweck', 'ehrenamtlich' => 'Ehrenamtlich', 'kommerziell' => 'Kommerziell', 'institutionell' => 'Institutionell'];
}
protected function einheit(): array
{
return ['Rechteprofil', 'Rechteprofile'];
}
protected function leer(): array
{
return ['titel' => 'Noch keine Rechteprofile', 'text' => 'Mit „Rechteprofil anlegen“ oben entsteht das erste Profil.'];
}
} }
@@ -2,10 +2,119 @@
namespace App\Filament\Resources\RightsProfiles\Pages; 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\Resources\RightsProfiles\RightsProfileResource;
use App\Filament\Support\CatalogLabels;
use Filament\Resources\Pages\ViewRecord; 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 class ViewRightsProfile extends ViewRecord
{ {
protected static string $resource = RightsProfileResource::class; 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; 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\Resources\Users\UserResource;
use App\Filament\Support\ListsCatalog;
use App\Models\User;
use Filament\Actions\CreateAction; use Filament\Actions\CreateAction;
use Filament\Resources\Pages\ListRecords; use Filament\Resources\Pages\ListRecords;
class ListUsers extends ListRecords class ListUsers extends ListRecords
{ {
use ListsCatalog;
protected static string $resource = UserResource::class; protected static string $resource = UserResource::class;
protected function getHeaderActions(): array protected function getHeaderActions(): array
{ {
return [ 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';
}
} }
+53
View File
@@ -0,0 +1,53 @@
<?php
namespace App\Filament\Support;
use App\Domain\Catalog\Composition;
use App\Domain\Catalog\LicenseArticle;
use App\Domain\Catalog\Pillar;
use App\Domain\Catalog\PillarService;
/**
* Fachliche Säulen im Redaktionsmanager von Modul, Programm und Lizenzartikel (wie bei Medien): Die Auswahl kommt aus
* der zentralen Säulenverwaltung, die Zuordnung ersetzt die bisherige vollständig und bleibt beim Speichern anderer
* Angaben erhalten, weil der gespeicherte Stand geladen und mitgeschrieben wird.
*
* Eine Zuordnung veröffentlicht nichts: Ob eine Säule eine Themenseite hat, entscheidet allein die Säulenverwaltung.
*/
trait AssignsPillars
{
/** @var list<int|string> */
public array $pillarIds = [];
/**
* @return array{legend: string, model: string, values: list<array{id: int, label: string}>}|null
*/
public function pillarGroup(): ?array
{
$values = Pillar::query()->orderBy('sort_order')->orderBy('name')->get(['id', 'name'])
->map(fn (Pillar $pillar): array => ['id' => (int) $pillar->id, 'label' => (string) $pillar->name])
->all();
return $values === [] ? null : ['legend' => 'Fachliche Säulen', 'model' => 'pillarIds', 'values' => $values];
}
protected function loadPillarIds(Composition|LicenseArticle $subject): void
{
$this->pillarIds = $subject->pillars()->pluck('pillars.id')->map(fn (mixed $id): string => (string) (int) $id)->all();
}
protected function persistPillarIds(Composition|LicenseArticle $subject): void
{
app(PillarService::class)->assign($subject, array_map(intval(...), $this->pillarIds));
}
protected function pillarsUnsaved(Composition|LicenseArticle $subject): bool
{
$stored = $subject->pillars()->pluck('pillars.id')->map(fn (mixed $id): int => (int) $id)->all();
$current = array_map(intval(...), $this->pillarIds);
sort($stored);
sort($current);
return $stored !== $current;
}
}
+12
View File
@@ -0,0 +1,12 @@
<?php
namespace App\Filament\Support;
/**
* Werte der gemeinsamen Bestandsliste (ShowsBestand, Ansicht filament.verwaltung.bestand).
*/
final class Bestand
{
/** So viele Einträge zeigt eine Liste zunächst und je „Weitere anzeigen“. */
public const SCHRITT = 50;
}
+63
View File
@@ -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, ',', '.').' €';
}
}
+270
View File
@@ -0,0 +1,270 @@
<?php
namespace App\Filament\Support;
use App\Domain\Catalog\ContentElement;
use App\Domain\Catalog\ContentElementVersion;
use App\Domain\Catalog\EditorialVocabulary;
use App\Domain\Catalog\Pillar;
use App\Domain\Cms\Catalog\PublicMaterialReader;
use App\Domain\Cms\Widgets\Support\WebsiteImage;
use App\Http\Controllers\ContentPreviewController;
/**
* Gemeinsamer visueller Picker (Dokument 14 §9): Zustand, Suche, Treffer, Betrachten, Markieren und Detail. Die
* Ansicht ist filament.verwaltung.picker. Die Seite bestimmt Zweck, Titel, Typen, Mehrfachauswahl und was
* „Übernehmen“ bewirkt (pickerAllowsMany, pickerKinds, pickerTitle, pickerConfirmLabel, pickerKontext, confirmPicker,
* closePicker). Genutzt von der Redaktion (ManagesEditorialSurface) und vom CMS (ChoosesWebsiteImages).
*/
trait ChoosesMedia
{
public bool $pickerOpen = false;
public string $pickerPurpose = 'praesentation';
public string $pickerQuery = '';
public string $pickerKind = 'alle';
public string $pickerDimension = '';
/** Filter „Fachliche Säule“ (Kennung der Säule aus der zentralen Säulenverwaltung). */
public string $pickerSaeule = '';
/** Filter „Fachliche Materialart“ (Kennung), gleiche Regel wie Medieneditor und Medienfilter. */
public string $pickerMaterialart = '';
public string $pickerInspected = '';
public string $pickerSelected = '';
/** @var array<string, string> Ziel => Titel; bleibt bei Suche und Filter erhalten */
public array $pickerMarked = [];
public string $presentationRole = 'titelbild';
public bool $bindToVersion = false;
public ?string $replacingKey = null;
abstract public function pickerAllowsMany(): bool;
abstract public function closePicker(): void;
abstract public function confirmPicker(): void;
public function inspectPicker(string $target, bool $mark = false): void
{
$this->pickerInspected = $target;
if ($mark) {
$this->markPicker($target, true);
}
}
public function togglePick(string $target): void
{
$this->markPicker($target, ! isset($this->pickerMarked[$target]));
}
public function markPicker(string $target, bool $on): void
{
if (! $on) {
unset($this->pickerMarked[$target]);
if ($this->pickerSelected === $target) {
$this->pickerSelected = '';
}
return;
}
$row = app(EditorialCatalog::class)->rowForTarget($target, $this->pickerExceptId(), allowDraft: true);
if ($row === null) {
return;
}
if (! $this->pickerAllowsMany()) {
$this->pickerMarked = [];
$this->pickerSelected = $target;
}
$this->pickerMarked[$target] = (string) $row['title'];
if ($this->pickerInspected === '') {
$this->pickerInspected = $target;
}
}
/**
* @return array{items: list<array<string, mixed>>, more: bool}
*/
public function pickerResult(): array
{
if (! $this->pickerOpen) {
return ['items' => [], 'more' => false];
}
if ($this->pickerPurpose === 'aufbau') {
return $this->filterByMaterialart(app(EditorialCatalog::class)->browse(
$this->pickerQuery,
$this->pickerKind,
$this->pickerDimension,
$this->pickerExceptId(),
false,
ctype_digit($this->pickerSaeule) ? (int) $this->pickerSaeule : 0,
));
}
$result = app(EditorialCatalog::class)->presentationBrowse($this->pickerQuery, $this->pickerKind);
$result = $this->filterByMaterialart($result);
// CMS: nur Bilder, die als Website-Bild wählbar sind (keine vertraulichen Arten, nicht archiviert).
if ($this->pickerPurpose === 'website-bild') {
$ids = array_values(array_filter(array_map(fn (array $item): int => (int) ($item['element_id'] ?? 0), $result['items'])));
$elements = ContentElement::query()->with('editorialContentKind')->whereKey($ids)->get()->keyBy('id');
$result['items'] = array_values(array_filter($result['items'], function (array $item) use ($elements): bool {
$element = $elements->get((int) ($item['element_id'] ?? 0));
return $element !== null && WebsiteImage::isSelectable($element);
}));
}
return $result;
}
/**
* @return array<string, mixed>|null
*/
public function pickerDetail(): ?array
{
$target = $this->pickerInspected !== '' ? $this->pickerInspected : $this->pickerSelected;
if ($target === '') {
return null;
}
$row = app(EditorialCatalog::class)->rowForTarget($target, $this->pickerExceptId(), allowDraft: true);
if ($row === null) {
return null;
}
$row['playback'] = null;
$row['file_url'] = null;
$elementId = isset($row['element_id']) ? (int) $row['element_id'] : 0;
if (preg_match('/^element:(\d+)$/', (string) $row['target'], $match) === 1) {
$version = ContentElementVersion::query()->with('element.editorialContentKind')->find($match[1]);
if ($version instanceof ContentElementVersion) {
$row['playback'] = app(ContentPreviewController::class)->playback($version);
}
}
$element = $elementId > 0 ? ContentElement::query()->with(['editorialContentKind', 'pillars'])->find($elementId) : null;
if ($element instanceof ContentElement) {
$row['visibility'] = app(PublicMaterialReader::class)->visibilityNote($element);
$row['released'] = $element->website_released_at !== null;
$row['output_label'] = PublicMaterialReader::outputLabel((string) $element->output_class);
$row['pillars'] = $element->pillars->pluck('name')->all();
$row['material'] = $element->editorialContentKind?->label;
$row['usage'] = app(CatalogReading::class)->elementUsage($element);
}
return $row;
}
/**
* @return list<array{target: string, label: string, current: bool}>
*/
public function pickerVersions(): array
{
$detail = $this->pickerDetail();
if ($detail === null) {
return [];
}
$options = app(EditorialCatalog::class)->alternatives((string) ($detail['identity'] ?? ''), $this->pickerExceptId());
if ($options === []) {
return [];
}
$current = $options[array_key_last($options)]['target'];
return array_map(fn (array $option): array => $option + ['current' => $option['target'] === $current], $options);
}
protected function pickerExceptId(): int
{
return 0;
}
protected function resetPicker(string $purpose): void
{
$this->pickerPurpose = $purpose;
$this->pickerOpen = true;
$this->pickerQuery = '';
$this->pickerDimension = '';
$this->pickerSaeule = '';
$this->pickerMaterialart = '';
$this->pickerInspected = '';
$this->pickerSelected = '';
$this->pickerMarked = [];
$this->replacingKey = null;
$this->bindToVersion = false;
}
/**
* Fachliche Materialarten, nach denen der Picker Medien eingrenzen kann (Kontext Medium).
*
* @return array<string, string>
*/
public function pickerMaterialarten(): array
{
return app(EditorialVocabulary::class)->kindFilterOptions('medium', $this->pickerMaterialart);
}
/**
* @param array{items: list<array<string, mixed>>, more: bool} $result
* @return array{items: list<array<string, mixed>>, more: bool}
*/
private function filterByMaterialart(array $result): array
{
if (! ctype_digit($this->pickerMaterialart)) {
return $result;
}
$ids = array_values(array_filter(array_map(fn (array $item): int => (int) ($item['element_id'] ?? 0), $result['items'])));
$passend = ContentElement::query()->whereKey($ids)->where('editorial_content_kind_id', (int) $this->pickerMaterialart)->pluck('id')->map(fn ($id): int => (int) $id)->all();
$result['items'] = array_values(array_filter($result['items'], fn (array $item): bool => in_array((int) ($item['element_id'] ?? 0), $passend, true)));
return $result;
}
/**
* Säulen für den Picker-Filter, in der Reihenfolge der Säulenverwaltung.
*
* @return array<string, string>
*/
public function pickerSaeulen(): array
{
return Pillar::query()->orderBy('sort_order')->orderBy('name')->pluck('name', 'id')
->mapWithKeys(fn (string $name, int|string $id): array => [(string) $id => $name])->all();
}
/**
* Einordnungsfilter des Pickers: dieselbe Filterregel wie Medien- und Kompositionslisten (verwendete inaktive Werte
* bleiben auffindbar, ein gewählter Filter bleibt sichtbar).
*
* @return list<array{label: string, values: list<array{id: int, label: string}>}>
*/
public function pickerDimensionGroups(): array
{
return app(EditorialVocabulary::class)->dimensionFilterGroups(ctype_digit($this->pickerDimension) ? [(int) $this->pickerDimension] : []);
}
}
@@ -0,0 +1,132 @@
<?php
namespace App\Filament\Support;
use App\Domain\Catalog\ContentElement;
use App\Domain\Cms\Widgets\Support\WebsiteImage;
use Filament\Notifications\Notification;
/**
* Bildauswahl im CMS über den gemeinsamen visuellen Picker (Dokument 14 §9) statt einer eigenen Auswahlliste.
* Ein Bildfeld (filament.cms.bild-feld) öffnet den Picker mit seinem Formularpfad; „Bild übernehmen“ schreibt die
* Kennung des Mediums in genau dieses Feld, auch im geöffneten Bausteindialog. Gespeichert wird weiterhin nur mit dem
* Seitenentwurf. Die Auswahl gibt kein Bild für die Website frei.
*/
trait ChoosesWebsiteImages
{
use ChoosesMedia;
/** Formularpfad des Bildfelds, in das die Auswahl übernommen wird. */
public ?string $bildZiel = null;
public function openWebsiteImagePicker(string $pfad): void
{
if (preg_match('/^(data|mountedActions\.\d+\.data)(\.[A-Za-z0-9_-]+)+$/', $pfad) !== 1) {
return;
}
$this->resetPicker('website-bild');
$this->pickerKind = 'bild';
$this->bildZiel = $pfad;
$this->forceRenderForPicker();
}
/**
* Filament rendert bei offenen Aktionsdialogen nur den Dialogteil neu; der Picker liegt darüber und braucht die
* ganze Seite.
*/
public function hydrateChoosesWebsiteImages(): void
{
if ($this->pickerOpen) {
$this->forceRenderForPicker();
}
}
public function pickerAllowsMany(): bool
{
return false;
}
public function closePicker(): void
{
$this->pickerOpen = false;
$this->pickerSelected = '';
$this->pickerInspected = '';
$this->pickerMarked = [];
$this->bildZiel = null;
$this->forceRenderForPicker();
}
public function confirmPicker(): void
{
$target = array_key_first($this->pickerMarked);
$ziel = $this->bildZiel;
if ($target === null || $ziel === null) {
return;
}
$row = app(EditorialCatalog::class)->rowForTarget((string) $target, 0, allowDraft: true);
$element = isset($row['element_id']) ? ContentElement::query()->find((int) $row['element_id']) : null;
if (! $element instanceof ContentElement || ! WebsiteImage::isSelectable($element)) {
Notification::make()->danger()->title('Dieses Medium kann nicht als Website-Bild gewählt werden.')->send();
return;
}
data_set($this, $ziel, $element->id);
$this->closePicker();
}
/**
* @return array<string, string>
*/
public function pickerKinds(): array
{
return ['bild' => 'Bilder'];
}
public function pickerTitle(): string
{
return 'Bild aus dem Medienmanager';
}
public function pickerConfirmLabel(): string
{
return 'Bild übernehmen';
}
/**
* @return array{art: string, titel: string}
*/
public function pickerKontext(): array
{
$pfad = property_exists($this, 'record') && is_object($this->record ?? null) ? (string) ($this->record->path ?? '') : '';
return ['art' => 'die Seite', 'titel' => $pfad !== '' ? $pfad : 'neue Seite'];
}
/**
* @return array<string, string>
*/
public function presentationRoleOptions(): array
{
return [];
}
/**
* @return array<string, mixed>|null
*/
public function pickerReplacing(): ?array
{
return null;
}
private function forceRenderForPicker(): void
{
if (method_exists($this, 'forceRender')) {
$this->forceRender();
}
}
}
+56 -15
View File
@@ -272,7 +272,7 @@ public function search(string $query, string $scope, int $exceptCompositionId):
/** /**
* @return array{items: list<array<string, string|null>>, more: bool} * @return array{items: list<array<string, string|null>>, more: bool}
*/ */
public function browse(string $query, string $kind, string $dimension, int $exceptCompositionId, bool $elementsOnly = false): array public function browse(string $query, string $kind, string $dimension, int $exceptCompositionId, bool $elementsOnly = false, int $pillarId = 0): array
{ {
$query = trim($query); $query = trim($query);
$like = '%'.str_replace(['%', '_'], ['', ''], $query).'%'; $like = '%'.str_replace(['%', '_'], ['', ''], $query).'%';
@@ -284,8 +284,8 @@ public function browse(string $query, string $kind, string $dimension, int $exce
$latestElements = ContentElementVersion::query() $latestElements = ContentElementVersion::query()
->selectRaw('MAX(id)') ->selectRaw('MAX(id)')
->whereIn('status', [ContentVersionStatus::Bereit, ContentVersionStatus::Entwurf]) ->whereIn('status', [ContentVersionStatus::Bereit, ContentVersionStatus::Entwurf])
->whereHas('element', function ($builder) use ($query, $like, $kind, $dimensionId): void { ->whereHas('element', function ($builder) use ($query, $like, $kind, $dimensionId, $pillarId): void {
$this->constrainElement($builder, $query, $like, $kind, $dimensionId); $this->constrainElement($builder, $query, $like, $kind, $dimensionId, $pillarId);
}) })
->groupBy('content_element_id'); ->groupBy('content_element_id');
$elements = ContentElementVersion::query() $elements = ContentElementVersion::query()
@@ -309,7 +309,7 @@ public function browse(string $query, string $kind, string $dimension, int $exce
->selectRaw('MAX(id)') ->selectRaw('MAX(id)')
->where('status', ContentVersionStatus::Bereit) ->where('status', ContentVersionStatus::Bereit)
->where('composition_id', '!=', $exceptCompositionId) ->where('composition_id', '!=', $exceptCompositionId)
->whereHas('composition', function ($builder) use ($query, $like, $kind, $dimensionId): void { ->whereHas('composition', function ($builder) use ($query, $like, $kind, $dimensionId, $pillarId): void {
if ($kind === 'modul') { if ($kind === 'modul') {
$builder->where('kind', CompositionKind::Uebung); $builder->where('kind', CompositionKind::Uebung);
} }
@@ -318,6 +318,10 @@ public function browse(string $query, string $kind, string $dimension, int $exce
$builder->whereIn('id', $this->dimensionSubjectIds(Composition::class, $dimensionId)); $builder->whereIn('id', $this->dimensionSubjectIds(Composition::class, $dimensionId));
} }
if ($pillarId > 0) {
$builder->whereIn('id', $this->pillarSubjectIds(Composition::class, $pillarId));
}
if ($query === '') { if ($query === '') {
return; return;
} }
@@ -370,6 +374,10 @@ public function browse(string $query, string $kind, string $dimension, int $exce
continue; continue;
} }
if ($pillarId > 0 && ! in_array($composition->id, $this->pillarSubjectIds(Composition::class, $pillarId), true)) {
continue;
}
$title = $this->compositionTitle($composition); $title = $this->compositionTitle($composition);
if ($query !== '' && ! str_contains(mb_strtolower($title.' '.(string) ($composition->summary ?? '')), mb_strtolower($query))) { if ($query !== '' && ! str_contains(mb_strtolower($title.' '.(string) ($composition->summary ?? '')), mb_strtolower($query))) {
@@ -398,9 +406,21 @@ public function browse(string $query, string $kind, string $dimension, int $exce
* *
* @return array{items: list<array<string, string|null>>, more: bool} * @return array{items: list<array<string, string|null>>, more: bool}
*/ */
public function presentationBrowse(string $query): array public function presentationBrowse(string $query, string $kind = 'alle'): array
{ {
$catalog = $this->browse($query, 'alle', '', 0, elementsOnly: true); $catalog = $this->browse($query, $kind, '', 0, elementsOnly: true);
$outputs = match ($kind) {
'bild' => ['bild'],
'film' => ['film'],
'audio' => ['audio'],
'dokument' => [],
default => ['bild', 'film', 'audio'],
};
// Reine Texte sind Lehrinhalt oder Beschreibung, keine Präsentationsmedien.
$catalog['items'] = array_values(array_filter(
$catalog['items'],
fn (array $item): bool => ($item['output'] ?? '') !== 'text',
));
$seen = []; $seen = [];
foreach ($catalog['items'] as $item) { foreach ($catalog['items'] as $item) {
@@ -413,7 +433,7 @@ public function presentationBrowse(string $query): array
$like = '%'.str_replace(['%', '_'], ['', ''], $query).'%'; $like = '%'.str_replace(['%', '_'], ['', ''], $query).'%';
$elements = ContentElement::query() $elements = ContentElement::query()
->with('editorialContentKind') ->with('editorialContentKind')
->whereIn('output_class', ['bild', 'film', 'audio']) ->whereIn('output_class', $outputs)
->whereNull('archived_at') ->whereNull('archived_at')
->whereDoesntHave('versions') ->whereDoesntHave('versions')
->where(function ($builder): void { ->where(function ($builder): void {
@@ -552,12 +572,13 @@ private function withVisibility(array $rows): array
/** /**
* @param Builder<ContentElement> $builder * @param Builder<ContentElement> $builder
*/ */
private function constrainElement($builder, string $query, string $like, string $kind, int $dimensionId): void private function constrainElement($builder, string $query, string $like, string $kind, int $dimensionId, int $pillarId = 0): void
{ {
$outputs = match ($kind) { $outputs = match ($kind) {
'film' => ['film'], 'film' => ['film'],
'text' => ['text'], 'text' => ['text'],
'bild' => ['bild'], 'bild' => ['bild'],
'audio' => ['audio'],
'dokument' => ['pdf', 'document'], 'dokument' => ['pdf', 'document'],
default => null, default => null,
}; };
@@ -570,6 +591,10 @@ private function constrainElement($builder, string $query, string $like, string
$builder->whereIn('id', $this->dimensionSubjectIds(ContentElement::class, $dimensionId)); $builder->whereIn('id', $this->dimensionSubjectIds(ContentElement::class, $dimensionId));
} }
if ($pillarId > 0) {
$builder->whereIn('id', $this->pillarSubjectIds(ContentElement::class, $pillarId));
}
if ($query === '') { if ($query === '') {
return; return;
} }
@@ -584,6 +609,22 @@ private function constrainElement($builder, string $query, string $like, string
}); });
} }
/**
* Direkt einer Säule zugeordnete Medien oder Module und Programme (zentrale Säulenverwaltung).
*
* @param class-string<Model> $class
* @return list<int>
*/
private function pillarSubjectIds(string $class, int $pillarId): array
{
[$table, $column] = $class === Composition::class
? ['composition_pillar', 'composition_id']
: ['content_element_pillar', 'content_element_id'];
return DB::table($table)->where('pillar_id', $pillarId)->pluck($column)
->map(fn (mixed $id): int => (int) $id)->all();
}
/** /**
* @param class-string<Model> $class * @param class-string<Model> $class
* @return list<int> * @return list<int>
@@ -748,13 +789,13 @@ public function statusChips(Composition $composition, bool $offered): array
$chips[] = ['label' => 'Entwurf offen', 'tone' => 'yellow']; $chips[] = ['label' => 'Entwurf offen', 'tone' => 'yellow'];
} }
$chips[] = $stand['released_number'] !== null // Zeigt die Bibliothek eine ältere Fassung, nennt der Chip sie; „In der Mitgliederbibliothek“ neben
? ['label' => 'In der Mitgliederbibliothek', 'tone' => 'pine'] // „Fassung 2“ läse sich sonst, als wäre Fassung 2 sichtbar.
: ['label' => 'Nicht in der Mitgliederbibliothek', 'tone' => 'quiet']; $chips[] = match (true) {
$stand['released_number'] === null => ['label' => 'Nicht in der Mitgliederbibliothek', 'tone' => 'quiet'],
if ($stand['released_number'] !== null && $stand['released_number'] !== $stand['number']) { $stand['released_number'] === $stand['number'] => ['label' => 'In der Mitgliederbibliothek', 'tone' => 'pine'],
$chips[] = ['label' => 'Bibliothek zeigt Fassung '.$stand['released_number'], 'tone' => 'pine']; default => ['label' => 'Bibliothek zeigt Fassung '.$stand['released_number'], 'tone' => 'pine'],
} };
} }
$chips[] = ['label' => 'Nicht auf der Website', 'tone' => 'quiet']; $chips[] = ['label' => 'Nicht auf der Website', 'tone' => 'quiet'];
+95
View File
@@ -0,0 +1,95 @@
<?php
namespace App\Filament\Support;
use Filament\Schemas\Components\View;
use Filament\Schemas\Schema;
use Filament\Support\Enums\Width;
use Livewire\Attributes\Url;
/**
* Kataloglisten (Lizenzartikel, Pakete, Rechteprofile, Angebote) in der gemeinsamen Bestandsliste. Die Seite liefert
* Zeilen mit 'suchtext' und 'zustand' (Liste von Zustandsschlüsseln) sowie die Zustandsoptionen.
*/
trait ListsCatalog
{
use ShowsBestand;
#[Url(as: 'suche', except: '')]
public string $suche = '';
#[Url(as: 'zustand', except: 'alle')]
public string $zustand = 'alle';
/**
* @return list<array<string, mixed>>
*/
abstract protected function catalogRows(): array;
/**
* @return array<string, string> Zustandsschlüssel => Bezeichnung, beginnend mit 'alle'
*/
abstract protected function zustandOptionen(): array;
/**
* @return array{0: string, 1: string}
*/
abstract protected function einheit(): array;
/**
* @return array{titel: string, text: string}
*/
abstract protected function leer(): array;
protected function bestandFilterEigenschaften(): array
{
return ['suche', 'zustand'];
}
protected function suchPlatzhalter(): string
{
return 'Name oder Beschreibung';
}
public function getMaxContentWidth(): Width|string|null
{
return Width::Full;
}
public function content(Schema $schema): Schema
{
return $schema->components([View::make('filament.verwaltung.bestand')]);
}
public function resetFilters(): void
{
$this->suche = '';
$this->zustand = 'alle';
$this->bestandGrenze = Bestand::SCHRITT;
}
/**
* @return array<string, mixed>
*/
public function bestand(): array
{
$needle = mb_strtolower(trim($this->suche));
$rows = array_values(array_filter($this->catalogRows(), function (array $row) use ($needle): bool {
if ($this->zustand !== 'alle' && ! in_array($this->zustand, $row['zustand'] ?? [], true)) {
return false;
}
return $needle === '' || str_contains(mb_strtolower(implode(' ', array_filter([
$row['titel'], $row['meta'] ?? '', $row['text'] ?? '', $row['suchtext'] ?? '',
]))), $needle);
}));
return [
'suche' => ['eigenschaft' => 'suche', 'label' => 'Suche', 'platzhalter' => $this->suchPlatzhalter()],
'filter' => [['eigenschaft' => 'zustand', 'label' => 'Zustand', 'vorgabe' => 'alle', 'optionen' => $this->zustandOptionen()]],
'zeilen' => $rows,
'einheit' => $this->einheit(),
'leer' => $this->leer(),
];
}
}
+327
View File
@@ -0,0 +1,327 @@
<?php
namespace App\Filament\Support;
use App\Domain\Catalog\Composition;
use App\Domain\Catalog\CompositionKind;
use App\Domain\Catalog\ContentVersionStatus;
use App\Domain\Catalog\EditorialVocabulary;
use App\Domain\Catalog\IdentityDimensionValue;
use App\Domain\Catalog\Pillar;
use App\Domain\Catalog\PillarFilterCompat;
use App\Filament\Resources\ContentElements\ContentElementResource;
use Filament\Actions\Action;
use Filament\Forms\Components\TextInput;
use Illuminate\Support\Facades\DB;
use Livewire\Attributes\Url;
/**
* Eine Liste für Programme und Module (Arbeitsplatz, „Module“, „Programme“): dieselben Zeilen, Filter und derselbe
* Anlegedialog. Seiten mit festem Typ setzen fixedKind(); der Arbeitsplatz zeigt beide Arten mit Umschalter.
*/
trait ListsCompositions
{
use ShowsBestand;
#[Url]
public string $query = '';
#[Url]
public string $kindFilter = 'alle';
#[Url]
public string $pillar = '';
/** Fachliche Säule (zentrale Säulenverwaltung), direkt zugeordnet. */
#[Url(as: 'saeule', except: '')]
public string $saeule = '';
#[Url]
public string $visibility = 'alle';
protected function fixedKind(): ?CompositionKind
{
return null;
}
protected function bestandFilterEigenschaften(): array
{
return ['query', 'kindFilter', 'pillar', 'saeule', 'visibility'];
}
public function resetFilters(): void
{
$this->query = '';
$this->kindFilter = 'alle';
$this->pillar = '';
$this->saeule = '';
$this->visibility = 'alle';
$this->bestandGrenze = Bestand::SCHRITT;
}
public function hasActiveFilters(): bool
{
return trim($this->query) !== '' || $this->kindFilter !== 'alle' || $this->pillar !== '' || $this->saeule !== '' || $this->visibility !== 'alle';
}
/**
* @return array<string, mixed>
*/
public function bestand(): array
{
$this->normalizeLegacyPillarFilter();
$fixed = $this->fixedKind();
$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 = [];
foreach ($this->dimensionFilters() as $gruppe) {
$optionen = [];
foreach ($gruppe['values'] as $value) {
$optionen[(string) $value['id']] = $value['label'];
}
$gruppen[] = ['label' => $gruppe['label'], 'optionen' => $optionen];
}
return [
'suche' => ['eigenschaft' => 'query', 'label' => 'Suche', 'platzhalter' => 'Titel oder Kurzbeschreibung'],
'segmente' => $fixed === null ? [[
'eigenschaft' => 'kindFilter', 'label' => 'Art', 'vorgabe' => 'alle',
'optionen' => ['alle' => 'Alle', 'programm' => 'Programme', 'modul' => 'Module'],
]] : [],
'filter' => [[
'eigenschaft' => 'visibility', 'label' => 'Stand', 'vorgabe' => 'alle',
'optionen' => ['alle' => 'Jeder Stand', 'bibliothek' => 'In der Mitgliederbibliothek', 'verborgen' => 'Nicht in der Mitgliederbibliothek', 'entwurf' => 'Noch ohne Fassung'],
]],
'weitere' => [
...($this->pillarOptions() === [] ? [] : [[
'eigenschaft' => 'saeule', 'label' => 'Fachliche Säule', 'vorgabe' => '', 'alle' => 'Alle Säulen', 'optionen' => $this->pillarOptions(),
]]),
...($gruppen === [] ? [] : [[
'eigenschaft' => 'pillar', 'label' => 'Fachliche Einordnung', 'vorgabe' => '', 'alle' => 'Alle Einordnungen', 'gruppen' => $gruppen,
]]),
],
'zeilen' => $this->entries(),
'einheit' => $einheit,
'leer' => [
'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.',
],
];
}
/**
* @return list<array{label: string, values: list<array{id: int, label: string}>}>
*/
public function dimensionFilters(): array
{
return app(EditorialVocabulary::class)->dimensionFilterGroups(ctype_digit($this->pillar) ? [(int) $this->pillar] : []);
}
/**
* Zeilen der gemeinsamen Bestandsliste.
*
* @return list<array<string, mixed>>
*/
public function entries(): array
{
$needle = mb_strtolower(trim($this->query));
$catalog = app(EditorialCatalog::class);
$offered = $catalog->offeredCompositionIds();
$this->normalizeLegacyPillarFilter();
$pillarIds = $this->pillar === '' ? null : $this->pillarSubjects((int) $this->pillar);
$saeuleIds = ctype_digit($this->saeule) && $this->saeule !== '' ? $this->saeuleSubjects((int) $this->saeule) : null;
$fixed = $this->fixedKind();
$kinds = $fixed !== null ? [$fixed] : match ($this->kindFilter) {
'programm' => [CompositionKind::Kurs],
'modul' => [CompositionKind::Uebung],
default => [CompositionKind::Kurs, CompositionKind::Uebung],
};
$canEdit = ContentElementResource::editor();
$rows = [];
$compositions = Composition::query()
->whereIn('kind', $kinds)
->with(['editorialContentKind', 'versions.members.contentElementVersion.element'])
->orderBy('designation')
->get();
foreach ($compositions as $composition) {
$kind = $composition->kind instanceof CompositionKind
? $composition->kind
: CompositionKind::from((string) $composition->kind);
if ($pillarIds !== null && ! in_array($composition->id, $pillarIds, true)) {
continue;
}
if ($saeuleIds !== null && ! in_array($composition->id, $saeuleIds, true)) {
continue;
}
$stand = $catalog->stand($composition);
if (! $this->matchesVisibility($stand)) {
continue;
}
$title = $catalog->compositionTitle($composition);
$summary = trim((string) ($composition->summary ?? ''));
$haystack = mb_strtolower($title.' '.$composition->designation.' '.$summary.' '.(string) $composition->description);
if ($needle !== '' && ! str_contains($haystack, $needle)) {
continue;
}
$cover = $catalog->cover($composition, $this->coverMembers($composition));
$url = EditorialCatalog::editUrl($composition);
$rows[] = [
'schluessel' => 'c'.$composition->id,
'titel' => $title,
'meta' => $kind->deskLabel().($title !== $composition->designation ? ' · '.$composition->designation : ''),
'text' => $summary,
'bild' => $cover['url'],
'bildFehlt' => 'Kein Titelbild',
'hinweise' => filled($cover['note']) ? ['Bild: '.$cover['note']] : [],
'symbol' => 'modul',
'url' => $url,
'chips' => array_map(fn (array $chip): array => [
'label' => $chip['label'],
'ton' => match ($chip['tone']) {
'pine' => 'gut',
'yellow' => 'offen',
'quiet' => 'leise',
default => 'neutral',
},
], $catalog->statusChips($composition, in_array($composition->id, $offered, true))),
'aktionen' => array_values(array_filter([
['label' => 'Aufbau', 'href' => $url, 'icon' => 'modul'],
$canEdit ? ['label' => 'Redaktion', 'href' => $url.'?redaktion=1', 'icon' => 'stift'] : null,
])),
];
}
return $rows;
}
/**
* Anlegedialog für Module und Programme; derselbe auf dem Arbeitsplatz und in den Listen.
*/
protected function createCompositionAction(CompositionKind $kind): Action
{
$label = $kind === CompositionKind::Kurs ? 'Programm' : 'Modul';
return Action::make($kind === CompositionKind::Kurs ? 'createProgram' : 'createModule')
->label($label.' anlegen')
->modalHeading('Neues '.$label)
->modalDescription('Der Name genügt. Danach öffnet sich der Aufbau; Texte, Bilder und Einordnung folgen dort und in der Redaktion.')
->modalSubmitActionLabel($label.' anlegen')
->modalWidth('lg')
->visible(fn (): bool => ContentElementResource::editor())
->schema([
TextInput::make('designation')->label('Name')->required()->maxLength(255),
])
->action(function (array $data) use ($kind): void {
abort_unless(ContentElementResource::editor(), 403);
$composition = app(EditorialCatalog::class)->create(trim((string) $data['designation']), $kind);
$this->redirect(EditorialCatalog::editUrl($composition), navigate: false);
});
}
/**
* @return list<array{target: string}>
*/
private function coverMembers(Composition $composition): array
{
$draft = $composition->working_draft;
if (is_array($draft) && is_array($draft['members'] ?? null) && $draft['members'] !== []) {
return $draft['members'];
}
$version = $composition->versions
->filter(fn ($item): bool => $item->status === ContentVersionStatus::Bereit)
->sortByDesc('number')
->first();
if ($version === null) {
return [];
}
$members = [];
foreach ($version->members as $member) {
$members[] = ['target' => $member->content_element_version_id
? 'element:'.$member->content_element_version_id
: 'composition:'.$member->nested_composition_version_id];
}
return $members;
}
/**
* Alte Adressen mit einem Säulenwert der Einordnung (`?pillar=…`) gelten für die zentrale Säule.
*/
private function normalizeLegacyPillarFilter(): void
{
if (ctype_digit($this->pillar) && $this->pillar !== '' && $this->saeule === '' && is_int($pillar = PillarFilterCompat::pillarOfLegacyValue((int) $this->pillar))) {
[$this->saeule, $this->pillar] = [(string) $pillar, ''];
}
}
/**
* @return array<string, string>
*/
private function pillarOptions(): array
{
return Pillar::query()->orderBy('sort_order')->orderBy('name')->pluck('name', 'id')
->mapWithKeys(fn (string $name, int|string $id): array => [(string) $id => $name])->all();
}
/**
* Direkt zugeordnete Module und Programme einer Säule. Die Säulen der enthaltenen Medien zählen hier nicht.
*
* @return list<int>
*/
private function saeuleSubjects(int $pillarId): array
{
return DB::table('composition_pillar')->where('pillar_id', $pillarId)->pluck('composition_id')
->map(fn (mixed $id): int => (int) $id)->all();
}
/**
* @return list<int>
*/
private function pillarSubjects(int $valueId): array
{
return IdentityDimensionValue::query()
->where('subject_type', (new Composition)->getMorphClass())
->where('editorial_dimension_value_id', $valueId)
->pluck('subject_id')
->map(fn (mixed $id): int => (int) $id)
->all();
}
/**
* @param array{text: string, number: int|null, released_number: int|null} $stand
*/
private function matchesVisibility(array $stand): bool
{
return match ($this->visibility) {
'bibliothek' => $stand['released_number'] !== null,
'verborgen' => $stand['number'] !== null && $stand['released_number'] === null,
'entwurf' => $stand['number'] === null,
default => true,
};
}
}
File diff suppressed because it is too large. Load diff
+19 -9
View File
@@ -8,9 +8,10 @@
use App\Domain\Catalog\ContentElement; use App\Domain\Catalog\ContentElement;
use App\Domain\Catalog\ContentElementVersion; use App\Domain\Catalog\ContentElementVersion;
use App\Domain\Catalog\ContentVersionStatus; use App\Domain\Catalog\ContentVersionStatus;
use App\Domain\Catalog\EditorialDimension; use App\Domain\Catalog\EditorialVocabulary;
use App\Domain\Catalog\IdentityDimensionValue; use App\Domain\Catalog\IdentityDimensionValue;
use App\Domain\Catalog\Pillar; use App\Domain\Catalog\Pillar;
use App\Domain\Catalog\PillarFilterCompat;
use App\Domain\Catalog\ReleaseContent; use App\Domain\Catalog\ReleaseContent;
use App\Domain\Media\ThumbnailRef; use App\Domain\Media\ThumbnailRef;
use App\Filament\Resources\ContentElements\ContentElementResource; use App\Filament\Resources\ContentElements\ContentElementResource;
@@ -50,15 +51,16 @@ public function pillars(): array
/** /**
* @return list<array{id: int, label: string}> * @return list<array{id: int, label: string}>
*/ */
public function classifications(): array public function classifications(array $selectedIds = []): array
{ {
$options = []; $options = [];
foreach (EditorialDimension::query()->with('values')->orderBy('label')->get() as $dimension) { // Gleiche Regel wie Editor und Picker; verwendete inaktive Werte und gewählte Filter bleiben auffindbar.
foreach ($dimension->values->sortBy('label') as $value) { foreach (app(EditorialVocabulary::class)->dimensionFilterGroups($selectedIds) as $dimension) {
foreach ($dimension['values'] as $value) {
$options[] = [ $options[] = [
'id' => $value->id, 'id' => $value['id'],
'label' => $dimension->label.': '.$value->label, 'label' => $dimension['label'].': '.$value['label'],
]; ];
} }
} }
@@ -131,6 +133,13 @@ public function cards(array $filters, bool $canEdit): array
*/ */
private function normalize(array $filters): array private function normalize(array $filters): array
{ {
$saeule = ctype_digit($filters['saeule'] ?? '') ? $filters['saeule'] : '';
$einordnung = ctype_digit($filters['einordnung'] ?? '') ? $filters['einordnung'] : '';
if ($einordnung !== '' && $saeule === '' && is_int($pillar = PillarFilterCompat::pillarOfLegacyValue((int) $einordnung))) {
[$saeule, $einordnung] = [(string) $pillar, ''];
}
return [ return [
'suche' => trim($filters['suche'] ?? ''), 'suche' => trim($filters['suche'] ?? ''),
'art' => $this->choice($filters['art'] ?? '', ['film', 'text', 'document', 'bild', 'audio']), 'art' => $this->choice($filters['art'] ?? '', ['film', 'text', 'document', 'bild', 'audio']),
@@ -138,8 +147,8 @@ private function normalize(array $filters): array
'entwurf' => $this->choice($filters['entwurf'] ?? '', ['offen', 'keiner']), 'entwurf' => $this->choice($filters['entwurf'] ?? '', ['offen', 'keiner']),
'fassung' => $this->choice($filters['fassung'] ?? '', ['mit', 'nur']), 'fassung' => $this->choice($filters['fassung'] ?? '', ['mit', 'nur']),
'nutzung' => $this->choice($filters['nutzung'] ?? '', ['verwendet', 'unbenutzt']), 'nutzung' => $this->choice($filters['nutzung'] ?? '', ['verwendet', 'unbenutzt']),
'saeule' => ctype_digit($filters['saeule'] ?? '') ? $filters['saeule'] : '', 'saeule' => $saeule,
'einordnung' => ctype_digit($filters['einordnung'] ?? '') ? $filters['einordnung'] : '', 'einordnung' => $einordnung,
'inhaltsart' => ctype_digit($filters['inhaltsart'] ?? '') ? $filters['inhaltsart'] : '', 'inhaltsart' => ctype_digit($filters['inhaltsart'] ?? '') ? $filters['inhaltsart'] : '',
'verarbeitung' => $this->choice($filters['verarbeitung'] ?? '', ['fehler', 'uebernahme']), 'verarbeitung' => $this->choice($filters['verarbeitung'] ?? '', ['fehler', 'uebernahme']),
'archiv' => $this->choice($filters['archiv'] ?? '', ['aktiv', 'archiviert', 'alle'], 'aktiv'), 'archiv' => $this->choice($filters['archiv'] ?? '', ['aktiv', 'archiviert', 'alle'], 'aktiv'),
@@ -190,6 +199,7 @@ private function placements(array $versionIds): array
'name' => $this->catalog->compositionTitle($composition), 'name' => $this->catalog->compositionTitle($composition),
'type' => $this->kindLabel($composition), 'type' => $this->kindLabel($composition),
'mediumVersion' => $this->versionLabel($version), 'mediumVersion' => $this->versionLabel($version),
'mediumVersionId' => $version->id,
'hostVersion' => 'Fassung '.$compositionVersion->number, 'hostVersion' => 'Fassung '.$compositionVersion->number,
'url' => EditorialCatalog::editUrl($composition), 'url' => EditorialCatalog::editUrl($composition),
'roles' => [], 'roles' => [],
@@ -503,7 +513,7 @@ private function card(ContentElement $element, array $portrait, array $uses, arr
'usages' => $uses, 'usages' => $uses,
'licenseText' => $this->licenseText($codes), 'licenseText' => $this->licenseText($codes),
'url' => ContentElementResource::getUrl('view', ['record' => $element]), 'url' => ContentElementResource::getUrl('view', ['record' => $element]),
'editUrl' => $canEdit ? ContentElementResource::getUrl('edit', ['record' => $element]) : null, 'editUrl' => $canEdit ? ContentElementResource::getUrl('view', ['record' => $element, 'redaktion' => 1]) : null,
]; ];
} }
+151 -68
View File
@@ -37,7 +37,8 @@ public static function repeater(string $name = 'sections'): Repeater
->label('Abschnitte') ->label('Abschnitte')
->hiddenLabel() ->hiddenLabel()
->schema(self::sectionSchema()) ->schema(self::sectionSchema())
->itemLabel(fn (array $state, ?int $index): string => self::sectionLabel($state, $index)) ->columns(['default' => 1, 'xl' => 2])
->itemLabel(fn (array $state, ?int $index): HtmlString => self::sectionLabel($state, $index))
->addActionLabel('Abschnitt hinzufügen') ->addActionLabel('Abschnitt hinzufügen')
->addBetweenActionLabel('Abschnitt hier einfügen') ->addBetweenActionLabel('Abschnitt hier einfügen')
->defaultItems(0) ->defaultItems(0)
@@ -48,6 +49,7 @@ public static function repeater(string $name = 'sections'): Repeater
->deletable() ->deletable()
->maxItems(PageSections::MAX_SECTIONS) ->maxItems(PageSections::MAX_SECTIONS)
->cloneAction(fn (Action $action): Action => $action ->cloneAction(fn (Action $action): Action => $action
->label('Abschnitt duplizieren')
->tooltip('Abschnitt duplizieren') ->tooltip('Abschnitt duplizieren')
->action(function (array $arguments, Repeater $component): void { ->action(function (array $arguments, Repeater $component): void {
// Die Kopie steht direkt hinter dem Original (Filament hängt sie sonst ans Seitenende). // Die Kopie steht direkt hinter dem Original (Filament hängt sie sonst ans Seitenende).
@@ -56,16 +58,28 @@ public static function repeater(string $name = 'sections'): Repeater
$component->shouldPartiallyRenderAfterActionsCalled() ? $component->partiallyRender() : null; $component->shouldPartiallyRenderAfterActionsCalled() ? $component->partiallyRender() : null;
})) }))
->deleteAction(fn (Action $action): Action => $action ->deleteAction(fn (Action $action): Action => $action
->label('Abschnitt löschen')
->tooltip('Abschnitt löschen') ->tooltip('Abschnitt löschen')
->requiresConfirmation() ->requiresConfirmation()
->modalHeading('Abschnitt löschen?') ->modalHeading('Abschnitt löschen?')
->modalDescription('Der Abschnitt und die Widgets darin werden aus dem Entwurf entfernt. Bereits gespeicherte Revisionen bleiben erhalten.') ->modalDescription('Der Abschnitt und die Widgets darin werden aus dem Entwurf entfernt. Bereits gespeicherte Revisionen bleiben erhalten.')
->modalSubmitActionLabel('Löschen')) ->modalSubmitActionLabel('Löschen'))
->moveUpAction(fn (Action $action): Action => $action->tooltip('Abschnitt nach oben')) ->moveUpAction(fn (Action $action): Action => $action->label('Abschnitt nach oben')->tooltip('Abschnitt nach oben'))
->moveDownAction(fn (Action $action): Action => $action->tooltip('Abschnitt nach unten')) ->moveDownAction(fn (Action $action): Action => $action->label('Abschnitt nach unten')->tooltip('Abschnitt nach unten'))
->reorderAction(fn (Action $action): Action => $action->tooltip('Abschnitt ziehen')) ->reorderAction(fn (Action $action): Action => $action->label('Abschnitt ziehen')->tooltip('Abschnitt ziehen'))
->collapseAction(fn (Action $action): Action => $action->tooltip('Abschnitt einklappen')) ->extraItemActions([
->expandAction(fn (Action $action): Action => $action->tooltip('Abschnitt aufklappen')) // Seiten-Arbeitsplatz (EditPage): Raster und Gestaltung im eigenen Kontext statt an jedem Abschnitt.
Action::make('gestalten')
->label('Abschnitt gestalten')
->icon('heroicon-o-swatch')
->button()
->size('sm')
->color('gray')
->visible(fn ($livewire): bool => is_object($livewire) && method_exists($livewire, 'openAbschnitt'))
->action(fn (array $arguments, Repeater $component) => $component->getLivewire()->openAbschnitt((string) $arguments['item'])),
])
->collapseAction(fn (Action $action): Action => $action->label('Abschnitt einklappen')->tooltip('Abschnitt einklappen'))
->expandAction(fn (Action $action): Action => $action->label('Abschnitt aufklappen')->tooltip('Abschnitt aufklappen'))
->extraAttributes(['class' => 'luf-sections']) ->extraAttributes(['class' => 'luf-sections'])
->columnSpanFull(); ->columnSpanFull();
} }
@@ -77,33 +91,50 @@ private static function sectionSchema(): array
{ {
return [ return [
Hidden::make('id'), Hidden::make('id'),
ToggleButtons::make('layout') // Abschnittsgestaltung in drei Gruppen. Im Seiten-Arbeitsplatz nur im Kontext „Abschnitt gestalten“
->label('Raster') // sichtbar und dort offen; beim Anlegen einer Seite an jedem Abschnitt, eingeklappt.
->options(self::layoutOptions()) Section::make('Raster und Breite')
->default(SectionLayouts::DEFAULT) ->columnSpanFull()
->required() ->extraAttributes(['class' => 'luf-nur-gestalten luf-gestaltung'])
->inline() ->collapsible(fn ($livewire): bool => ! self::onWorkplace($livewire))
->live() ->collapsed(fn ($livewire): bool => ! self::onWorkplace($livewire))
->disableOptionWhen(fn (string $value, Get $get): bool => self::filledCount($get('slots')) > SectionLayouts::slotCount($value))
->helperText(fn (Get $get): ?string => self::filledCount($get('slots')) > 1
? 'Raster mit weniger Plätzen als eingesetzten Widgets sind gesperrt. Entfernen oder verschieben Sie zuerst ein Widget; beim Wechsel geht kein Widget verloren.'
: null)
->afterStateUpdated(function (?string $state, Get $get, Set $set): void {
$set('slots', self::arrangeSlots($get('slots'), $state ?? SectionLayouts::DEFAULT));
})
->extraAttributes(['class' => 'luf-layout-picker']),
Section::make('Gestaltung des Abschnitts')
->description(fn (Get $get): string => SectionStyle::summary(is_array($get('style')) ? $get('style') : []))
->icon('heroicon-o-swatch')
->collapsible()
->collapsed()
->compact() ->compact()
->schema([ ->schema([
Group::make(self::styleFields()) ToggleButtons::make('layout')
->statePath('style') ->label('Raster')
->columns(['default' => 1, 'md' => 2, 'xl' => 4]), ->options(self::layoutOptions())
->default(SectionLayouts::DEFAULT)
->required()
->inline()
->live()
->disableOptionWhen(fn (string $value, Get $get): bool => self::filledCount($get('slots')) > SectionLayouts::slotCount($value))
->helperText(fn (Get $get): ?string => self::filledCount($get('slots')) > 1
? 'Raster mit weniger Plätzen als eingesetzten Widgets sind gesperrt. Entfernen oder verschieben Sie zuerst ein Widget; beim Wechsel geht kein Widget verloren.'
: null)
->afterStateUpdated(function (?string $state, Get $get, Set $set): void {
$set('slots', self::arrangeSlots($get('slots'), $state ?? SectionLayouts::DEFAULT));
})
->extraAttributes(['class' => 'luf-layout-picker']),
Group::make([self::widthField()])->statePath('style')->columns(['default' => 1, 'md' => 2]),
]),
Section::make('Hintergrund')
->extraAttributes(['class' => 'luf-nur-gestalten luf-gestaltung'])
->collapsible(fn ($livewire): bool => ! self::onWorkplace($livewire))
->collapsed(fn ($livewire): bool => ! self::onWorkplace($livewire))
->compact()
->schema([
Group::make(self::backgroundFields())->statePath('style')->columns(['default' => 1, 'md' => 2]),
]),
Section::make('Abstände und Trenner')
->extraAttributes(['class' => 'luf-nur-gestalten luf-gestaltung'])
->collapsible(fn ($livewire): bool => ! self::onWorkplace($livewire))
->collapsed(fn ($livewire): bool => ! self::onWorkplace($livewire))
->compact()
->schema([
Group::make(self::spacingFields())->statePath('style')->columns(['default' => 1, 'md' => 2]),
]), ]),
Repeater::make('slots') Repeater::make('slots')
->columnSpanFull()
->label('Plätze im Raster') ->label('Plätze im Raster')
->hiddenLabel() ->hiddenLabel()
->schema([ ->schema([
@@ -113,8 +144,8 @@ private static function sectionSchema(): array
->deletable(false) ->deletable(false)
->reorderableWithDragAndDrop() ->reorderableWithDragAndDrop()
->reorderableWithButtons(false) ->reorderableWithButtons(false)
->reorderAction(fn (Action $action): Action => $action->tooltip('Widget auf einen anderen Platz ziehen')) ->reorderAction(fn (Action $action): Action => $action->label('Baustein auf einen anderen Platz ziehen')->tooltip('Baustein auf einen anderen Platz ziehen'))
->itemLabel(fn (array $state, ?int $index, Get $get): string => self::slotLabel($state, $index, $get('layout'))) ->itemLabel(fn (array $state, ?int $index, Get $get): HtmlString => self::slotLabel($state, $index, $get('layout')))
->default(fn (): array => self::arrangeSlots([], SectionLayouts::DEFAULT)) ->default(fn (): array => self::arrangeSlots([], SectionLayouts::DEFAULT))
->extraAttributes(fn (Get $get): array => [ ->extraAttributes(fn (Get $get): array => [
'class' => 'luf-slots', 'class' => 'luf-slots',
@@ -123,10 +154,27 @@ private static function sectionSchema(): array
]; ];
} }
private static function onWorkplace(mixed $livewire): bool
{
return is_object($livewire) && method_exists($livewire, 'openAbschnitt');
}
private static function widthField(): Select
{
return Select::make('width')
->label('Inhaltsbreite')
->options(SectionStyle::WIDTHS)
->default('standard')
->selectablePlaceholder(false)
->hintIcon('heroicon-o-question-mark-circle', 'Ein Hintergrund reicht immer über die ganze Bildschirmbreite.');
}
/** /**
* Hintergrund; Bild, Ausschnitt und Überlagerung nur beim Hintergrund „Bild“.
*
* @return list<mixed> * @return list<mixed>
*/ */
private static function styleFields(): array private static function backgroundFields(): array
{ {
return [ return [
Select::make('background') Select::make('background')
@@ -135,35 +183,6 @@ private static function styleFields(): array
->default('default') ->default('default')
->selectablePlaceholder(false) ->selectablePlaceholder(false)
->live(), ->live(),
Select::make('width')
->label('Breite')
->options(SectionStyle::WIDTHS)
->default('standard')
->selectablePlaceholder(false)
->helperText('Ein Hintergrund reicht immer über die ganze Bildschirmbreite.'),
Select::make('spacing_top')
->label('Abstand oben')
->options(SectionStyle::SPACINGS)
->default(SectionStyle::DEFAULTS['spacing_top'])
->selectablePlaceholder(false)
->helperText('Vor dem Inhalt. Zwischen zwei Abschnitten addieren sich „unten“ und „oben“; „Kein Abstand“ lässt einen Einstieg direkt unter der Kopfzeile beginnen.'),
Select::make('spacing_bottom')
->label('Abstand unten')
->options(SectionStyle::SPACINGS)
->default(SectionStyle::DEFAULTS['spacing_bottom'])
->selectablePlaceholder(false)
->helperText('Nach dem Inhalt. Bei eigener Fläche liegen beide Abstände innerhalb der Fläche.'),
Select::make('gap')
->label('Widget-Abstand')
->options(SectionStyle::SPACINGS)
->default(SectionStyle::DEFAULTS['gap'])
->selectablePlaceholder(false)
->helperText('Zwischen den Plätzen dieses Abschnitts, nebeneinander und gestapelt. Abstände innerhalb eines Widgets bleiben Sache des Widgets.'),
Select::make('divider')
->label('Trenner zum nächsten Abschnitt')
->options(SectionStyle::DIVIDERS)
->default('none')
->selectablePlaceholder(false),
...array_map( ...array_map(
fn ($field) => $field->visible(fn (Get $get): bool => $get('background') === 'image')->columnSpan(['default' => 1, 'md' => 2]), fn ($field) => $field->visible(fn (Get $get): bool => $get('background') === 'image')->columnSpan(['default' => 1, 'md' => 2]),
ImageRefFields::fields('Hintergrundbild'), ImageRefFields::fields('Hintergrundbild'),
@@ -173,18 +192,50 @@ private static function styleFields(): array
->options(SectionStyle::FOCUS) ->options(SectionStyle::FOCUS)
->default('center') ->default('center')
->selectablePlaceholder(false) ->selectablePlaceholder(false)
->helperText('Dieser Bereich bleibt auf schmalen Bildschirmen sichtbar.') ->hintIcon('heroicon-o-question-mark-circle', 'Dieser Bereich bleibt auf schmalen Bildschirmen sichtbar.')
->visible(fn (Get $get): bool => $get('background') === 'image'), ->visible(fn (Get $get): bool => $get('background') === 'image'),
Select::make('overlay') Select::make('overlay')
->label('Überlagerung') ->label('Überlagerung')
->options(SectionStyle::OVERLAYS) ->options(SectionStyle::OVERLAYS)
->default('light') ->default('light')
->selectablePlaceholder(false) ->selectablePlaceholder(false)
->helperText('Sorgt für lesbaren Text auf dem Bild.') ->hintIcon('heroicon-o-question-mark-circle', 'Sorgt für lesbaren Text auf dem Bild.')
->visible(fn (Get $get): bool => $get('background') === 'image'), ->visible(fn (Get $get): bool => $get('background') === 'image'),
]; ];
} }
/**
* @return list<mixed>
*/
private static function spacingFields(): array
{
return [
Select::make('spacing_top')
->label('Abstand oben')
->options(SectionStyle::SPACINGS)
->default(SectionStyle::DEFAULTS['spacing_top'])
->selectablePlaceholder(false)
->hintIcon('heroicon-o-question-mark-circle', 'Vor dem Inhalt. Zwischen zwei Abschnitten addieren sich „unten“ und „oben“; „Kein Abstand“ lässt einen Einstieg direkt unter der Kopfzeile beginnen.'),
Select::make('spacing_bottom')
->label('Abstand unten')
->options(SectionStyle::SPACINGS)
->default(SectionStyle::DEFAULTS['spacing_bottom'])
->selectablePlaceholder(false)
->hintIcon('heroicon-o-question-mark-circle', 'Nach dem Inhalt. Bei eigener Fläche liegen beide Abstände innerhalb der Fläche.'),
Select::make('gap')
->label('Widget-Abstand')
->options(SectionStyle::SPACINGS)
->default(SectionStyle::DEFAULTS['gap'])
->selectablePlaceholder(false)
->hintIcon('heroicon-o-question-mark-circle', 'Zwischen den Plätzen dieses Abschnitts, nebeneinander und gestapelt. Abstände innerhalb eines Widgets bleiben Sache des Widgets.'),
Select::make('divider')
->label('Trenner zum nächsten Abschnitt')
->options(SectionStyle::DIVIDERS)
->default('none')
->selectablePlaceholder(false),
];
}
/** /**
* Gespeicherte Abschnitte (PageSections::read) als Formularzustand. * Gespeicherte Abschnitte (PageSections::read) als Formularzustand.
* *
@@ -481,7 +532,7 @@ private static function editorColumns(mixed $layout): string
/** /**
* @param array<string, mixed> $state * @param array<string, mixed> $state
*/ */
private static function sectionLabel(array $state, ?int $index): string private static function sectionLabel(array $state, ?int $index): HtmlString
{ {
$layout = SectionLayouts::has($state['layout'] ?? null) ? $state['layout'] : SectionLayouts::DEFAULT; $layout = SectionLayouts::has($state['layout'] ?? null) ? $state['layout'] : SectionLayouts::DEFAULT;
$registry = app(WidgetRegistry::class); $registry = app(WidgetRegistry::class);
@@ -495,16 +546,48 @@ private static function sectionLabel(array $state, ?int $index): string
} }
} }
$label = 'Abschnitt '.(($index ?? 0) + 1).' · Raster '.SectionLayouts::short($layout) // Kurz sichtbar: Nummer, Raster und nur abweichende Gestaltung. Vollständig im Titel und für Screenreader.
.' · '.SectionStyle::summary(is_array($state['style'] ?? null) ? $state['style'] : []); $style = SectionStyle::fromStored(is_array($state['style'] ?? null) ? $state['style'] : []);
$meta = ['Raster '.SectionLayouts::short($layout)];
if ($style['background'] !== 'default') {
$meta[] = SectionStyle::BACKGROUNDS[$style['background']] ?? $style['background'];
}
if ($style['width'] !== 'standard') {
$meta[] = SectionStyle::WIDTHS[$style['width']] ?? $style['width'];
}
if ($style['divider'] !== 'none') {
$meta[] = 'Trenner';
}
if ($names === []) {
$meta[] = 'noch leer';
}
return $names === [] ? $label.' · noch leer' : $label.' · '.implode(', ', $names); $name = 'Abschnitt '.(($index ?? 0) + 1);
$full = 'Raster '.SectionLayouts::short($layout).' · '.SectionStyle::summary($style)
.($names === [] ? ' · noch leer' : ' · '.implode(', ', $names));
return new HtmlString('<span class="luf-abschnitt" title="'.e($full).'"><span class="luf-abschnitt-nr">'.e($name).'</span>'
.'<span class="luf-abschnitt-meta" aria-hidden="true">'.e(implode(' · ', $meta)).'</span>'
.'<span class="vw-sr">: '.e($full).'</span></span>');
} }
/** /**
* @param array<string, mixed> $state * @param array<string, mixed> $state
*/ */
private static function slotLabel(array $state, ?int $index, mixed $layout): string private static function slotLabel(array $state, ?int $index, mixed $layout): HtmlString
{
$text = self::slotText($state, $index, $layout);
// Plätze zeigen sich über Lage und Breite; benannt werden sie nur für Screenreader oder bei einem Problem.
return str_contains($text, 'passt nicht') || str_contains($text, 'außerhalb')
? new HtmlString('<span class="luf-platz-warnung">'.e($text).'</span>')
: new HtmlString('<span class="vw-sr">'.e($text).'</span>');
}
/**
* @param array<string, mixed> $state
*/
private static function slotText(array $state, ?int $index, mixed $layout): string
{ {
$layout = SectionLayouts::has($layout) ? $layout : SectionLayouts::DEFAULT; $layout = SectionLayouts::has($layout) ? $layout : SectionLayouts::DEFAULT;
$units = SectionLayouts::units($layout); $units = SectionLayouts::units($layout);
+40
View File
@@ -0,0 +1,40 @@
<?php
namespace App\Filament\Support;
/**
* Gemeinsame Bestandsliste (Ansicht filament.verwaltung.bestand). Die Seite beschreibt Suche, Filter und Zeilen in
* bestand() und setzt alle Filter in resetFilters() zurück. Die Liste zeigt zunächst Bestand::SCHRITT Einträge; jede
* Filteränderung beginnt wieder oben.
*/
trait ShowsBestand
{
public int $bestandGrenze = Bestand::SCHRITT;
/**
* @return array<string, mixed>
*/
abstract public function bestand(): array;
abstract public function resetFilters(): void;
public function mehrAnzeigen(): void
{
$this->bestandGrenze += Bestand::SCHRITT;
}
/**
* Eigenschaften, deren Änderung die Liste wieder oben beginnen lässt (Suche und Filter). Andere Änderungen,
* etwa Eingaben in einem geöffneten Anlegedialog, lassen die angezeigte Menge unverändert.
*
* @return list<string>
*/
abstract protected function bestandFilterEigenschaften(): array;
public function updatedShowsBestand(string $name): void
{
if (in_array($name, $this->bestandFilterEigenschaften(), true)) {
$this->bestandGrenze = Bestand::SCHRITT;
}
}
}
+78 -6
View File
@@ -2,10 +2,12 @@
namespace App\Filament\Support; namespace App\Filament\Support;
use App\Domain\Cms\Sections\SectionLayouts;
use App\Domain\Cms\Widgets\RenderContext; use App\Domain\Cms\Widgets\RenderContext;
use App\Domain\Cms\Widgets\WidgetRegistry; use App\Domain\Cms\Widgets\WidgetRegistry;
use App\Domain\Cms\Widgets\WidgetRenderer; use App\Domain\Cms\Widgets\WidgetRenderer;
use App\Domain\Cms\Widgets\WidgetType; use App\Domain\Cms\Widgets\WidgetType;
use Filament\Actions\Action;
use Filament\Forms\Components\Builder; use Filament\Forms\Components\Builder;
use Filament\Forms\Components\Builder\Block; use Filament\Forms\Components\Builder\Block;
use Filament\Forms\Components\Hidden; use Filament\Forms\Components\Hidden;
@@ -20,6 +22,7 @@
use Filament\Schemas\Components\Text; use Filament\Schemas\Components\Text;
use Filament\Schemas\Components\Utilities\Get; use Filament\Schemas\Components\Utilities\Get;
use Filament\Schemas\Components\View; use Filament\Schemas\Components\View;
use Filament\Support\Enums\Width;
use Illuminate\Foundation\Vite; use Illuminate\Foundation\Vite;
use Illuminate\Support\HtmlString; use Illuminate\Support\HtmlString;
use Illuminate\Support\Str; use Illuminate\Support\Str;
@@ -82,8 +85,38 @@ public static function slotBuilder(string $name = 'widget'): Builder
->deletable() ->deletable()
->collapsible(false) ->collapsible(false)
->addAction(fn ($action) => $action->modalHeading('Widget einrichten')->modalWidth('4xl')->icon('heroicon-o-plus')) ->addAction(fn ($action) => $action->modalHeading('Widget einrichten')->modalWidth('4xl')->icon('heroicon-o-plus'))
->editAction(fn ($action) => $action->modalHeading('Widget bearbeiten')->modalWidth('4xl')->modalSubmitActionLabel('Übernehmen')->tooltip('Widget bearbeiten')) // Baustein konfigurieren (Dokument 12, CMS-R03/R11): großer Kontext mit Vorschau. „Zur Seite“ übernimmt die
->deleteAction(fn ($action) => $action->tooltip('Widget aus diesem Platz entfernen')->requiresConfirmation()->modalHeading('Widget entfernen?')->modalDescription('Das Widget wird aus dem Entwurf entfernt. Gespeicherte Revisionen bleiben erhalten.')->modalSubmitActionLabel('Entfernen')) // Eingaben in den Seitenentwurf; Verwerfen ist eine ausdrückliche Handlung, Esc und Klick daneben verwerfen
// nichts still. Eine Bearbeitung direkt in der Seite war gemessen deutlich langsamer (Abnahme Teil C).
->editAction(fn (Action $action) => $action
->label('Konfigurieren')
->icon('heroicon-o-adjustments-horizontal')
->button()
->size('sm')
->color('gray')
->modalHeading(fn (Builder $component, array $arguments): string => self::configureHeading($component, (string) ($arguments['item'] ?? '')))
->modalDescription(fn ($livewire): string => method_exists($livewire, 'openAbschnitt')
? 'Eingaben gelten im Seitenentwurf. „Zum Seitenaufbau“ kehrt an diese Stelle zurück, „Entwurf speichern“ sichert zusätzlich die Seite.'
: 'Eingaben gelten im Entwurf der neuen Seite.')
->modalWidth(Width::Screen)
->modalSubmitActionLabel('Zum Seitenaufbau')
// Kein Zwischenschritt: Speichern geht direkt aus dem Baustein (übernimmt und speichert den Entwurf).
->extraModalFooterActions(fn (Action $action, $livewire): array => method_exists($livewire, 'saveFromBlock')
? [$action->makeModalSubmitAction('entwurfSpeichern', arguments: ['speichern' => true])->label('Entwurf speichern')->color('gray')]
: [])
->after(function (array $arguments, $livewire): void {
if (($arguments['speichern'] ?? false) && method_exists($livewire, 'saveFromBlock')) {
$livewire->saveFromBlock();
}
})
->modalCancelActionLabel('Änderungen verwerfen')
->closeModalByClickingAway(false)
->closeModalByEscaping(false)
->modalCloseButton(false)
// Eigener Scrollbereich: Sonst wächst der Inhalt über das Fenster und der Dialogfuß ist bei schmalen
// Fenstern (Vorschau unter dem Formular) nicht erreichbar.
->extraModalWindowAttributes(['class' => 'luf-baustein-dialog']))
->deleteAction(fn ($action) => $action->label('Baustein entfernen')->tooltip('Baustein aus diesem Platz entfernen')->requiresConfirmation()->modalHeading('Widget entfernen?')->modalDescription('Das Widget wird aus dem Entwurf entfernt. Gespeicherte Revisionen bleiben erhalten.')->modalSubmitActionLabel('Entfernen'))
->columnSpanFull(); ->columnSpanFull();
} }
@@ -146,11 +179,14 @@ public static function block(WidgetType $type): Block
]); ]);
} }
// Auf breiten Schirmen stehen Inhalt/Medien/Darstellung und die Bausteinvorschau nebeneinander.
$schema = [ $schema = [
Hidden::make('id'), Hidden::make('id'),
...$variantField, ...$variantField,
Tabs::make('Widget')->tabs($tabs)->contained(false), Grid::make(['default' => 1, 'xl' => 5])->schema([
self::livePreview($type), Tabs::make('Widget')->tabs($tabs)->contained(false)->columnSpan(['default' => 1, 'xl' => 3]),
self::livePreview($type)->columnSpan(['default' => 1, 'xl' => 2]),
]),
]; ];
} }
@@ -167,6 +203,35 @@ public static function block(WidgetType $type): Block
->preview('filament.cms.widget-preview'); ->preview('filament.cms.widget-preview');
} }
/**
* „Programmkarte konfigurieren · Abschnitt 2 · Platz 2 · 1 Einheit“ aus dem Zustandspfad des Platzes.
*/
public static function configureHeading(Builder $component, string $itemKey): string
{
$registry = app(WidgetRegistry::class);
$type = $component->getRawState()[$itemKey]['type'] ?? null;
$heading = ($registry->has($type) ? $registry->get($type)->label() : 'Baustein').' konfigurieren';
if (preg_match('/sections\.([^.]+)\.slots\.([^.]+)\.widget$/', (string) $component->getStatePath(), $match) !== 1) {
return $heading;
}
$sections = $component->getLivewire()->data['sections'] ?? [];
$sectionIndex = array_search($match[1], array_map('strval', array_keys(is_array($sections) ? $sections : [])), true);
$slots = is_array($sections[$match[1]]['slots'] ?? null) ? $sections[$match[1]]['slots'] : [];
$slotIndex = array_search($match[2], array_map('strval', array_keys($slots)), true);
if ($sectionIndex === false || $slotIndex === false) {
return $heading;
}
$layout = $sections[$match[1]]['layout'] ?? SectionLayouts::DEFAULT;
$units = SectionLayouts::units(SectionLayouts::has($layout) ? $layout : SectionLayouts::DEFAULT)[$slotIndex] ?? null;
return $heading.' · Abschnitt '.($sectionIndex + 1).' · Platz '.($slotIndex + 1)
.($units !== null ? ' · '.$units.' '.($units === 1 ? 'Einheit' : 'Einheiten') : '');
}
/** /**
* Gespeicherte Bausteine (Altformat oder Hülle) als Builder-Zustand. * Gespeicherte Bausteine (Altformat oder Hülle) als Builder-Zustand.
* *
@@ -305,6 +370,9 @@ private static function livePreview(WidgetType $type): Section
->hiddenLabel() ->hiddenLabel()
->options($widths) ->options($widths)
->default($default) ->default($default)
// Beim Bearbeiten fehlt der Wert (er wird nicht gespeichert); ohne ihn zeigte die Vorschau die
// Vorgabe, ohne dass ein Knopf als gewählt markiert war.
->afterStateHydrated(fn (ToggleButtons $component, mixed $state) => filled($state) ? null : $component->state($default))
->inline() ->inline()
->live() ->live()
->dehydrated(false) ->dehydrated(false)
@@ -385,7 +453,7 @@ private static function unitsHint(WidgetType $type): string
/** /**
* @param array<string, mixed> $state * @param array<string, mixed> $state
*/ */
private static function itemLabel(WidgetType $type, array $state): string private static function itemLabel(WidgetType $type, array $state): HtmlString
{ {
$variant = $state['variant'] ?? $type->defaultVariant(); $variant = $state['variant'] ?? $type->defaultVariant();
$variantLabel = $type->variants()[$variant] ?? null; $variantLabel = $type->variants()[$variant] ?? null;
@@ -409,7 +477,11 @@ private static function itemLabel(WidgetType $type, array $state): string
$label = implode(' · ', $parts); $label = implode(' · ', $parts);
return $summary !== '' ? $label.' – '.Str::limit($summary, 90) : $label; // Kurzer Name des Bausteins und eine knappe Inhaltsangabe; vollständig im Titel.
return new HtmlString('<span class="luf-baustein" title="'.e($summary !== '' ? $label.' – '.$summary : $label).'">'
.'<span class="luf-baustein-name">'.e($type->label()).'</span>'
.($summary !== '' ? '<span class="luf-baustein-kurz">'.e(Str::limit($summary, 60)).'</span>' : '')
.'</span>');
} }
private static function schematicSvg(WidgetType $type): string private static function schematicSvg(WidgetType $type): string
@@ -25,7 +25,8 @@ public function verify(EmailVerificationRequest $request): RedirectResponse
$request->fulfill(); $request->fulfill();
app(GrantIssuer::class)->grantRegistrationOffers($request->user()); app(GrantIssuer::class)->grantRegistrationOffers($request->user());
return redirect()->route('member.dashboard'); // Wer aus dem Warenkorb kam, kehrt nach der Bestätigung zur Kasse zurück (gespeichertes Ziel der Sitzung).
return redirect()->intended(route('member.dashboard'));
} }
public function send(Request $request): RedirectResponse public function send(Request $request): RedirectResponse
+88
View File
@@ -0,0 +1,88 @@
<?php
namespace App\Http\Controllers;
use App\Domain\Catalog\Offer;
use App\Domain\Cms\Catalog\PublicCatalogReader;
use App\Domain\Commerce\Cart;
use App\Domain\Commerce\Money;
use App\Domain\Commerce\OrderHolders;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\View\View;
/**
* Öffentlicher Warenkorb (Etappe 1, nur Testzahlung). Er ist vor der Anmeldung nutzbar; die Prüfung der
* vorhandenen Rechte erfolgt, sobald ein Konto angemeldet ist.
*/
class CartController extends Controller
{
public function show(Request $request, Cart $cart, OrderHolders $holders): View
{
$user = $request->user();
$review = $cart->review($user, $request->integer('bestellen_als') ?: null);
return view('shop.cart', [
'review' => $review,
'holders' => $user === null ? collect() : $holders->for($user),
]);
}
public function add(Offer $offer, Cart $cart, PublicCatalogReader $catalog): RedirectResponse
{
$page = $offer->composition;
$result = $page !== null && $catalog->shownVersion($page) !== null
? $cart->add($offer)
: Cart::UNAVAILABLE;
$back = $this->productPage($offer);
return match ($result) {
Cart::ADDED => $back->with('status', 'Die Option liegt im Warenkorb.'),
Cart::PRESENT => $back->with('status', 'Diese Option liegt bereits im Warenkorb. Sie erscheint nur einmal.'),
Cart::ALTERNATIVE => $back->with('shop.switch', $offer->id),
default => $back->withErrors(['shop' => 'Diese Option ist gerade nicht erhältlich.']),
};
}
/**
* Ausdrücklicher Wechsel zwischen Alternativoptionen derselben Produktseite.
*/
public function switch(Offer $offer, Cart $cart): RedirectResponse
{
if (! $cart->switchTo($offer)) {
return $this->productPage($offer)->withErrors(['shop' => 'Diese Option ist gerade nicht erhältlich.']);
}
return redirect()->route('cart')->with('status', 'Die Option wurde gewechselt.');
}
public function remove(Offer $offer, Cart $cart): RedirectResponse
{
$cart->remove($offer);
return redirect()->route('cart')->with('status', 'Die Position ist entfernt.');
}
/**
* Der Käufer übernimmt den aktuell gezeigten Preis und die aktuellen Bedingungen einer Position.
*/
public function accept(Offer $offer, Cart $cart): RedirectResponse
{
$seen = $cart->items()[$offer->id]['price_cents'] ?? null;
$cart->acceptCurrent($offer);
$price = $cart->purchasable($offer)?->price_cents;
return redirect()->route('cart')->with('status', match (true) {
$price === null => 'Die Option ist nicht mehr erhältlich.',
$seen !== null && (int) $seen !== (int) $price => 'Der aktuelle Preis von '.Money::format($price).' ist übernommen.',
default => 'Die aktuellen Bedingungen sind übernommen.',
});
}
private function productPage(Offer $offer): RedirectResponse
{
return $offer->composition_id !== null
? redirect()->route('public.program', $offer->composition_id)
: redirect()->route('cart');
}
}
@@ -5,8 +5,11 @@
use App\Domain\Catalog\DomainRuleException; use App\Domain\Catalog\DomainRuleException;
use App\Domain\Catalog\Offer; use App\Domain\Catalog\Offer;
use App\Domain\Catalog\OfferStatus; use App\Domain\Catalog\OfferStatus;
use App\Domain\Commerce\Cart;
use App\Domain\Commerce\Checkout; use App\Domain\Commerce\Checkout;
use App\Domain\Commerce\Order; use App\Domain\Commerce\Order;
use App\Domain\Commerce\OrderHolders;
use App\Domain\Commerce\StaleOverview;
use App\Domain\Entitlement\GrantIssuer; use App\Domain\Entitlement\GrantIssuer;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse; use Illuminate\Http\RedirectResponse;
@@ -48,10 +51,50 @@ public function place(Request $request, Offer $offer, Checkout $checkout): Redir
return redirect()->route('member.order', $order); return redirect()->route('member.order', $order);
} }
/**
* Bestellübersicht: zeigt die geprüften Positionen mit dem Inhaber, für den bestellt wird.
*/
public function checkout(Request $request, Cart $cart, OrderHolders $holders): View|RedirectResponse
{
if ($cart->count() === 0) {
return redirect()->route('cart');
}
$review = $cart->review($request->user(), $request->integer('bestellen_als') ?: null);
return view('shop.checkout', [
'review' => $review,
'holders' => $holders->for($request->user()),
]);
}
/**
* Legt die Bestellung an, aber nur, wenn die serverseitige Prüfung zur gezeigten Übersicht passt.
*/
public function placeOrder(Request $request, Cart $cart, Checkout $checkout): RedirectResponse
{
$data = $request->validate([
'digest' => ['required', 'string'],
'bestellen_als' => ['nullable', 'integer'],
]);
$holderId = isset($data['bestellen_als']) ? (int) $data['bestellen_als'] : null;
$back = redirect()->route('checkout', array_filter(['bestellen_als' => $holderId]));
try {
$order = $checkout->placeFromCart($request->user(), $cart, $holderId, $data['digest']);
} catch (StaleOverview $exception) {
return $back->withErrors(['checkout' => $exception->getMessage()]);
} catch (DomainRuleException $exception) {
return $back->withErrors(['checkout' => $exception->getMessage()]);
}
return redirect()->route('member.order', $order)->with('status', 'Die Bestellung ist angelegt. Bestätige jetzt die Testzahlung.');
}
public function show(Request $request, Order $order): View public function show(Request $request, Order $order): View
{ {
abort_unless($order->user_id === $request->user()->id, 403); abort_unless($order->user_id === $request->user()->id, 403);
$order->load('lines.offerVersion.offer', 'payments'); $order->load('lines.offerVersion.offer', 'lines.holder', 'payments', 'party', 'user');
return view('member.order', [ return view('member.order', [
'order' => $order, 'order' => $order,
@@ -6,9 +6,11 @@
use App\Domain\Catalog\Composition; use App\Domain\Catalog\Composition;
use App\Domain\Catalog\ContentElement; use App\Domain\Catalog\ContentElement;
use App\Domain\Catalog\ContentElementVersion; use App\Domain\Catalog\ContentElementVersion;
use App\Domain\Catalog\EditorialDimension; use App\Domain\Catalog\EditorialVocabulary;
use App\Domain\Catalog\IdentityDimension; use App\Domain\Catalog\IdentityDimension;
use App\Domain\Catalog\LicenseArticle; use App\Domain\Catalog\LicenseArticle;
use App\Domain\Catalog\Pillar;
use App\Domain\Catalog\PillarFilterCompat;
use App\Domain\Entitlement\DecideAccess; use App\Domain\Entitlement\DecideAccess;
use App\Domain\Entitlement\Grant; use App\Domain\Entitlement\Grant;
use App\Domain\Entitlement\GrantStatus; use App\Domain\Entitlement\GrantStatus;
@@ -20,8 +22,10 @@
use App\Http\CourseOutline; use App\Http\CourseOutline;
use App\Http\LibraryCatalog; use App\Http\LibraryCatalog;
use App\Http\SignedLink; use App\Http\SignedLink;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\Response; use Illuminate\Http\Response;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use Illuminate\View\View; use Illuminate\View\View;
use Symfony\Component\HttpFoundation\StreamedResponse; use Symfony\Component\HttpFoundation\StreamedResponse;
@@ -35,8 +39,21 @@ public function index(Request $request, ?string $sicht = null): View
$query = trim((string) $request->query('q', '')); $query = trim((string) $request->query('q', ''));
$nutzung = (string) $request->query('nutzung', ''); $nutzung = (string) $request->query('nutzung', '');
$dimensionIds = array_values(array_filter(array_map(intval(...), (array) $request->query('dimension', [])))); $dimensionIds = array_values(array_filter(array_map(intval(...), (array) $request->query('dimension', []))));
$saeuleIds = array_values(array_filter(array_map(intval(...), (array) $request->query('saeule', []))));
$dimensions = app(IdentityDimension::class); $dimensions = app(IdentityDimension::class);
// Alte Adressen: Säulen waren ein Wert der Einordnung. Mit belastbarer Verknüpfung gilt der Filter der Säule.
foreach ($dimensionIds as $index => $valueId) {
if (is_int($pillarId = PillarFilterCompat::pillarOfLegacyValue($valueId))) {
$saeuleIds[] = $pillarId;
unset($dimensionIds[$index]);
}
}
$dimensionIds = array_values($dimensionIds);
$saeuleIds = array_values(array_unique($saeuleIds));
$pillarOptions = $this->visiblePillars($catalog, $saeuleIds);
foreach (['programs', 'modules'] as $shelf) { foreach (['programs', 'modules'] as $shelf) {
if ($query !== '') { if ($query !== '') {
$catalog[$shelf] = array_values(array_filter( $catalog[$shelf] = array_values(array_filter(
@@ -50,6 +67,12 @@ public function index(Request $request, ?string $sicht = null): View
fn (array $card): bool => $dimensions->matches($card['composition'], $dimensionIds), fn (array $card): bool => $dimensions->matches($card['composition'], $dimensionIds),
)); ));
} }
if ($saeuleIds !== []) {
$catalog[$shelf] = array_values(array_filter(
$catalog[$shelf],
fn (array $card): bool => $this->hasPillar($card['composition'], $saeuleIds),
));
}
if (in_array($nutzung, ['nutzbar', 'teilweise', 'nicht enthalten'], true)) { if (in_array($nutzung, ['nutzbar', 'teilweise', 'nicht enthalten'], true)) {
$catalog[$shelf] = array_values(array_filter( $catalog[$shelf] = array_values(array_filter(
$catalog[$shelf], $catalog[$shelf],
@@ -79,6 +102,13 @@ function (array $card) use ($dimensions, $dimensionIds): bool {
)); ));
} }
if ($saeuleIds !== []) {
$catalog['materials'] = array_values(array_filter(
$catalog['materials'],
fn (array $card): bool => $this->hasPillar($this->materialSubject($card), $saeuleIds),
));
}
if ($nutzung === 'teilweise' || $nutzung === 'nicht enthalten') { if ($nutzung === 'teilweise' || $nutzung === 'nicht enthalten') {
$catalog['materials'] = []; $catalog['materials'] = [];
} }
@@ -89,11 +119,65 @@ function (array $card) use ($dimensions, $dimensionIds): bool {
'sicht' => $sicht, 'sicht' => $sicht,
'nutzung' => $nutzung, 'nutzung' => $nutzung,
'dimensionIds' => $dimensionIds, 'dimensionIds' => $dimensionIds,
'filterDimensions' => EditorialDimension::query()->with('values')->orderBy('label')->get(), 'saeuleIds' => $saeuleIds,
'filterPillars' => $pillarOptions,
'filterDimensions' => app(EditorialVocabulary::class)->memberFilterDimensions(array_map(intval(...), $dimensionIds)),
'libraryEmpty' => $untouched, 'libraryEmpty' => $untouched,
]); ]);
} }
/**
* Subjekt eines Materialkarte: Programm oder Modul, Medium oder der Artikel selbst.
*
* @param array<string, mixed> $card
*/
private function materialSubject(array $card): Model
{
$release = $card['article']->currentRelease;
return $release?->rootCompositionVersion?->composition
?? $release?->rootElementVersion?->element
?? $card['article'];
}
/**
* Direkte Säulenzuordnung des Objekts selbst; die Säulen enthaltener Medien zählen hier nicht.
*
* @param list<int> $pillarIds
*/
private function hasPillar(Model $subject, array $pillarIds): bool
{
return $subject->pillars()->whereIn('pillars.id', $pillarIds)->exists();
}
/**
* Säulen für den Filter: nur solche, die ein sichtbares Objekt der Bibliothek tatsächlich trägt, und eine bereits
* gewählte. So erscheinen neue oder interne Säulen ohne Zuordnung nicht in der Bibliothek.
*
* @param array<string, mixed> $catalog
* @param list<int> $selected
* @return Collection<int, Pillar>
*/
private function visiblePillars(array $catalog, array $selected)
{
$used = [];
foreach (array_merge($catalog['programs'], $catalog['modules']) as $card) {
foreach ($card['composition']->pillars()->pluck('pillars.id') as $id) {
$used[(int) $id] = true;
}
}
foreach ($catalog['materials'] as $card) {
foreach ($this->materialSubject($card)->pillars()->pluck('pillars.id') as $id) {
$used[(int) $id] = true;
}
}
return Pillar::query()->whereIn('id', array_values(array_unique([...array_keys($used), ...$selected])))
->orderBy('sort_order')->orderBy('name')->get();
}
public function programs(Request $request): View public function programs(Request $request): View
{ {
return $this->index($request, 'programme'); return $this->index($request, 'programme');
@@ -382,7 +466,7 @@ private function grantQuery(Request $request)
{ {
return Grant::query() return Grant::query()
->where('status', GrantStatus::Aktiv) ->where('status', GrantStatus::Aktiv)
->whereHas('acquisition', fn ($query) => $query->where('party_id', $request->user()->party_id)) ->usableBy($request->user())
->with('article.currentRelease') ->with('article.currentRelease')
->orderBy('id'); ->orderBy('id');
} }
@@ -5,6 +5,9 @@
use App\Domain\Catalog\Composition; use App\Domain\Catalog\Composition;
use App\Domain\Catalog\CompositionStructureReader; use App\Domain\Catalog\CompositionStructureReader;
use App\Domain\Cms\Catalog\PublicCatalogReader; use App\Domain\Cms\Catalog\PublicCatalogReader;
use App\Domain\Commerce\Cart;
use App\Domain\Commerce\ProductOptions;
use App\Domain\Commerce\Shop;
use Illuminate\View\View; use Illuminate\View\View;
class PublicCatalogController extends Controller class PublicCatalogController extends Controller
@@ -14,7 +17,7 @@ public function index(PublicCatalogReader $catalog): View
return view('public.programs', ['programs' => $catalog->publicPrograms()]); return view('public.programs', ['programs' => $catalog->publicPrograms()]);
} }
public function program(Composition $composition, PublicCatalogReader $catalog): View public function program(Composition $composition, PublicCatalogReader $catalog, ProductOptions $products, Cart $cart): View
{ {
$version = $catalog->shownVersion($composition); $version = $catalog->shownVersion($composition);
abort_if($version === null, 404); abort_if($version === null, 404);
@@ -23,6 +26,9 @@ public function program(Composition $composition, PublicCatalogReader $catalog):
'composition' => $composition, 'composition' => $composition,
'version' => $version, 'version' => $version,
'nodes' => app(CompositionStructureReader::class)->tree($version), 'nodes' => app(CompositionStructureReader::class)->tree($version),
'options' => Shop::enabled() ? $products->forComposition($composition) : [],
'cart' => $cart,
'switchTo' => session('shop.switch'),
]); ]);
} }
} }
+50
View File
@@ -0,0 +1,50 @@
<?php
namespace App\Http\Controllers;
use App\Domain\Catalog\Composition;
use App\Domain\Cms\Catalog\PublicCatalogReader;
use App\Domain\Commerce\Money;
use App\Domain\Commerce\ProductOptions;
use Illuminate\Http\Request;
use Illuminate\View\View;
/**
* Durchsuchbarer Shop (Etappe 1): macht kaufbare Produkte auffindbar. Treffer öffnen dieselbe öffentliche Produktseite
* wie die Programmkacheln. Gelistet wird nur, was zur Anzeige freigegeben ist und mindestens eine kaufbare Option hat.
*/
class ShopController extends Controller
{
public function index(Request $request, ProductOptions $products, PublicCatalogReader $catalog): View
{
$term = trim((string) $request->query('suche', ''));
$summaries = $products->summaries();
$cards = [];
foreach (Composition::query()->whereIn('id', array_keys($summaries))->orderBy('designation')->get() as $composition) {
$version = $catalog->shownVersion($composition);
if ($version === null) {
continue;
}
$title = (string) ($composition->display_title ?: $composition->designation);
$haystack = mb_strtolower($title.' '.$composition->teaser.' '.$composition->summary.' '.$composition->search_terms);
if ($term !== '' && ! str_contains($haystack, mb_strtolower($term))) {
continue;
}
$summary = $summaries[$composition->id];
$cards[] = [
'composition' => $composition,
'title' => $title,
'teaser' => (string) ($composition->teaser ?: $composition->summary),
'from' => Money::format($summary['from_cents']),
'count' => $summary['count'],
];
}
return view('shop.index', ['cards' => $cards, 'term' => $term]);
}
}
+1 -1
View File
@@ -266,7 +266,7 @@ private function grants(User $user): Collection
{ {
return Grant::query() return Grant::query()
->where('status', GrantStatus::Aktiv) ->where('status', GrantStatus::Aktiv)
->whereHas('acquisition', fn ($query) => $query->where('party_id', $user->party_id)) ->usableBy($user)
->with([ ->with([
'article.currentRelease.rootCompositionVersion.composition.editorialContentKind', 'article.currentRelease.rootCompositionVersion.composition.editorialContentKind',
'article.currentRelease.rootElementVersion.element.editorialContentKind', 'article.currentRelease.rootElementVersion.element.editorialContentKind',
+21
View File
@@ -0,0 +1,21 @@
<?php
namespace App\Http\Middleware;
use App\Domain\Commerce\Shop;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
/**
* Warenkorb und Kasse gibt es nur mit Testzahlung und nie in Produktion (Etappe 1 erteilt keine Produktivfreigabe).
*/
class EnsureShopEnabled
{
public function handle(Request $request, Closure $next): Response
{
abort_unless(Shop::enabled(), 404);
return $next($request);
}
}
@@ -36,7 +36,7 @@ public function panel(Panel $panel): Panel
->brandName('Verwaltung') ->brandName('Verwaltung')
->authGuard('staff') ->authGuard('staff')
->colors([ ->colors([
'primary' => Color::hex('#0F6E56'), 'primary' => Color::hex('#3b7b09'),
]) ])
->multiFactorAuthentication([ ->multiFactorAuthentication([
AppAuthentication::make() AppAuthentication::make()
@@ -69,7 +69,7 @@ public function panel(Panel $panel): Panel
]) ])
->renderHook( ->renderHook(
PanelsRenderHook::STYLES_AFTER, PanelsRenderHook::STYLES_AFTER,
fn (): string => view('filament.cms.styles')->render(), fn (): string => view('filament.cms.styles')->render().view('filament.verwaltung.styles')->render(),
) )
->renderHook( ->renderHook(
PanelsRenderHook::BODY_END, PanelsRenderHook::BODY_END,
+2 -2
View File
@@ -42,8 +42,8 @@
], ],
/* /*
| Vorbereiteter Warenkorbzugang in der Kopfzeile. Der Warenkorb ist Teil des kommerziellen Anwendungssystems | Früher vorbereiteter Warenkorbzugang. Seit Etappe 1 folgt der Eintrag in der Kopfzeile dem Shop
| und noch nicht umgesetzt; solange enabled false ist, erscheint kein Warenkorbsymbol. | (App\Domain\Commerce\Shop::enabled: Testzahlung, nie in Produktion). Diese Werte werden nicht mehr gelesen.
*/ */
'cart' => [ 'cart' => [
'enabled' => (bool) env('LUF_CART_ENABLED', false), 'enabled' => (bool) env('LUF_CART_ENABLED', false),
@@ -0,0 +1,72 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
/**
* Redaktionelle Stammdaten zentral pflegen (FACH-56 bis FACH-58). Nur Ergänzungen, nichts wird umbenannt oder gelöscht:
*
* - Fachliche Materialarten: aktiv/inaktiv und zulässige Objektkontexte (medium, modul, programm, lizenzartikel).
* - Werte der Einordnung (Zielgruppe, Einsatzbereich, Verwendungszweck): aktiv/inaktiv und Reihenfolge.
*
* Die Kontexte werden einmalig aus dem Bestand abgeleitet: Programm und Modul gelten für ihre Objektart, alle übrigen
* Materialarten für Medien; Lizenzartikel behalten wie bisher die ganze Auswahl. Danach wird jeder Kontext ergänzt, in
* dem eine Materialart tatsächlich verwendet wird, damit keine vorhandene Zuordnung unzulässig wird.
*/
return new class extends Migration
{
public function up(): void
{
Schema::table('editorial_content_kinds', function (Blueprint $table) {
$table->boolean('is_active')->default(true)->after('sort_order');
$table->json('contexts')->nullable()->after('is_active');
});
Schema::table('editorial_dimension_values', function (Blueprint $table) {
$table->unsignedInteger('sort_order')->default(0)->after('label');
$table->boolean('is_active')->default(true)->after('sort_order');
});
foreach (DB::table('editorial_dimension_values')->orderBy('editorial_dimension_id')->orderBy('id')->get(['id', 'editorial_dimension_id']) as $index => $value) {
DB::table('editorial_dimension_values')->where('id', $value->id)->update(['sort_order' => ($index + 1) * 10]);
}
$compositionContexts = ['kurs' => 'programm', 'uebung' => 'modul'];
foreach (DB::table('editorial_content_kinds')->get(['id', 'slug']) as $kind) {
$contexts = match ($kind->slug) {
'programm' => ['programm', 'lizenzartikel'],
'modul' => ['modul', 'lizenzartikel'],
default => ['medium', 'lizenzartikel'],
};
if (DB::table('content_elements')->where('editorial_content_kind_id', $kind->id)->exists()) {
$contexts[] = 'medium';
}
foreach (DB::table('compositions')->where('editorial_content_kind_id', $kind->id)->distinct()->pluck('kind') as $compositionKind) {
if (isset($compositionContexts[$compositionKind])) {
$contexts[] = $compositionContexts[$compositionKind];
}
}
$order = ['medium', 'modul', 'programm', 'lizenzartikel'];
$contexts = array_values(array_filter($order, fn (string $context): bool => in_array($context, $contexts, true)));
DB::table('editorial_content_kinds')->where('id', $kind->id)->update(['contexts' => json_encode($contexts)]);
}
}
public function down(): void
{
Schema::table('editorial_dimension_values', function (Blueprint $table) {
$table->dropColumn(['sort_order', 'is_active']);
});
Schema::table('editorial_content_kinds', function (Blueprint $table) {
$table->dropColumn(['is_active', 'contexts']);
});
}
};
@@ -0,0 +1,59 @@
<?php
use App\Domain\Catalog\LegacyPillarAdoption;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Schema;
/**
* Fachliche Säulen vereinheitlichen: Module, Programme und Lizenzartikel verwenden wie Medien und Seiten die zentrale
* Säulenverwaltung (`pillars`) statt der Kopie „Fachliche Säule“ in den redaktionellen Dimensionen.
*
* Nur Ergänzungen: zwei Zuordnungstabellen (die Säule wird beim Löschen nie still entfernt, wie bei Medien und Seiten),
* die Verknüpfung `pillar_id` an den alten Dimensionswerten und die einmalige, wiederholbare Übernahme durch
* LegacyPillarAdoption. Alte Tabellen und Zeilen bleiben unverändert erhalten.
*/
return new class extends Migration
{
public function up(): void
{
Schema::create('composition_pillar', function (Blueprint $table) {
$table->foreignId('composition_id')->constrained()->cascadeOnDelete();
$table->foreignId('pillar_id')->constrained()->restrictOnDelete();
$table->primary(['composition_id', 'pillar_id']);
});
Schema::create('license_article_pillar', function (Blueprint $table) {
$table->foreignId('license_article_id')->constrained()->cascadeOnDelete();
$table->foreignId('pillar_id')->constrained()->restrictOnDelete();
$table->primary(['license_article_id', 'pillar_id']);
});
Schema::table('editorial_dimension_values', function (Blueprint $table) {
$table->foreignId('pillar_id')->nullable()->after('editorial_dimension_id')->constrained('pillars')->nullOnDelete();
});
$report = (new LegacyPillarAdoption)->run();
foreach (LegacyPillarAdoption::lines($report) as $line) {
if ($line !== '') {
Log::info('Säulenübernahme: '.$line);
}
}
if ($report['unresolved'] !== []) {
Log::warning('Säulenübernahme: '.count($report['unresolved']).' Fälle ungeklärt; „php artisan luf:saeulen-uebernehmen --dry-run“ listet sie.');
}
}
public function down(): void
{
Schema::table('editorial_dimension_values', function (Blueprint $table) {
$table->dropConstrainedForeignId('pillar_id');
});
Schema::dropIfExists('license_article_pillar');
Schema::dropIfExists('composition_pillar');
}
};
@@ -0,0 +1,82 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
/**
* Etappe 1 (Testkauf): nur ergänzend, keine Daten werden gelöscht oder umbenannt.
*
* - Ein Angebot (Lizenzoption) kann auf die Komposition zeigen, deren öffentliche Seite die Produktseite ist
* (`offers.composition_id`). Angebote derselben Komposition bilden die Angebotsgruppe (Alternativen).
* - Mitgliedschaft eines Kontos in einer Organisation mit Bestellberechtigung (Domänenmodell 04, MEMBERSHIP).
* - Der Erwerb hält das auslösende Konto, die Bestellung Gesamtsumme und Währung, die Position Inhaber, Währung,
* Steuerklasse und Vergabeart als Kopie. `orders.party_id` ist der Lizenzinhaber, `orders.user_id` das handelnde Konto.
*/
return new class extends Migration
{
public function up(): void
{
Schema::table('offers', function (Blueprint $table) {
$table->foreignId('composition_id')->nullable()->constrained('compositions')->nullOnDelete();
$table->string('option_label')->nullable();
});
Schema::create('memberships', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->foreignId('party_id')->constrained()->restrictOnDelete();
$table->string('role')->default('mitglied');
$table->boolean('may_order')->default(false);
$table->date('valid_from')->nullable();
$table->date('valid_until')->nullable();
$table->timestamps();
$table->unique(['user_id', 'party_id']);
});
Schema::table('acquisitions', function (Blueprint $table) {
$table->foreignId('acting_user_id')->nullable()->constrained('users')->nullOnDelete();
});
Schema::table('orders', function (Blueprint $table) {
$table->unsignedInteger('total_cents')->nullable();
$table->string('currency', 3)->default('EUR');
});
Schema::table('order_lines', function (Blueprint $table) {
$table->string('currency', 3)->default('EUR');
$table->string('tax_class')->nullable();
$table->string('grant_kind')->nullable();
$table->foreignId('holder_party_id')->nullable()->constrained('parties')->restrictOnDelete();
});
// Bestehende Bestellungen: Summe und Inhaber der Position aus den vorhandenen Angaben.
foreach (DB::table('orders')->get() as $order) {
DB::table('orders')->where('id', $order->id)->update([
'total_cents' => (int) DB::table('order_lines')->where('order_id', $order->id)->sum('price_cents'),
]);
DB::table('order_lines')->where('order_id', $order->id)->update(['holder_party_id' => $order->party_id]);
}
}
public function down(): void
{
Schema::table('order_lines', function (Blueprint $table) {
$table->dropConstrainedForeignId('holder_party_id');
$table->dropColumn(['currency', 'tax_class', 'grant_kind']);
});
Schema::table('orders', function (Blueprint $table) {
$table->dropColumn(['total_cents', 'currency']);
});
Schema::table('acquisitions', function (Blueprint $table) {
$table->dropConstrainedForeignId('acting_user_id');
});
Schema::dropIfExists('memberships');
Schema::table('offers', function (Blueprint $table) {
$table->dropConstrainedForeignId('composition_id');
$table->dropColumn('option_label');
});
}
};
+189
View File
@@ -0,0 +1,189 @@
<?php
namespace Database\Seeders;
use App\Domain\Catalog\ArticleService;
use App\Domain\Catalog\BundleService;
use App\Domain\Catalog\CompositionDisplayRelease;
use App\Domain\Catalog\CompositionVersion;
use App\Domain\Catalog\ContentService;
use App\Domain\Catalog\EditorialContentKind;
use App\Domain\Catalog\LicenseArticle;
use App\Domain\Catalog\Offer;
use App\Domain\Catalog\OfferService;
use App\Domain\Catalog\RightsProfileVersion;
use App\Domain\Identity\AccountStatus;
use App\Domain\Identity\Membership;
use App\Domain\Identity\Party;
use App\Domain\Identity\PartyType;
use App\Domain\Identity\RegisterAccount;
use App\Models\User;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
/**
* Testdaten für den Testkauf (Etappe 1): zwei Programme mit Film und Begleitmaterial, ein Starterpaket, die
* Lizenzoptionen für Privatpersonen und für einen Verein, ein Testverein mit bestellberechtigtem Konto und drei
* Testkonten. Nur für Entwicklung und die Testinstanz; in Produktion läuft der Seeder nicht.
* Mehrfach ausführbar: Vorhandenes bleibt unverändert.
*/
class ShopDemoSeeder extends Seeder
{
/** Nur für automatisierte Tests. Außerhalb von Tests gilt LUF_DEMO_PASSWORD oder ein zufälliges Passwort. */
public const PASSWORD = 'testkauf-passwort-1';
private ?string $password = null;
public function run(): void
{
if (app()->isProduction() || LicenseArticle::query()->where('code', 'shop-konflikte')->exists()) {
return;
}
$content = app(ContentService::class);
$articles = app(ArticleService::class);
$bundles = app(BundleService::class);
$offers = app(OfferService::class);
$this->password = app()->runningUnitTests()
? self::PASSWORD
: (getenv('LUF_DEMO_PASSWORD') ?: Str::random(24));
$editor = $this->account('Demo Redaktion', 'shop-demo-redaktion@example.test');
[$konflikteVersion, $konflikteArticle] = $this->program(
$content, $articles, $editor, 'shop-konflikte', 'Konflikte im Training',
'Wie Trainerinnen und Trainer Konflikte in der Gruppe ruhig und klar begleiten.',
'Ein Film, ein Arbeitsblatt und eine Anleitung für sechs Trainingseinheiten.',
'Konflikte erkennen, benennen und gemeinsam lösen.',
);
[$grenzenVersion, $grenzenArticle] = $this->program(
$content, $articles, $editor, 'shop-grenzen', 'Grenzen setzen im Verein',
'Sicher auftreten, Grenzen vermitteln und Kinder stärken.',
'Film und Begleitmaterial für einen Übungsabend zu Grenzen und Respekt.',
'Grenzen verständlich vermitteln.',
);
[$starterVersion, $starterArticle] = $this->program(
$content, $articles, $editor, 'shop-starter', 'Starterpaket für neue Trainer',
'Das Einstiegspaket mit beiden Programmen und einer Einführung für neue Trainerinnen und Trainer.',
'Zusätzlich zu beiden Programmen enthält das Paket eine Einführung ins Konzept.',
'Das Konzept kennenlernen.',
);
$privat = $offers->createRightsProfile('Privatlizenz ehrenamtlich', 'ehrenamtlich', [
'film' => ['streamen', 'laden'],
'pdf' => ['ansehen', 'laden'],
]);
$verein = $offers->createRightsProfile('Vereinslizenz institutionell', 'institutionell', [
'film' => ['streamen', 'laden'],
'pdf' => ['ansehen', 'laden'],
]);
$this->offer($offers, 'Konflikte im Training: Privatlizenz', 'Privatlizenz', $konflikteVersion, [$konflikteArticle, $privat], 4900, 'person');
$this->offer($offers, 'Konflikte im Training: Vereinslizenz', 'Mehrfachlizenz für Vereine', $konflikteVersion, [$konflikteArticle, $verein], 14900, 'organisation');
$this->offer($offers, 'Grenzen setzen: Privatlizenz', 'Privatlizenz', $grenzenVersion, [$grenzenArticle, $privat], 2900, 'person');
$bundle = $bundles->create('Starterpaket');
$starter = $bundles->publish($bundle, [$konflikteArticle->fresh(), $grenzenArticle->fresh(), $starterArticle->fresh()]);
$paket = $offers->create('Starterpaket: Privatlizenz');
$offers->activate($paket, [['target' => $starter, 'rights' => $privat]], ['grant_kind' => 'kauf', 'price_cents' => 5900, 'holder_kind' => 'person']);
$offers->assignProduct($paket, $starterVersion->composition_id, 'Starterpaket (zwei Programme und Einführung)');
$tina = $this->account('Tina Trainerin', 'tina.trainerin@example.test');
$vera = $this->account('Vera Vorstand', 'vera.vorstand@example.test');
$max = $this->account('Max Mitglied', 'max.mitglied@example.test');
$club = Party::query()->firstOrCreate(
['type' => PartyType::Organisation, 'display_name' => 'Testverein Musterstadt e. V.'],
);
Membership::query()->firstOrCreate(['user_id' => $vera->id, 'party_id' => $club->id], ['role' => 'org_admin', 'may_order' => true]);
Membership::query()->firstOrCreate(['user_id' => $max->id, 'party_id' => $club->id], ['role' => 'mitglied', 'may_order' => false]);
unset($tina);
if (! app()->runningUnitTests()) {
$this->command?->info('Testkonten angelegt (tina.trainerin, vera.vorstand, max.mitglied und shop-demo-redaktion bei example.test). Passwort: '.($this->password));
}
}
/**
* Zwei Dateien (Film, Begleitmaterial) als Platzhalter im Speicher, ein Programm als Komposition mit
* Anzeigefreigabe und ein Lizenzartikel dazu.
*
* @return array{0: CompositionVersion, 1: LicenseArticle}
*/
private function program(
ContentService $content,
ArticleService $articles,
User $editor,
string $code,
string $title,
string $teaser,
string $summary,
string $goal,
): array {
$disk = Storage::disk('media_derived');
$disk->put('inhalte/'.$code.'/film.mp4', 'Platzhalter für den Film '.$title);
$disk->put('inhalte/'.$code.'/begleitmaterial.pdf', "%PDF-1.4\n% Platzhalter für das Begleitmaterial ".$title."\n%%EOF\n");
$film = $content->publishElementVersion(
$content->createElement('film', 'film', 'Film '.$title),
null,
['file' => 'inhalte/'.$code.'/film.mp4'],
);
$sheet = $content->publishElementVersion(
$content->createElement('pdf', 'pdf', 'Begleitmaterial '.$title),
null,
['file' => 'inhalte/'.$code.'/begleitmaterial.pdf'],
);
$composition = $content->createComposition($title);
$composition->editorial_content_kind_id = EditorialContentKind::query()->where('slug', 'programm')->value('id');
$composition->display_title = $title;
$composition->teaser = $teaser;
$composition->summary = $summary;
$composition->save();
$version = $content->publishComposition(
$composition,
[['role' => 'Film', 'target' => $film], ['role' => 'Begleitmaterial', 'target' => $sheet]],
null,
null,
['learning_goal' => $goal],
);
app(CompositionDisplayRelease::class)->release($version, $editor);
$article = $articles->create($code, 'Testkauf');
$article->working_title = $title;
$article->display_title = $title;
$article->save();
$articles->publishRelease($article, $version, 'Programm für den Testkauf.');
return [$version, $article->fresh()];
}
/**
* @param array{0: LicenseArticle, 1: RightsProfileVersion} $line
*/
private function offer(OfferService $offers, string $name, string $label, CompositionVersion $version, array $line, int $cents, string $holder): Offer
{
$offer = $offers->create($name);
$offers->activate($offer, [['target' => $line[0], 'rights' => $line[1]]], [
'grant_kind' => 'kauf',
'price_cents' => $cents,
'holder_kind' => $holder,
]);
$offers->assignProduct($offer, $version->composition_id, $label);
return $offer;
}
private function account(string $name, string $email): User
{
$existing = User::query()->where('email', $email)->first();
if ($existing !== null) {
return $existing;
}
$user = app(RegisterAccount::class)->register($name, $email, (string) $this->password, true);
$user->forceFill(['email_verified_at' => now(), 'status' => AccountStatus::Aktiv])->save();
return $user;
}
}
+7 -1
View File
@@ -4,6 +4,11 @@ server {
root /var/www/html/public; root /var/www/html/public;
index index.php; index index.php;
# Dockers interner DNS: Der Name „app“ wird zur Laufzeit aufgelöst (höchstens 10 s zwischengespeichert), nicht
# einmal beim Start von nginx. Sonst zeigt nginx nach jeder Neuerzeugung des App-Containers (neue Adresse) auf die
# alte Adresse und antwortet mit 502 – etwa bei einem erneuten Deploy-Lauf nach einer Änderung der Env-Datei.
resolver 127.0.0.11 valid=10s ipv6=off;
client_max_body_size 2048m; client_max_body_size 2048m;
client_body_timeout 3600s; client_body_timeout 3600s;
send_timeout 3600s; send_timeout 3600s;
@@ -13,7 +18,8 @@ server {
} }
location ~ \.php$ { location ~ \.php$ {
fastcgi_pass app:9000; set $php_upstream app:9000;
fastcgi_pass $php_upstream;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params; include fastcgi_params;
set $forwarded_proto $http_x_forwarded_proto; set $forwarded_proto $http_x_forwarded_proto;
@@ -0,0 +1,25 @@
/* Lara & Felix – draft brand tokens; source imagery sampled 2026-11-15.
Do not treat these color values or fonts as final without approval. */
:root {
--lf-navy: #032551;
--lf-navy-deep: #01244C;
--lf-green: #5B8625;
--lf-green-deep: #3B7B09;
--lf-yellow: #FCD10A;
--lf-cream: #F7F6F2;
--lf-white: #FFFFFF;
--lf-surface: #F9FAF7;
--lf-ink: #15243A;
--lf-muted: #5D6A78;
--lf-border: #DDE5E3;
--lf-focus: #1769AA;
--lf-error: #B92F38;
--lf-radius-sm: 8px;
--lf-radius-md: 14px;
--lf-radius-lg: 22px;
--lf-radius-pill: 999px;
--lf-shadow-card: 0 12px 30px rgb(3 37 81 / .07);
--lf-max-container: 1180px;
--lf-font-ui: "Nunito Sans", "Segoe UI", system-ui, sans-serif;
--lf-font-display: "Nunito", "Trebuchet MS", system-ui, sans-serif;
}
@@ -0,0 +1,147 @@
{
"$schema": "https://design-tokens.github.io/community-group/format/",
"status": "working draft, needs formal brand approval",
"source": "sampled colors from uploaded title/denkpause, with supporting UI tokens chosen for accessibility",
"color": {
"navy": {
"$type": "color",
"$value": "#032551"
},
"navy_deep": {
"$type": "color",
"$value": "#01244C"
},
"green": {
"$type": "color",
"$value": "#5B8625"
},
"green_deep": {
"$type": "color",
"$value": "#3B7B09"
},
"yellow": {
"$type": "color",
"$value": "#FCD10A"
},
"cream": {
"$type": "color",
"$value": "#F7F6F2"
},
"white": {
"$type": "color",
"$value": "#FFFFFF"
},
"surface": {
"$type": "color",
"$value": "#F9FAF7"
},
"ink": {
"$type": "color",
"$value": "#15243A"
},
"muted": {
"$type": "color",
"$value": "#5D6A78"
},
"border": {
"$type": "color",
"$value": "#DDE5E3"
},
"focus": {
"$type": "color",
"$value": "#1769AA"
},
"error": {
"$type": "color",
"$value": "#B92F38"
}
},
"radius": {
"sm": {
"$type": "dimension",
"$value": "8px"
},
"md": {
"$type": "dimension",
"$value": "14px"
},
"lg": {
"$type": "dimension",
"$value": "22px"
},
"pill": {
"$type": "dimension",
"$value": "999px"
}
},
"space": {
"1": {
"$type": "dimension",
"$value": "4px"
},
"2": {
"$type": "dimension",
"$value": "8px"
},
"3": {
"$type": "dimension",
"$value": "12px"
},
"4": {
"$type": "dimension",
"$value": "16px"
},
"5": {
"$type": "dimension",
"$value": "20px"
},
"6": {
"$type": "dimension",
"$value": "24px"
},
"7": {
"$type": "dimension",
"$value": "28px"
},
"8": {
"$type": "dimension",
"$value": "32px"
},
"9": {
"$type": "dimension",
"$value": "36px"
},
"10": {
"$type": "dimension",
"$value": "40px"
},
"11": {
"$type": "dimension",
"$value": "44px"
},
"12": {
"$type": "dimension",
"$value": "48px"
},
"13": {
"$type": "dimension",
"$value": "52px"
},
"14": {
"$type": "dimension",
"$value": "56px"
},
"15": {
"$type": "dimension",
"$value": "60px"
},
"16": {
"$type": "dimension",
"$value": "64px"
}
},
"typography": {
"display": "Rounded friendly display – select licensed font",
"body": "Highly readable sans – select licensed font"
}
}
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><rect width="64" height="64" rx="17" fill="#032551"/><path d="M10 45V17h8v20h12v8z" fill="#fff"/><text x="31" y="42" font-family="system-ui,sans-serif" font-size="19" font-weight="900" fill="white">F</text><path d="M9 53Q28 43 55 49" stroke="#FCD10A" stroke-width="5" fill="none" stroke-linecap="round"/></svg>

After

Width:  |  Height:  |  Size: 370 B

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><g fill="none" stroke="#032551" stroke-width="5" stroke-linejoin="round" stroke-linecap="round"><path d="M20 53V30c0-9 13-9 13 0V16c0-9 13-9 13 0v11-17c0-9 13-9 13 0v18-14c0-9 13-9 13 0v36l7-10c7-9 20-3 15 7L76 82C67 93 43 94 30 86L9 64C2 56 13 47 20 53z"/></g></svg>

After

Width:  |  Height:  |  Size: 329 B

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 360 258"><path d="M59 68C72 19 132 6 165 35c39-37 103-10 113 30 56-3 78 45 56 86 10 45-42 89-95 75-39 30-94 12-109-11-38 21-100-11-99-56-27-29-20-78 28-91z" fill="#FFFFFF" stroke="#032551" stroke-width="7" stroke-linejoin="round"/><circle cx="48" cy="233" r="14" fill="white" stroke="#032551" stroke-width="6"/><circle cx="17" cy="253" r="6" fill="white" stroke="#032551" stroke-width="4"/></svg>

After

Width:  |  Height:  |  Size: 449 B

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 85"><g fill="none" stroke="#FCD10A" stroke-linecap="round" stroke-width="11"><path d="M23 52L6 40"/><path d="M48 29L46 9"/><path d="M74 44L89 23"/></g></svg>

After

Width:  |  Height:  |  Size: 214 B

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 280 28"><path d="M9 18 Q102 1 270 12" fill="none" stroke="#FCD10A" stroke-width="13" stroke-linecap="round"/></svg>

After

Width:  |  Height:  |  Size: 168 B

Loaded 100 of 610 files, more files were not shown because too many files have changed in this diff. Show more