@shopbite-de/storefront 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +3 -1
- package/.github/workflows/build.yaml +1 -1
- package/.github/workflows/ci.yaml +5 -5
- package/CLAUDE.md +6 -3
- package/api-types/storeApiSchema.json +5 -0
- package/api-types/storeApiTypes.d.ts +2 -0
- package/app/components/Category/Listing.vue +53 -0
- package/app/components/Menu/BonCard.vue +13 -0
- package/app/components/Menu/FoodLabelLegend.vue +28 -0
- package/app/components/Navigation/MobileTop.vue +98 -9
- package/app/components/Product/FoodLabels.vue +39 -0
- package/app/components/Product/QuickView.vue +1 -0
- package/app/components/Sb/Sheet.vue +36 -18
- package/app/composables/useHomeMenuCategories.ts +6 -4
- package/app/composables/useMenuRootId.ts +27 -0
- package/app/composables/useNavigation.ts +2 -5
- package/app/composables/useProductQuickView.ts +4 -1
- package/app/composables/useTopSellers.ts +4 -1
- package/app/utils/menuGroups.ts +57 -0
- package/app/utils/menuRoot.ts +15 -0
- package/app/utils/product.ts +132 -0
- package/nuxt.config.ts +3 -0
- package/package.json +1 -1
- package/server/api/__sitemap__/urls.get.ts +1 -4
- package/server/api/_cache/purge.post.ts +31 -0
- package/server/api/listing/[categoryId].get.ts +13 -1
- package/server/api/product/[productId].get.ts +10 -1
- package/server/api/search.get.ts +11 -1
- package/server/routes/llms.txt.ts +3 -3
- package/server/utils/cachePurge.ts +62 -0
- package/server/utils/menuRoot.ts +25 -0
- package/test/nuxt/NavigationMobileTop.test.ts +90 -0
- package/test/nuxt/SbSheetHeader.test.ts +44 -0
- package/test/unit/cachePurge.spec.ts +65 -0
- package/test/unit/menuGroups.spec.ts +56 -0
- package/test/unit/menuRoot.spec.ts +21 -0
- package/test/unit/product.spec.ts +78 -0
- package/.gitignore +0 -45
package/.env.example
CHANGED
|
@@ -50,4 +50,6 @@ NUXT_AI_CRAWLERS_SEARCH=true
|
|
|
50
50
|
NUXT_AI_CRAWLERS_TRAINING=true
|
|
51
51
|
|
|
52
52
|
NUXT_STORE_NAME="ShopBite"
|
|
53
|
-
STORE_DESCRIPTION="Reduziere deine Kosten und steigere deinen Umsatz"
|
|
53
|
+
STORE_DESCRIPTION="Reduziere deine Kosten und steigere deinen Umsatz"
|
|
54
|
+
# Secret of POST /api/_cache/purge, the backoffice empties the Store API caches after menu changes (empty = off)
|
|
55
|
+
NUXT_CACHE_PURGE_SECRET=
|
|
@@ -25,7 +25,7 @@ jobs:
|
|
|
25
25
|
|
|
26
26
|
- uses: pnpm/action-setup@v6
|
|
27
27
|
with:
|
|
28
|
-
version: 12.
|
|
28
|
+
version: 12.11.2
|
|
29
29
|
|
|
30
30
|
- uses: actions/setup-node@v7
|
|
31
31
|
with:
|
|
@@ -69,7 +69,7 @@ jobs:
|
|
|
69
69
|
|
|
70
70
|
- uses: pnpm/action-setup@v6
|
|
71
71
|
with:
|
|
72
|
-
version: 12.
|
|
72
|
+
version: 12.11.2
|
|
73
73
|
|
|
74
74
|
- uses: actions/setup-node@v7
|
|
75
75
|
with:
|
|
@@ -105,7 +105,7 @@ jobs:
|
|
|
105
105
|
|
|
106
106
|
- uses: pnpm/action-setup@v6
|
|
107
107
|
with:
|
|
108
|
-
version: 12.
|
|
108
|
+
version: 12.11.2
|
|
109
109
|
|
|
110
110
|
- uses: actions/setup-node@v7
|
|
111
111
|
with:
|
|
@@ -134,7 +134,7 @@ jobs:
|
|
|
134
134
|
|
|
135
135
|
- uses: pnpm/action-setup@v6
|
|
136
136
|
with:
|
|
137
|
-
version: 12.
|
|
137
|
+
version: 12.11.2
|
|
138
138
|
|
|
139
139
|
- uses: actions/setup-node@v7
|
|
140
140
|
with:
|
|
@@ -172,7 +172,7 @@ jobs:
|
|
|
172
172
|
|
|
173
173
|
- uses: pnpm/action-setup@v6
|
|
174
174
|
with:
|
|
175
|
-
version: 12.
|
|
175
|
+
version: 12.11.2
|
|
176
176
|
|
|
177
177
|
- uses: actions/setup-node@v7
|
|
178
178
|
with:
|
package/CLAUDE.md
CHANGED
|
@@ -98,10 +98,11 @@ Key custom composables:
|
|
|
98
98
|
|
|
99
99
|
The storefront reads plain Shopware entities with fixed names; seed data must match them exactly (`shopware/scripts/seed-demo-menu.py` is a working example):
|
|
100
100
|
|
|
101
|
-
- **Navigation:** menu sections are the children of the sales channel navigation root (`readNavigation main-navigation`),
|
|
101
|
+
- **Navigation:** menu sections are the children of the sales channel navigation root (`readNavigation main-navigation`), scoped to the menu root: `runtimeConfig.public.shopBite.menuCategoryId` if set, else `menuCategoryId` from `/store-api/shopbite/config` (plugin configuration per sales channel, #486). Always resolve it through `useMenuRootId()` (app) or `menuRootId()` (server), never read the env directly. Category icon comes from the custom field `shopbite_category_icon` (icones.js.org name such as `i-lucide-pizza`), set by the ShopBite plugin.
|
|
102
102
|
- **Property groups:** `Hauptzutaten` (ingredients on the card, deselectable on the detail page, removed ones are appended to the cart label with "-"), `Vegetarisch` and `Vegan` with the option `Ja` (diet badges), `Küche` (kitchen badge). Filterable groups appear as listing filters.
|
|
103
103
|
- **Extras:** product cross-sellings of type `productList`; the cross-selling name is the label ("Extras", "Beilagen"), the assigned products need a price and sales-channel visibility but no category. In the quick view each cross-selling is a collapsible checkbox list that shows 6 entries of a long list and a search field above 15 entries (`Product/CrossSelling.vue`). Selected extras are sent as children of a `container` line item (`useAddToCart.ts`, handled by the ShopBite plugin). The bon card opens the quick view sheet (`Product/QuickView.vue`), whose state is the `produkt` query parameter (product number) via `useProductQuickView` (#325). That deep link is the product URL (#289, no product pages): `productDeepLink()` (`app/utils/productUrl.ts`) takes the product SEO URL when it carries `?produkt=` (the ShopBite plugin sets the template, shopware-plugin#28; the number must be `|url_encode|raw` in the template, the SEO escaper slugifies `ß`) and otherwise builds it from the category SEO URL. The card name is a stretched link to it (a plain click stays in place); a number not in the list (a variant) is loaded and opens with its options selected. The quick view keeps its configuration in the URL (#411): `ohne` (deselected ingredients by name) and `extras` (extras by product number), written live with `router.replace` by `useQuickViewConfiguration`; a variant switch updates `produkt` without swapping the sheet's product (numbers the sheet switched to itself are pinned). The share button (`useShareLink`) uses the Web Share API, else copies the link.
|
|
104
104
|
- **Custom fields on products:** `shopbite_receipt_print_type` (`number` prints the menu number on the receipt, `label` prints the name) and `shopbite_delivery_time_factor` (int) and `shopbite_cart_upsell` (bool, suggests the product on the order confirmation step `/bestellung/bestaetigen` via `useCartUpsell`; variant parents are never suggested, a flag on a parent applies to its variants), all from the ShopBite plugin.
|
|
105
|
+
- **Allergens and additives (#485):** property groups `Allergene` and `Zusatzstoffe` from the ShopBite plugin (shopware-plugin#36, maintained in the backoffice), code in the option custom field `shopbite_code` (A-R, 1-12), product custom field `shopbite_allergens_checked` = lists complete. `getFoodLabels()`/`foodLabelCodes()`/`foodLabelText()`/`foodLabelLegend()` in `app/utils/product.ts`. The bon card shows the codes (names for screen readers), `Menu/FoodLabelLegend.vue` explains the codes used in the list (native `<details>`), `Product/FoodLabels.vue` writes them out in the sheet; without `shopbite_allergens_checked` the sheet points to the restaurant's phone and never says "no allergens". **Includes filter `translated` too:** custom fields only come back when `customFields` is in the `product` and `property_group_option` includes (listing, search, product route, quick view, top sellers).
|
|
105
106
|
- **Variants:** standard configurator settings (`Product/Configurator.vue`); `server/api/product/variant.get.ts` resolves a variant by option ids.
|
|
106
107
|
|
|
107
108
|
### Server routes
|
|
@@ -113,6 +114,8 @@ The storefront reads plain Shopware entities with fixed names; seed data must ma
|
|
|
113
114
|
`server/utils/storeApi.ts` — `storeApiPost()` and `MEDIA_INCLUDES` for the routes above. Always send Store API criteria as a POST body (also via `apiClient.invoke("… post …", { body })`): as `_criteria` query parameters Shopware ignores the `includes` projection and returns every field (#312).
|
|
114
115
|
Pages without content throw `createNotFoundError()` (`app/utils/notFound.ts`): fatal only in the browser, because a fatal error makes Nitro log a `[request error] [fatal]` block per scanner request (#363).
|
|
115
116
|
`modules/dev-tooling.ts` registers `@nuxt/eslint`, `@nuxt/hints` and `@nuxt/test-utils/module` only when the storefront itself is the project (not for shops extending the layer, not inside `node_modules`); they are devDependencies, so never add them to `modules` in `nuxt.config.ts` (#378).
|
|
117
|
+
The cached Store API handlers (`defineCachedEventHandler`, TTL `public.shopBite.cacheTtl`, a day for products, listings, categories) can be emptied by the backoffice: `POST /api/_cache/purge` with `Authorization: Bearer $NUXT_CACHE_PURGE_SECRET` (route off without the secret, #484). `server/utils/cachePurge.ts` picks the Nitro keys (`cache:nitro:handlers:<name>:<escaped key>`) by id, so a new cached handler needs its `name` in `ALL` there and the id in its `getKey`.
|
|
118
|
+
|
|
116
119
|
`modules/public-cache.ts` (local module, also active in shops extending the layer) adds a 30-day `Cache-Control` route rule for every file in the `public/` folders of all layers; Nitro serves them without one. `image.ipx.maxAge` gives resized logos the same lifetime. Replace a public file under a new name (#273).
|
|
117
120
|
`server/api/content/*.get.ts` — Nuxt Content queries for the pages. Do not call `queryCollection()` in page code: in the browser it downloads the SQLite WASM build (865 KB) on client-side navigation (#314).
|
|
118
121
|
|
|
@@ -134,8 +137,8 @@ Pages without content throw `createNotFoundError()` (`app/utils/notFound.ts`): f
|
|
|
134
137
|
- Components style only with the `--sb-*` colour tokens and `--font-sb-display`/`--font-sb-body` (the `--font` prefix makes @nuxt/fonts resolve the family and add metric fallbacks) through the `sb-*` utilities (`bg-sb-surface`, `text-sb-ink-muted`, `font-display`, `rounded-sb-control`). No colour mode switch: the preset fixes light or dark.
|
|
135
138
|
- Base components live in `app/components/Sb/` (`SbButton`, `SbIconButton`, `SbSegmentedControl`, `SbSheet`, `SbChoiceGroup`, `SbCheckbox`, `SbField` + `SbInput`, `SbSelect` (native), `SbStepper`, `SbChip`, `SbStatusPill`, `SbStars`, `SbConfirmDialog`, `SbIcon` with inline stroke icons). Behaviour and accessibility come from Reka UI (radio groups, checkbox, dialog and alert dialog with focus trap). Every control is at least 44 px and has a visible focus ring; icon-only buttons need a `label`; toggles use `aria-pressed` with a stable name. Hide a base component responsively with a wrapper (`<span class="hidden sm:block">`): its own `inline-flex` wins over a `hidden` passed as class. Elements focused only by script (`tabindex="-1"`) get no focus ring. Entry animations go behind `motion-safe:` (a `motion-reduce:animate-none` loses against `data-[state=open]:animate-…`).
|
|
136
139
|
- No toasts (removed in #445, other responses to be designed): results and errors show where they happen, e.g. `role="alert"` boxes in forms and the checkout, `role="status"` regions, the voucher error at its field.
|
|
137
|
-
- Menu (#441): `Category/Listing.vue` has three columns from `lg` (`MenuCategoryIndex` word list, the list, `MenuCartPanel`), `NavigationMobileTop` below `lg
|
|
138
|
-
- Product sheet (#442): `SbSheet` with a bon header (number strip, name as `DialogTitle`, diet and description as `DialogDescription`); `Configurator` shows variants as `SbChoiceGroup` (required), `DeselectIngredient` as `SbChip` ingredient chips (pressed = included), `CrossSelling` as `SbCheckbox` rows with a search, `Detail` a sticky footer with `SbStepper` and the add button.
|
|
140
|
+
- Menu (#441): `Category/Listing.vue` has three columns from `lg` (`MenuCategoryIndex` word list, the list, `MenuCartPanel`), `NavigationMobileTop` below `lg` (section chips; the open section's sub-categories as a second chip row led by "Alle", the current chip scrolls into view); `MenuSectionHeader` and `MenuBonCard` (one column, number strip, `photo` for the `bonPhoto` view). The card's button adds a product straight to the cart unless `productNeedsChoice()` (a parent with variants, `childCount` in the listing projection), which opens the quick view; extras stay optional. Cards hydrate on approach (`hydrateWhenVisible`), so a click on a card that has not hydrated yet is lost. Filters live in an `SbSheet`, sorting is an `SbSelect` (`toSortingOptions()`). A section with sub-sections (#487) lists its dishes grouped: direct dishes first, then an `h2` per sub-section in navigation order (`groupBySubsections()`/`findCategory()` in `app/utils/menuGroups.ts`, needs `categoryIds` in the listing projection); the sub-section pages stay.
|
|
141
|
+
- Product sheet (#442): `SbSheet` with a bon header (a custom `#header` gets the full width below a toolbar with the `#actions` and the close button; next to the buttons a long name broke after four letters on a 393 px phone) (number strip, name as `DialogTitle`, diet and description as `DialogDescription`); `Configurator` shows variants as `SbChoiceGroup` (required), `DeselectIngredient` as `SbChip` ingredient chips (pressed = included), `CrossSelling` as `SbCheckbox` rows with a search, `Detail` a sticky footer with `SbStepper` and the add button.
|
|
139
142
|
- Cart and checkout (#443): `MenuOrderMode` (`useOrderMode`) and the checkout's shipping section list ALL active shipping methods (`useShippingMethodChoice`, `onlyAvailable: false`), because a delivery-area rule on the shipping city never matches before the guest has an address (La Fattoria, fixed in 2.0.3); `useCheckoutMethodGuard` switches only a blocked payment method, a blocked shipping method is reported in the checkout and never switched to pickup. It shows the shipping methods as an `SbSegmentedControl` only when there are two to four. The header cart opens an `SbSheet`; `Cart/Item` uses `SbStepper` (remove at 1). The checkout is one page, `/bestellung/kasse` (the old step routes 301 there, `routeRules`): numbered sections Lieferung oder Abholung (`CheckoutPaymentAndDelivery part="shipping"`), Wann, Ihre Angaben (`CheckoutLoginOrRegister` with Reka tabs, `UserRegistrationForm` (logic in `useRegistrationForm`) / `UserLoginForm`, or `UserDetail`), Bezahlung (`part="payment"`) and the order card in `Checkout/Summary.vue`; the order button says "Zahlungspflichtig bestellen" (§ 312j BGB). Forms validate with Zod on submit and show errors at the fields plus a focused summary in form order; `AddressFields` sets `autocomplete`.
|
|
140
143
|
- Order and account (#445): `/bestellung/<id>/erfolg` and `/bestellung/<id>` render `OrderConfirmation` (`OrderDetail`: facts incl. the wished time from the `customerComment`, receipt lines, totals; call card), `/bestellung/<id>/fehler` a payment retry. Login, registration, password pages and the registration confirmation render in `UserAuthPanel`; the account pages in `layouts/account.vue` (link navigation with `aria-current`) with `UserAccountHeader`; `AddressForm` (also used when an address is edited in the checkout). Irreversible actions confirm with `SbConfirmDialog` (focus starts on "Abbrechen"). Search, contact (`useContactForm`), wishlist (`useWishlistEntries`, #467), content pages and `error.vue` (with its own `Header`/`Footer`, because the error page replaces `app.vue`) use the same pieces.
|
|
141
144
|
- Home page (#444): `pages/index.vue` renders `HomeHero` (kicker, `[highlight]{.text-primary}` part in the accent colour via `splitHighlight()`, buttons from `hero.links`, live status, rating card from the Google `usp`; the photo is `hero.image` with the blurred video `hero.poster` as fallback, cropped 4:5 at `hero.imagePosition` (object-position); it sits in a `<picture>` with a `min-width: 640px` source, so phones load a 1 px GIF), `HomeFacts` (`features`), `HomeCategories` (word list, `useHomeMenuCategories`; a wide first category image switches to a full-width photo below the words, and `sizes` asks for the width the crop needs, since thumbnails are picked by width), `HomeHighlights` (top sellers as bon cards), `HomeRestaurant` (`gallery` + opening hours in the SSR HTML) and the two-column `HomeFaq`; `cta` and `mittagstisch` in `content/index.yml` are not shown.
|
|
@@ -10687,6 +10687,11 @@
|
|
|
10687
10687
|
"type": "integer",
|
|
10688
10688
|
"minimum": 1,
|
|
10689
10689
|
"description": "Default delivery time in minutes"
|
|
10690
|
+
},
|
|
10691
|
+
"menuCategoryId": {
|
|
10692
|
+
"type": "string",
|
|
10693
|
+
"pattern": "^[0-9a-f]{32}$",
|
|
10694
|
+
"description": "Root category of the menu: the configured menu category, else the navigation category of the sales channel"
|
|
10690
10695
|
}
|
|
10691
10696
|
},
|
|
10692
10697
|
"required": ["isCheckoutEnabled", "deliveryTime"]
|
|
@@ -5362,6 +5362,8 @@ export type Schemas = {
|
|
|
5362
5362
|
deliveryTime: number;
|
|
5363
5363
|
/** Whether checkout is enabled for ShopBite */
|
|
5364
5364
|
isCheckoutEnabled: boolean;
|
|
5365
|
+
/** Root category of the menu: the configured menu category, else the navigation category of the sales channel (plugin 2026-10, missing in older plugins) */
|
|
5366
|
+
menuCategoryId?: string;
|
|
5365
5367
|
};
|
|
5366
5368
|
ShopBiteWishlistItem: {
|
|
5367
5369
|
/** Format: date-time */
|
|
@@ -46,6 +46,18 @@ useMenuSectionSchema(category, elements);
|
|
|
46
46
|
|
|
47
47
|
const quickView = useProductQuickView(elements);
|
|
48
48
|
|
|
49
|
+
// A section with sub-sections lists its dishes under their sub-section (#487):
|
|
50
|
+
// direct dishes first, then one heading per sub-section in backoffice order.
|
|
51
|
+
// Navigation to them is the chip row (phones) and the word-list index (desktop).
|
|
52
|
+
const { menuCardNavigation } = useNavigation(true);
|
|
53
|
+
const grouped = computed(() =>
|
|
54
|
+
groupBySubsections(
|
|
55
|
+
elements.value,
|
|
56
|
+
findCategory(menuCardNavigation.value ?? undefined, props.id)?.children ??
|
|
57
|
+
undefined,
|
|
58
|
+
),
|
|
59
|
+
);
|
|
60
|
+
|
|
49
61
|
// Derived from the listing data instead of snapshotted at setup time, which
|
|
50
62
|
// would be a hydration mismatch (#239); see useSortingSelection.
|
|
51
63
|
const { currentSorting } = useSortingSelection(currentSortingOrder);
|
|
@@ -209,6 +221,46 @@ async function openFilterDrawer() {
|
|
|
209
221
|
>
|
|
210
222
|
<LazyProductCardSkeleton v-for="i in 6" :key="i" />
|
|
211
223
|
</div>
|
|
224
|
+
<div
|
|
225
|
+
v-else-if="grouped"
|
|
226
|
+
class="flex flex-col gap-6 transition-opacity duration-200"
|
|
227
|
+
:class="{ 'pointer-events-none opacity-40': loading }"
|
|
228
|
+
>
|
|
229
|
+
<div v-if="grouped.direct.length" class="grid grid-cols-1 gap-3">
|
|
230
|
+
<MenuBonCardWhenVisible
|
|
231
|
+
v-for="product in grouped.direct"
|
|
232
|
+
:key="product.id"
|
|
233
|
+
:product="product"
|
|
234
|
+
:photo="menuView === 'bonPhoto'"
|
|
235
|
+
:href="productDeepLink(product, category?.seoUrl)"
|
|
236
|
+
@select="quickView.show"
|
|
237
|
+
/>
|
|
238
|
+
</div>
|
|
239
|
+
<section
|
|
240
|
+
v-for="group in grouped.groups"
|
|
241
|
+
:id="`u-${group.id}`"
|
|
242
|
+
:key="group.id"
|
|
243
|
+
:aria-labelledby="`u-${group.id}-titel`"
|
|
244
|
+
class="scroll-mt-28"
|
|
245
|
+
>
|
|
246
|
+
<h2
|
|
247
|
+
:id="`u-${group.id}-titel`"
|
|
248
|
+
class="mb-3 font-display text-xl text-sb-ink"
|
|
249
|
+
>
|
|
250
|
+
{{ group.name }}
|
|
251
|
+
</h2>
|
|
252
|
+
<div class="grid grid-cols-1 gap-3">
|
|
253
|
+
<MenuBonCardWhenVisible
|
|
254
|
+
v-for="product in group.products"
|
|
255
|
+
:key="product.id"
|
|
256
|
+
:product="product"
|
|
257
|
+
:photo="menuView === 'bonPhoto'"
|
|
258
|
+
:href="productDeepLink(product, category?.seoUrl)"
|
|
259
|
+
@select="quickView.show"
|
|
260
|
+
/>
|
|
261
|
+
</div>
|
|
262
|
+
</section>
|
|
263
|
+
</div>
|
|
212
264
|
<div
|
|
213
265
|
v-else
|
|
214
266
|
class="grid grid-cols-1 gap-3 transition-opacity duration-200"
|
|
@@ -223,6 +275,7 @@ async function openFilterDrawer() {
|
|
|
223
275
|
@select="quickView.show"
|
|
224
276
|
/>
|
|
225
277
|
</div>
|
|
278
|
+
<MenuFoodLabelLegend v-if="!showSkeleton" :products="elements" />
|
|
226
279
|
<LazyProductQuickView
|
|
227
280
|
v-if="quickView.mounted.value"
|
|
228
281
|
v-model:open="quickView.open.value"
|
|
@@ -35,6 +35,11 @@ const diets = computed(() =>
|
|
|
35
35
|
diet === "vegan" ? "Vegan" : "Vegetarisch",
|
|
36
36
|
),
|
|
37
37
|
);
|
|
38
|
+
// Allergen and additive codes (#485); the legend below the list explains
|
|
39
|
+
// them, screen readers get the names.
|
|
40
|
+
const foodLabels = computed(() => getFoodLabels(sortedProperties.value));
|
|
41
|
+
const foodCodes = computed(() => foodLabelCodes(foodLabels.value));
|
|
42
|
+
const foodText = computed(() => foodLabelText(foodLabels.value));
|
|
38
43
|
// Read before the name; the strip with the number is aria-hidden. Built in
|
|
39
44
|
// script: a trailing space in the template would be condensed away.
|
|
40
45
|
// The strip has a fixed width so the cards line up (#441); menu numbers
|
|
@@ -151,6 +156,14 @@ function onLinkClick(event: MouseEvent) {
|
|
|
151
156
|
<p v-if="ingredients" class="text-sm leading-snug text-sb-ink-muted">
|
|
152
157
|
{{ ingredients }}
|
|
153
158
|
</p>
|
|
159
|
+
<p
|
|
160
|
+
v-if="foodCodes.length"
|
|
161
|
+
class="text-xs tracking-wide text-sb-ink-muted tabular-nums"
|
|
162
|
+
data-testid="food-codes"
|
|
163
|
+
>
|
|
164
|
+
<span aria-hidden="true">{{ foodCodes.join(", ") }}</span
|
|
165
|
+
><span class="sr-only">{{ foodText }}</span>
|
|
166
|
+
</p>
|
|
154
167
|
<div class="mt-auto flex items-center justify-between pt-1.5">
|
|
155
168
|
<span class="text-base font-bold tabular-nums">{{ price }}</span>
|
|
156
169
|
<span
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { Schemas } from "#shopware";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Explains the allergen and additive codes on the cards of the list
|
|
6
|
+
* (#485). Native <details>, so the legend is in the SSR HTML.
|
|
7
|
+
*/
|
|
8
|
+
const props = defineProps<{ products: Schemas["Product"][] }>();
|
|
9
|
+
|
|
10
|
+
const legend = computed(() => foodLabelLegend(props.products));
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<template>
|
|
14
|
+
<details
|
|
15
|
+
v-if="legend.length"
|
|
16
|
+
class="mt-6 rounded-sb-card bg-sb-surface px-4 py-3 text-sm text-sb-ink"
|
|
17
|
+
>
|
|
18
|
+
<summary class="min-h-11 cursor-pointer py-2.5 font-semibold">
|
|
19
|
+
Allergene und Zusatzstoffe
|
|
20
|
+
</summary>
|
|
21
|
+
<dl class="grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1 pb-2">
|
|
22
|
+
<template v-for="entry in legend" :key="entry.code">
|
|
23
|
+
<dt class="font-semibold tabular-nums">{{ entry.code }}</dt>
|
|
24
|
+
<dd class="text-sb-ink-muted">{{ entry.name }}</dd>
|
|
25
|
+
</template>
|
|
26
|
+
</dl>
|
|
27
|
+
</details>
|
|
28
|
+
</template>
|
|
@@ -1,30 +1,119 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import type { Schemas } from "#shopware";
|
|
2
3
|
import { useNavigation } from "~/composables/useNavigation";
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
|
-
* Menu categories as
|
|
6
|
+
* Menu categories as horizontally scrolling rows on phones and tablets
|
|
6
7
|
* (#445); the desktop menu has the word-list index (MenuCategoryIndex).
|
|
8
|
+
* The first row holds the menu sections. When the open section has
|
|
9
|
+
* sub-categories (La Fattoria: Fleischgerichte → Vom Rind, Hähnchen …),
|
|
10
|
+
* a second row lists them, led by "Alle" for the section itself; deeper
|
|
11
|
+
* levels follow in the same row. The current chip scrolls into view.
|
|
7
12
|
*/
|
|
8
|
-
const {
|
|
13
|
+
const { menuCardNavigation } = useNavigation(true);
|
|
9
14
|
const route = useRoute();
|
|
10
15
|
|
|
16
|
+
type Chip = { label: string; to: string };
|
|
17
|
+
|
|
18
|
+
const normalize = (path: string) =>
|
|
19
|
+
decodeURI(path).replace(/\/+$/, "").toLowerCase();
|
|
20
|
+
|
|
11
21
|
const isCurrent = (to?: string) =>
|
|
12
|
-
!!to &&
|
|
22
|
+
!!to && normalize(route.path) === normalize(to);
|
|
23
|
+
|
|
24
|
+
function toChip(category: Schemas["Category"]): Chip {
|
|
25
|
+
return {
|
|
26
|
+
label: category.translated?.name ?? category.name ?? "",
|
|
27
|
+
to: category.seoUrl ?? "",
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function descendants(category: Schemas["Category"]): Schemas["Category"][] {
|
|
32
|
+
return (category.children ?? []).flatMap((child) => [
|
|
33
|
+
child,
|
|
34
|
+
...descendants(child),
|
|
35
|
+
]);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const sections = computed(() => menuCardNavigation.value ?? []);
|
|
39
|
+
|
|
40
|
+
// The section the current page belongs to: itself or one of its children.
|
|
41
|
+
const activeSection = computed(() =>
|
|
42
|
+
sections.value.find(
|
|
43
|
+
(section) =>
|
|
44
|
+
isCurrent(section.seoUrl ?? undefined) ||
|
|
45
|
+
descendants(section).some((child) =>
|
|
46
|
+
isCurrent(child.seoUrl ?? undefined),
|
|
47
|
+
),
|
|
48
|
+
),
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
const subChips = computed<Chip[]>(() => {
|
|
52
|
+
const section = activeSection.value;
|
|
53
|
+
if (!section) return [];
|
|
54
|
+
const children = descendants(section).map(toChip);
|
|
55
|
+
if (!children.length) return [];
|
|
56
|
+
return [{ label: "Alle", to: section.seoUrl ?? "" }, ...children];
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const nav = ref<HTMLElement | null>(null);
|
|
60
|
+
|
|
61
|
+
// Long rows scroll sideways: bring the current chips into view.
|
|
62
|
+
function revealCurrent() {
|
|
63
|
+
nav.value
|
|
64
|
+
?.querySelectorAll<HTMLElement>('[aria-current="page"], [data-section]')
|
|
65
|
+
.forEach((chip) =>
|
|
66
|
+
chip.scrollIntoView({ block: "nearest", inline: "center" }),
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
onMounted(revealCurrent);
|
|
71
|
+
watch(
|
|
72
|
+
() => route.path,
|
|
73
|
+
() => nextTick(revealCurrent),
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
const chipClass =
|
|
77
|
+
"flex min-h-11 items-center rounded-sb-control px-3.5 font-semibold whitespace-nowrap focus-visible:outline-3 focus-visible:-outline-offset-3 focus-visible:outline-sb-focus";
|
|
13
78
|
</script>
|
|
14
79
|
|
|
15
80
|
<template>
|
|
16
81
|
<nav
|
|
17
|
-
v-if="
|
|
82
|
+
v-if="sections.length"
|
|
83
|
+
ref="nav"
|
|
18
84
|
aria-label="Kategorien der Speisekarte"
|
|
19
85
|
class="border-b border-sb-line bg-sb-bg/95 font-body backdrop-blur-sm"
|
|
20
86
|
>
|
|
21
87
|
<ul class="flex gap-1 overflow-x-auto px-4 py-2 sm:px-6">
|
|
22
|
-
<li v-for="
|
|
88
|
+
<li v-for="section in sections" :key="section.id">
|
|
89
|
+
<NuxtLink
|
|
90
|
+
:to="section.seoUrl ?? ''"
|
|
91
|
+
:aria-current="isCurrent(section.seoUrl ?? '') ? 'page' : undefined"
|
|
92
|
+
:data-section="section === activeSection ? '' : undefined"
|
|
93
|
+
:class="[
|
|
94
|
+
chipClass,
|
|
95
|
+
section === activeSection
|
|
96
|
+
? 'bg-sb-ink text-sb-bg'
|
|
97
|
+
: 'text-sb-ink hover:bg-sb-muted',
|
|
98
|
+
]"
|
|
99
|
+
>{{ toChip(section).label }}</NuxtLink
|
|
100
|
+
>
|
|
101
|
+
</li>
|
|
102
|
+
</ul>
|
|
103
|
+
<ul
|
|
104
|
+
v-if="subChips.length"
|
|
105
|
+
:aria-label="`Unterkategorien von ${toChip(activeSection!).label}`"
|
|
106
|
+
class="flex gap-1 overflow-x-auto border-t border-sb-line px-4 py-2 text-[15px] sm:px-6"
|
|
107
|
+
>
|
|
108
|
+
<li v-for="chip in subChips" :key="chip.to">
|
|
23
109
|
<NuxtLink
|
|
24
|
-
:to="
|
|
25
|
-
:aria-current="isCurrent(
|
|
26
|
-
class="
|
|
27
|
-
|
|
110
|
+
:to="chip.to"
|
|
111
|
+
:aria-current="isCurrent(chip.to) ? 'page' : undefined"
|
|
112
|
+
:class="[
|
|
113
|
+
chipClass,
|
|
114
|
+
'border border-sb-line text-sb-ink hover:bg-sb-muted aria-[current=page]:border-sb-ink aria-[current=page]:bg-sb-muted',
|
|
115
|
+
]"
|
|
116
|
+
>{{ chip.label }}</NuxtLink
|
|
28
117
|
>
|
|
29
118
|
</li>
|
|
30
119
|
</ul>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { Schemas } from "#shopware";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Allergens and additives in the product sheet (#485). Without the
|
|
6
|
+
* restaurant's confirmation an empty list is "not entered yet", so the
|
|
7
|
+
* sheet never claims "free of allergens" then and points to the phone.
|
|
8
|
+
*/
|
|
9
|
+
const props = defineProps<{ product: Schemas["Product"] }>();
|
|
10
|
+
|
|
11
|
+
const { site } = useRuntimeConfig().public;
|
|
12
|
+
const labels = computed(() =>
|
|
13
|
+
getFoodLabels(
|
|
14
|
+
props.product.sortedProperties as Schemas["PropertyGroup"][] | undefined,
|
|
15
|
+
),
|
|
16
|
+
);
|
|
17
|
+
const checked = computed(() => allergensChecked(props.product));
|
|
18
|
+
const text = computed(() => foodLabelText(labels.value));
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<template>
|
|
22
|
+
<p class="text-sm text-sb-ink-muted" data-testid="food-labels">
|
|
23
|
+
<template v-if="text">{{ text }}</template>
|
|
24
|
+
<template v-else-if="checked"
|
|
25
|
+
>Ohne kennzeichnungspflichtige Allergene und Zusatzstoffe.</template
|
|
26
|
+
>
|
|
27
|
+
<template v-else>
|
|
28
|
+
Angaben zu Allergenen und Zusatzstoffen erhalten Sie im
|
|
29
|
+
Restaurant<template v-if="site.telephone"
|
|
30
|
+
>:
|
|
31
|
+
<a
|
|
32
|
+
:href="toTelHref(site.telephone)"
|
|
33
|
+
class="font-semibold text-sb-ink underline underline-offset-4"
|
|
34
|
+
>{{ site.telephone }}</a
|
|
35
|
+
></template
|
|
36
|
+
>.
|
|
37
|
+
</template>
|
|
38
|
+
</p>
|
|
39
|
+
</template>
|
|
@@ -39,25 +39,43 @@ const open = defineModel<boolean>("open", { default: false });
|
|
|
39
39
|
<div class="flex justify-center pt-2.5 md:hidden" aria-hidden="true">
|
|
40
40
|
<span class="h-1 w-9 rounded-full bg-sb-line" />
|
|
41
41
|
</div>
|
|
42
|
-
|
|
42
|
+
<!-- A custom header (the product sheet's bon card) gets the full
|
|
43
|
+
width below a toolbar with the actions and the close button:
|
|
44
|
+
next to three 44 px buttons a long dish name broke after four
|
|
45
|
+
letters on a 393 px phone. -->
|
|
46
|
+
<header
|
|
47
|
+
v-if="$slots.header"
|
|
48
|
+
class="flex flex-col gap-2 px-5 pt-2 pb-2 md:pt-4"
|
|
49
|
+
>
|
|
50
|
+
<div class="flex items-center justify-end gap-2">
|
|
51
|
+
<slot name="actions" />
|
|
52
|
+
<DialogClose as-child>
|
|
53
|
+
<SbIconButton label="Schließen">
|
|
54
|
+
<SbIcon name="close" />
|
|
55
|
+
</SbIconButton>
|
|
56
|
+
</DialogClose>
|
|
57
|
+
</div>
|
|
58
|
+
<div class="min-w-0">
|
|
59
|
+
<slot name="header" />
|
|
60
|
+
</div>
|
|
61
|
+
</header>
|
|
62
|
+
<header v-else class="flex items-start gap-3 px-5 pt-3 pb-2 md:pt-6">
|
|
43
63
|
<div class="min-w-0 flex-1">
|
|
44
|
-
<
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
</DialogDescription>
|
|
60
|
-
</slot>
|
|
64
|
+
<DialogTitle
|
|
65
|
+
:class="
|
|
66
|
+
hideTitle
|
|
67
|
+
? 'sr-only'
|
|
68
|
+
: 'font-display text-2xl leading-tight text-sb-ink'
|
|
69
|
+
"
|
|
70
|
+
>
|
|
71
|
+
{{ title }}
|
|
72
|
+
</DialogTitle>
|
|
73
|
+
<DialogDescription
|
|
74
|
+
v-if="description"
|
|
75
|
+
class="mt-1 text-sm text-sb-ink-muted"
|
|
76
|
+
>
|
|
77
|
+
{{ description }}
|
|
78
|
+
</DialogDescription>
|
|
61
79
|
</div>
|
|
62
80
|
<slot name="actions" />
|
|
63
81
|
<DialogClose as-child>
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The menu sections of the home page (#388, #444): the children of the menu
|
|
3
|
-
* root (
|
|
3
|
+
* root (useMenuRootId: env, plugin configuration, navigation root) with their photo
|
|
4
4
|
* (`category.media`). Shared by the tiles and the word list of the presets.
|
|
5
5
|
*/
|
|
6
6
|
export async function useHomeMenuCategories() {
|
|
7
7
|
const { apiClient } = useShopwareContext();
|
|
8
|
-
const
|
|
9
|
-
const rootId = config.public.shopBite.menuCategoryId || "main-navigation";
|
|
8
|
+
const menuRootId = useMenuRootId();
|
|
10
9
|
|
|
11
10
|
const { data: categories } = await useAsyncData(
|
|
12
11
|
"home-menu-categories",
|
|
@@ -30,7 +29,10 @@ export async function useHomeMenuCategories() {
|
|
|
30
29
|
media_thumbnail: ["url", "width"],
|
|
31
30
|
},
|
|
32
31
|
},
|
|
33
|
-
pathParams: {
|
|
32
|
+
pathParams: {
|
|
33
|
+
activeId: "main-navigation",
|
|
34
|
+
rootId: await menuRootId(),
|
|
35
|
+
},
|
|
34
36
|
},
|
|
35
37
|
);
|
|
36
38
|
return response.data;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolves the menu root once per visit (app/utils/menuRoot.ts). Call the
|
|
3
|
+
* returned function inside `useAsyncData` handlers; without the environment
|
|
4
|
+
* variable it asks the plugin configuration a single time.
|
|
5
|
+
*/
|
|
6
|
+
export function useMenuRootId() {
|
|
7
|
+
const { apiClient } = useShopwareContext();
|
|
8
|
+
const configured = useRuntimeConfig().public.shopBite.menuCategoryId as
|
|
9
|
+
string | undefined;
|
|
10
|
+
const root = useState<string | null>("menu-root-id", () =>
|
|
11
|
+
configured ? configured : null,
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
return async (): Promise<string> => {
|
|
15
|
+
if (root.value) return root.value;
|
|
16
|
+
try {
|
|
17
|
+
const { data } = await apiClient.invoke(
|
|
18
|
+
"shopbite.config.get get /shopbite/config",
|
|
19
|
+
);
|
|
20
|
+
root.value = pickMenuRoot(configured, data.menuCategoryId);
|
|
21
|
+
return root.value;
|
|
22
|
+
} catch {
|
|
23
|
+
// not remembered: the next call tries again
|
|
24
|
+
return pickMenuRoot(configured, undefined);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
@@ -11,10 +11,7 @@ export interface NavigationMenuItem {
|
|
|
11
11
|
|
|
12
12
|
export function useNavigation(withChildren: boolean | undefined) {
|
|
13
13
|
const { apiClient } = useShopwareContext();
|
|
14
|
-
const
|
|
15
|
-
const menuCategoryId = computed(
|
|
16
|
-
() => config.public.shopBite.menuCategoryId ?? "main-navigation",
|
|
17
|
-
);
|
|
14
|
+
const menuRootId = useMenuRootId();
|
|
18
15
|
|
|
19
16
|
// Sent as a POST body: as `_criteria` query parameters the projection is
|
|
20
17
|
// ignored and every category arrives with media, translations, cms page
|
|
@@ -101,7 +98,7 @@ export function useNavigation(withChildren: boolean | undefined) {
|
|
|
101
98
|
body: criteria,
|
|
102
99
|
pathParams: {
|
|
103
100
|
activeId: "main-navigation",
|
|
104
|
-
rootId:
|
|
101
|
+
rootId: await menuRootId(),
|
|
105
102
|
},
|
|
106
103
|
},
|
|
107
104
|
);
|
|
@@ -190,9 +190,12 @@ async function loadProductByNumber(
|
|
|
190
190
|
"translated",
|
|
191
191
|
"description",
|
|
192
192
|
"sortedProperties",
|
|
193
|
+
// Allergens checked (#485); includes filter `translated` as well,
|
|
194
|
+
// so custom fields only come back when listed here.
|
|
195
|
+
"customFields",
|
|
193
196
|
],
|
|
194
197
|
property_group: ["id", "name", "translated", "options"],
|
|
195
|
-
property_group_option: ["id", "name", "translated"],
|
|
198
|
+
property_group_option: ["id", "name", "translated", "customFields"],
|
|
196
199
|
},
|
|
197
200
|
associations: {
|
|
198
201
|
properties: { associations: { group: {} } },
|
|
@@ -30,6 +30,9 @@ export function useTopSellers(): useTopSellersReturn {
|
|
|
30
30
|
"available",
|
|
31
31
|
"cover",
|
|
32
32
|
"sortedProperties",
|
|
33
|
+
// Allergens checked (#485); includes filter `translated` as well,
|
|
34
|
+
// so custom fields only come back when listed here.
|
|
35
|
+
"customFields",
|
|
33
36
|
// Card link to the quick view deep link (#289).
|
|
34
37
|
"seoUrls",
|
|
35
38
|
],
|
|
@@ -38,7 +41,7 @@ export function useTopSellers(): useTopSellersReturn {
|
|
|
38
41
|
media: ["url", "thumbnails"],
|
|
39
42
|
media_thumbnail: ["width", "url"],
|
|
40
43
|
property_group: ["id", "name", "translated", "options"],
|
|
41
|
-
property_group_option: ["id", "name", "translated"],
|
|
44
|
+
property_group_option: ["id", "name", "translated", "customFields"],
|
|
42
45
|
},
|
|
43
46
|
associations: {
|
|
44
47
|
cover: { associations: { media: {} } },
|