Collapse and expand records in a section

Each record gets a Collapse/Expand button; each records section gets
Collapse all and Expand all. View mode only; print and edit unaffected.

Closes #16

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 16:50:14 -05:00
parent 3c347c4ad6
commit 661d2cf936
3 changed files with 22 additions and 7 deletions

View File

@@ -11,6 +11,7 @@
dirty: false, dirty: false,
baseline: null, // deep copy of the document at open/save; Cancel reverts to it baseline: null, // deep copy of the document at open/save; Cancel reverts to it
pwChanged: false, // passphrase changed since the last save pwChanged: false, // passphrase changed since the last save
collapsed: new Set(), // ids of records folded to just their title (view mode only)
revealed: new WeakSet(), // secret field objects currently shown revealed: new WeakSet(), // secret field objects currently shown
blob: null, // encrypted payload taken from a file the user chose to open blob: null, // encrypted payload taken from a file the user chose to open
handle: null, // File System Access handle once the user picked a save location handle: null, // File System Access handle once the user picked a save location
@@ -230,11 +231,24 @@
} }
function viewRecord(r) { function viewRecord(r) {
return h('article', { class: 'card' }, const closed = state.collapsed.has(r.id);
h('h3', {}, r.title, ' ', statusBadge(r.status)), const toggle = () => { state.collapsed[closed ? 'delete' : 'add'](r.id); render(); };
r.fields.length ? h('dl', {}, r.fields.map(viewField)) : null, return h('article', { class: 'card' + (closed ? ' collapsed' : '') },
r.notes ? h('p', { class: 'notes' }, r.notes) : null, h('div', { class: 'rechead' },
h('p', { class: 'muted small' }, 'Updated ' + r.updated)); h('h3', {}, r.title, ' ', statusBadge(r.status)),
btn(closed ? 'Expand' : 'Collapse', toggle, 'small', { 'aria-expanded': String(!closed), 'aria-label': (closed ? 'Expand ' : 'Collapse ') + r.title })),
closed ? null : [
r.fields.length ? h('dl', {}, r.fields.map(viewField)) : null,
r.notes ? h('p', { class: 'notes' }, r.notes) : null,
h('p', { class: 'muted small' }, 'Updated ' + r.updated)]);
}
function foldBar(s) {
const recs = s.records.filter((r) => !isSequence(r));
if (!recs.length) return null;
const setAll = (fold) => { recs.forEach((r) => state.collapsed[fold ? 'add' : 'delete'](r.id)); render(); };
return h('div', { class: 'row foldbar' },
btn('Collapse all', () => setAll(true), 'small'), btn('Expand all', () => setAll(false), 'small'));
} }
// A frame is hidden (picture and text) if marked secret and not revealed. // A frame is hidden (picture and text) if marked secret and not revealed.
@@ -271,7 +285,7 @@
return [ return [
s.intro ? h('p', { class: 'intro' }, s.intro) : null, s.intro ? h('p', { class: 'intro' }, s.intro) : null,
s.kind === 'text' ? [h('p', { class: 'body' }, s.body), (s.sequences || []).map(viewSequence)] : null, s.kind === 'text' ? [h('p', { class: 'body' }, s.body), (s.sequences || []).map(viewSequence)] : null,
s.kind === 'records' ? s.records.map((r) => (isSequence(r) ? viewSequence(r) : viewRecord(r))) : null, s.kind === 'records' ? [foldBar(s), s.records.map((r) => (isSequence(r) ? viewSequence(r) : viewRecord(r)))] : null,
s.kind === 'steps' ? h('ol', { class: 'items' }, s.items.map((i) => (isSequence(i) ? seqItem(i) : viewItem(i)))) : null, s.kind === 'steps' ? h('ol', { class: 'items' }, s.items.map((i) => (isSequence(i) ? seqItem(i) : viewItem(i)))) : null,
s.kind === 'checklist' ? h('ul', { class: 'items' }, s.items.map((i) => (isSequence(i) ? seqItem(i) : viewItem(i)))) : null, s.kind === 'checklist' ? h('ul', { class: 'items' }, s.items.map((i) => (isSequence(i) ? seqItem(i) : viewItem(i)))) : null,
]; ];

View File

@@ -33,6 +33,7 @@ ol.items, ul.items { padding-left: 1.4rem; } .item { margin-bottom: .75rem; } .i
input, select, textarea { font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--line); border-radius: .35rem; padding: .35rem .5rem; min-width: 0; } input, select, textarea { font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--line); border-radius: .35rem; padding: .35rem .5rem; min-width: 0; }
textarea { width: 100%; display: block; } label { display: block; margin-top: .5rem; } label.check { display: inline-flex; gap: .25rem; margin: 0; align-items: center; white-space: nowrap; } textarea { width: 100%; display: block; } label { display: block; margin-top: .5rem; } label.check { display: inline-flex; gap: .25rem; margin: 0; align-items: center; white-space: nowrap; }
.row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .5rem; } .row input:not([type=checkbox]) { flex: 1 1 10rem; } .row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .5rem; } .row input:not([type=checkbox]) { flex: 1 1 10rem; }
.rechead { display: flex; justify-content: space-between; align-items: center; gap: .75rem; } .rechead h3 { margin: 0; } .card.collapsed { padding-top: .5rem; padding-bottom: .5rem; }
.btn { font: inherit; padding: .35rem .8rem; border-radius: .4rem; border: 1px solid var(--line); background: var(--card); color: inherit; cursor: pointer; } .btn { font: inherit; padding: .35rem .8rem; border-radius: .4rem; border: 1px solid var(--line); background: var(--card); color: inherit; cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--bg); border-color: var(--accent); } .btn.primary { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.btn.link { border: 0; background: none; color: var(--accent); padding: 0 .5rem; text-decoration: underline; } .btn.link { border: 0; background: none; color: var(--accent); padding: 0 .5rem; text-decoration: underline; }

View File

@@ -2,7 +2,7 @@
// YYMMDD is the date, X the iteration that day (A first, B second, ...). // YYMMDD is the date, X the iteration that day (A first, B second, ...).
// Bump with `npm run bump` (see bump-version.js). build.js strips `export`. // Bump with `npm run bump` (see bump-version.js). build.js strips `export`.
export const APP_VERSION = '261109A'; export const APP_VERSION = '261117A';
const VERSION_RE = /^(\d{6})([A-Z])$/; const VERSION_RE = /^(\d{6})([A-Z])$/;
export const isVersion = (v) => typeof v === 'string' && VERSION_RE.test(v); export const isVersion = (v) => typeof v === 'string' && VERSION_RE.test(v);