Biete in der Shopliste Auswahl, Reihenfolge, Listenansicht und Seiten
CI Feature / test (push) Successful in 6m4s
CI Feature / test (push) Successful in 6m4s
- ShopCatalog::listing mit Auswahl nach Thema, Materialart, Eignung und Nutzerkreis, Reihenfolge, Ansicht und Seiten - Listenansicht shop/zeile, gemeinsame Liste fuer Shopseite und Widget (Variante Liste, Einstellung Auswahl fuer Besucher) - Werte aus dem Abfragetext werden gegen vorhandene Werte geprueft, Felder als Liste und Zahlen ausserhalb des Bereichs sind harmlos - Suchfeld heisst nach dem Umbau Zurücksetzen statt Suche zuruecksetzen (Test bewusst angepasst) - ADR-57 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
95a888d1ca
commit
f0ffb47210
15 files changed
+651
-73
No files matched your search
@@ -79,6 +79,7 @@ public function variants(): array
|
||||
{
|
||||
return [
|
||||
'kacheln' => 'Kacheln mit Bild',
|
||||
'liste' => 'Liste mit kleinem Bild',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -88,6 +89,7 @@ public function settings(): array
|
||||
'sort' => ['name' => 'Alphabetisch', 'neu' => 'Neueste zuerst', 'preis' => 'Preis aufsteigend'],
|
||||
'limit' => ['alle' => 'Alle Produkte', 'n3' => '3 Produkte', 'n6' => '6 Produkte', 'n9' => '9 Produkte', 'n12' => '12 Produkte', 'n24' => '24 Produkte'],
|
||||
'search' => ['aus' => 'Ohne Suchfeld', 'an' => 'Mit Suchfeld'],
|
||||
'filter' => ['aus' => 'Ohne Auswahl', 'an' => 'Mit Suche, Auswahl, Ansicht und Seiten'],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -96,13 +98,14 @@ public function settingLabels(): array
|
||||
return [
|
||||
'sort' => ['Reihenfolge', 'Ohne Wahl gilt die Reihenfolge der Shopseite: Altbestand, Artikel, Pakete.'],
|
||||
'limit' => ['Anzahl', 'Wie viele Produkte höchstens erscheinen. Ohne Wahl erscheinen alle.'],
|
||||
'search' => ['Suchfeld', 'Ein Suchfeld über den Kacheln. Es wirkt auf der Shopseite; auf anderen Seiten führt die Suche in den Shop.'],
|
||||
'search' => ['Suchfeld', 'Ein einfaches Suchfeld über den Kacheln. Es sendet an die Seite, auf der das Widget steht.'],
|
||||
'filter' => ['Auswahl für Besucher', 'Suche, Auswahl nach Thema, Materialart, Eignung und Nutzerkreis, Reihenfolge, Umschalter Kacheln und Liste und Seiten. Sinnvoll auf der Shopseite mit vielen Produkten. Ersetzt das einfache Suchfeld und die Einstellung „Anzahl“.'],
|
||||
];
|
||||
}
|
||||
|
||||
public function settingGroups(): array
|
||||
{
|
||||
return ['Auswahl' => ['sort', 'limit', 'search']];
|
||||
return ['Auswahl' => ['sort', 'limit', 'search', 'filter']];
|
||||
}
|
||||
|
||||
public function dataRules(): array
|
||||
@@ -165,21 +168,28 @@ public function clean(array $data, array $refs, WidgetErrors $errors): array
|
||||
public function resolve(array $widget, RenderContext $context): array
|
||||
{
|
||||
if (! Shop::visible()) {
|
||||
return ['cards' => [], 'term' => '', 'shopVisible' => false];
|
||||
return ['listing' => null, 'cards' => [], 'term' => '', 'shopVisible' => false];
|
||||
}
|
||||
|
||||
$settings = is_array($widget['settings'] ?? null) ? $widget['settings'] : [];
|
||||
$filters = ($settings['filter'] ?? 'aus') === 'an';
|
||||
$search = ($settings['search'] ?? 'aus') === 'an';
|
||||
$term = $search && ! $context->preview ? trim((string) request()->query('suche', '')) : '';
|
||||
$limit = preg_match('/^n(\d+)$/', (string) ($settings['limit'] ?? ''), $match) === 1 ? (int) $match[1] : null;
|
||||
$limit = preg_match('/^n(\\d+)$/', (string) ($settings['limit'] ?? ''), $match) === 1 ? (int) $match[1] : null;
|
||||
$query = $context->preview ? [] : request()->query();
|
||||
$term = ($search || $filters) && isset($query['suche']) && is_string($query['suche']) ? mb_substr(trim($query['suche']), 0, 100) : '';
|
||||
$fixed = [
|
||||
'pillar' => $widget['data']['pillar'] ?? null,
|
||||
'kind' => $widget['data']['kind'] ?? null,
|
||||
'sort' => $settings['sort'] ?? null,
|
||||
'limit' => $filters ? null : $limit,
|
||||
'view' => ($widget['variant'] ?? 'kacheln') === 'liste' ? 'liste' : 'kacheln',
|
||||
'filters' => $filters,
|
||||
];
|
||||
$listing = app(ShopCatalog::class)->listing($filters ? $query : ['suche' => $term], $fixed);
|
||||
|
||||
return [
|
||||
'cards' => app(ShopCatalog::class)->cards($term, [
|
||||
'pillar' => $widget['data']['pillar'] ?? null,
|
||||
'kind' => $widget['data']['kind'] ?? null,
|
||||
'sort' => $settings['sort'] ?? null,
|
||||
'limit' => $limit,
|
||||
]),
|
||||
'listing' => $listing,
|
||||
'cards' => $listing['cards'],
|
||||
'term' => $term,
|
||||
'shopVisible' => true,
|
||||
];
|
||||
|
||||
Reference in new issue
Block a user