@floless/app 0.164.0 → 0.166.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/floless-server.cjs +24056 -21153
- package/dist/schemas/drawing-check.profile.v1.schema.json +3 -1
- package/dist/skills/floless-app-knowledge/SKILL.md +8 -1
- package/dist/skills/floless-app-rfi/SKILL.md +31 -6
- package/dist/skills/floless-app-steel-model/SKILL.md +4 -1
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +18 -16
- package/dist/skills/floless-app-steel-takeoff/references/elevation-registration.md +15 -1
- package/dist/templates/college-phase-exporter.flo +42 -16
- package/dist/templates/screenshot-to-saved-settings.flo +12 -2
- package/dist/web/app.css +71 -6
- package/dist/web/aware.js +27 -10
- package/dist/web/chat-question-card.js +3 -1
- package/dist/web/chat.css +11 -1
- package/dist/web/chat.js +533 -59
- package/dist/web/commands-drawing-check.js +1 -0
- package/dist/web/commands-shell.js +107 -13
- package/dist/web/commands-steel.js +22 -2
- package/dist/web/drawing-check-editor.html +4 -0
- package/dist/web/drawing-check-editor.js +82 -2
- package/dist/web/index.html +6 -0
- package/dist/web/project-history.js +32 -9
- package/dist/web/project-modules.js +5 -0
- package/dist/web/project-rfis.js +219 -25
- package/dist/web/steel-ai-marks.js +128 -1
- package/dist/web/steel-editor.html +710 -35
- package/dist/web/steel-model-v2-projection.js +26 -20
- package/dist/web/workspaces.js +283 -45
- package/package.json +3 -2
package/dist/web/project-rfis.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* A
|
|
3
|
-
* may cite a page of this project's Knowledge or a
|
|
2
|
+
* A project's RFIs step (#2470 R6.6 General; R6.6d Trace, Revit, Tekla and Drawing Checker): the project's questions for
|
|
3
|
+
* the engineer, client or architect. Each RFI may cite a page of this project's Knowledge or, on a General project, a
|
|
4
|
+
* saved sheet of a project linked on its Modules step (only General links projects); FloLess sends
|
|
4
5
|
* it through the connected Gmail account (R6.6b, the same delivery engine as Steel's) or gives the email text for the
|
|
5
6
|
* person to send, and keeps what was sent, answered and closed.
|
|
6
7
|
*
|
|
@@ -10,6 +11,10 @@
|
|
|
10
11
|
*/
|
|
11
12
|
(() => {
|
|
12
13
|
const bridge = () => window.flolessBridge || {};
|
|
14
|
+
/** Only a General project links other projects (its Modules step), so only it can cite their sheets (#2470 R6.6d). */
|
|
15
|
+
const linksProjects = (project) => !!project && (project.templateId || project.app) === 'floless-general';
|
|
16
|
+
/** #2470 R6.6d: a Trace or Drawing Checker project's RFIs can also cite the project's own sheets (by its lineage root). */
|
|
17
|
+
const ownSheetsCitable = (project) => !!project && ['vectorize', 'drawing-check'].includes(project.templateId || project.app);
|
|
13
18
|
const api = (path, init) => {
|
|
14
19
|
if (typeof bridge().api === 'function') return bridge().api(path, init);
|
|
15
20
|
return fetch(path, { headers: { 'Content-Type': 'application/json' }, ...init }).then(async (res) => {
|
|
@@ -85,6 +90,83 @@
|
|
|
85
90
|
];
|
|
86
91
|
const dispositionLabel = (key) => DISPOSITIONS.find((d) => d.key === key)?.label || key;
|
|
87
92
|
|
|
93
|
+
/* ── Earlier rounds (#2470 R6.6d carve-out) ──────────────────────────────────────────────────────────────────────
|
|
94
|
+
A reopened RFI keeps every earlier round. The list carries only how many; the rounds load when the person opens
|
|
95
|
+
them, oldest first, each as what happened in order. Cached per RFI and revision, never the failure. */
|
|
96
|
+
const shortDay = (iso) => {
|
|
97
|
+
const t = Date.parse(iso); if (!Number.isFinite(t)) return '';
|
|
98
|
+
const at = new Date(t);
|
|
99
|
+
return at.toLocaleDateString(undefined, at.getFullYear() === new Date().getFullYear() ? { day: 'numeric', month: 'short' } : { day: 'numeric', month: 'short', year: 'numeric' });
|
|
100
|
+
};
|
|
101
|
+
/** A short date to read, the exact one to point at and for a screen reader. */
|
|
102
|
+
const dated = (iso) => `<time datetime="${esc(iso)}" data-tip="${esc(exact(iso))}"><span aria-hidden="true">${esc(shortDay(iso))}</span><span class="sr-only">${esc(exact(iso))}</span></time>`;
|
|
103
|
+
function roundEntryHtml(e) {
|
|
104
|
+
const line = (text) => `<li>${dated(e.at)} · ${text}</li>`;
|
|
105
|
+
switch (e.t) {
|
|
106
|
+
case 'raised': return line(`Filed${e.by === 'ai' ? ' by AI Chat' : ''}: ${esc(e.question)}`);
|
|
107
|
+
case 'reopened': return line(`Reopened: ${esc(e.why)}`);
|
|
108
|
+
case 'sent': return line(`${e.via === 'gmail' ? 'Sent with Gmail to' : e.via === 'other' ? `Sent another way (${esc(e.how || '')}) to` : 'Marked sent to'} ${esc(e.to)}`);
|
|
109
|
+
case 'answered': return line(`Answer: ${esc(e.text)}`);
|
|
110
|
+
case 'closed': return line(`Closed: ${esc(dispositionLabel(e.disposition))}${e.note ? `. ${esc(e.note)}` : '.'}`);
|
|
111
|
+
default: return '';
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function roundsHtml(rfi) {
|
|
115
|
+
if (!rfi.earlierRounds) return '';
|
|
116
|
+
const id = esc(rfi.id);
|
|
117
|
+
const open = state.roundsOpen?.has(rfi.id);
|
|
118
|
+
const toggle = `<button type="button" class="ghost" data-pr-rounds="${id}" aria-expanded="${open ? 'true' : 'false'}" aria-controls="pr-rounds-${id}"
|
|
119
|
+
data-command-id="shell.project-rfi-earlier-rounds#${esc(rfi.id)}" data-command-instance-label="${id}" data-tip="What was asked, sent, answered and closed before this RFI was reopened">Earlier rounds (${rfi.earlierRounds})</button>`;
|
|
120
|
+
let body = '';
|
|
121
|
+
const got = state.rounds?.get(rfi.id);
|
|
122
|
+
// A record's revision only rises, so rounds read at or after the list's revision are current for it.
|
|
123
|
+
const fresh = got && got.revision >= rfi.recordRevision ? got : null;
|
|
124
|
+
const busy = open && (!fresh || fresh.status === 'loading');
|
|
125
|
+
if (open) {
|
|
126
|
+
if (!fresh || fresh.status === 'loading') body = '<p class="pg-row-meta" role="status">Loading earlier rounds…</p>';
|
|
127
|
+
else if (fresh.status === 'error') body = `<p class="pg-row-meta" role="status">${esc(fresh.error)}</p>
|
|
128
|
+
<div class="pm-strip-acts"><button type="button" class="ghost" data-pr-rounds-again="${id}" data-command-id="shell.project-rfi-earlier-rounds-again#${esc(rfi.id)}" data-command-instance-label="${id}">Try again</button></div>`;
|
|
129
|
+
else if (!fresh.rounds.length) body = '<p class="pg-row-meta" role="status">No earlier rounds were found for this RFI.</p>';
|
|
130
|
+
else body = `<ol class="pr-rounds" aria-label="${esc(`Earlier rounds of ${rfi.id}`)}">${fresh.rounds.map((r) => {
|
|
131
|
+
const first = r.entries[0];
|
|
132
|
+
const head = first ? `${first.t === 'reopened' ? 'Reopened' : 'Filed'} ${dated(first.at)}` : '';
|
|
133
|
+
return `<li><p class="pr-round-head">Round ${r.round}${head ? ` · ${head}` : ''}</p><ul class="pg-row-meta pr-settled">${r.entries.map(roundEntryHtml).join('')}</ul></li>`;
|
|
134
|
+
}).join('')}</ol>`;
|
|
135
|
+
}
|
|
136
|
+
return `<div class="pm-strip-acts">${toggle}</div><div id="pr-rounds-${id}" class="pr-rounds-body"${busy ? ' aria-busy="true"' : ''}>${body}</div>`;
|
|
137
|
+
}
|
|
138
|
+
async function loadRounds(rfiId, revision) {
|
|
139
|
+
const mine = state;
|
|
140
|
+
mine.rounds ??= new Map();
|
|
141
|
+
mine.rounds.set(rfiId, { status: 'loading', revision });
|
|
142
|
+
try {
|
|
143
|
+
const res = await api(`/api/projects/${encodeURIComponent(target().projectId)}/correspondence-rfis/${encodeURIComponent(rfiId)}/rounds`);
|
|
144
|
+
if (state !== mine) return;
|
|
145
|
+
// Never below the revision asked for: an answer behind the list cannot start the reads over (Codex review).
|
|
146
|
+
const read = Math.max(res.recordRevision ?? revision, revision);
|
|
147
|
+
mine.rounds.set(rfiId, { status: 'ready', revision: read, rounds: res.rounds || [] });
|
|
148
|
+
const now = mine.view?.data?.rfis?.find((r) => r.id === rfiId);
|
|
149
|
+
if (now && mine.roundsOpen?.has(rfiId)) {
|
|
150
|
+
// The list moved on while this read was out: read the rounds it has now (the server answers at or past it).
|
|
151
|
+
if (now.recordRevision > read) { void loadRounds(rfiId, now.recordRevision); return; }
|
|
152
|
+
// The rounds are newer than the list (changed elsewhere): read the list once, never the rounds again.
|
|
153
|
+
// Not while a form is open: the list's repaint would drop what is being typed (refresh() holds the same line).
|
|
154
|
+
if (now.recordRevision < read && !mine.form) { mine.quietLoad = true; void load(); }
|
|
155
|
+
}
|
|
156
|
+
} catch (error) {
|
|
157
|
+
if (state !== mine) return;
|
|
158
|
+
mine.rounds.set(rfiId, { status: 'error', revision, error: said(error, 'FloLess couldn’t load the earlier rounds just now.') });
|
|
159
|
+
}
|
|
160
|
+
readDraft();
|
|
161
|
+
// Back to the toggle only if the person is still there (or on its Try again, gone while loading): never pull them
|
|
162
|
+
// out of a form or another pane when the rounds land.
|
|
163
|
+
const at = document.activeElement;
|
|
164
|
+
if (!at || at === document.body || at.getAttribute?.('data-pr-rounds') === rfiId || at.getAttribute?.('data-pr-rounds-again') === rfiId) {
|
|
165
|
+
state.focusAfter = `[data-pr-rounds="${CSS.escape(rfiId)}"]`;
|
|
166
|
+
}
|
|
167
|
+
paint();
|
|
168
|
+
}
|
|
169
|
+
|
|
88
170
|
/** How a citation's state reads on its chip and in its tip (the server's reason first, when it gave one). */
|
|
89
171
|
const CITE_STATE = {
|
|
90
172
|
current: { word: '', tip: 'Still matches what was cited.' },
|
|
@@ -97,10 +179,18 @@
|
|
|
97
179
|
'sheet-unusable': { word: 'sheet unreadable', tip: 'FloLess couldn’t read this sheet just now.' },
|
|
98
180
|
detached: { word: 'from a copy', tip: 'This came with a copy of the project and is not checked against the current links. File it again to cite a sheet here.' },
|
|
99
181
|
'not-checked': { word: 'not checked', tip: 'Not looked at from this chat.' },
|
|
182
|
+
// #2470 R6.6d: a project's own sheets (the server's reason is the tip; these are the fallbacks).
|
|
183
|
+
'sheet-changed': { word: 'sheet changed', tip: 'This sheet changed since it was cited. The RFI keeps what it cited.' },
|
|
184
|
+
'not-in-latest': { word: 'not in latest check', tip: 'The latest check did not include this drawing. The check it was cited from is kept.' },
|
|
100
185
|
};
|
|
101
|
-
const
|
|
186
|
+
const OWN_PREFIX = { trace: 'Sheet', 'checker-reference': 'Reference', 'checker-run': 'Checked' };
|
|
187
|
+
// Two pages of one drawing can share a drawing number, so a page the label doesn't already say is added to it.
|
|
188
|
+
const ownPage = (c) => (c.pageNumber && !String(c.sheet).endsWith(`page ${c.pageNumber}`) ? `page ${c.pageNumber}` : '');
|
|
189
|
+
const citeLabel = (c) => (c.kind === 'knowledge-page' ? `Knowledge · ${c.title}`
|
|
190
|
+
: c.kind === 'own-sheet' ? `${OWN_PREFIX[c.source] || 'Sheet'} · ${c.sheet}${ownPage(c) ? ` · ${ownPage(c)}` : ''}` : `Drawing · ${c.sheet} · ${c.linkedProjectName}`);
|
|
102
191
|
function chipHtml(c) {
|
|
103
|
-
|
|
192
|
+
// A state this page doesn't know is never shown as fine: it reads as not checked.
|
|
193
|
+
const st = CITE_STATE[c.state] || CITE_STATE['not-checked'];
|
|
104
194
|
const word = st.word ? ` · ${st.word}` : '';
|
|
105
195
|
return `<span class="pw-chip pr-cite${st.word ? ' is-muted' : ''}" role="listitem" tabindex="0" data-tip="${esc(c.reason || st.tip)}">${esc(citeLabel(c))}${esc(word)}</span>`;
|
|
106
196
|
}
|
|
@@ -262,6 +352,8 @@
|
|
|
262
352
|
if (rfi.sent) meta.push(`<span data-tip="${esc(exact(rfi.sent.at))}">${rfi.sent.via === 'gmail' ? 'Sent with Gmail to' : rfi.sent.via === 'other' ? `Sent another way (${esc(rfi.sent.how || '')}) to` : 'Marked sent to'} ${esc(rfi.sent.to)} · ${esc(ago(rfi.sent.at, now))}</span>`);
|
|
263
353
|
else meta.push(`<span data-tip="${esc(exact(rfi.raisedAt))}">Filed ${esc(ago(rfi.raisedAt, now))}${rfi.raisedBy === 'ai' ? ' by AI Chat' : ''}</span>`);
|
|
264
354
|
if (rfi.reopens) meta.push(`Reopened ${rfi.reopens === 1 ? 'once' : `${rfi.reopens} times`}`);
|
|
355
|
+
// #2470 R6.6d: why the current round is open again, under the question it reopens.
|
|
356
|
+
const reopenedNote = rfi.reopened ? `<p class="pm-note pr-reopened">Reopened ${dated(rfi.reopened.at)}: ${esc(rfi.reopened.why)}</p>` : '';
|
|
265
357
|
const answer = rfi.answer ? `<blockquote class="pr-answer"><span class="pr-answer-label">Answer</span> ${esc(rfi.answer.text)}</blockquote>` : '';
|
|
266
358
|
const closed = rfi.closed ? `<p class="pg-row-meta">Closed: ${esc(dispositionLabel(rfi.closed.disposition))}${rfi.closed.note ? `. ${esc(rfi.closed.note)}` : '.'}</p>` : '';
|
|
267
359
|
const provenance = rfi.provenance ? `<p class="pm-note">${esc(rfi.provenance)}</p>` : '';
|
|
@@ -334,7 +426,7 @@
|
|
|
334
426
|
<div class="pg-row-line"><span class="pg-row-title" tabindex="-1" data-pr-title="${id}">${id} · ${esc(rfi.title)}</span>
|
|
335
427
|
<span class="pw-chip${rfi.status === 'closed' ? ' is-muted' : ''}">${esc(STATUS[rfi.status] || rfi.status)}</span>${pending ? `<span class="pw-chip is-muted">${d.status === 'prepared' ? 'Unfinished' : 'Not confirmed'}</span>` : ''}</div>
|
|
336
428
|
<span class="pg-row-meta">${meta.join(' · ')}</span>
|
|
337
|
-
<p class="pr-question">${esc(rfi.question)}</p>${answer}${closed}${provenance}${cites}${driftNote}${deliveryNote}
|
|
429
|
+
<p class="pr-question">${esc(rfi.question)}</p>${reopenedNote}${answer}${closed}${provenance}${cites}${driftNote}${deliveryNote}${roundsHtml(rfi)}
|
|
338
430
|
${form || `<div class="pm-strip-acts pr-acts">${verbButtons}</div>`}
|
|
339
431
|
${state.copied?.rfiId === rfi.id ? `<textarea class="pr-input pr-text pr-copied" data-pr-copied="1" readonly rows="6" data-command-id="shell.project-rfi-copied-text#${esc(rfi.id)}" data-command-instance-label="${id}" aria-label="${esc(`Email text of ${rfi.id}`)}">${esc(state.copied.text)}</textarea>` : ''}</div>`;
|
|
340
432
|
}
|
|
@@ -409,7 +501,15 @@
|
|
|
409
501
|
const data = await api(`/api/projects/${encodeURIComponent(mine.project.id)}/correspondence-rfis`);
|
|
410
502
|
if (state !== mine || mine.generation !== generation) return;
|
|
411
503
|
mine.view = { status: 'ready', data, error: null };
|
|
504
|
+
// An open Earlier rounds whose RFI changed since it loaded reads again (#2470 R6.6d).
|
|
505
|
+
for (const rfi of data.rfis) {
|
|
506
|
+
if (!mine.roundsOpen?.has(rfi.id) || !rfi.earlierRounds) continue;
|
|
507
|
+
const got = mine.rounds?.get(rfi.id);
|
|
508
|
+
if (!got || (got.revision < rfi.recordRevision && got.status !== 'loading')) void loadRounds(rfi.id, rfi.recordRevision);
|
|
509
|
+
}
|
|
412
510
|
if (mine.form && !data.rfis.some((r) => r.id === mine.form.rfiId)) mine.form = null;
|
|
511
|
+
// A form opened while this read was out keeps what was typed across the repaint (Codex review, #2470 R6.6d).
|
|
512
|
+
readDraft();
|
|
413
513
|
paint();
|
|
414
514
|
settleWant();
|
|
415
515
|
if (data.store === 'ok') {
|
|
@@ -880,7 +980,13 @@
|
|
|
880
980
|
if (!sheet || sheet.mode !== 'form' || sheet.uncertain) return;
|
|
881
981
|
for (const el of $body.querySelectorAll('[data-pr-field]')) sheet[el.getAttribute('data-pr-field')] = el.value;
|
|
882
982
|
}
|
|
883
|
-
|
|
983
|
+
// An own sheet's key carries its run, so the same file in a newer check is another option (plan R6.6d, Codex round 2 item 16).
|
|
984
|
+
const citeKey = (c) => (c.kind === 'knowledge-page' ? `k:${c.slug}`
|
|
985
|
+
: c.kind === 'own-sheet' ? `o:${c.source}:${c.ref}:${c.pageNumber ?? '-'}:${c.digest}:${c.runId || '-'}` : `d:${c.linkedProjectUuid}:${c.pageId}:${c.sourceHash}`);
|
|
986
|
+
/** What filing sends for one cited item: its identity only — the server takes every label from what it reads. */
|
|
987
|
+
const citationBody = (c) => (c.kind === 'knowledge-page' ? { kind: c.kind, generationId: c.generationId, slug: c.slug }
|
|
988
|
+
: c.kind === 'own-sheet' ? { kind: c.kind, source: c.source, ref: c.ref, pageNumber: c.pageNumber, digest: c.digest, ...(c.runId ? { runId: c.runId } : {}) }
|
|
989
|
+
: { kind: c.kind, linkedProjectUuid: c.linkedProjectUuid, pageId: c.pageId, sourceHash: c.sourceHash });
|
|
884
990
|
|
|
885
991
|
/** Try Gmail again asks first, in a dialog with a tick the person must give (owner ruling, #2470 R6.6e). */
|
|
886
992
|
function openAgain(f) {
|
|
@@ -924,6 +1030,20 @@
|
|
|
924
1030
|
void sendSettle(mine, f, f.sent);
|
|
925
1031
|
}
|
|
926
1032
|
|
|
1033
|
+
/**
|
|
1034
|
+
* #2470 R6.6d: filing found that one cited item no longer matches. Nothing was filed; the person chooses: cite it
|
|
1035
|
+
* again, or file without it. Bound to that item's key (not its position), so an edit since can't aim it elsewhere.
|
|
1036
|
+
*/
|
|
1037
|
+
function recoveryHtml(mine) {
|
|
1038
|
+
const c = mine.cites.find((x) => citeKey(x) === mine.recovery.key);
|
|
1039
|
+
if (!c) return `<div class="pm-note pr-alert" role="alert">${esc(mine.error)}</div>`;
|
|
1040
|
+
const alone = mine.cites.length === 1;
|
|
1041
|
+
return `<div class="pm-note pr-alert" role="alert"><p>${esc(citeLabel(c))}: ${esc(mine.error)}${alone ? ' Filed without it, the RFI cites nothing.' : ''}</p>
|
|
1042
|
+
<p><button type="button" class="ghost" data-pr-recover="again" data-command-id="shell.project-rfi-cite-again">Choose it again</button>
|
|
1043
|
+
<button type="button" class="ghost" data-pr-recover="without" data-command-id="shell.project-rfi-file-without"
|
|
1044
|
+
data-tip="Takes ${esc(citeLabel(c))} out of what this RFI cites, then files it">File without it</button></p></div>`;
|
|
1045
|
+
}
|
|
1046
|
+
|
|
927
1047
|
function paintSheet() {
|
|
928
1048
|
const t = target();
|
|
929
1049
|
if (!sheet || !t) return;
|
|
@@ -932,12 +1052,13 @@
|
|
|
932
1052
|
$title.textContent = 'New RFI';
|
|
933
1053
|
$sub.textContent = `A question from “${t.name}”. FloLess keeps it; after filing you can send it with Gmail or copy its email text.`;
|
|
934
1054
|
const ro = sheet.uncertain || sheet.busy ? ' readonly' : '';
|
|
935
|
-
const chips = sheet.cites.map((c, i) => `<span class="pw-chip pr-cite${c.changed ? ' is-muted' : ''}" role="listitem">${esc(citeLabel(c))}${c.changed ? ' · changed' : ''}
|
|
1055
|
+
const chips = sheet.cites.map((c, i) => `<span class="pw-chip pr-cite${c.changed ? ' is-muted' : ''}" role="listitem">${esc(citeLabel(c))}${c.changed ? (c.changed === 'citation-project-unavailable' ? ' · can’t be read now' : c.kind === 'own-sheet' ? ' · sheet changed' : ' · changed') : ''}
|
|
936
1056
|
<button type="button" class="pr-chip-x" data-pr-uncite="${i}" aria-label="${esc(`Remove ${citeLabel(c)}`)}" data-command-id="shell.project-rfi-cite-remove#${esc(citeKey(c))}"
|
|
937
|
-
data-command-instance-label="${esc(citeLabel(c))}"${sheet.uncertain ? ' disabled' : ''}>✕</button></span>`).join('');
|
|
1057
|
+
data-command-instance-label="${esc(citeLabel(c))}"${sheet.uncertain || sheet.busy ? ' disabled' : ''}>✕</button></span>`).join('');
|
|
938
1058
|
const full = sheet.cites.length >= MAX_CITES;
|
|
939
1059
|
const banner = sheet.uncertain
|
|
940
1060
|
? `<div class="pm-note pr-alert" role="alert">FloLess couldn’t confirm it was filed. It may already be in the list. To change something, choose Edit; FloLess will treat it as a new RFI.</div>`
|
|
1061
|
+
: sheet.recovery && sheet.error ? recoveryHtml(sheet)
|
|
941
1062
|
: sheet.error ? `<div class="pm-note pr-alert" role="alert">${esc(sheet.error)}</div>` : '';
|
|
942
1063
|
$body.innerHTML = `${banner}
|
|
943
1064
|
<label class="pr-field">Title<input class="pr-input" data-pr-field="title" maxlength="120" value="${esc(sheet.title)}" data-command-id="shell.project-rfi-title"${ro}></label>
|
|
@@ -945,7 +1066,7 @@
|
|
|
945
1066
|
<div class="pr-field"><span>Cited</span>
|
|
946
1067
|
<div class="pr-cites" role="list" aria-label="Cited items">${chips || '<span class="pg-row-meta">Nothing cited yet. You can cite up to 5 items.</span>'}</div>
|
|
947
1068
|
<p><button type="button" class="ghost" data-pr-cite="1" aria-haspopup="listbox" data-command-id="shell.project-rfi-cite"
|
|
948
|
-
data-tip="${full ? 'You can cite up to 5 items. Remove one to cite another.' : 'Cite a page of this project’s Knowledge or a saved sheet of a linked project'}"${full || sheet.uncertain ? ' aria-disabled="true"' : ''}>Cite…</button></p></div>
|
|
1069
|
+
data-tip="${full ? 'You can cite up to 5 items. Remove one to cite another.' : linksProjects(state?.project) ? 'Cite a page of this project’s Knowledge or a saved sheet of a linked project' : ownSheetsCitable(state?.project) ? 'Cite a Knowledge page or one of this project’s sheets' : 'Cite a page of this project’s Knowledge'}"${full || sheet.uncertain || sheet.busy ? ' aria-disabled="true"' : ''}>Cite…</button></p></div>
|
|
949
1070
|
<label class="pr-field">To (optional)<input type="email" class="pr-input" data-pr-field="to" value="${esc(sheet.to)}" autocomplete="email" data-command-id="shell.project-rfi-to"${ro}>
|
|
950
1071
|
<span class="pg-row-meta">Only needed to record who you sent it to.</span></label>`;
|
|
951
1072
|
$foot.innerHTML = sheet.uncertain
|
|
@@ -980,25 +1101,54 @@
|
|
|
980
1101
|
return `<button type="button" class="pr-option" role="option" aria-selected="${picked}" data-pr-option="${esc(k)}"
|
|
981
1102
|
data-command-id="shell.project-rfi-cite-option#${esc(k)}" data-command-instance-label="${esc(citeLabel(c))}">
|
|
982
1103
|
<span class="pr-check" aria-hidden="true">${picked ? '✓' : ''}</span><span class="pg-row-title">${esc(c.kind === 'knowledge-page' ? c.title : c.sheet)}</span>
|
|
983
|
-
${c.kind === 'linked-drawing' && c.pageNumber ? `<span class="pg-row-meta">page ${esc(c.pageNumber)}</span>` : ''}
|
|
1104
|
+
${c.kind === 'linked-drawing' && c.pageNumber ? `<span class="pg-row-meta">page ${esc(c.pageNumber)}</span>` : ''}
|
|
1105
|
+
${c.kind === 'own-sheet' && ((c.drawing && !c.sheet.includes(c.drawing)) || ownPage(c)) ? `<span class="pg-row-meta">${esc([c.drawing && !c.sheet.includes(c.drawing) ? c.drawing : '', ownPage(c)].filter(Boolean).join(' · '))}</span>` : ''}</button>`;
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
const ownOption = (r) => ({ kind: 'own-sheet', source: r.source, ref: r.ref, pageNumber: r.pageNumber, digest: r.digest, sheet: r.sheet, drawing: r.drawing, ...(r.runId ? { runId: r.runId } : {}) });
|
|
1109
|
+
const dayOf = (iso) => { const d = new Date(iso); return Number.isNaN(d.getTime()) ? '' : d.toLocaleDateString(undefined, { day: 'numeric', month: 'short', year: 'numeric' }); };
|
|
1110
|
+
/** #2470 R6.6d: one group of this project's own sheets — a Trace's traced sheets, a Drawing Checker's references or its latest check. */
|
|
1111
|
+
function ownGroupHtml(g, i, picks) {
|
|
1112
|
+
const title = g.source === 'trace' ? 'Traced sheets' : g.source === 'checker-reference' ? 'Reference drawings'
|
|
1113
|
+
: g.ranAt ? (g.unreadableRuns ? `Last check FloLess could read · ${dayOf(g.ranAt)}` : `Latest check · ${dayOf(g.ranAt)}`) : 'Latest check';
|
|
1114
|
+
const empty = g.source === 'trace' ? 'No traced sheets yet. Trace the drawing on its Traced step, then cite its sheets here.'
|
|
1115
|
+
: g.source === 'checker-reference' ? 'No reference drawings yet. Add them to the checklist, then cite them here.'
|
|
1116
|
+
: g.ranAt ? `The latest check (${dayOf(g.ranAt)}) has no drawings FloLess can cite.` : 'No check run yet. Run a check, then cite its drawings here.';
|
|
1117
|
+
const options = (g.sheets || []).map(ownOption);
|
|
1118
|
+
const omitted = g.omitted ? `<p class="pm-note">${g.omitted === 1 ? 'One traced sheet shares' : `${g.omitted} traced sheets share`} an id with another, so FloLess can’t cite ${g.omitted === 1 ? 'it' : 'them'}. Trace the drawing again to fix it.</p>` : '';
|
|
1119
|
+
const note = omitted + (g.unreadableRuns ? `<p class="pm-note">${g.unreadableRuns === 1 ? 'One check result couldn’t be read' : `${g.unreadableRuns} check results couldn’t be read`}, so a newer check may exist.</p>` : '');
|
|
1120
|
+
const body = g.state === 'ok' ? (options.length ? options.map((c) => optionHtml(c, picks.has(citeKey(c)))).join('') : g.omitted ? '' : '<p class="pm-note">No sheet matches.</p>')
|
|
1121
|
+
+ (g.truncated ? '<p class="pg-row-meta">Showing the first 200. Type in Filter to narrow it.</p>' : '')
|
|
1122
|
+
: g.state === 'empty' ? `<p class="pm-note">${empty}</p>`
|
|
1123
|
+
: `<p class="pm-note">${esc(g.reason || 'These sheets can’t be read just now.')}</p><p><button type="button" class="ghost" data-pr-cite-retry="1"
|
|
1124
|
+
data-command-id="shell.project-rfi-cite-retry#own-${esc(g.source)}" data-command-instance-label="this project">Try again</button></p>`;
|
|
1125
|
+
return `<div role="group" aria-labelledby="pr-g-o${i}"><p class="pr-group" id="pr-g-o${i}">${esc(title)}</p>${note}${body}</div>`;
|
|
984
1126
|
}
|
|
985
1127
|
|
|
986
1128
|
function paintPicker() {
|
|
987
1129
|
const mine = sheet;
|
|
988
1130
|
$title.textContent = 'Cite';
|
|
989
|
-
$sub.textContent = 'A page of this project’s Knowledge, or a saved sheet of a project linked on its Modules step.'
|
|
1131
|
+
$sub.textContent = linksProjects(state?.project) ? 'A page of this project’s Knowledge, or a saved sheet of a project linked on its Modules step.'
|
|
1132
|
+
: ownSheetsCitable(state?.project) ? 'A page of this project’s Knowledge, or one of this project’s own sheets.'
|
|
1133
|
+
: 'A page of this project’s Knowledge.';
|
|
990
1134
|
const picks = mine.picks;
|
|
991
1135
|
const search = `<input type="search" class="ws-landing-search pr-search" data-pr-search="1" placeholder="Filter" aria-label="Filter what can be cited" value="${esc(mine.query)}" data-command-id="shell.project-rfi-cite-search">`;
|
|
992
1136
|
let groups = '';
|
|
1137
|
+
// Nothing to filter (no Knowledge pages and no linked project): the Filter box is left out rather than shown idle.
|
|
1138
|
+
let filterable = true;
|
|
993
1139
|
if (mine.pickerError) groups = `<p class="pm-note pr-alert" role="alert">${esc(mine.pickerError)}</p>`;
|
|
994
1140
|
else if (!mine.citable) groups = '<p class="pg-loading-line">Loading…</p>';
|
|
995
1141
|
else {
|
|
996
1142
|
const k = mine.citable.knowledge;
|
|
997
1143
|
const kOptions = k.state === 'ok' ? k.pages.map((p) => ({ kind: 'knowledge-page', generationId: k.generationId, slug: p.slug, title: p.title })) : [];
|
|
998
1144
|
const kBody = k.state === 'ok' ? (kOptions.length ? kOptions.map((c) => optionHtml(c, picks.has(citeKey(c)))).join('') : '<p class="pm-note">No page matches.</p>')
|
|
999
|
-
|
|
1145
|
+
// #2470 R6.6d: on a Trace, Revit, Tekla or Drawing Checker project this is the only group, so it says how to get pages.
|
|
1146
|
+
: k.state === 'none' ? '<p class="pm-note">This project has no Knowledge pages yet. Add references on the Knowledge step and choose Organize, then cite them here.</p>'
|
|
1000
1147
|
: '<p class="pm-note">FloLess couldn’t list this project’s Knowledge just now.</p>';
|
|
1001
1148
|
groups = `<div role="group" aria-labelledby="pr-g-k"><p class="pr-group" id="pr-g-k">This project’s Knowledge</p>${kBody}</div>`;
|
|
1149
|
+
const own = mine.citable.own || [];
|
|
1150
|
+
filterable = k.state !== 'none' || mine.citable.linked.length > 0 || own.some((g) => g.state === 'ok') || !!mine.query;
|
|
1151
|
+
own.forEach((g, i) => { groups += ownGroupHtml(g, i, picks); });
|
|
1002
1152
|
mine.citable.linked.forEach((l, i) => {
|
|
1003
1153
|
const options = (l.sheets || []).map((s) => ({ kind: 'linked-drawing', linkedProjectUuid: l.projectUuid, linkedProjectName: l.name, pageId: s.pageId, sourceHash: s.sourceHash, sheet: s.sheet, pageNumber: s.pageNumber }));
|
|
1004
1154
|
const body = l.state === 'ok' ? (options.length ? options.map((c) => optionHtml(c, picks.has(citeKey(c)))).join('') : '<p class="pm-note">No sheet matches.</p>')
|
|
@@ -1007,10 +1157,10 @@
|
|
|
1007
1157
|
data-command-id="shell.project-rfi-cite-retry#${esc(l.projectUuid)}" data-command-instance-label="${esc(l.name)}">Try again</button></p>` : ''}`;
|
|
1008
1158
|
groups += `<div role="group" aria-labelledby="pr-g-${i}"><p class="pr-group" id="pr-g-${i}">Saved sheets in ${esc(l.name)}</p>${body}</div>`;
|
|
1009
1159
|
});
|
|
1010
|
-
mine.options = new Map([...kOptions, ...mine.citable.linked.flatMap((l) => (l.sheets || []).map((s) => ({ kind: 'linked-drawing', linkedProjectUuid: l.projectUuid, linkedProjectName: l.name, pageId: s.pageId, sourceHash: s.sourceHash, sheet: s.sheet, pageNumber: s.pageNumber })))].map((c) => [citeKey(c), c]));
|
|
1160
|
+
mine.options = new Map([...kOptions, ...own.flatMap((g) => (g.sheets || []).map(ownOption)), ...mine.citable.linked.flatMap((l) => (l.sheets || []).map((s) => ({ kind: 'linked-drawing', linkedProjectUuid: l.projectUuid, linkedProjectName: l.name, pageId: s.pageId, sourceHash: s.sourceHash, sheet: s.sheet, pageNumber: s.pageNumber })))].map((c) => [citeKey(c), c]));
|
|
1011
1161
|
}
|
|
1012
1162
|
const hadFocus = document.activeElement?.hasAttribute?.('data-pr-search');
|
|
1013
|
-
$body.innerHTML = `${search}<p class="sr-only pr-pick-live" role="status" aria-live="polite"></p><div class="pr-options" role="listbox" aria-multiselectable="true" aria-label="What can be cited">${groups}</div>`;
|
|
1163
|
+
$body.innerHTML = `${filterable ? search : ''}<p class="sr-only pr-pick-live" role="status" aria-live="polite"></p><div class="pr-options" role="listbox" aria-multiselectable="true" aria-label="What can be cited">${groups}</div>`;
|
|
1014
1164
|
if (hadFocus) { const input = $body.querySelector('[data-pr-search]'); input?.focus(); input?.setSelectionRange?.(mine.query.length, mine.query.length); }
|
|
1015
1165
|
$foot.innerHTML = `<button type="button" class="ghost" data-pr-pick-back="1" data-command-id="shell.project-rfi-cite-back">← Back to the RFI</button>
|
|
1016
1166
|
<button type="button" class="primary" data-pr-pick-done="1" data-command-id="shell.project-rfi-cite-done">${picks.size ? `Cite ${picks.size}` : 'Cite none'}</button>`;
|
|
@@ -1025,7 +1175,7 @@
|
|
|
1025
1175
|
void loadCitable();
|
|
1026
1176
|
}
|
|
1027
1177
|
function closePicker(apply) {
|
|
1028
|
-
if (apply) sheet.cites = [...sheet.picks.values()].map((c) => ({ ...c, changed: false }));
|
|
1178
|
+
if (apply) { sheet.cites = [...sheet.picks.values()].map((c) => ({ ...c, changed: false })); sheet.recovery = null; }
|
|
1029
1179
|
sheet.mode = 'form';
|
|
1030
1180
|
paintSheet();
|
|
1031
1181
|
requestAnimationFrame(() => $body.querySelector('[data-pr-cite]')?.focus());
|
|
@@ -1046,10 +1196,11 @@
|
|
|
1046
1196
|
return;
|
|
1047
1197
|
}
|
|
1048
1198
|
if (!mine.uncertain) mine.payload = { ...identity(), operationKey: mine.key, title, question,
|
|
1049
|
-
citations: mine.cites.map(
|
|
1050
|
-
: { kind: c.kind, linkedProjectUuid: c.linkedProjectUuid, pageId: c.pageId, sourceHash: c.sourceHash })),
|
|
1199
|
+
citations: mine.cites.map(citationBody),
|
|
1051
1200
|
...(markSent ? { markSentTo: to } : {}) };
|
|
1052
|
-
|
|
1201
|
+
// What was submitted, in order: a refusal's citationIndex names one of THESE (the cites can't change while busy).
|
|
1202
|
+
const submitted = mine.cites.slice();
|
|
1203
|
+
mine.busy = true; mine.error = null; mine.recovery = null; paintSheet();
|
|
1053
1204
|
try {
|
|
1054
1205
|
const res = await api(`/api/projects/${encodeURIComponent(t.projectId)}/correspondence-rfis`, { method: 'POST', body: JSON.stringify(mine.payload) });
|
|
1055
1206
|
if (sheet !== mine) return;
|
|
@@ -1070,12 +1221,20 @@
|
|
|
1070
1221
|
mine.error = said(error, 'FloLess couldn’t file it just now. Try again.');
|
|
1071
1222
|
mine.uncertain = false;
|
|
1072
1223
|
mine.key = newKey(); // the next send after a refusal is a new intent
|
|
1073
|
-
if (/^citation-/.test(error.body.code || ''))
|
|
1224
|
+
if (/^citation-/.test(error.body.code || '')) {
|
|
1225
|
+
const refused = Number.isInteger(error.body.citationIndex) ? submitted[error.body.citationIndex] : null;
|
|
1226
|
+
if (refused) {
|
|
1227
|
+
const key = citeKey(refused);
|
|
1228
|
+
// The chip says why: a sheet that changed, or one that can't be read just now (a lapsed module, an unreadable file).
|
|
1229
|
+
mine.cites = mine.cites.map((c) => (citeKey(c) === key ? { ...c, changed: error.body.code } : c));
|
|
1230
|
+
mine.recovery = { key };
|
|
1231
|
+
} else mine.cites = mine.cites.map((c) => ({ ...c, changed: error.body.code }));
|
|
1232
|
+
}
|
|
1074
1233
|
} else {
|
|
1075
1234
|
mine.uncertain = true; // same key, same payload on Try again
|
|
1076
1235
|
}
|
|
1077
1236
|
paintSheet();
|
|
1078
|
-
($foot.querySelector(mine.uncertain ? '[data-pr-sheet-retry]' : '[data-pr-sheet-file="file"]'))?.focus();
|
|
1237
|
+
(mine.recovery ? $body.querySelector('[data-pr-recover="again"]') : $foot.querySelector(mine.uncertain ? '[data-pr-sheet-retry]' : '[data-pr-sheet-file="file"]'))?.focus();
|
|
1079
1238
|
}
|
|
1080
1239
|
}
|
|
1081
1240
|
|
|
@@ -1092,16 +1251,29 @@
|
|
|
1092
1251
|
if (t.closest('[data-pr-sheet-retry]')) { void fileRfi(!!sheet.payload?.markSentTo); return; }
|
|
1093
1252
|
if (t.closest('[data-pr-sheet-edit]')) { sheet.uncertain = false; sheet.key = newKey(); paintSheet(); $body.querySelector('[data-pr-field="title"]')?.focus(); return; }
|
|
1094
1253
|
if (t.closest('[data-pr-sheet-check]')) { closeSheet(); if (state) void load(); return; }
|
|
1254
|
+
const recover = t.closest('[data-pr-recover]');
|
|
1255
|
+
if (recover && sheet.recovery && !sheet.busy) {
|
|
1256
|
+
const key = sheet.recovery.key;
|
|
1257
|
+
if (recover.getAttribute('data-pr-recover') === 'again') { sheet.recovery = null; sheet.error = null; sheet.cites = sheet.cites.filter((c) => citeKey(c) !== key); openPicker(); return; }
|
|
1258
|
+
readSheet(); sheet.cites = sheet.cites.filter((c) => citeKey(c) !== key); sheet.recovery = null; void fileRfi(!!sheet.payload?.markSentTo); return;
|
|
1259
|
+
}
|
|
1260
|
+
// While a filing is in flight its citations are fixed: a refusal names one of what was sent.
|
|
1261
|
+
if (sheet.busy && (t.closest('[data-pr-cite]') || t.closest('[data-pr-uncite]') || t.closest('[data-pr-option]'))) return;
|
|
1095
1262
|
const cite = t.closest('[data-pr-cite]');
|
|
1096
1263
|
if (cite) { if (cite.getAttribute('aria-disabled') === 'true') { toast('You can cite up to 5 items. Remove one to cite another.', 'info'); return; } openPicker(); return; }
|
|
1097
1264
|
const uncite = t.closest('[data-pr-uncite]');
|
|
1098
|
-
if (uncite) { readSheet(); sheet.cites.splice(Number(uncite.getAttribute('data-pr-uncite')), 1); paintSheet(); $body.querySelector('[data-pr-cite]')?.focus(); return; }
|
|
1265
|
+
if (uncite) { readSheet(); sheet.cites.splice(Number(uncite.getAttribute('data-pr-uncite')), 1); sheet.recovery = null; paintSheet(); $body.querySelector('[data-pr-cite]')?.focus(); return; }
|
|
1099
1266
|
const option = t.closest('[data-pr-option]');
|
|
1100
1267
|
if (option) {
|
|
1101
1268
|
const k = option.getAttribute('data-pr-option');
|
|
1269
|
+
// A newer read of a sheet already picked (it changed since) replaces the older one, so one sheet is never cited twice.
|
|
1270
|
+
const picked = sheet.options.get(k);
|
|
1271
|
+
if (!sheet.picks.has(k) && picked?.kind === 'own-sheet') {
|
|
1272
|
+
for (const [key, c] of sheet.picks) if (c.kind === 'own-sheet' && citeKey({ ...c, digest: '' }) === citeKey({ ...picked, digest: '' })) sheet.picks.delete(key);
|
|
1273
|
+
}
|
|
1102
1274
|
if (sheet.picks.has(k)) sheet.picks.delete(k);
|
|
1103
1275
|
else if (sheet.picks.size >= MAX_CITES) { const live = $body.querySelector('.pr-pick-live'); if (live) live.textContent = 'You can cite up to 5 items.'; return; }
|
|
1104
|
-
else sheet.picks.set(k,
|
|
1276
|
+
else sheet.picks.set(k, picked);
|
|
1105
1277
|
paintPicker();
|
|
1106
1278
|
$body.querySelector(`[data-pr-option="${CSS.escape(k)}"]`)?.focus();
|
|
1107
1279
|
return;
|
|
@@ -1132,6 +1304,26 @@
|
|
|
1132
1304
|
if (t.closest('[data-pr-gmail-check]')) { state.form = null; state.quietLoad = true; void load(); return; }
|
|
1133
1305
|
const settle = t.closest('[data-pr-settle]');
|
|
1134
1306
|
if (settle) { openSettle(settle.getAttribute('data-pr-settle'), settle.getAttribute('data-pr-attempt')); return; }
|
|
1307
|
+
const rounds = t.closest('[data-pr-rounds]');
|
|
1308
|
+
if (rounds) {
|
|
1309
|
+
const rfiId = rounds.getAttribute('data-pr-rounds');
|
|
1310
|
+
state.roundsOpen ??= new Set();
|
|
1311
|
+
if (state.roundsOpen.has(rfiId)) state.roundsOpen.delete(rfiId);
|
|
1312
|
+
else {
|
|
1313
|
+
state.roundsOpen.add(rfiId);
|
|
1314
|
+
const rfi = state.view?.data?.rfis?.find((r) => r.id === rfiId);
|
|
1315
|
+
const got = state.rounds?.get(rfiId);
|
|
1316
|
+
if (rfi && !(got && got.revision >= rfi.recordRevision && got.status !== 'error')) void loadRounds(rfiId, rfi.recordRevision);
|
|
1317
|
+
}
|
|
1318
|
+
readDraft(); state.focusAfter = `[data-pr-rounds="${CSS.escape(rfiId)}"]`; paint(); return;
|
|
1319
|
+
}
|
|
1320
|
+
const roundsAgain = t.closest('[data-pr-rounds-again]');
|
|
1321
|
+
if (roundsAgain) {
|
|
1322
|
+
const rfiId = roundsAgain.getAttribute('data-pr-rounds-again');
|
|
1323
|
+
const rfi = state.view?.data?.rfis?.find((r) => r.id === rfiId);
|
|
1324
|
+
if (rfi) void loadRounds(rfiId, rfi.recordRevision);
|
|
1325
|
+
readDraft(); state.focusAfter = `[data-pr-rounds="${CSS.escape(rfiId)}"]`; paint(); return;
|
|
1326
|
+
}
|
|
1135
1327
|
const history = t.closest('[data-pr-history]');
|
|
1136
1328
|
if (history) {
|
|
1137
1329
|
const rfiId = history.getAttribute('data-pr-history');
|
|
@@ -1168,8 +1360,10 @@
|
|
|
1168
1360
|
const rfi = state.view.data.rfis.find((r) => r.id === again.getAttribute('data-pr-again'));
|
|
1169
1361
|
if (rfi) openSheet(again, { title: rfi.title, question: rfi.question,
|
|
1170
1362
|
// A page that reads current in a newer Knowledge version is cited there: a filing names the version published now.
|
|
1171
|
-
|
|
1172
|
-
|
|
1363
|
+
// A traced sheet re-numbered by a re-read is cited under its new id (same content: still current).
|
|
1364
|
+
cites: rfi.citations.filter((c) => c.state === 'current').map(({ state: _s, reason: _r, refileGenerationId, refileRef, ...c }) => (
|
|
1365
|
+
c.kind === 'knowledge-page' && refileGenerationId ? { ...c, generationId: refileGenerationId }
|
|
1366
|
+
: c.kind === 'own-sheet' && refileRef ? { ...c, ref: refileRef } : c)) });
|
|
1173
1367
|
return;
|
|
1174
1368
|
}
|
|
1175
1369
|
if (t.closest('[data-pr-retry]')) { state.view = { status: 'loading', data: null }; paint(); void load(); return; }
|
|
@@ -1224,7 +1418,7 @@
|
|
|
1224
1418
|
});
|
|
1225
1419
|
|
|
1226
1420
|
/**
|
|
1227
|
-
* The sentence a Duplicate or Import adds about a
|
|
1421
|
+
* The sentence a Duplicate or Import adds about a project's RFIs-step RFIs (#2470 R6.6; any kind that keeps them, R6.6d). Null when there is nothing to
|
|
1228
1422
|
* say. A source that could not be carried is said, never turned into silence.
|
|
1229
1423
|
*/
|
|
1230
1424
|
function transferNote(raw, operation = 'duplicate') {
|
|
@@ -202,7 +202,47 @@ export function aiDecisionMarksOf(model) {
|
|
|
202
202
|
return {
|
|
203
203
|
state: !readable ? 'unknown' : dependencies.size ? 'marks' : 'none',
|
|
204
204
|
members, ends, joints: [...jointsById.values()], views, model: note, entries,
|
|
205
|
-
decisionCount: dependencies.size,
|
|
205
|
+
decisionCount: dependencies.size, dependencyIds: [...dependencies],
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* The marks of the decisions nobody has reviewed yet (#2521 row 8a): what the canvas, 3D and the strip show. A decision a
|
|
211
|
+
* person confirmed in Make precise stops being marked; Inspect keeps the full analysis and says who reviewed it. A mark
|
|
212
|
+
* resting on several decisions stays while any of them is unreviewed, naming only those. An unreadable reading stays
|
|
213
|
+
* unknown: a review never vouches for what FloLess could not read.
|
|
214
|
+
* @param {ReturnType<typeof aiDecisionMarksOf>} marks
|
|
215
|
+
* @param {{ has(id: string): boolean } | null | undefined} reviewed the reviewed decision ids
|
|
216
|
+
*/
|
|
217
|
+
export function unreviewedMarksOf(marks, reviewed) {
|
|
218
|
+
if (!reviewed || !marks.dependencyIds.some((id) => reviewed.has(id))) return marks;
|
|
219
|
+
const open = (id) => !reviewed.has(id);
|
|
220
|
+
const members = new Map();
|
|
221
|
+
for (const [memberId, list] of marks.members) {
|
|
222
|
+
const kept = [];
|
|
223
|
+
for (const mark of list) {
|
|
224
|
+
if (mark.kind === 'height') {
|
|
225
|
+
const decisionIds = mark.decisionIds.filter(open);
|
|
226
|
+
if (decisionIds.length) kept.push({ ...mark, decisionIds });
|
|
227
|
+
} else if (open(mark.decisionId)) kept.push(mark);
|
|
228
|
+
}
|
|
229
|
+
if (kept.length) members.set(memberId, kept);
|
|
230
|
+
}
|
|
231
|
+
const views = new Map();
|
|
232
|
+
for (const [viewId, rows] of marks.views) {
|
|
233
|
+
const kept = rows.filter((row) => open(row.decisionId));
|
|
234
|
+
if (kept.length) views.set(viewId, kept);
|
|
235
|
+
}
|
|
236
|
+
const dependencyIds = marks.dependencyIds.filter(open);
|
|
237
|
+
return {
|
|
238
|
+
state: marks.state === 'unknown' ? 'unknown' : dependencyIds.length ? 'marks' : 'none',
|
|
239
|
+
members,
|
|
240
|
+
ends: marks.ends.flatMap((e) => { const decisionIds = e.decisionIds.filter(open); return decisionIds.length ? [{ ...e, decisionIds }] : []; }),
|
|
241
|
+
joints: marks.joints.flatMap((j) => { const decisionIds = j.decisionIds.filter(open); return decisionIds.length ? [{ ...j, decisionIds }] : []; }),
|
|
242
|
+
views,
|
|
243
|
+
model: marks.model.filter((item) => item.decisionId === null || open(item.decisionId)),
|
|
244
|
+
entries: marks.entries,
|
|
245
|
+
decisionCount: dependencyIds.length, dependencyIds,
|
|
206
246
|
};
|
|
207
247
|
}
|
|
208
248
|
|
|
@@ -231,3 +271,90 @@ export function canvasMarksOf(marks) {
|
|
|
231
271
|
...(j.mainEnd !== undefined ? { mainEnd: j.mainEnd } : {}), ...(j.place ? { place: j.place } : {}) })),
|
|
232
272
|
};
|
|
233
273
|
}
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* What a Make precise Confirm or Confirm all says it did (#2521 row 8a). It words only what THIS confirm did, from the
|
|
277
|
+
* server's answers to it: another window may review the same decisions at any moment, so of the rest it says only that
|
|
278
|
+
* this confirm did not record them, never that they are unreviewed.
|
|
279
|
+
* @param {{ byYou: number, already: number, unsettled: number, left?: number | null,
|
|
280
|
+
* failure?: 'changed' | 'error' | 'unknown', refusal?: string, changed?: boolean }} o
|
|
281
|
+
* byYou: recorded as reviewed by this confirm; already: in what it settled, those someone had already reviewed;
|
|
282
|
+
* unsettled: those it did not record; left: what is still to review after it, when the server said; failure: why the
|
|
283
|
+
* unsettled were not recorded ('unknown': the answer was lost, so they may have been); refusal: FloLess's own sentence
|
|
284
|
+
* for a refusal, used only when nothing was settled; changed (#2521 row 8b): the person marked it changed, so what
|
|
285
|
+
* was recorded is said as a change.
|
|
286
|
+
*/
|
|
287
|
+
export function makePreciseOutcome(o) {
|
|
288
|
+
const was = (n) => (n === 1 ? 'was' : 'were');
|
|
289
|
+
const settled = o.byYou + o.already;
|
|
290
|
+
if (!o.unsettled) {
|
|
291
|
+
const left = Number.isSafeInteger(o.left) && o.left > 0 ? ` ${o.left} to review.` : '';
|
|
292
|
+
if (!o.byYou) return `${o.already} ${was(o.already)} already reviewed, so nothing new was recorded.${left}`;
|
|
293
|
+
const as = o.changed ? 'changed' : 'reviewed';
|
|
294
|
+
const mine = o.byYou === 1 && !o.already ? `Recorded as ${as} by you.` : `Recorded ${o.byYou} as ${as} by you.`;
|
|
295
|
+
return mine + (o.already ? ` ${o.already} ${was(o.already)} already reviewed.` : '') + left;
|
|
296
|
+
}
|
|
297
|
+
const changed = o.failure === 'changed', lost = o.failure === 'unknown';
|
|
298
|
+
if (!settled) {
|
|
299
|
+
if (lost) return 'FloLess did not get an answer, so it cannot tell whether this was recorded. The list now shows what is still to review.';
|
|
300
|
+
if (changed) {
|
|
301
|
+
return o.unsettled === 1
|
|
302
|
+
? 'Nothing was recorded: it changed since the list was shown. Check it and confirm again.'
|
|
303
|
+
: 'Nothing was recorded: some of these changed since the list was shown. Check them and confirm again.';
|
|
304
|
+
}
|
|
305
|
+
return o.refusal || 'FloLess could not record this just now, so nothing was recorded. Your model is unchanged. Try again in a moment.';
|
|
306
|
+
}
|
|
307
|
+
const done = !o.byYou
|
|
308
|
+
? `${o.already} ${was(o.already)} already reviewed, so this confirm recorded nothing new.`
|
|
309
|
+
: `This confirm recorded ${o.byYou} as reviewed by you${o.already ? `; ${o.already} ${was(o.already)} already reviewed` : ''}.`;
|
|
310
|
+
if (lost) {
|
|
311
|
+
const them = o.unsettled === 1 ? 'the other one, FloLess did not get an answer, so it cannot tell whether it was'
|
|
312
|
+
: `the other ${o.unsettled}, FloLess did not get an answer, so it cannot tell whether they were`;
|
|
313
|
+
return `${done} For ${them} recorded. The list now shows what is still to review.`;
|
|
314
|
+
}
|
|
315
|
+
const why = changed
|
|
316
|
+
? (o.unsettled === 1 ? 'it changed since the list was shown. Check it and confirm again.' : 'some changed since the list was shown. Check them and confirm again.')
|
|
317
|
+
: `FloLess could not record ${o.unsettled === 1 ? 'it' : 'them'} just now. Try again in a moment.`;
|
|
318
|
+
return `${done} ${o.unsettled} ${was(o.unsettled)} not recorded by it: ${why}`;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Send a Make precise confirm a batch at a time (#2521 row 8a). One request may carry only so many decisions, and each
|
|
323
|
+
* is all or nothing, so a later batch that fails leaves the earlier ones recorded; it stops at the first batch that did
|
|
324
|
+
* not settle and says what the settled ones were.
|
|
325
|
+
* @template {{ decisionId: string }} T
|
|
326
|
+
* @param {T[]} items
|
|
327
|
+
* @param {number} size what one request may carry
|
|
328
|
+
* @param {(batch: T[]) => Promise<{ ok: boolean, status: number, json(): Promise<any> }>} send throws an error with
|
|
329
|
+
* `notSent: true` when the request never left (nothing can have been recorded)
|
|
330
|
+
* @param {(settled: number) => void} [onBatch] called before each batch after the first, with how many settled so far
|
|
331
|
+
* @returns {Promise<{ settled: number, byYou: number, already: number, reviewedIds: string[], quick: unknown,
|
|
332
|
+
* res: { ok: boolean, status: number } | null, d: any, unknown: boolean, error?: unknown }>}
|
|
333
|
+
* settled: how many of `items` the server settled; byYou / already: of those, recorded by this confirm / reviewed
|
|
334
|
+
* before it; reviewedIds: both, as the server named them; quick: the label of the last answer that settled
|
|
335
|
+
* (undefined when none did); res, d: the last answer and its body (null when there was none); unknown: the last
|
|
336
|
+
* request may have been recorded but its answer was lost (no answer, or an OK one that could not be read).
|
|
337
|
+
*/
|
|
338
|
+
export async function confirmInBatches(items, size, send, onBatch) {
|
|
339
|
+
const out = { settled: 0, byYou: 0, already: 0, reviewedIds: [], quick: undefined, res: null, d: null, unknown: false };
|
|
340
|
+
for (let i = 0; i < items.length; i += size) {
|
|
341
|
+
const batch = items.slice(i, i + size);
|
|
342
|
+
if (i && onBatch) onBatch(out.settled);
|
|
343
|
+
out.res = null; out.d = null;
|
|
344
|
+
try {
|
|
345
|
+
out.res = await send(batch);
|
|
346
|
+
out.d = await out.res.json().catch(() => null);
|
|
347
|
+
} catch (error) {
|
|
348
|
+
out.res = null; out.d = null; out.error = error;
|
|
349
|
+
out.unknown = !(error && error.notSent);
|
|
350
|
+
}
|
|
351
|
+
if (out.res && out.res.ok && !out.d) out.unknown = true;
|
|
352
|
+
if (!(out.res && out.res.ok && out.d)) break;
|
|
353
|
+
const mine = Array.isArray(out.d.confirmed) ? out.d.confirmed : [];
|
|
354
|
+
const before = Array.isArray(out.d.alreadyReviewed) ? out.d.alreadyReviewed : [];
|
|
355
|
+
out.reviewedIds.push(...mine, ...before);
|
|
356
|
+
out.quick = out.d.quick ?? null;
|
|
357
|
+
out.settled += batch.length; out.byYou += mine.length; out.already += before.length;
|
|
358
|
+
}
|
|
359
|
+
return out;
|
|
360
|
+
}
|