Add lawyer's summary print: records with lawyer-level fields only (Fixes #30)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
23
src/app.js
23
src/app.js
@@ -828,6 +828,26 @@
|
||||
r.notes ? h('p', { class: 'pnotes' }, r.notes) : null);
|
||||
}
|
||||
|
||||
// The lawyer's summary: just the records with lawyer-level fields, as one compact list.
|
||||
function printSummary(doc) {
|
||||
const groups = summaryGroups(doc);
|
||||
const list = groups.length ? groups.map((s) => h('section', { class: 'psumsec' },
|
||||
h('h2', {}, s.section),
|
||||
s.groups.map((g) => [g.title == null ? null : h('h3', { class: 'psubhead' }, g.title),
|
||||
g.records.map((r) => h('div', { class: 'prec' }, h('h3', {}, r.title),
|
||||
h('table', {}, h('tbody', {}, r.fields.map((f) => h('tr', {}, h('th', {}, f.label), h('td', { class: 'psecret' }, f.value || '(not set)')))))))])))
|
||||
: h('p', {}, 'Nothing to list: no record has a lawyer-level field.');
|
||||
printRoot.replaceChildren(h('table', { class: 'ptable' },
|
||||
h('thead', {}, h('tr', {}, h('td', {}, headerEl(doc)))),
|
||||
h('tbody', {}, h('tr', {}, h('td', {},
|
||||
h('section', { class: 'pcover psumcover' },
|
||||
h('h1', {}, (doc.meta.title || 'Final Wishes') + ": lawyer's summary"),
|
||||
doc.meta.owner ? h('p', { class: 'powner' }, 'Prepared by ' + doc.meta.owner) : null,
|
||||
h('p', {}, 'Last update: ' + doc.meta.lastUpdated),
|
||||
h('p', { class: 'pnote warn' }, "This is the LAWYER'S SUMMARY. It lists only the accounts and details a lawyer needs, in clear text. Keep it locked away.")),
|
||||
list)))));
|
||||
}
|
||||
|
||||
function printItem(it, numbered) {
|
||||
return h('li', { class: 'pitem ' + it.status },
|
||||
box(it.status), h('strong', {}, it.text), it.status === 'tbd' ? h('span', { class: 'ptag' }, 'TBD') : null,
|
||||
@@ -836,6 +856,7 @@
|
||||
|
||||
function buildPrintDoc(rawMode) {
|
||||
const mode = normalizeMode(rawMode);
|
||||
if (mode === 'summary') return printSummary(state.doc);
|
||||
const doc = state.doc;
|
||||
const kept = mode === 'complete' ? 'This copy INCLUDES passwords, PINs and other secrets. Keep it locked away (fire safe or sealed envelope).'
|
||||
: mode === 'lawyer' ? "This is the LAWYER'S VIEW. It includes account numbers and other details a lawyer needs, but the most private secrets (passwords, PINs, balances) are WITHHELD. Keep it locked away."
|
||||
@@ -867,12 +888,14 @@
|
||||
|
||||
function openPrintDialog() {
|
||||
const n = countByLevel(state.doc);
|
||||
const sum = summaryCounts(state.doc);
|
||||
const plural = (c) => c + ' secret value' + (c === 1 ? '' : 's');
|
||||
const radio = (value, checked, text) => h('label', { class: 'radio' }, h('input', { type: 'radio', name: 'mode', value, checked }), ' ' + text);
|
||||
const dlg = h('dialog', { class: 'card', 'aria-label': 'Print options' },
|
||||
h('h3', {}, 'Print'),
|
||||
radio('masked', true, 'Withhold secrets (safe overview; ' + plural(n.lawyer + n.secret) + ' hidden)'),
|
||||
radio('lawyer', false, "Lawyer's view (shows " + n.lawyer + ' lawyer-level value' + (n.lawyer === 1 ? '' : 's') + '; ' + plural(n.secret) + ' hidden)'),
|
||||
radio('summary', false, "Lawyer's summary (a short list of " + sum.records + ' record' + (sum.records === 1 ? '' : 's') + ' with lawyer-level values, ' + sum.values + ' value' + (sum.values === 1 ? '' : 's') + ')'),
|
||||
radio('complete', false, 'Include secrets (full copy: store it securely)'),
|
||||
h('div', { class: 'row' },
|
||||
btn('Cancel', () => { dlg.close(); dlg.remove(); }),
|
||||
|
||||
Reference in New Issue
Block a user