Add ?reset=1 route that erases secret-flagged values (Refs #19)
After unlock, a banner offers to clear every secret field and secret sequence step. Nothing is written until Save. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
16
src/ops.js
16
src/ops.js
@@ -180,6 +180,22 @@ export function allSequences(doc) {
|
||||
return out;
|
||||
}
|
||||
|
||||
// Erase the content of every secret field and secret frame (labels, structure
|
||||
// and the secret flags stay). Returns how many values were erased.
|
||||
export function clearSecrets(doc) {
|
||||
let n = 0;
|
||||
const frames = (q) => { for (const f of q.frames) if (f.secret && (f.image || String(f.text || '').trim())) { f.image = ''; f.text = ''; n++; } };
|
||||
for (const s of doc.sections) {
|
||||
for (const r of s.records || []) {
|
||||
if (isSequence(r)) frames(r);
|
||||
else for (const f of r.fields) if (f.secret && f.value) { f.value = ''; n++; }
|
||||
}
|
||||
for (const it of s.items || []) if (isSequence(it)) frames(it);
|
||||
for (const q of s.sequences || []) frames(q);
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
// The ordered list a new sequence goes into for this kind of section.
|
||||
export function sequenceList(section) {
|
||||
if (section.kind === 'records') return section.records;
|
||||
|
||||
Reference in New Issue
Block a user