30 lines
3.2 KiB
JavaScript
30 lines
3.2 KiB
JavaScript
// Read-only presentation of selected-chapter evidence, separate from document reading/checking.
|
|
(() => {
|
|
const pd = window.PlotDirector ||= {};
|
|
pd.wordChapterStatus = (packet, lease, bookId, chapterId) => {
|
|
if (!lease) return {label:'Word disconnected', text:'No current Word document connection. Saved accepted text remains available.'};
|
|
if (!chapterId) return {label:'Choose a chapter', text:'Select a chapter to inspect its current Word verification.'};
|
|
if (lease.wordSaved !== true) return {label:lease.wordSaved === false ? 'Save Word to verify' : 'Word state unknown', text:'Current saved Word state is not confirmed. Accepted chapter data is retained.'};
|
|
const entry = packet.chapterVerifications?.find(row => row.instanceId === lease.instanceId && row.sessionId === lease.sessionId && Number(row.bookId) === bookId && Number(row.chapterId) === chapterId && String(row.wordRevision) === String(lease.revision));
|
|
const evidence = entry?.verification;
|
|
const identity = evidence?.manuscriptID === lease.manuscriptId && packet.canonical?.manuscriptID === lease.manuscriptId;
|
|
let label, text;
|
|
if (!evidence) {
|
|
label = 'Verification unavailable'; text = 'Current chapter verification has not been returned. Saved accepted text remains available; a synchronisation acknowledgement is not chapter verification.';
|
|
} else if (!identity || !evidence.checkpointStatus) {
|
|
label = 'No accepted chapter'; text = 'No accepted checkpoint for this chapter and manuscript identity was found. Inspect Manuscript structure and evidence; do not reimport just to clear a status.';
|
|
} else if (evidence.checkpointStatus === 'Needs review') {
|
|
label = 'Chapter needs review'; text = evidence.checkpointMessage || 'This chapter checkpoint requires review in Manuscript structure and evidence. Accepted content is retained.';
|
|
} else if (evidence.isCurrent === true) {
|
|
label = 'Chapter verified'; text = 'This chapter has matching accepted evidence for the current Word session and revision.';
|
|
if (evidence.validatedUtc) text += ' Verified: ' + new Date(evidence.validatedUtc).toLocaleString() + '.';
|
|
} else {
|
|
label = 'Chapter not verified'; text = 'The saved checkpoint exists, but this chapter has no matching unexpired verification for the current Word session and revision. Inspect the chapter-reading/checking status in Companion; Synchronise alone does not establish chapter acceptance.';
|
|
}
|
|
if (identity && evidence.lastAcceptedUtc && new Date(evidence.lastAcceptedUtc).getUTCFullYear() > 1) text += ' Content checkpoint accepted: ' + new Date(evidence.lastAcceptedUtc).toLocaleString() + ' (historical; not a current failure).';
|
|
if (lease.chapterIssue === 'needs_review') text += ' Companion separately reports a chapter-reading failure. Open Companion Settings → Advanced mode → Troubleshooting for diagnostics and reading recovery options.';
|
|
else if (lease.chapterProgress?.state === 'Needs review') text += ' The document chapter-check operation needs review; other chapters may be affected. See Companion details.';
|
|
return {label, text};
|
|
};
|
|
})();
|