Zeige auf der Shopkachel Titelbild, Saeulen, Materialart mit Symbol und Marker
- ShopCatalog als gemeinsame Datenquelle der Kacheln, shop/kachel als Partial - Titelbild nur mit Website-Freigabe (PresentationMedia::coverPresentation), schmueckend mit leerem alt - Symbol je Materialart (Stammdaten), Marker Neu, Aktualisiert, Beliebt mit Einstellung am Artikel - Migration 2026_12_01_100000, rein ergaenzend - ADR-54, Plan, DEPLOYMENT.md Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
db3a6ba779
commit
0ac70884cc
18 files changed
+991
-88
No files matched your search
@@ -14,6 +14,8 @@
|
||||
use App\Filament\Resources\LicenseArticles\LicenseArticleResource;
|
||||
use App\Filament\Resources\Pillars\PillarResource;
|
||||
use App\Filament\Support\EditorialCatalog;
|
||||
use App\Filament\Support\SymbolField;
|
||||
use App\Support\Brand\SymbolCatalog;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\ActionGroup;
|
||||
use Filament\Forms\Components\Checkbox;
|
||||
@@ -261,6 +263,8 @@ private function formular(?Model $record): array
|
||||
];
|
||||
|
||||
if ($this->istMaterialart()) {
|
||||
$felder[] = SymbolField::make('symbol', 'Symbol im Shop')
|
||||
->helperText('Optional. Das Symbol steht auf der Shopkachel bei Artikeln dieser Materialart, auch wenn kein Bild gepflegt ist.');
|
||||
$system = $record instanceof EditorialContentKind && $record->isSystem();
|
||||
$felder[] = CheckboxList::make('contexts')
|
||||
->label('Zulässig für')
|
||||
@@ -325,6 +329,7 @@ private function bearbeitenAction(): Action
|
||||
->schema(fn (Model $record): array => $this->formular($record))
|
||||
->fillForm(fn (Model $record): array => [
|
||||
'label' => $record->label,
|
||||
'symbol' => $record instanceof EditorialContentKind ? $record->symbol : null,
|
||||
'contexts' => $record instanceof EditorialContentKind ? (array) ($record->contexts ?? []) : [],
|
||||
])
|
||||
->modalSubmitActionLabel('Speichern')
|
||||
@@ -337,11 +342,21 @@ private function bearbeitenAction(): Action
|
||||
$record->contexts = $this->kontexte((array) $data['contexts']);
|
||||
}
|
||||
|
||||
if ($record instanceof EditorialContentKind) {
|
||||
$record->symbol = $this->symbol($data['symbol'] ?? null);
|
||||
}
|
||||
|
||||
$record->save();
|
||||
Notification::make()->success()->title('Gespeichert')->body('Die neue Bezeichnung gilt sofort in Redaktion, Filtern und Picker.')->send();
|
||||
});
|
||||
}
|
||||
|
||||
/** Ein Symbol wird nur gespeichert, wenn die Symbolbibliothek es kennt; sonst bleibt die Materialart ohne Symbol. */
|
||||
private function symbol(mixed $value): ?string
|
||||
{
|
||||
return is_string($value) && array_key_exists($value, SymbolCatalog::options()) ? $value : null;
|
||||
}
|
||||
|
||||
private function anlegen(array $data): void
|
||||
{
|
||||
$label = trim((string) $data['label']);
|
||||
@@ -354,6 +369,7 @@ private function anlegen(array $data): void
|
||||
'sort_order' => (int) EditorialContentKind::query()->max('sort_order') + 10,
|
||||
'is_active' => true,
|
||||
'contexts' => $this->kontexte((array) ($data['contexts'] ?? [])),
|
||||
'symbol' => $this->symbol($data['symbol'] ?? null),
|
||||
]);
|
||||
} else {
|
||||
$dimension = $this->dimension();
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
use App\Domain\Catalog\StatusValue;
|
||||
use App\Domain\Commerce\Money;
|
||||
use App\Domain\Commerce\ProductOptions;
|
||||
use App\Domain\Commerce\ShopMarkers;
|
||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||
use App\Filament\Resources\LicenseArticles\LicenseArticleResource;
|
||||
use App\Filament\Resources\Offers\OfferResource;
|
||||
@@ -554,6 +555,50 @@ public function optionAction(): Action
|
||||
});
|
||||
}
|
||||
|
||||
/** Die Marker, die die Kachel im Shop gerade zeigt (Wort je Marker), mit der Einstellung der Redaktion. */
|
||||
public function markerRows(): array
|
||||
{
|
||||
/** @var LicenseArticle $article */
|
||||
$article = $this->getRecord();
|
||||
$markers = app(ShopMarkers::class);
|
||||
$offerIds = array_map(fn (Offer $offer): int => (int) $offer->id, app(ProductOptions::class)->offersOfArticle($article));
|
||||
|
||||
return [
|
||||
'sichtbar' => array_column($markers->visible($article, $offerIds), 'label'),
|
||||
'einstellung' => $markers->settings($article),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Marker für die Kachel im Shop: „Neu“ und „Aktualisiert“ folgen automatisch den Daten und lassen sich fest an- oder
|
||||
* abschalten, „Beliebt“ setzt die Redaktion von Hand. Die Aktion speichert nur die Marker, sonst nichts (nicht die
|
||||
* Redaktion des Artikels).
|
||||
*/
|
||||
public function markersAction(): Action
|
||||
{
|
||||
return Action::make('markers')
|
||||
->modalWidth('lg')
|
||||
->modalHeading('Marker für die Kachel im Shop')
|
||||
->modalDescription('Marker erscheinen mit ihrem Wort auf der Kachel des Artikels. „Neu“ und „Aktualisiert“ richten sich automatisch nach den Daten; hier kannst du sie fest an- oder abschalten. „Beliebt“ setzt du von Hand, bis es Verkaufszahlen gibt.')
|
||||
->modalSubmitActionLabel('Marker speichern')
|
||||
->fillForm(fn (): array => $this->markerRows()['einstellung'])
|
||||
->schema(collect(ShopMarkers::CHOICES)->map(fn (array $choices, string $key): Select => Select::make($key)
|
||||
->label(ShopMarkers::KEYS[$key])
|
||||
->options($choices)
|
||||
->required()
|
||||
->native(false))->values()->all())
|
||||
->action(function (array $data): void {
|
||||
$this->report(function () use ($data): string {
|
||||
/** @var LicenseArticle $article */
|
||||
$article = $this->getRecord();
|
||||
app(ShopMarkers::class)->save($article, $data);
|
||||
|
||||
return 'Die Marker sind gespeichert.';
|
||||
}, 'Die Marker sind gespeichert.');
|
||||
$this->refreshRecord();
|
||||
});
|
||||
}
|
||||
|
||||
/** Eine Option aus dem Verkauf nehmen: nur die aktive Fassung dieser Option wird beendet. */
|
||||
public function optionEndAction(): Action
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user