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:
26
src/app.js
26
src/app.js
@@ -11,6 +11,7 @@
|
||||
dirty: false,
|
||||
baseline: null, // deep copy of the document at open/save; Cancel reverts to it
|
||||
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
|
||||
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
|
||||
@@ -230,11 +231,24 @@
|
||||
}
|
||||
|
||||
function viewRecord(r) {
|
||||
return h('article', { class: 'card' },
|
||||
h('h3', {}, r.title, ' ', statusBadge(r.status)),
|
||||
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));
|
||||
const closed = state.collapsed.has(r.id);
|
||||
const toggle = () => { state.collapsed[closed ? 'delete' : 'add'](r.id); render(); };
|
||||
return h('article', { class: 'card' + (closed ? ' collapsed' : '') },
|
||||
h('div', { class: 'rechead' },
|
||||
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.
|
||||
@@ -271,7 +285,7 @@
|
||||
return [
|
||||
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 === '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 === 'checklist' ? h('ul', { class: 'items' }, s.items.map((i) => (isSequence(i) ? seqItem(i) : viewItem(i)))) : null,
|
||||
];
|
||||
|
||||
@@ -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; }
|
||||
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; }
|
||||
.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.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; }
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// 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`.
|
||||
|
||||
export const APP_VERSION = '261109A';
|
||||
export const APP_VERSION = '261117A';
|
||||
|
||||
const VERSION_RE = /^(\d{6})([A-Z])$/;
|
||||
export const isVersion = (v) => typeof v === 'string' && VERSION_RE.test(v);
|
||||
|
||||
Reference in New Issue
Block a user