diff --git a/src/app/core/model/operations.ts b/src/app/core/model/operations.ts index cbbcab3..3a3a1e0 100644 --- a/src/app/core/model/operations.ts +++ b/src/app/core/model/operations.ts @@ -623,7 +623,9 @@ export function forgetPrintFor(doc: TreeDocument, kept: PrintSettings): TreeDocu /** Print settings kept for a couple, made the print's settings. */ export function useSavedPrint(doc: TreeDocument, kept: PrintSettings): TreeDocument { - return { ...doc, print: { ...kept } }; + // Who was left out is the studio's to hold (it is only kept with the saved print), not a setting of the print at hand. + const { omitted: _left, ...print } = kept; + return { ...doc, print }; } /** diff --git a/src/app/core/model/types.ts b/src/app/core/model/types.ts index aef8034..750a381 100644 --- a/src/app/core/model/types.ts +++ b/src/app/core/model/types.ts @@ -370,6 +370,11 @@ export interface PrintSettings extends CardSettings { * family), whatever the reach above leaves out: the parents of a former partner, say. */ added?: readonly string[]; + /** + * People left out of the print by a click on their card or a line, by id. Only kept with the settings saved for a + * couple (TreeDocument.savedPrints): the print at hand holds them in the studio's state until it is saved. + */ + omitted?: readonly string[]; /** People whose partners stand on the other side of them, by id (see LayoutOptions.flipped); asked from a card's menu. */ flipped?: readonly string[]; /** How each couple stands, as a word at their marker: "married", "divorced". */ diff --git a/src/app/core/xml/parser.ts b/src/app/core/xml/parser.ts index b8a7077..8691162 100644 --- a/src/app/core/xml/parser.ts +++ b/src/app/core/xml/parser.ts @@ -194,6 +194,7 @@ const KNOWN = { 'lineBends', 'gaps', 'added', + 'omitted', 'flipped', 'ancestors', 'descendants', @@ -525,6 +526,8 @@ class Reader { // "I12 I13 I40": people brought onto the print by hand. const added = [...new Set((el.getAttribute('added') ?? '').split(/\s+/).filter(Boolean))]; if (added.length) print.added = added; + const omitted = [...new Set((el.getAttribute('omitted') ?? '').split(/\s+/).filter(Boolean))]; + if (omitted.length) print.omitted = omitted; const flipped = [...new Set((el.getAttribute('flipped') ?? '').split(/\s+/).filter(Boolean))]; if (flipped.length) print.flipped = flipped; const box = parseLegendBox(el.getAttribute('legendBox')); diff --git a/src/app/core/xml/serializer.ts b/src/app/core/xml/serializer.ts index 03d53bb..9f3d6b0 100644 --- a/src/app/core/xml/serializer.ts +++ b/src/app/core/xml/serializer.ts @@ -260,6 +260,7 @@ function writePrint(w: XmlWriter, p: PrintSettings): void { : undefined, ], ['added', p.added?.length ? p.added.join(' ') : undefined], + ['omitted', p.omitted?.length ? p.omitted.join(' ') : undefined], ['flipped', p.flipped?.length ? p.flipped.join(' ') : undefined], ['tiles', p.tiles || undefined], ['tilesBorderless', p.tilesBorderless ? 'true' : undefined], diff --git a/src/app/core/xml/xml.spec.ts b/src/app/core/xml/xml.spec.ts index d6747e2..1cfc811 100644 --- a/src/app/core/xml/xml.spec.ts +++ b/src/app/core/xml/xml.spec.ts @@ -223,6 +223,13 @@ describe('XML format', () => { expect(serializeTree(read.doc)).not.toMatch(/legendTop/); }); + it('keeps who a saved print leaves out', () => { + const doc = sampleDocument(new Date('2026-01-01T00:00:00Z')); + doc.savedPrints = [{ ...DEFAULT_PRINT, centerId: 'I1', omitted: ['I3', 'I7'] }]; + expect(serializeTree(doc)).toContain('omitted="I3 I7"'); + expect(roundTrip(doc).savedPrints?.[0].omitted).toEqual(['I3', 'I7']); + }); + it('round-trips what is arranged by hand in a print: moved cards, the title, the options', () => { const doc = sampleDocument(new Date('2026-01-01T00:00:00Z')); doc.print = { diff --git a/src/app/features/print-studio/print-address.ts b/src/app/features/print-studio/print-address.ts index f0d0907..935ff1b 100644 --- a/src/app/features/print-studio/print-address.ts +++ b/src/app/features/print-studio/print-address.ts @@ -69,6 +69,7 @@ const IN_ADDRESS: { readonly [K in keyof PrintSettings]-?: boolean } = { lineBends: false, gaps: true, added: true, + omitted: false, flipped: true, unionText: true, tiles: true, diff --git a/src/app/features/print-studio/print-model.ts b/src/app/features/print-studio/print-model.ts index 475dafb..ad8b7d0 100644 --- a/src/app/features/print-studio/print-model.ts +++ b/src/app/features/print-studio/print-model.ts @@ -236,6 +236,15 @@ export class PrintModel { this.staged.set({}); }); }); + // The studio opens (or a tree is read while it is open): whoever the print saved for the middle leaves out stays out. + effect(() => { + this.store.loadId(); + if (!this.ui.printOpen()) return; + untracked(() => { + const left = this.kept()?.omitted; + if (left?.length) this.ui.setPrintOmitted(left); + }); + }); } private draw(request: PosterInput | null): void { @@ -877,16 +886,31 @@ export class PrintModel { if (s.centerId === null) { const whole: PrintSettings = { ...s, centerId: null }; delete whole.partnerId; - return whole; + return this.withOmitted(whole); } const p = this.poster(); const drawn = p?.centerId === this.middleId() ? (p.partnerId ?? undefined) : undefined; const partnerId = s.partnerId === null ? null : (s.partnerId ?? drawn); const keep: PrintSettings = { ...s, centerId: this.middleId(), partnerId }; if (partnerId === undefined) delete keep.partnerId; - return keep; + return this.withOmitted(keep); }); + /** Settings to keep, with the people left out of the print (in the order of their ids, so the same people compare equal). */ + private withOmitted(keep: PrintSettings): PrintSettings { + const omitted = [...this.ui.printOmitted()].sort(); + const out = { ...keep }; + if (omitted.length) out.omitted = omitted; + else delete out.omitted; + return out; + } + + /** Takes the saved print for the print at hand, with the people it leaves out. */ + private useKept(kept: PrintSettings, step: string): void { + this.store.update((doc) => useSavedPrint(doc, kept), step); + this.ui.setPrintOmitted(kept.omitted ?? []); + } + /** The print settings kept for the couple in the middle, as kept (see TreeDocument.savedPrints). */ private readonly kept = computed(() => { const doc = this.store.doc(); @@ -937,7 +961,7 @@ export class PrintModel { const kept = this.kept(); if (!kept) return; this.staged.set({}); - this.store.update((doc) => useSavedPrint(doc, kept), 'print use'); + this.useKept(kept, 'print use'); this.ui.printEdited(); } @@ -949,8 +973,12 @@ export class PrintModel { this.staged.set({}); const centerId = id || null; const kept = savedPrintOf(this.store.doc(), centerId); - if (kept) this.store.update((doc) => useSavedPrint(doc, kept), 'print'); - else this.store.update((doc) => ({ ...doc, print: { ...printDefaults(doc.view), centerId } }), 'print'); + if (kept) this.useKept(kept, 'print'); + else { + this.store.update((doc) => ({ ...doc, print: { ...printDefaults(doc.view), centerId } }), 'print'); + // Another print: nobody left out of it yet. + this.ui.setPrintOmitted([]); + } this.ui.printEdited(); } @@ -965,7 +993,7 @@ export class PrintModel { // Only what was kept for this very couple (not settings kept without naming a partner). if (kept && kept.partnerId !== undefined) { this.staged.set({}); - this.store.update((doc) => useSavedPrint(doc, kept), 'print'); + this.useKept(kept, 'print'); this.ui.printEdited(); } else { this.set({ partnerId }); diff --git a/src/app/features/print-studio/print-preview/print-preview.html b/src/app/features/print-studio/print-preview/print-preview.html index 0620c25..1714b49 100644 --- a/src/app/features/print-studio/print-preview/print-preview.html +++ b/src/app/features/print-studio/print-preview/print-preview.html @@ -149,38 +149,40 @@ }

- {{ summary() }} - @if (note(); as n) { - {{ n.text }} - } - @if (omitted(); as count) { - - {{ t('print.omitted', { count }) }} - - - } - @if (added(); as count) { - - {{ t('print.addedPeople', { count }) }} - - - } - @if (bent(); as count) { - - {{ t('print.bentLines', { count }) }} - - - } - @if (gapped(); as count) { - - {{ t('print.widenedGaps', { count }) }} - - - } - @if (moved(); as count) { - - {{ t('print.movedCards', { count }) }} - - - } + {{ summary() }} + + @if (note(); as n) { + {{ n.text }} + } + @if (omitted(); as count) { + + {{ t('print.omitted', { count }) }} + + + } + @if (added(); as count) { + + {{ t('print.addedPeople', { count }) }} + + + } + @if (bent(); as count) { + + {{ t('print.bentLines', { count }) }} + + + } + @if (gapped(); as count) { + + {{ t('print.widenedGaps', { count }) }} + + + } + @if (moved(); as count) { + + {{ t('print.movedCards', { count }) }} + + + } +

diff --git a/src/app/features/print-studio/print-preview/print-preview.scss b/src/app/features/print-studio/print-preview/print-preview.scss index 65c0681..14c2f10 100644 --- a/src/app/features/print-studio/print-preview/print-preview.scss +++ b/src/app/features/print-studio/print-preview/print-preview.scss @@ -360,15 +360,23 @@ .summary { display: flex; - flex-wrap: wrap; - justify-content: center; - gap: 2px 10px; + flex-direction: column; + align-items: center; + gap: 2px; margin: 0; color: var(--ink-2); font-size: var(--text-sm); font-variant-numeric: tabular-nums; text-align: center; + .line { + display: flex; + flex-wrap: wrap; + justify-content: center; + gap: 2px 10px; + min-height: 1.4em; + } + .warn { color: var(--danger); font-weight: 500; diff --git a/src/app/state/ui-state.ts b/src/app/state/ui-state.ts index 5518525..a1494cb 100644 --- a/src/app/state/ui-state.ts +++ b/src/app/state/ui-state.ts @@ -85,6 +85,13 @@ export class UiState { this.omitRedo.set([]); } + /** The people a saved print leaves out, as the ones left out now; nothing to undo or redo there. */ + setPrintOmitted(ids: readonly string[]): void { + this.printOmitted.set([...ids]); + this.omitSteps.set([]); + this.omitRedo.set([]); + } + /** Everyone back in the print; nothing left to undo or redo there. */ clearPrintOmitted(): void { this.printOmitted.set([]);