Add lawyer's view: a third field level and print mode (Fixes #29)
Fields and steps are Normal, Lawyer or Secret. Lawyer is stored as secret: true plus lawyer: true, so older builds treat it as a plain secret. Print offers masked, lawyer and complete views. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
16
src/model.js
16
src/model.js
@@ -24,12 +24,16 @@ import { isImageDataUrl, MAX_IMAGE_DATA_CHARS, isMark } from './images.js';
|
||||
//
|
||||
// Record: { id, title, status: 'ok'|'tbd', updated: 'YYYY-MM-DD',
|
||||
// fields: [Field], notes?: string }
|
||||
// Field: { label, value, secret?: boolean, kind?: 'text'|'image' } (kind defaults to text)
|
||||
// Field: { label, value, secret?: boolean, lawyer?: boolean, kind?: 'text'|'image' } (kind defaults to text)
|
||||
// Three levels: normal (no flags), lawyer (`secret: true, lawyer: true`: masked on screen and
|
||||
// in the masked print, shown in the lawyer's view) and secret (`secret: true`: shown only in
|
||||
// the complete print). `lawyer` is only valid together with `secret: true`, so an older
|
||||
// build that ignores it still treats the item as a secret.
|
||||
// An image field's value is a PNG/JPEG data URL, or '' when no image is set yet.
|
||||
// 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, lawyer?: 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
|
||||
// marks?: [Mark] overlay on the picture: { type:'marker', x, y } or
|
||||
@@ -182,6 +186,7 @@ export function validate(doc) {
|
||||
if (!isStr(f.label) || !f.label) errs.push(`${fw}: missing label`);
|
||||
if (!isStr(f.value)) errs.push(`${fw}: value must be a string`);
|
||||
if (f.secret !== undefined && typeof f.secret !== 'boolean') errs.push(`${fw}: secret must be a boolean`);
|
||||
checkLawyer(f, fw);
|
||||
if (f.id !== undefined) {
|
||||
if (!isStr(f.id) || !f.id) errs.push(`${fw}: id must be a non-empty string`);
|
||||
else if (fieldIds.has(f.id)) errs.push(`${fw}: duplicate field id "${f.id}"`);
|
||||
@@ -194,6 +199,12 @@ export function validate(doc) {
|
||||
});
|
||||
}
|
||||
|
||||
function checkLawyer(f, fw) {
|
||||
if (f.lawyer === undefined) return;
|
||||
if (typeof f.lawyer !== 'boolean') errs.push(`${fw}: lawyer must be a boolean`);
|
||||
else if (f.lawyer && f.secret !== true) errs.push(`${fw}: lawyer needs secret: true`);
|
||||
}
|
||||
|
||||
function checkSequence(q, where) {
|
||||
if (!isObj(q)) return errs.push(`${where}: must be an object`);
|
||||
checkId(q.id, where);
|
||||
@@ -210,6 +221,7 @@ 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`);
|
||||
checkLawyer(f, fw);
|
||||
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`);
|
||||
if (f.marks !== undefined) {
|
||||
|
||||
Reference in New Issue
Block a user