Add lawyer's view: a third field level and print mode (Fixes #29)

Fields and steps are Normal, Lawyer or Secret. Lawyer is stored as
secret: true plus lawyer: true, so older builds treat it as a plain secret.
Print offers masked, lawyer and complete views.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-30 20:15:47 -05:00
parent edb85d4f64
commit eeba5d00db
10 changed files with 218 additions and 51 deletions

View File

@@ -61,7 +61,7 @@ Git-ignored on purpose: `*.pdf`, `data/` (plaintext working copies with real sec
- `records` (records with labeled `fields`; a field is text or an image). It can optionally have sub-tabs: `subsections: [{id, title}]`, a `generalTitle` for the catch-all first tab (default "General"), and a `subsection` id on each record or sequence. No `subsection`, or one that matches no tab, means General.
- `steps` and `checklist` (ordered `items`)
A **visual sequence** (`kind: 'sequence'`, numbered `frames` of image + text with a layout of right / under / none) is an entry in the same ordered list as a section's records or items, or in a text section's `sequences` array. It is not a record or an item: no step number and no tick box. Ids are unique across the whole document. `secret` flags exist on fields and frames. Validation is `validate()` / `assertValid()`; the save path refuses an invalid document.
A **visual sequence** (`kind: 'sequence'`, numbered `frames` of image + text with a layout of right / under / none) is an entry in the same ordered list as a section's records or items, or in a text section's `sequences` array. It is not a record or an item: no step number and no tick box. Ids are unique across the whole document. `secret` flags exist on fields and frames; a `lawyer` flag (valid only with `secret: true`) makes a third level (see Print). Validation is `validate()` / `assertValid()`; the save path refuses an invalid document.
**UI** (`src/app.js`, a single IIFE): state lives in one `state` object (including `collapsed`, the folded record ids). Edits mutate `state.doc` in place and then call `markDirty()` or `changed(record)` (which also stamps `updated` and `meta.lastUpdated`). `render()` rebuilds the page. `changed` clears `state.status`, so set the status afterwards.
- **Editing and Cancel:** edit mode is global. **Cancel** reverts the section (or the print header) on screen to a deep-copy baseline taken at open and at each save, then leaves edit mode.
@@ -80,7 +80,7 @@ A **visual sequence** (`kind: 'sequence'`, numbered `frames` of image + text wit
**Upgrading app code, keeping data.** A file runs the code it was saved with. On the start screen, "Open your existing Final Wishes file" extracts the `#payload` from an older `.html`, unlocks it with the passphrase, and Save then writes it out with the newer code.
**Print.** Built only when Print is chosen and cleared on `afterprint`, so secrets don't linger in the DOM. It is a `<table>` whose `<thead>` holds the running header, which the browser repeats at the top of every page. Each section starts a new page (a section with sub-tabs gets a sub-heading per non-empty tab), records and sequence steps avoid page breaks inside them, and checklist items have tick boxes. The print dialog offers "withhold secrets" (default) or "include secrets". Images are decoded before `window.print()`.
**Print.** Built only when Print is chosen and cleared on `afterprint`, so secrets don't linger in the DOM. It is a `<table>` whose `<thead>` holds the running header, which the browser repeats at the top of every page. Each section starts a new page (a section with sub-tabs gets a sub-heading per non-empty tab), records and sequence steps avoid page breaks inside them, and checklist items have tick boxes. The print dialog offers three views (issue #29): "withhold secrets" (default, mode `masked`), "lawyer's view" (`lawyer`: shows secrets flagged `lawyer: true`, still withholds plain secrets) and "include secrets" (`complete`). `isHidden()`, `displayValue()`, `frameView()` and `usesView()` in `print.js` take the mode (a boolean still works: true is complete); `levelOf()`/`setLevel()` in `ops.js` keep the flags canonical and the edit UI uses a Normal/Lawyer/Secret select. Older builds read a lawyer-level item as a plain secret, which fails closed. `countByLevel()` feeds the dialog counts; `?reset=1` still erases lawyer-level values. Images are decoded before `window.print()`.
## Integrations