- Move the global 'Show macros' toggle from the Palette tab to the Catalog tab,
next to 'Cargar menú', where catalog assembly lives
- Section.showMacros boolean (default true) + migration 0006; existing sections
default to showing (so turning the global on shows all by default)
- Per-section toggle in the editor, visible only when the global toggle is on
- Hierarchy: global wins. A dish shows macros only if Restaurant.showMacros AND
its Section.showMacros are both true. Applies to card flip, list tap-image, the
gallery, and the color-code legend (legend shows only if some visible section does)
- Turning the global off only HIDES — macro data is never deleted; the disclaimer
is reassuring ('Macros will stop showing to the public, but they are not deleted')
- Live read: global + per-section showMacros are overlaid onto the published
snapshot at read time (new applyLiveSectionMacros helper) so toggles take effect
instantly without republishing; old snapshots default section macros on
- sections PATCH accepts showMacros; settings PATCH still handles the global
- i18n: sectionMacros + soft disclaimer (es/en parity); hint reworded
Verified: build passes; 6 migrations apply; section toggle persists; /menu reflects
the global+section hierarchy live; macro data preserved in DB and API when toggled off.
106 lines
3.8 KiB
Plaintext
106 lines
3.8 KiB
Plaintext
generator client {
|
|
provider = "prisma-client-js"
|
|
// native = host platform (builder/runner are both node:20-alpine = musl).
|
|
// The explicit musl target guards the runtime engine in the final image.
|
|
binaryTargets = ["native", "linux-musl-openssl-3.0.x"]
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
model Restaurant {
|
|
id String @id @default(cuid())
|
|
slug String @unique
|
|
name String
|
|
editorSecret String
|
|
username String
|
|
hashedPassword String
|
|
palette Json @default("{}")
|
|
qrConfig Json @default("{}") // artistic QR styling (qr-code-styling config)
|
|
ordersEnabled Boolean @default(false)
|
|
showMacros Boolean @default(false) // when false, the public menu hides all macro layers
|
|
|
|
defaultLocale String @default("es")
|
|
active Boolean @default(true)
|
|
publishedVersionId String? @unique
|
|
createdAt DateTime @default(now())
|
|
|
|
publishedVersion MenuVersion? @relation("PublishedVersion", fields: [publishedVersionId], references: [id])
|
|
versions MenuVersion[] @relation("RestaurantVersions")
|
|
sections Section[]
|
|
products Product[]
|
|
orders Order[]
|
|
}
|
|
|
|
// Versioning system: a published snapshot of the whole menu.
|
|
model MenuVersion {
|
|
id String @id @default(cuid())
|
|
restaurantId String
|
|
versionName String
|
|
snapshot Json
|
|
publishedAt DateTime @default(now())
|
|
createdBy String?
|
|
|
|
restaurant Restaurant @relation("RestaurantVersions", fields: [restaurantId], references: [id], onDelete: Cascade)
|
|
publishedFor Restaurant? @relation("PublishedVersion")
|
|
|
|
@@index([restaurantId])
|
|
}
|
|
|
|
// Working DRAFT (not what the public sees).
|
|
model Section {
|
|
id String @id @default(cuid())
|
|
restaurantId String
|
|
name Json // { es, en }
|
|
order Int @default(0)
|
|
showMacros Boolean @default(true) // per-section override; only applies when Restaurant.showMacros is on
|
|
createdAt DateTime @default(now())
|
|
|
|
restaurant Restaurant @relation(fields: [restaurantId], references: [id], onDelete: Cascade)
|
|
products Product[]
|
|
|
|
@@index([restaurantId])
|
|
}
|
|
|
|
// Working DRAFT product.
|
|
model Product {
|
|
id String @id @default(cuid())
|
|
sectionId String
|
|
restaurantId String
|
|
name Json // { es, en }
|
|
description Json @default("{}") // { es, en }
|
|
price Decimal @default(0) @db.Decimal(10, 2)
|
|
order Int @default(0)
|
|
isActive Boolean @default(true)
|
|
allergens String[] @default([])
|
|
dietTags String[] @default([])
|
|
macros Json @default("{}") // { protein, carbs, sugar, fat, fiber, kcal }
|
|
media Json @default("[]") // [{ type, path, order }]
|
|
translationStatus Json @default("{}") // { en: auto|reviewed }
|
|
aiEstimated Json @default("{}") // { macros: bool, allergens: bool } — flags AI-inferred data to verify
|
|
createdAt DateTime @default(now())
|
|
|
|
section Section @relation(fields: [sectionId], references: [id], onDelete: Cascade)
|
|
restaurant Restaurant @relation(fields: [restaurantId], references: [id], onDelete: Cascade)
|
|
|
|
@@index([restaurantId])
|
|
@@index([sectionId])
|
|
}
|
|
|
|
model Order {
|
|
id String @id @default(cuid())
|
|
restaurantId String
|
|
tableNumber Int
|
|
items Json // [{ productId, name, qty, note?, price? }]
|
|
note String? // general note for the whole order
|
|
status String @default("active") // active | completed
|
|
createdAt DateTime @default(now())
|
|
completedAt DateTime?
|
|
|
|
restaurant Restaurant @relation(fields: [restaurantId], references: [id], onDelete: Cascade)
|
|
|
|
@@index([restaurantId, status])
|
|
}
|