Add ifStuck/stop to frames and captured date to sequences (Refs #23)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -29,7 +29,10 @@ import { isImageDataUrl, MAX_IMAGE_DATA_CHARS } from './images.js';
|
||||
// Item: { id, text, status: 'open'|'done'|'tbd', detail?: string }
|
||||
// Sequence (visual sequence): { id, kind: 'sequence', title, updated: 'YYYY-MM-DD',
|
||||
// frames: [Frame] } -- a numbered series of pictures with optional text.
|
||||
// Frame: { image: PNG/JPEG data URL or '', text, layout: 'right'|'under'|'none', secret?: boolean }
|
||||
// Frame: { image: PNG/JPEG data URL or '', text, layout: 'right'|'under'|'none', secret?: boolean,
|
||||
// ifStuck?: string, what to do if the screen looks different or the step fails
|
||||
// stop?: boolean } "stop here and call someone" marker; ifStuck says who/why
|
||||
// A sequence may also carry `captured: 'YYYY-MM-DD'`, set when a step is captured from the screen.
|
||||
// A sequence lives in the same ordered list as the records (records sections) or
|
||||
// items (steps / checklist sections), so it sits wherever the user puts it, but it
|
||||
// is not a record or an item (no number, no tick box). A 'text' section keeps its
|
||||
@@ -184,6 +187,7 @@ export function validate(doc) {
|
||||
if (q.kind !== 'sequence') errs.push(`${where}: kind must be "sequence"`);
|
||||
if (!isStr(q.title) || !q.title) errs.push(`${where}: missing title`);
|
||||
if (!DATE_RE.test(q.updated ?? '')) errs.push(`${where}: updated must be YYYY-MM-DD`);
|
||||
if (q.captured !== undefined && !DATE_RE.test(q.captured)) errs.push(`${where}: captured must be YYYY-MM-DD`);
|
||||
if (!Array.isArray(q.frames)) return errs.push(`${where}: frames must be an array`);
|
||||
q.frames.forEach((f, k) => {
|
||||
const fw = `${where}.frames[${k}]`;
|
||||
@@ -193,6 +197,8 @@ export function validate(doc) {
|
||||
if (!isStr(f.text)) errs.push(`${fw}: text must be a string`);
|
||||
if (!FRAME_LAYOUTS.includes(f.layout)) errs.push(`${fw}: bad layout "${f.layout}"`);
|
||||
if (f.secret !== undefined && typeof f.secret !== 'boolean') errs.push(`${fw}: secret must be a boolean`);
|
||||
if (f.ifStuck !== undefined && !isStr(f.ifStuck)) errs.push(`${fw}: ifStuck must be a string`);
|
||||
if (f.stop !== undefined && typeof f.stop !== 'boolean') errs.push(`${fw}: stop must be a boolean`);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
10
src/ops.js
10
src/ops.js
@@ -184,7 +184,7 @@ export function allSequences(doc) {
|
||||
// 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++; } };
|
||||
const frames = (q) => { for (const f of q.frames) if (f.secret && (f.image || String(f.text || '').trim() || String(f.ifStuck || '').trim())) { f.image = ''; f.text = ''; if (f.ifStuck) f.ifStuck = ''; n++; } };
|
||||
for (const s of doc.sections) {
|
||||
for (const r of s.records || []) {
|
||||
if (isSequence(r)) frames(r);
|
||||
@@ -217,6 +217,14 @@ export function addFrame(seq, image = '', layout = 'under') {
|
||||
return f;
|
||||
}
|
||||
|
||||
// A step captured from the screen: a new frame, and the sequence remembers when,
|
||||
// so the reader can be told the site may have changed since.
|
||||
export function addCapture(seq, image) {
|
||||
const f = addFrame(seq, image);
|
||||
seq.captured = today();
|
||||
return f;
|
||||
}
|
||||
|
||||
// ---- what a section holds (for the delete confirmation) ----
|
||||
export function sectionContents(section) {
|
||||
const c = { records: 0, items: 0, sequences: 0, images: 0, text: false };
|
||||
|
||||
@@ -46,19 +46,21 @@ export function frameLayout(frame) {
|
||||
// What to show for a frame. A secret frame (picture and text) is withheld
|
||||
// unless secrets are included; a frame with nothing in it is never "withheld".
|
||||
export function frameView(frame, includeSecrets) {
|
||||
const hasContent = !!(frame.image || String(frame.text || '').trim());
|
||||
const hasContent = !!(frame.image || String(frame.text || '').trim() || String(frame.ifStuck || '').trim());
|
||||
const withheld = !!frame.secret && !includeSecrets && hasContent;
|
||||
return {
|
||||
withheld,
|
||||
image: withheld ? '' : frame.image,
|
||||
text: withheld ? '' : frame.text,
|
||||
ifStuck: withheld ? '' : String(frame.ifStuck || '').trim(),
|
||||
stop: withheld ? false : !!frame.stop,
|
||||
layout: withheld ? 'none' : frameLayout(frame),
|
||||
};
|
||||
}
|
||||
|
||||
export function countSecrets(doc) {
|
||||
let n = 0;
|
||||
const frames = (q) => { for (const f of q.frames) if (f.secret && (f.image || String(f.text || '').trim())) n++; };
|
||||
const frames = (q) => { for (const f of q.frames) if (f.secret && (f.image || String(f.text || '').trim() || String(f.ifStuck || '').trim())) n++; };
|
||||
for (const s of doc.sections) {
|
||||
for (const r of s.records || []) {
|
||||
if (isSequence(r)) frames(r);
|
||||
|
||||
@@ -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 = '261123A';
|
||||
export const APP_VERSION = '261124A';
|
||||
|
||||
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