diff --git a/bootstrap/bootstrap.mjs b/bootstrap/bootstrap.mjs index 3ea1751..687dfaf 100644 --- a/bootstrap/bootstrap.mjs +++ b/bootstrap/bootstrap.mjs @@ -185,6 +185,10 @@ const collections = [ f('active', 'boolean', { interface: 'boolean', default: true, note: 'Im Konfigurator (app.skrift.de) sichtbar.' }), f('show_manual', 'boolean', { interface: 'boolean', default: true, note: 'Im manuellen Druck (Admin) sichtbar.' }), f('show_check', 'boolean', { interface: 'boolean', default: false, note: 'Im Textmengencheck (app.skrift.de/textmenge) wählbar – auch ohne öffentliche Bestellung.' }), + // Für das Ausrichtungs-Dropdown im Textmengencheck: gleiche family + je Ausrichtung + // ein Eintrag (hoch/quer). Leere orientation = Format hat nur eine Ausrichtung. + f('family', 'string', { interface: 'input', note: 'Format-Familie fürs Dropdown (z. B. A4, A5, A6, DIN lang). Leer = eigener Eintrag.' }), + dropdown('orientation', ['hoch', 'quer'], { note: 'Ausrichtung innerhalb der Familie. Leer = keine Wahl (nur eine Ausrichtung).' }), ] }, { collection: 'motifs', meta: { icon: 'image', note: 'Motiv-Katalog für Postkarten.' }, fields: [ @@ -842,19 +846,31 @@ async function applySeed() { } catch { /* nicht kritisch */ } const formats = [ - { product: productByKey.briefe.id, key: 'a4', name: 'A4', active: true, show_check: true }, + { product: productByKey.briefe.id, key: 'a4', name: 'A4', active: true, show_check: true, family: 'A4', orientation: null }, // A5 + DIN lang (komplett beschrieben, Volltext): NUR manueller Druck + Textmengencheck, // NICHT im öffentlichen Konfigurator bestellbar. Render-Keys = Directus-render_formats-Keys. - { product: productByKey.briefe.id, key: 'a5p', name: 'A5 Hochformat', active: false, show_manual: true, show_check: true }, - { product: productByKey.briefe.id, key: 'a5l', name: 'A5 Querformat', active: false, show_manual: true, show_check: true }, - { product: productByKey.briefe.id, key: 'dinlang_karte', name: 'DIN lang (komplett beschrieben)', active: false, show_manual: true, show_check: true }, - { product: productByKey.postkarten.id, key: 'a6_hoch', name: 'A6 Hochformat', active: true, show_check: true }, - { product: productByKey.postkarten.id, key: 'a6_quer', name: 'A6 Querformat', active: true, show_check: true }, + // Gleiche family + orientation hoch/quer → Ausrichtungs-Dropdown im Textmengencheck. + { product: productByKey.briefe.id, key: 'a5p', name: 'A5 Hochformat', active: false, show_manual: true, show_check: true, family: 'A5', orientation: 'hoch' }, + { product: productByKey.briefe.id, key: 'a5l', name: 'A5 Querformat', active: false, show_manual: true, show_check: true, family: 'A5', orientation: 'quer' }, + { product: productByKey.briefe.id, key: 'dinlang_karte', name: 'DIN lang (komplett beschrieben)', active: false, show_manual: true, show_check: true, family: 'DIN lang', orientation: null }, + { product: productByKey.postkarten.id, key: 'a6_hoch', name: 'A6 Hochformat', active: true, show_check: true, family: 'A6', orientation: 'hoch' }, + { product: productByKey.postkarten.id, key: 'a6_quer', name: 'A6 Querformat', active: true, show_check: true, family: 'A6', orientation: 'quer' }, // Postkarten-Layout (Text links, Adresse rechts) – NUR manueller Druck, nicht in der App. { product: productByKey.postkarten.id, key: 'a6_postkarte', name: 'A6 Postkarte (Text + Adresse)', active: false, show_manual: true }, { product: productByKey.postkarten.id, key: 'dinlang_postkarte', name: 'DIN lang Postkarte (Text + Adresse)', active: false, show_manual: true }, ]; - for (const fmt of formats) await seedItem('formats', 'key', fmt); + // Upsert: neue Zeilen anlegen; bei bestehenden NUR die Check-/Ausrichtungs-Metadaten + // nachziehen (admin-gepflegte Felder name/active/product/show_manual bleiben unangetastet). + for (const fmt of formats) { + const vorhanden = await api('GET', `/items/formats?filter[key][_eq]=${encodeURIComponent(fmt.key)}&limit=1&fields=id`); + if (vorhanden && vorhanden.length) { + const meta = {}; + for (const k of ['show_check', 'family', 'orientation']) if (fmt[k] !== undefined) meta[k] = fmt[k]; + if (Object.keys(meta).length) await api('PATCH', `/items/formats/${vorhanden[0].id}`, meta); + } else { + await api('POST', '/items/formats', fmt); log('seed + formats.' + fmt.key); + } + } // Preise: kundenseitige Werte aus dem Konfigurator; 0 = im Admin setzen. const priceItems = [