Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/app/core/model/operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
}

/**
Expand Down
5 changes: 5 additions & 0 deletions src/app/core/model/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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". */
Expand Down
3 changes: 3 additions & 0 deletions src/app/core/xml/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ const KNOWN = {
'lineBends',
'gaps',
'added',
'omitted',
'flipped',
'ancestors',
'descendants',
Expand Down Expand Up @@ -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'));
Expand Down
1 change: 1 addition & 0 deletions src/app/core/xml/serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
7 changes: 7 additions & 0 deletions src/app/core/xml/xml.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
1 change: 1 addition & 0 deletions src/app/features/print-studio/print-address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
40 changes: 34 additions & 6 deletions src/app/features/print-studio/print-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
}

Expand All @@ -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();
}

Expand All @@ -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 });
Expand Down
70 changes: 36 additions & 34 deletions src/app/features/print-studio/print-preview/print-preview.html
Original file line number Diff line number Diff line change
Expand Up @@ -149,38 +149,40 @@
}
</div>
<p class="summary">
{{ summary() }}
@if (note(); as n) {
<span [class.warn]="n.warn">{{ n.text }}</span>
}
@if (omitted(); as count) {
<span class="omitted">
{{ t('print.omitted', { count }) }}
<button type="button" class="link" (click)="restore.emit()">{{ t('print.omittedRestore') }}</button>
</span>
}
@if (added(); as count) {
<span class="omitted">
{{ t('print.addedPeople', { count }) }}
<button type="button" class="link" (click)="unadd.emit()">{{ t('print.unaddAll') }}</button>
</span>
}
@if (bent(); as count) {
<span class="omitted">
{{ t('print.bentLines', { count }) }}
<button type="button" class="link" (click)="unbend.emit()">{{ t('print.unbendAll') }}</button>
</span>
}
@if (gapped(); as count) {
<span class="omitted">
{{ t('print.widenedGaps', { count }) }}
<button type="button" class="link" (click)="ungap.emit()">{{ t('print.ungapAll') }}</button>
</span>
}
@if (moved(); as count) {
<span class="omitted">
{{ t('print.movedCards', { count }) }}
<button type="button" class="link" (click)="unmove.emit()">{{ t('print.unmoveAll') }}</button>
</span>
}
<span class="line">{{ summary() }}</span>
<span class="line extras">
@if (note(); as n) {
<span [class.warn]="n.warn">{{ n.text }}</span>
}
@if (omitted(); as count) {
<span class="omitted">
{{ t('print.omitted', { count }) }}
<button type="button" class="link" (click)="restore.emit()">{{ t('print.omittedRestore') }}</button>
</span>
}
@if (added(); as count) {
<span class="omitted">
{{ t('print.addedPeople', { count }) }}
<button type="button" class="link" (click)="unadd.emit()">{{ t('print.unaddAll') }}</button>
</span>
}
@if (bent(); as count) {
<span class="omitted">
{{ t('print.bentLines', { count }) }}
<button type="button" class="link" (click)="unbend.emit()">{{ t('print.unbendAll') }}</button>
</span>
}
@if (gapped(); as count) {
<span class="omitted">
{{ t('print.widenedGaps', { count }) }}
<button type="button" class="link" (click)="ungap.emit()">{{ t('print.ungapAll') }}</button>
</span>
}
@if (moved(); as count) {
<span class="omitted">
{{ t('print.movedCards', { count }) }}
<button type="button" class="link" (click)="unmove.emit()">{{ t('print.unmoveAll') }}</button>
</span>
}
</span>
</p>
14 changes: 11 additions & 3 deletions src/app/features/print-studio/print-preview/print-preview.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions src/app/state/ui-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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([]);
Expand Down