Format-Templates: Standard je Format (default_format) statt fester Keys
format_templates.default_format (Format-Key) -> Druck-Dialog waehlt das als Standard markierte Template vor, unabhaengig von fest verdrahteten Keys. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -399,6 +399,7 @@ const collections = [
|
||||
f('key', 'string', { interface: 'input', unique: true, required: true }),
|
||||
f('name', 'string', { interface: 'input', required: true }),
|
||||
dropdown('type', ['brief', 'umschlag', 'signatur'], { default: 'brief' }),
|
||||
f('default_format', 'string', { interface: 'input', note: 'Standard-Template für dieses Format (Format-Key: a4, a6_hoch, a6_quer, dinlang, c6). Leer = kein Standard.' }),
|
||||
f('width', 'float', { interface: 'input', note: 'Zoll' }),
|
||||
f('height', 'float', { interface: 'input', note: 'Zoll' }),
|
||||
f('xpos', 'float', { interface: 'input', default: 0 }),
|
||||
|
||||
@@ -308,7 +308,7 @@ const Board = defineComponent({
|
||||
} }),
|
||||
ladeJobs(),
|
||||
ladeMachines(),
|
||||
api.get('/items/format_templates', { params: { limit: -1, fields: 'id,key,name,type,width,height,xpos,ypos,scale,rotation' } }),
|
||||
api.get('/items/format_templates', { params: { limit: -1, fields: 'id,key,name,type,width,height,xpos,ypos,scale,rotation,default_format' } }),
|
||||
api.get('/items/muster_settings', { params: { fields: 'text_du,text_sie' } }).catch(() => ({ data: { data: { text_du: '', text_sie: '' } } })),
|
||||
]);
|
||||
orders.value = o.data?.data || [];
|
||||
@@ -578,15 +578,18 @@ const Board = defineComponent({
|
||||
|
||||
// ── Druck-Popup ──
|
||||
const tplByKey = (key, typ) => templates.value.find((t) => t.key === key && t.type === typ) || templates.value.find((t) => t.type === typ) || null;
|
||||
// Bevorzugt das als Standard fürs Format markierte Template (default_format), sonst Fallback.
|
||||
const tplForFormat = (fmt, typ) => (fmt && templates.value.find((t) => t.type === typ && t.default_format && t.default_format === fmt)) || null;
|
||||
const tplToFelder = (t) => ({ tplId: t?.id ?? null, width: t?.width ?? 0, height: t?.height ?? 0, xpos: t?.xpos ?? 0, ypos: t?.ypos ?? 0, scale: t?.scale ?? 1, rotation: t?.rotation ?? 0 });
|
||||
|
||||
function openDruck(order) {
|
||||
const bt = tplByKey(LETTER_TPL[order.format?.key] || 'a4_single', 'brief');
|
||||
// Standard-Template fürs Format (default_format) hat Vorrang, sonst alte Zuordnung.
|
||||
const bt = tplForFormat(order.format?.key, 'brief') || tplByKey(LETTER_TPL[order.format?.key] || 'a4_single', 'brief');
|
||||
const wantsEnv = order.needs_envelope && order.envelope_labeling && order.envelope_labeling !== 'keine';
|
||||
// Bei individuellem Text die Variante 2 des Kuverts vorschlagen (v1 = Empfängeradresse).
|
||||
let envKey = ENVELOPE_TPL[order.envelope_format] || 'kuvert_a_v1';
|
||||
if (wantsEnv && order.envelope_labeling === 'freitext') envKey = envKey.replace('_v1', '_v2');
|
||||
const et = wantsEnv ? (tplByKey(envKey, 'umschlag') || tplByKey(ENVELOPE_TPL[order.envelope_format], 'umschlag')) : null;
|
||||
const et = wantsEnv ? (tplForFormat(order.envelope_format, 'umschlag') || tplByKey(envKey, 'umschlag') || tplByKey(ENVELOPE_TPL[order.envelope_format], 'umschlag')) : null;
|
||||
const n = Math.max(1, order.entries_count || 1);
|
||||
druck.order = order;
|
||||
druck.machine = aktiveMaschinen.value[0]?.id ?? null;
|
||||
|
||||
Reference in New Issue
Block a user