@floless/app 0.169.0 → 0.171.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 +65531 -43728
- package/dist/schemas/drawing-check.profile.v1.schema.json +12 -2
- package/dist/schemas/steel.model.v2.schema.json +196 -4
- package/dist/skills/floless-app-bridge/SKILL.md +3 -3
- package/dist/skills/floless-app-knowledge/SKILL.md +46 -15
- package/dist/skills/floless-app-new-workflow/SKILL.md +8 -1
- package/dist/skills/floless-app-onboarding/SKILL.md +5 -4
- package/dist/skills/floless-app-onboarding/references/floless-surfaces.md +0 -3
- package/dist/skills/floless-app-queue/SKILL.md +2 -3
- package/dist/skills/floless-app-report-issue/SKILL.md +2 -2
- package/dist/skills/floless-app-routines/SKILL.md +2 -2
- package/dist/skills/floless-app-routines/references/routines-api.md +20 -8
- package/dist/skills/floless-app-steel-model/SKILL.md +42 -39
- package/dist/skills/floless-app-steel-model/references/custom-connections.md +47 -0
- package/dist/skills/floless-app-steel-model/references/custom-sections.md +32 -0
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +31 -1
- package/dist/skills/floless-app-ui/SKILL.md +71 -126
- package/dist/skills/floless-app-workflows/SKILL.md +22 -3
- package/dist/skills/floless-app-workflows/references/agent-steps.md +40 -6
- package/dist/skills/floless-app-workflows/references/exec-contract.md +27 -0
- package/dist/skills/floless-app-workflows/references/script-runner.md +105 -0
- package/dist/web/add-ons.js +407 -0
- package/dist/web/agent-steps.js +89 -18
- package/dist/web/agents.js +32 -22
- package/dist/web/analytics.js +1 -1
- package/dist/web/app.css +331 -190
- package/dist/web/app.js +33 -13
- package/dist/web/aware.js +926 -218
- package/dist/web/chat.css +6 -1
- package/dist/web/chat.js +316 -112
- package/dist/web/checkpoint-standard.js +5 -3
- package/dist/web/commands-drawing-check.js +1 -0
- package/dist/web/commands-filter.js +23 -0
- package/dist/web/commands-shell.js +479 -78
- package/dist/web/commands-steel.js +69 -2
- package/dist/web/commands-tekla-parser.js +23 -0
- package/dist/web/connections.js +14 -3
- package/dist/web/drawing-check-editor.js +352 -88
- package/dist/web/failure-copy.js +33 -2
- package/dist/web/filter-ai-proposal.js +11 -8
- package/dist/web/flo-3d.js +1 -1
- package/dist/web/guide.js +36 -29
- package/dist/web/index.html +98 -57
- package/dist/web/instructor.js +101 -17
- package/dist/web/kb-categories.js +64 -7
- package/dist/web/left-pane.js +4 -1
- package/dist/web/local-discovery.js +8 -7
- package/dist/web/missed-routines.js +239 -0
- package/dist/web/model-change-findings.js +430 -0
- package/dist/web/model-change-review.js +414 -0
- package/dist/web/model-editor-steel-adapter.js +2 -2
- package/dist/web/model-measure.js +6 -0
- package/dist/web/model-spatial-panel.js +19 -4
- package/dist/web/model-spatial-tools.js +3 -3
- package/dist/web/model-viewport-revit-adapter.js +3 -3
- package/dist/web/origin-rule.js +155 -0
- package/dist/web/project-access.js +1 -1
- package/dist/web/project-history.js +7 -1
- package/dist/web/project-modules.js +2 -2
- package/dist/web/project-rfis.js +6 -1
- package/dist/web/project-workflows.js +2 -2
- package/dist/web/revit-editor.css +85 -0
- package/dist/web/revit-editor.js +58 -9
- package/dist/web/run-history.js +12 -1
- package/dist/web/sha256-sync.js +62 -0
- package/dist/web/steel-3d-core.js +46 -9
- package/dist/web/steel-3d-flo.js +153 -7
- package/dist/web/steel-3d-view.js +33 -5
- package/dist/web/steel-ai-marks.js +3 -1
- package/dist/web/steel-custom-connection.js +161 -0
- package/dist/web/steel-custom-sections.js +1796 -0
- package/dist/web/steel-editor.html +732 -161
- package/dist/web/steel-environments.js +297 -0
- package/dist/web/steel-filter-usage.js +299 -0
- package/dist/web/steel-filter.html +104 -6
- package/dist/web/steel-model-v2-client-validation.js +11 -1
- package/dist/web/steel-model-v2-commands.js +116 -13
- package/dist/web/steel-model-v2-projection.js +1 -1
- package/dist/web/steel-read-confidence.js +1 -56
- package/dist/web/step-rename.js +3 -2
- package/dist/web/tekla-editor.html +1 -0
- package/dist/web/terminal-requests.js +1 -1
- package/dist/web/tool-updates.js +7 -6
- package/dist/web/workspaces.js +1968 -138
- package/launch.mjs +87 -9
- package/package.json +4 -1
- package/dist/web/panels.js +0 -831
package/dist/web/workspaces.js
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* workspaces.js — the Workspaces | Workflows mode shell (slice 1).
|
|
3
3
|
* Owns: mode state, the landing project grid, the open-project view (Drawings |
|
|
4
4
|
* Model iframes), the project picker + lifecycle menu, and per-project Approve.
|
|
5
|
-
* Composes with app.js
|
|
5
|
+
* Composes with app.js by CLASS-GATING (CSS hides Workflows chrome under
|
|
6
6
|
* .app.mode-workspaces) — it never removes their DOM or unwires their handlers.
|
|
7
7
|
* Reuses app.js globals (escapeHtml, escapeAttr, showToast) and the flolessBridge
|
|
8
|
-
* seams (api, formModal, loadRequests)
|
|
9
|
-
* SECURITY CONTRACT
|
|
8
|
+
* seams (api, formModal, loadRequests).
|
|
9
|
+
* SECURITY CONTRACT: every innerHTML interpolation passes
|
|
10
10
|
* escapeHtml/escapeAttr — project names are user-authored; no unescaped string may
|
|
11
11
|
* ever reach the DOM. textContent wherever no markup is needed.
|
|
12
12
|
* See docs/superpowers/specs/2026-07-03-workspaces-two-mode-shell-design.md.
|
|
@@ -518,21 +518,21 @@
|
|
|
518
518
|
|
|
519
519
|
const TEKLA_PICK_LIMITS = Object.freeze({ files: 10_000, fileBytes: 512 * 1024 * 1024, totalBytes: 1.5 * 1024 * 1024 * 1024, depth: 32, pathBytes: 512 });
|
|
520
520
|
function validateTeklaPickedEntries(entries) {
|
|
521
|
-
if (!entries.length) throw
|
|
522
|
-
if (entries.length > TEKLA_PICK_LIMITS.files) throw
|
|
521
|
+
if (!entries.length) throw personError('The selected folder is empty.');
|
|
522
|
+
if (entries.length > TEKLA_PICK_LIMITS.files) throw personError('The selected folder contains more than 10,000 files.');
|
|
523
523
|
let total = 0;
|
|
524
524
|
for (const entry of entries) {
|
|
525
525
|
const path = String(entry.path || '').replaceAll('\\', '/').replace(/^\/+/, '');
|
|
526
526
|
const parts = path.split('/');
|
|
527
527
|
if (!path || path.includes(':') || parts.length > TEKLA_PICK_LIMITS.depth || parts.some((part) => !part || part === '.' || part === '..')) {
|
|
528
|
-
throw
|
|
528
|
+
throw personError('The selected folder contains an unsafe file path.');
|
|
529
529
|
}
|
|
530
530
|
if (new TextEncoder().encode(path).byteLength > TEKLA_PICK_LIMITS.pathBytes) {
|
|
531
|
-
throw
|
|
531
|
+
throw personError('The selected folder contains a file path longer than 512 bytes.');
|
|
532
532
|
}
|
|
533
|
-
if (entry.file.size > TEKLA_PICK_LIMITS.fileBytes) throw
|
|
533
|
+
if (entry.file.size > TEKLA_PICK_LIMITS.fileBytes) throw personError(`${entry.file.name} is larger than 512 MB.`);
|
|
534
534
|
total += entry.file.size;
|
|
535
|
-
if (!Number.isSafeInteger(total) || total > TEKLA_PICK_LIMITS.totalBytes) throw
|
|
535
|
+
if (!Number.isSafeInteger(total) || total > TEKLA_PICK_LIMITS.totalBytes) throw personError('The selected folder is larger than 1.5 GB.');
|
|
536
536
|
entry.path = path;
|
|
537
537
|
}
|
|
538
538
|
entries.sort((left, right) => left.path.localeCompare(right.path));
|
|
@@ -542,7 +542,7 @@
|
|
|
542
542
|
async function filesFromDirectoryHandle(root) {
|
|
543
543
|
const entries = [];
|
|
544
544
|
async function visit(directory, prefix, depth) {
|
|
545
|
-
if (depth > TEKLA_PICK_LIMITS.depth) throw
|
|
545
|
+
if (depth > TEKLA_PICK_LIMITS.depth) throw personError('The selected folder is nested too deeply.');
|
|
546
546
|
const children = [];
|
|
547
547
|
for await (const pair of directory.entries()) children.push(pair);
|
|
548
548
|
children.sort(([left], [right]) => left.localeCompare(right));
|
|
@@ -550,11 +550,12 @@
|
|
|
550
550
|
const logicalPath = prefix ? `${prefix}/${name}` : name;
|
|
551
551
|
if (handle.kind === 'file') entries.push({ path: logicalPath, file: await handle.getFile() });
|
|
552
552
|
else if (handle.kind === 'directory') await visit(handle, logicalPath, depth + 1);
|
|
553
|
-
if (entries.length > TEKLA_PICK_LIMITS.files) throw
|
|
553
|
+
if (entries.length > TEKLA_PICK_LIMITS.files) throw personError('The selected folder contains more than 10,000 files.');
|
|
554
554
|
}
|
|
555
555
|
}
|
|
556
556
|
await visit(root, '', 1);
|
|
557
|
-
|
|
557
|
+
// `root` lets change review list the folder again after the copy, so a file that appeared is seen too (#3352).
|
|
558
|
+
return { label: root.name, kind: 'folder', entries: validateTeklaPickedEntries(entries), root };
|
|
558
559
|
}
|
|
559
560
|
|
|
560
561
|
async function pickTeklaFolder(fallbackInput) {
|
|
@@ -582,7 +583,7 @@
|
|
|
582
583
|
|
|
583
584
|
// One ZIP of a Tekla model as a source — shared by the ZIP picker and a ZIP dropped on the card.
|
|
584
585
|
function teklaZipSource(file) {
|
|
585
|
-
if (!/\.zip$/i.test(file.name) || file.size > 1024 * 1024 * 1024) throw
|
|
586
|
+
if (!/\.zip$/i.test(file.name) || file.size > 1024 * 1024 * 1024) throw personError('Choose one Tekla model ZIP up to 1 GB.');
|
|
586
587
|
return { label: file.name, kind: 'zip', entries: [{ path: file.name, file }] };
|
|
587
588
|
}
|
|
588
589
|
async function pickTeklaZip(fallbackInput) {
|
|
@@ -721,10 +722,18 @@
|
|
|
721
722
|
let renderTicker = null;
|
|
722
723
|
const exportReceipts = new Map(); // projectId:kind → reconciled receipt counts for this browser session
|
|
723
724
|
const exportBusy = new Set(); // projectId:kind → one in-flight export
|
|
725
|
+
// #3273: how long a send's consent and source cleanup may take before its busy claim is released anyway. The server
|
|
726
|
+
// expires both on its own, so giving up on the request loses nothing; waiting on it forever left "Sending…" up.
|
|
727
|
+
const SEND_CLEANUP_MS = 15_000;
|
|
728
|
+
// #3273: how long one Exports refresh waits on each of its answers (the approval review, the listing, the export
|
|
729
|
+
// sources, render readiness). Generous, the same 90 s as the #1604 polls, because a loaded PC answers these slowly
|
|
730
|
+
// (#3139: a CPU-starved server took 44 s for the export sources); past it the pane says what it could not load
|
|
731
|
+
// instead of waiting for good.
|
|
732
|
+
const EXPORTS_REFRESH_MS = 90_000;
|
|
724
733
|
if (!$switch || !$landing || !$app) return; // markup absent — nothing to wire
|
|
725
734
|
|
|
726
735
|
// The picker menu is a `.menu` (display:none by default; `.menu.show` → display:block, which
|
|
727
|
-
// OVERRIDES the `hidden` attribute). So close must clear BOTH
|
|
736
|
+
// OVERRIDES the `hidden` attribute). So close must clear BOTH.
|
|
728
737
|
// Hand focus back to the kebab BEFORE hiding, when the menu is what currently holds it. Clicking a
|
|
729
738
|
// menu item focuses that item (browsers focus a <button> on click), and the very next thing several
|
|
730
739
|
// items do is open a formModal, which on close returns focus to whatever was focused when it opened
|
|
@@ -1449,7 +1458,9 @@
|
|
|
1449
1458
|
renderApprovalHeader();
|
|
1450
1459
|
return null;
|
|
1451
1460
|
}
|
|
1452
|
-
|
|
1461
|
+
// #3273: with a deadline, because every surface that waits for this verdict (the Exports listing among them) waits
|
|
1462
|
+
// on this request, and one that never answers is not an error: it would hold them all on "Loading…" for good.
|
|
1463
|
+
const review = await api(`/api/projects/${encodeURIComponent(projectId)}/approval-review`, { timeoutMs: EXPORTS_REFRESH_MS });
|
|
1453
1464
|
if (gen !== approvalStateGen || !current || current.id !== projectId) return null;
|
|
1454
1465
|
// NOT an error, and kept apart from one on purpose: the route answers this 200 for a project
|
|
1455
1466
|
// that legitimately has nothing to review (no model read in yet, or too old to carry the
|
|
@@ -1477,8 +1488,9 @@
|
|
|
1477
1488
|
return review;
|
|
1478
1489
|
} catch (error) {
|
|
1479
1490
|
if (gen !== approvalStateGen || !current || current.id !== projectId) return null;
|
|
1491
|
+
// A deadline that ran out has no sentence for a person, so it takes the generic one.
|
|
1480
1492
|
approvalState = { status: 'error', review: null, pendingCount: 0, headVersion: null,
|
|
1481
|
-
error: (error && error.message) || 'Approval status is unavailable — try again.' };
|
|
1493
|
+
error: (error && error.name !== 'TimeoutError' && error.message) || 'Approval status is unavailable — try again.' };
|
|
1482
1494
|
renderApprovalHeader();
|
|
1483
1495
|
if (!$wsExports.hidden) paintExports(current.approvedAt);
|
|
1484
1496
|
return null;
|
|
@@ -2094,6 +2106,7 @@
|
|
|
2094
2106
|
// A save invalidates exactly one registered display row. The event grants no authority:
|
|
2095
2107
|
// the keyed route checks the physical target and returns its current registration view.
|
|
2096
2108
|
async function refreshRegisteredProject(event) {
|
|
2109
|
+
await loadSteelEnvironments(); // units below are inferred from the project's standard; awaited BEFORE anything is captured
|
|
2097
2110
|
const root = window.flolessWorkspaceRoot?.current()?.root;
|
|
2098
2111
|
if (!root || event.rootId !== root.rootId || event.generation !== root.generation) return;
|
|
2099
2112
|
const registrationId = event.registrationId;
|
|
@@ -2121,11 +2134,11 @@
|
|
|
2121
2134
|
|| !['available', 'unavailable'].includes(registration.status)) {
|
|
2122
2135
|
throw new Error('The project view no longer matches this registration.');
|
|
2123
2136
|
}
|
|
2124
|
-
const wasUnits = (cached
|
|
2137
|
+
const wasUnits = shownUnits(cached);
|
|
2125
2138
|
const wasApproved = cached.approvedAt;
|
|
2126
2139
|
const wasSortKeys = { name: cached.name, createdAt: cached.createdAt, updatedAt: cached.updatedAt };
|
|
2127
2140
|
Object.assign(cached, fresh, {
|
|
2128
|
-
displayUnits: (fresh
|
|
2141
|
+
displayUnits: shownUnits(fresh),
|
|
2129
2142
|
registrationState: registration.status,
|
|
2130
2143
|
registrationRevision: registration.entryRevision,
|
|
2131
2144
|
registrationReason: registration.reason,
|
|
@@ -2237,6 +2250,8 @@
|
|
|
2237
2250
|
async function reconcileOpenProject() {
|
|
2238
2251
|
if (reconciling) { reconcileAgain = true; return; } // fold in, never drop — see above
|
|
2239
2252
|
reconciling = true;
|
|
2253
|
+
// Awaited BEFORE the open project is captured: waiting afterwards would act on a read that predates a project switch.
|
|
2254
|
+
await loadSteelEnvironments();
|
|
2240
2255
|
// The id this run has actually CHECKED against the server. The loop keeps going while it does not
|
|
2241
2256
|
// name the open project, so "the user switched project while we were reading" re-runs instead of
|
|
2242
2257
|
// exiting — a trailing pass conditioned only on a new EVENT arriving would leave the project they
|
|
@@ -2317,7 +2332,7 @@
|
|
|
2317
2332
|
// that never had a unit choice arrives as `undefined` — and assigning that raw made the
|
|
2318
2333
|
// `!==` test true on every `projects-changed`, discarding the server's `exportUnits` and
|
|
2319
2334
|
// repainting for nothing. (Review round 5.)
|
|
2320
|
-
const freshUnits = (mine
|
|
2335
|
+
const freshUnits = shownUnits(mine);
|
|
2321
2336
|
const freshName = typeof mine.name === 'string' ? mine.name : current.name;
|
|
2322
2337
|
if (current && current.id === id && current.name !== freshName) {
|
|
2323
2338
|
current.name = freshName;
|
|
@@ -3541,8 +3556,11 @@
|
|
|
3541
3556
|
else if (teklaSourceChoice === choice) setTeklaSourcePicking(false,
|
|
3542
3557
|
'FloLess could not open project setup. Close any other setup window, then choose the source again.');
|
|
3543
3558
|
} catch (error) {
|
|
3544
|
-
|
|
3545
|
-
|
|
3559
|
+
// #3097: the pick checks throw a sentence for the person (personError); a browser read error or a refusal is said
|
|
3560
|
+
// through errorText, never as its own message.
|
|
3561
|
+
const said = errorText(error, { action: 'read that Tekla source', retrySafe: true });
|
|
3562
|
+
if (teklaSourceChoice === choice) setTeklaSourcePicking(false, said);
|
|
3563
|
+
showToast(said, 'warn');
|
|
3546
3564
|
}
|
|
3547
3565
|
}
|
|
3548
3566
|
$teklaSourceFolder?.addEventListener('click', () => { void chooseTeklaSource('folder'); });
|
|
@@ -3785,19 +3803,19 @@
|
|
|
3785
3803
|
if (!folderCount) source = teklaZipSource(files[0]);
|
|
3786
3804
|
else {
|
|
3787
3805
|
const handle = await folder;
|
|
3788
|
-
if (handle?.kind !== 'directory') throw
|
|
3806
|
+
if (handle?.kind !== 'directory') throw personError('FloLess couldn’t read the dropped folder, so nothing was opened. Click the card to choose the Tekla model folder instead.');
|
|
3789
3807
|
source = await filesFromDirectoryHandle(handle);
|
|
3790
3808
|
}
|
|
3791
3809
|
// The read may have outlasted the moment: never open setup over another window or a project.
|
|
3792
3810
|
if (projectSetupState || teklaSourceChoice || $landing.hidden) {
|
|
3793
|
-
throw
|
|
3811
|
+
throw personError(`FloLess finished reading ${label}, but something else is open now, so nothing was opened. Drop the model on Tekla Parser again when you are ready.`);
|
|
3794
3812
|
}
|
|
3795
3813
|
await createFromTeklaSource(appId, templateId, source, zone.isConnected ? zone : null);
|
|
3796
3814
|
} catch (error) {
|
|
3797
|
-
// Our own checks throw a
|
|
3798
|
-
// failing to read a file (moved, locked, unreadable), whose message is not written for people.
|
|
3799
|
-
if (error?.
|
|
3800
|
-
showToast(error?.
|
|
3815
|
+
// Our own checks throw a sentence for the person (personError) that already says what to do. Anything else is the
|
|
3816
|
+
// browser failing to read a file (moved, locked, unreadable), whose message is not written for people.
|
|
3817
|
+
if (error?.forPerson !== true) console.warn('[workspaces] could not read a dropped Tekla model', error);
|
|
3818
|
+
showToast(error?.forPerson === true ? errorText(error)
|
|
3801
3819
|
: 'FloLess couldn’t read every file of that Tekla model, so nothing was opened. Check it is still there and not open in another program, then drop it again or click the card to choose it.', 'warn');
|
|
3802
3820
|
} finally {
|
|
3803
3821
|
teklaDropReading = false;
|
|
@@ -3862,6 +3880,45 @@
|
|
|
3862
3880
|
return res && typeof res.name === 'string' && res.name.trim() ? res.name.trim() : null;
|
|
3863
3881
|
}
|
|
3864
3882
|
|
|
3883
|
+
/**
|
|
3884
|
+
* The steel-environment TRAIT registry (`web/steel-environments.js`), loaded the same way and for the
|
|
3885
|
+
* same reason as the label table below (`index.html` loads this file as a classic script). Started
|
|
3886
|
+
* HERE, at script evaluation, so it has long settled before a project list has been fetched and
|
|
3887
|
+
* rendered; `loadSteelEnvironments()` is what the two paths that ADOPT units from a fetched row await
|
|
3888
|
+
* (project-metadata refresh and the open-project reconcile), so an inferred unit is never written from
|
|
3889
|
+
* a registry that has not loaded. Until it has, a read answers the imperial default and claims nothing
|
|
3890
|
+
* else. A failed load is logged, not swallowed: it leaves a legacy UK project showing feet-inches.
|
|
3891
|
+
*/
|
|
3892
|
+
let steelEnvironments = null;
|
|
3893
|
+
let steelEnvironmentsPromise = null;
|
|
3894
|
+
function loadSteelEnvironments() {
|
|
3895
|
+
if (!steelEnvironmentsPromise) {
|
|
3896
|
+
steelEnvironmentsPromise = import('./steel-environments.js').then(
|
|
3897
|
+
(m) => { steelEnvironments = m; return m; },
|
|
3898
|
+
(error) => {
|
|
3899
|
+
// Not cached: a transient failure must not bar every later attempt. The caller carries on with the imperial default.
|
|
3900
|
+
steelEnvironmentsPromise = null;
|
|
3901
|
+
console.error('[workspaces] the steel-environment registry could not be loaded; units inferred from a project\u2019s standard fall back to feet-inches', error);
|
|
3902
|
+
return null;
|
|
3903
|
+
},
|
|
3904
|
+
);
|
|
3905
|
+
}
|
|
3906
|
+
return steelEnvironmentsPromise;
|
|
3907
|
+
}
|
|
3908
|
+
loadSteelEnvironments();
|
|
3909
|
+
const isRegisteredEnvironment = (id) => !!steelEnvironments?.traitsOf(id);
|
|
3910
|
+
const registeredEnvironmentIds = () => (steelEnvironments ? [...steelEnvironments.STEEL_ENVIRONMENT_IDS] : []);
|
|
3911
|
+
/**
|
|
3912
|
+
* The units a project row is shown in: its own `displayUnits`, or, where its owner never chose, what
|
|
3913
|
+
* its environment implies (the client mirror of the server's `shownUnitsOfProject`; one trait, read in
|
|
3914
|
+
* both places).
|
|
3915
|
+
*/
|
|
3916
|
+
function shownUnits(project) {
|
|
3917
|
+
return project?.displayUnits === 'mm' || project?.displayUnits === 'ft-in'
|
|
3918
|
+
? project.displayUnits
|
|
3919
|
+
: (steelEnvironments ? steelEnvironments.traitsFor(project?.environment).defaultDisplayUnits : 'ft-in');
|
|
3920
|
+
}
|
|
3921
|
+
|
|
3865
3922
|
/**
|
|
3866
3923
|
* How a steel standard names itself to a person — `US · AISC/ASTM`, `UK · BS/EN`.
|
|
3867
3924
|
*
|
|
@@ -3887,8 +3944,13 @@
|
|
|
3887
3944
|
let standardLabelsPromise = null;
|
|
3888
3945
|
function loadStandardLabels() {
|
|
3889
3946
|
if (!standardLabelsPromise) {
|
|
3890
|
-
|
|
3891
|
-
|
|
3947
|
+
// The registry rides along: the setup dialog's readiness and its button loop both read it, and
|
|
3948
|
+
// `sourceReady` is only set after this resolves.
|
|
3949
|
+
standardLabelsPromise = Promise.all([import('./checkpoint-standard.js'), loadSteelEnvironments()])
|
|
3950
|
+
.then(([m, envs]) => {
|
|
3951
|
+
if (!envs) throw new Error('the steel-environment registry did not load');
|
|
3952
|
+
return m.STANDARD_LABEL;
|
|
3953
|
+
})
|
|
3892
3954
|
.catch((err) => { standardLabelsPromise = null; throw err; });
|
|
3893
3955
|
}
|
|
3894
3956
|
return standardLabelsPromise;
|
|
@@ -3915,6 +3977,7 @@
|
|
|
3915
3977
|
const $projectSetupQuickTermsTail = document.getElementById('project-setup-quick-terms-tail');
|
|
3916
3978
|
const $projectSetupFilter = document.getElementById('project-setup-filter');
|
|
3917
3979
|
const $projectSetupExclusions = document.getElementById('project-setup-exclusions');
|
|
3980
|
+
const $projectSetupOrigin = document.getElementById('project-setup-origin');
|
|
3918
3981
|
const $projectSetupBuildLocked = document.getElementById('project-setup-build-locked');
|
|
3919
3982
|
const $projectSetupCancel = document.getElementById('project-setup-cancel');
|
|
3920
3983
|
const $projectSetupCreateOnly = document.getElementById('project-setup-create-only');
|
|
@@ -4027,7 +4090,7 @@
|
|
|
4027
4090
|
|
|
4028
4091
|
function projectSetupReady(state = projectSetupState) {
|
|
4029
4092
|
return !!state && state.sourceReady && !!state.directory && !!state.name.trim()
|
|
4030
|
-
&& (!state.askCatalogue || state.environment
|
|
4093
|
+
&& (!state.askCatalogue || isRegisteredEnvironment(state.environment));
|
|
4031
4094
|
}
|
|
4032
4095
|
|
|
4033
4096
|
function setProjectSetupBusy(busy, label) {
|
|
@@ -4224,7 +4287,19 @@
|
|
|
4224
4287
|
}
|
|
4225
4288
|
}
|
|
4226
4289
|
if ($projectSetupQuickTermsTail) {
|
|
4227
|
-
|
|
4290
|
+
// #2909 (code review): the terms say what the person keeps, so a person-picked origin is said here too.
|
|
4291
|
+
$projectSetupQuickTermsTail.textContent = PROJECT_SETUP_TERMS_TAIL[filter === 'ai' && exclusions === 'person' ? 'aiKeep' : filter]
|
|
4292
|
+
+ (mode === 'quick' && projectSetupOriginChoice(state) === 'person' ? ' ' + PROJECT_SETUP_TERMS_ORIGIN : '');
|
|
4293
|
+
}
|
|
4294
|
+
// #2909: who chooses the model origin, asked only with Quick (Precise always asks it on the read's setup card).
|
|
4295
|
+
const origin = projectSetupOriginChoice(state);
|
|
4296
|
+
if ($projectSetupOrigin) {
|
|
4297
|
+
$projectSetupOrigin.hidden = mode !== 'quick';
|
|
4298
|
+
for (const button of $projectSetupOrigin.querySelectorAll('[data-origin-choice]')) {
|
|
4299
|
+
button.setAttribute('aria-pressed', String(button.dataset.originChoice === origin));
|
|
4300
|
+
if (locked) button.setAttribute('aria-disabled', 'true');
|
|
4301
|
+
else button.removeAttribute('aria-disabled');
|
|
4302
|
+
}
|
|
4228
4303
|
}
|
|
4229
4304
|
$projectSetupBuildLocked.hidden = !locked;
|
|
4230
4305
|
if (shown && mode === 'quick') $projectSetupCreateOnly.setAttribute('aria-describedby', 'project-setup-quick-create-only');
|
|
@@ -4254,6 +4329,20 @@
|
|
|
4254
4329
|
ai: 'The AI chooses the Drawing Filter, including what the read leaves out, recorded and labelled as its own; you still decide on the review.',
|
|
4255
4330
|
aiKeep: 'The AI chooses the Drawing Filter, recorded and labelled as its own; you approve what the read leaves out, and you still decide on the review.',
|
|
4256
4331
|
};
|
|
4332
|
+
const PROJECT_SETUP_TERMS_ORIGIN = 'You also choose the model origin, on the read’s setup card.';
|
|
4333
|
+
/**
|
|
4334
|
+
* #2909: who chooses the model origin with Quick: 'person' only when the person pressed "I'll choose it myself", else
|
|
4335
|
+
* the AI (the default, owner ruling 2026-11-08). Once sent it is the sent one, as for the Model choice.
|
|
4336
|
+
*/
|
|
4337
|
+
function projectSetupOriginChoice(state) {
|
|
4338
|
+
const value = state.submissionId ? state.sentOriginChoice : state.originChoice;
|
|
4339
|
+
return value === 'person' ? 'person' : 'ai';
|
|
4340
|
+
}
|
|
4341
|
+
function chooseProjectSetupOrigin(button) {
|
|
4342
|
+
if (!button || !projectSetupState || projectSetupState.busy || projectSetupState.submissionId) return;
|
|
4343
|
+
projectSetupState.originChoice = button.dataset.originChoice === 'person' ? 'person' : 'ai';
|
|
4344
|
+
renderProjectSetup();
|
|
4345
|
+
}
|
|
4257
4346
|
function chooseProjectSetupFilter(button) {
|
|
4258
4347
|
if (!button || !projectSetupState || projectSetupState.busy || projectSetupState.submissionId) return;
|
|
4259
4348
|
projectSetupState.filterChoice = button.dataset.filterChoice === 'ai' ? 'ai' : 'person';
|
|
@@ -4271,7 +4360,8 @@
|
|
|
4271
4360
|
if (!button || !projectSetupState || projectSetupState.busy || projectSetupState.submissionId) return;
|
|
4272
4361
|
projectSetupState.buildMode = button.dataset.buildMode === 'quick' ? 'quick' : 'precise';
|
|
4273
4362
|
// #2521 row 2c: the Filter choice belongs to Quick: Precise drops it, and Quick again starts from the person's Save.
|
|
4274
|
-
|
|
4363
|
+
// #2909: likewise the origin choice: Precise drops it, and Quick again starts from the AI's choice.
|
|
4364
|
+
if (projectSetupState.buildMode === 'precise') { projectSetupState.filterChoice = 'person'; projectSetupState.exclusionsChoice = 'ai'; projectSetupState.originChoice = 'ai'; }
|
|
4275
4365
|
renderProjectSetup();
|
|
4276
4366
|
if (projectSetupState.buildMode === 'quick') $projectSetupQuickTerms.scrollIntoView?.({ block: 'nearest' });
|
|
4277
4367
|
}
|
|
@@ -4469,6 +4559,8 @@
|
|
|
4469
4559
|
// #2521 row 2c: the Filter choice is sent only with Quick, and fixed with the first send like the Model choice.
|
|
4470
4560
|
if (!state.submissionId) state.sentFilterChoice = state.sentBuildMode === 'quick' && state.filterChoice === 'ai' ? 'ai' : null;
|
|
4471
4561
|
if (!state.submissionId) state.sentExclusionsChoice = state.sentFilterChoice === 'ai' ? (state.exclusionsChoice === 'person' ? 'person' : 'ai') : null;
|
|
4562
|
+
// #2909: the origin choice likewise, sent only with Quick and only when the person keeps it.
|
|
4563
|
+
if (!state.submissionId) state.sentOriginChoice = state.sentBuildMode === 'quick' && state.originChoice === 'person' ? 'person' : null;
|
|
4472
4564
|
const submissionId = state.submissionId || crypto.randomUUID();
|
|
4473
4565
|
state.submissionId = submissionId;
|
|
4474
4566
|
rememberProjectChatIntake(submissionId);
|
|
@@ -4482,6 +4574,7 @@
|
|
|
4482
4574
|
...(state.sentBuildMode === 'quick' ? { buildMode: 'quick' } : {}),
|
|
4483
4575
|
...(state.sentBuildMode === 'quick' && state.sentFilterChoice === 'ai' ? { quickFilterByAi: true } : {}),
|
|
4484
4576
|
...(state.sentBuildMode === 'quick' && state.sentFilterChoice === 'ai' && state.sentExclusionsChoice === 'ai' ? { quickFilterExclusionsByAi: true } : {}),
|
|
4577
|
+
...(state.sentBuildMode === 'quick' && state.sentOriginChoice === 'person' ? { quickOriginByPerson: true } : {}),
|
|
4485
4578
|
// #2470 R6.7b: added from a General project's Modules step, the project is made already linked there.
|
|
4486
4579
|
...(state.linkFrom ? { linkFrom: { projectId: state.linkFrom.projectId, sourceUuid: state.linkFrom.sourceUuid, rootId: state.linkFrom.rootId } } : {}),
|
|
4487
4580
|
...(state.linkFrom && state.withoutLink ? { withoutLink: true } : {}),
|
|
@@ -4512,7 +4605,7 @@
|
|
|
4512
4605
|
const outsideWorkspace = code === 'project-directory-outside-root';
|
|
4513
4606
|
// #2470 R6.7b: the server's own sentence on why the link can't be made, and the choice to go on without it.
|
|
4514
4607
|
const linkChoice = startChat && state.linkFrom && error?.linkChoice === true;
|
|
4515
|
-
setProjectSetupError(linkChoice ? projectSetupLinkChoiceMessage(state, code, error
|
|
4608
|
+
setProjectSetupError(linkChoice ? projectSetupLinkChoiceMessage(state, code, personText(error?.body)) : projectSetupErrorMessage(error), {
|
|
4516
4609
|
workspaceAction: outsideWorkspace,
|
|
4517
4610
|
withoutLinkAction: linkChoice ? () => { state.withoutLink = true; void createProjectFromSetup(true); } : null,
|
|
4518
4611
|
});
|
|
@@ -4571,7 +4664,7 @@
|
|
|
4571
4664
|
// It stays until the person acts on it; a choice that fails is offered again.
|
|
4572
4665
|
if (!projectChatIntakeLinkChoiceShown.has(submissionId)) {
|
|
4573
4666
|
projectChatIntakeLinkChoiceShown.add(submissionId);
|
|
4574
|
-
showToast(`A project you started from a General project wasn’t created yet. ${projectSetupLinkChoiceMessage({}, code, error
|
|
4667
|
+
showToast(`A project you started from a General project wasn’t created yet. ${projectSetupLinkChoiceMessage({}, code, personText(error?.body))}`, 'warn', {
|
|
4575
4668
|
persistent: true,
|
|
4576
4669
|
action: { label: 'Create without linking', commandId: 'shell.project-setup-recover-without-link',
|
|
4577
4670
|
onClick: () => recoverProjectChatIntake(submissionId, { withoutLink: true }).catch((retryError) => {
|
|
@@ -4631,6 +4724,8 @@
|
|
|
4631
4724
|
filterChoice: 'person',
|
|
4632
4725
|
// Revision 3: with "Let the AI choose", the AI also approves what the read leaves out unless the person keeps it.
|
|
4633
4726
|
exclusionsChoice: 'ai',
|
|
4727
|
+
// #2909: the AI chooses the model origin unless the person presses "I'll choose it myself" (with Quick only).
|
|
4728
|
+
originChoice: 'ai',
|
|
4634
4729
|
directory: null,
|
|
4635
4730
|
name: '',
|
|
4636
4731
|
nameDirty: false,
|
|
@@ -4654,7 +4749,7 @@
|
|
|
4654
4749
|
if (state.askCatalogue) {
|
|
4655
4750
|
const standards = await loadStandardLabels();
|
|
4656
4751
|
if (projectSetupState !== state) return;
|
|
4657
|
-
for (const env of
|
|
4752
|
+
for (const env of registeredEnvironmentIds()) {
|
|
4658
4753
|
const label = standards.get(env);
|
|
4659
4754
|
if (!label) throw new Error(`the shared label table names no standard for ${env}`);
|
|
4660
4755
|
$projectSetupStandard.querySelector(`[data-standard-label="${env}"]`).textContent = label;
|
|
@@ -4690,6 +4785,8 @@
|
|
|
4690
4785
|
$projectSetupBuild?.addEventListener('click', (event) => {
|
|
4691
4786
|
const exclusionsButton = event.target.closest('[data-exclusions-choice]');
|
|
4692
4787
|
if (exclusionsButton) { chooseProjectSetupExclusions(exclusionsButton); return; }
|
|
4788
|
+
const originButton = event.target.closest('[data-origin-choice]');
|
|
4789
|
+
if (originButton) { chooseProjectSetupOrigin(originButton); return; }
|
|
4693
4790
|
const filterButton = event.target.closest('[data-filter-choice]');
|
|
4694
4791
|
if (filterButton) chooseProjectSetupFilter(filterButton);
|
|
4695
4792
|
else chooseProjectSetupBuildMode(event.target.closest('[data-build-mode]'));
|
|
@@ -4862,8 +4959,20 @@
|
|
|
4862
4959
|
if (detailNode) detailNode.textContent = detail;
|
|
4863
4960
|
}
|
|
4864
4961
|
|
|
4962
|
+
/**
|
|
4963
|
+
* #3097: the server's own text for a Tekla source refusal. A ModelSnapshotError reply says diagnostic: true, so the
|
|
4964
|
+
* shared request helper does not put its `error` in the Error's message; it is matched below against reviewed
|
|
4965
|
+
* patterns only, and shown as written only by the branches that say so.
|
|
4966
|
+
*/
|
|
4967
|
+
function teklaRefusalText(error) {
|
|
4968
|
+
const raw = error?.body?.error;
|
|
4969
|
+
return typeof raw === 'string' && raw.trim() ? raw.trim() : error?.message || String(error || '');
|
|
4970
|
+
}
|
|
4865
4971
|
function teklaAdmissionMessage(error) {
|
|
4866
|
-
|
|
4972
|
+
// A sentence the server proved was written for the person (ModelSnapshotError.userMessage) is said as written.
|
|
4973
|
+
const written = error?.body?.userMessage;
|
|
4974
|
+
if (typeof written === 'string' && written.trim()) return written.trim();
|
|
4975
|
+
const message = teklaRefusalText(error);
|
|
4867
4976
|
// The server's copy-limit refusals (tekla-source-upload.ts / tekla-source-package.ts): sizes and counts.
|
|
4868
4977
|
const TEKLA_COPY_LIMIT = /^Tekla (?:ZIP|folder upload|source package)\b[^.]*\bexceeds? (?:its|their) (?:limit|compressed byte limit|total byte limit)$/;
|
|
4869
4978
|
// #1849: reading without some catalogue files needs a newer AWARE; the server names the version.
|
|
@@ -4889,7 +4998,7 @@
|
|
|
4889
4998
|
return 'FloLess could not read this Tekla source. Choose the model folder or ZIP again. The source model was not changed.';
|
|
4890
4999
|
}
|
|
4891
5000
|
function teklaAdmissionTitle(error) {
|
|
4892
|
-
const message =
|
|
5001
|
+
const message = teklaRefusalText(error);
|
|
4893
5002
|
const TEKLA_COPY_LIMIT = /^Tekla (?:ZIP|folder upload|source package)\b[^.]*\bexceeds? (?:its|their) (?:limit|compressed byte limit|total byte limit)$/; // as in teklaAdmissionMessage
|
|
4894
5003
|
if (TEKLA_COPY_LIMIT.test(message)) return 'This Tekla source is too large for one read';
|
|
4895
5004
|
const tooLarge = /^This Tekla model is too large for Tekla Parser to read\. .* Tekla Parser reads up to (\d+(?:\.\d)? [MG]B)\./.exec(message);
|
|
@@ -5086,9 +5195,12 @@
|
|
|
5086
5195
|
// #3097: the server's own sentence when it wrote one, else the shared one; never "(<status>)".
|
|
5087
5196
|
if (!upload.ok || uploaded.ok === false) {
|
|
5088
5197
|
console.warn('[rvt] upload refused', upload.status, uploaded);
|
|
5089
|
-
|
|
5090
|
-
|
|
5091
|
-
{
|
|
5198
|
+
// #3097: this route's `error` is a machine code and its `message` a developer's sentence; only `userMessage` is
|
|
5199
|
+
// written for the person. Marking the reply diagnostic lets personText / errorText read exactly that.
|
|
5200
|
+
const body = { ...uploaded, diagnostic: true };
|
|
5201
|
+
throw Object.assign(new Error(personText(body)
|
|
5202
|
+
|| failureCopy({ status: upload.status, body }, { action: 'copy the RVT file to FloLess', unsure: 'Choose the RVT file again.' }).text),
|
|
5203
|
+
{ status: upload.status, body });
|
|
5092
5204
|
}
|
|
5093
5205
|
const receipt = uploaded.receipt;
|
|
5094
5206
|
const started = await api('/api/model-imports', { method: 'POST', body: JSON.stringify({
|
|
@@ -5116,7 +5228,7 @@
|
|
|
5116
5228
|
headers: { 'content-type': 'application/octet-stream', 'x-floless-upload-offset': String(offset),
|
|
5117
5229
|
'x-floless-upload-total': String(file.size) } });
|
|
5118
5230
|
const body = await response.json().catch(() => ({}));
|
|
5119
|
-
if (!response.ok || body.ok === false) throw new Error(body.message || body.error || `source copy failed (${response.status})`);
|
|
5231
|
+
if (!response.ok || body.ok === false) throw Object.assign(new Error(body.message || body.error || `source copy failed (${response.status})`), { body, status: response.status });
|
|
5120
5232
|
onProgress(Math.min(file.size, offset + blob.size), file.size);
|
|
5121
5233
|
return body;
|
|
5122
5234
|
} catch (error) {
|
|
@@ -5170,7 +5282,7 @@
|
|
|
5170
5282
|
try { return JSON.parse(xhr.responseText || '{}'); } catch { return {}; }
|
|
5171
5283
|
})();
|
|
5172
5284
|
if (xhr.status < 200 || xhr.status >= 300 || body.ok === false) {
|
|
5173
|
-
finish(new Error(body.message || body.error || `source copy failed (${xhr.status})`));
|
|
5285
|
+
finish(Object.assign(new Error(body.message || body.error || `source copy failed (${xhr.status})`), { body, status: xhr.status }));
|
|
5174
5286
|
return;
|
|
5175
5287
|
}
|
|
5176
5288
|
finish(null, body);
|
|
@@ -5197,7 +5309,9 @@
|
|
|
5197
5309
|
teklaUploadProjectId = project.id;
|
|
5198
5310
|
const isCurrentProject = () => current?.id === project.id;
|
|
5199
5311
|
const declaredFiles = source.kind === 'folder'
|
|
5200
|
-
? source.entries.map((entry) => ({ path: entry.path, bytes: entry.file.size
|
|
5312
|
+
? source.entries.map((entry) => ({ path: entry.path, bytes: entry.file.size,
|
|
5313
|
+
...(Number.isSafeInteger(entry.file.lastModified) && entry.file.lastModified >= 0 ? { lastModified: entry.file.lastModified } : {}) }))
|
|
5314
|
+
: undefined;
|
|
5201
5315
|
let sessionId = null;
|
|
5202
5316
|
let finishAttempted = false;
|
|
5203
5317
|
try {
|
|
@@ -5268,8 +5382,17 @@
|
|
|
5268
5382
|
// A completed admission owns session cleanup. Retrying DELETE after its refusal only produces
|
|
5269
5383
|
// a spurious browser error for a session it already removed; earlier upload failures still delete.
|
|
5270
5384
|
finishAttempted = true;
|
|
5385
|
+
// #3352: look at every file again now the copy is done, so change review can tell whether Tekla saved during
|
|
5386
|
+
// it. Only a folder opened through the folder picker keeps handles to look again; otherwise say nothing.
|
|
5387
|
+
// Kept inside this function: test harnesses lift it whole, so a separate helper would be undefined there.
|
|
5388
|
+
// The whole folder is listed again (not only the files picked), so a file that appeared during the copy is seen.
|
|
5389
|
+
const recheck = source.kind === 'folder' && source.root
|
|
5390
|
+
? await filesFromDirectoryHandle(source.root)
|
|
5391
|
+
.then((again) => again.entries.map((entry) => ({ path: entry.path, bytes: entry.file.size, lastModified: entry.file.lastModified })))
|
|
5392
|
+
.catch(() => null) // the folder could not be listed again: the capture record says it was not rechecked
|
|
5393
|
+
: null;
|
|
5271
5394
|
const finalize = (catalogues) => api(`/api/tekla-source-sessions/${encodeURIComponent(sessionId)}/finalize`, {
|
|
5272
|
-
method: 'POST', body: JSON.stringify({ projectId: project.id, ...(catalogues ? { catalogues } : {}) }),
|
|
5395
|
+
method: 'POST', body: JSON.stringify({ projectId: project.id, ...(catalogues ? { catalogues } : {}), ...(recheck ? { recheck } : {}) }),
|
|
5273
5396
|
});
|
|
5274
5397
|
let started = await finalize();
|
|
5275
5398
|
let status = '';
|
|
@@ -5416,10 +5539,15 @@
|
|
|
5416
5539
|
} catch (err) {
|
|
5417
5540
|
const removed = await archiveEmptyProject(project.id);
|
|
5418
5541
|
// #2470 R6.7: the empty project is not kept linked either; the Modules step says what happened (spec §6.3).
|
|
5419
|
-
|
|
5542
|
+
// #3097: why, from the server's own sentence for the person, else the shared sentence's why-and-what-to-do (its
|
|
5543
|
+
// "Couldn’t …" lead is already said below); never the error's own text, which goes to the console.
|
|
5544
|
+
const said = err && err.body && typeof err.body === 'object' ? personText(err.body) : '';
|
|
5545
|
+
if (!said) console.warn('[rvt] import failed', err);
|
|
5546
|
+
const why = said || failureParts(err, { action: 'import the RVT', unsure: 'Choose the RVT file again.' }).detail;
|
|
5547
|
+
if (link) { await globalThis.flolessProjectModules?.afterCreate?.({ project, ...link, outcome: removed ? 'archived-empty' : 'left-empty', error: why }); return; }
|
|
5420
5548
|
showToast(removed
|
|
5421
|
-
? `Couldn’t import the RVT — the empty project was removed. ${
|
|
5422
|
-
: `Couldn’t import the RVT. An empty project was left behind; archive it from the ⋯ menu. ${
|
|
5549
|
+
? `Couldn’t import the RVT — the empty project was removed. ${why}`
|
|
5550
|
+
: `Couldn’t import the RVT. An empty project was left behind; archive it from the ⋯ menu. ${why}`, 'warn');
|
|
5423
5551
|
}
|
|
5424
5552
|
}
|
|
5425
5553
|
|
|
@@ -6537,13 +6665,13 @@
|
|
|
6537
6665
|
if (action === 'chat') {
|
|
6538
6666
|
Promise.resolve().then(() => {
|
|
6539
6667
|
if (typeof window.flolessChat?.startNewChat !== 'function') {
|
|
6540
|
-
throw
|
|
6668
|
+
throw personError('AI Chat is still loading. Try Start new chat again in a moment.');
|
|
6541
6669
|
}
|
|
6542
6670
|
return window.flolessChat.startNewChat(notice.projectId);
|
|
6543
6671
|
}).catch((err) => {
|
|
6544
6672
|
// A reason AI Chat wrote for the person is shown as it is; anything else is an unexpected failure. Opening a
|
|
6545
6673
|
// new chat changes nothing, so it is always safe to try again.
|
|
6546
|
-
if (err?.
|
|
6674
|
+
if (err?.forPerson === true) showToast(`Couldn’t start a new chat. ${errorText(err)}`, 'warn');
|
|
6547
6675
|
else showFailureToast(err, { action: 'start a new chat', retrySafe: true });
|
|
6548
6676
|
});
|
|
6549
6677
|
return;
|
|
@@ -7696,11 +7824,15 @@
|
|
|
7696
7824
|
/** The answer to "what does approving do": which version this becomes and what it replaces. */
|
|
7697
7825
|
function approvalVersionCardHtml(review) {
|
|
7698
7826
|
const mf = review.moveForward;
|
|
7827
|
+
// #3223 rank 7: a first approval that lands above versions already in History names its number and, when everything
|
|
7828
|
+
// below is an AI drawing read, says so, so "the first approved version" and the "v2" it becomes agree.
|
|
7829
|
+
const first = review.firstApproval && !mf && !review.base ? firstApprovalWords(review.firstApproval) : null;
|
|
7699
7830
|
const lead = mf ? (mf.replacesLatest ? `This replaces approved v${mf.toVersion}.` : `Your changes go on top of approved v${mf.toVersion} as the next approved version.`)
|
|
7700
7831
|
: review.base ? `This becomes the next approved version, after approved v${review.base.version}.`
|
|
7701
|
-
:
|
|
7832
|
+
: first ? `This becomes v${first.version}, the first approved version of this model.`
|
|
7833
|
+
: 'This becomes the first approved version of this model.';
|
|
7702
7834
|
return `<div class="approval-version-card"><b>${escapeHtml(lead)}</b>`
|
|
7703
|
-
+ '
|
|
7835
|
+
+ `<p>${first && first.card ? `${escapeHtml(first.card)} ` : ''}Approved exports and the compiled workflow use the approved version. You can keep editing the working copy afterwards.</p></div>`;
|
|
7704
7836
|
}
|
|
7705
7837
|
|
|
7706
7838
|
const review = approvalDialogState.review;
|
|
@@ -8048,7 +8180,7 @@
|
|
|
8048
8180
|
const ownsDialog = () => !!dialog && approvalDialogState === dialog && onProject();
|
|
8049
8181
|
if (ownsDialog() && $approvalRevisionNoteText) $approvalRevisionNoteText.value = '';
|
|
8050
8182
|
if (res && res.approvedAt) project.approvedAt = res.approvedAt;
|
|
8051
|
-
const { version: n, accepted, headline, assumed, quick, coverage } = approvalOutcomeWords(res);
|
|
8183
|
+
const { version: n, accepted, headline, reads, readsShort, assumed, quick, coverage } = approvalOutcomeWords(res);
|
|
8052
8184
|
if (n) expandDiffOnce = { projectId: project.id, n };
|
|
8053
8185
|
// An outcome can land while the person is editing this project again: a background check, or a dialog
|
|
8054
8186
|
// closed while the note above was saving. Reloading the editor then would discard edits not yet saved, so
|
|
@@ -8078,7 +8210,7 @@
|
|
|
8078
8210
|
// Edits still unsaved in the editor are not in any count FloLess read, so with them on screen no pending
|
|
8079
8211
|
// count is claimed at all: the sentence says what is known instead.
|
|
8080
8212
|
const keptEditsNote = 'Your newer edits stay in the editor and were not reloaded; once they are saved, reopen the model to see the approved version and what is still pending.';
|
|
8081
|
-
showToast(`${headline} ${quick}${coverage}${assumed ? `${assumed} ` : ''}${keptEdits ? keptEditsNote : pending === null ? pendingUnknown : pending ? `${pending} change${pending === 1 ? ' remains' : 's remain'} pending${saved ? ' in Saved work' : ''}; approved exports omit them unless you explicitly choose DRAFT.` : 'No changes remain pending.'}`, 'ok');
|
|
8213
|
+
showToast(`${headline} ${reads ? `${reads} ` : ''}${quick}${coverage}${assumed ? `${assumed} ` : ''}${keptEdits ? keptEditsNote : pending === null ? pendingUnknown : pending ? `${pending} change${pending === 1 ? ' remains' : 's remain'} pending${saved ? ' in Saved work' : ''}; approved exports omit them unless you explicitly choose DRAFT.` : 'No changes remain pending.'}`, 'ok');
|
|
8082
8214
|
track('workspace_project_approved', { app: project.app });
|
|
8083
8215
|
if (onProject() && !$wsExports.hidden) safeRenderExports('after approving this version');
|
|
8084
8216
|
if (onProject() && !$wsHistory.hidden) await renderHistory();
|
|
@@ -8088,8 +8220,10 @@
|
|
|
8088
8220
|
: 'No changes remain pending.';
|
|
8089
8221
|
// The footer described the decision ("…will be approved…"); the decision has happened.
|
|
8090
8222
|
$approvalCounts.textContent = '';
|
|
8091
|
-
$approvalBody.innerHTML = `<div class="approval-notice approval-notice-success"><b>${escapeHtml(headline)}</b> ${quick ? `${escapeHtml(quick)}` : ''}${coverage ? escapeHtml(coverage) : ''}The approved model and compiled workflow are ready.${assumed ? ' ' + escapeHtml(assumed) : ''}${revisionNoteStatus ? ' ' + escapeHtml(revisionNoteStatus) : ''}${accepted ? ' The findings stay listed in the Audit tab.' : ''}</div>`;
|
|
8092
|
-
|
|
8223
|
+
$approvalBody.innerHTML = `<div class="approval-notice approval-notice-success"><b>${escapeHtml(headline)}</b> ${reads ? `${escapeHtml(reads)} ` : ''}${quick ? `${escapeHtml(quick)}` : ''}${coverage ? escapeHtml(coverage) : ''}The approved model and compiled workflow are ready.${assumed ? ' ' + escapeHtml(assumed) : ''}${revisionNoteStatus ? ' ' + escapeHtml(revisionNoteStatus) : ''}${accepted ? ' The findings stay listed in the Audit tab.' : ''}</div>`;
|
|
8224
|
+
// The subtitle doubles as what a screen reader hears, so it carries the short form of the same sentence.
|
|
8225
|
+
const approvedPhase = accepted ? headline : `Approved${n ? ` as v${n}` : ''}`;
|
|
8226
|
+
setApprovalPhase('approved', readsShort ? `${accepted ? approvedPhase : `${approvedPhase}.`} ${readsShort}` : approvedPhase);
|
|
8093
8227
|
$approvalClose.focus();
|
|
8094
8228
|
}
|
|
8095
8229
|
|
|
@@ -8104,6 +8238,10 @@
|
|
|
8104
8238
|
// #1840: an approval that accepted open import findings is never announced as a plain "Approved".
|
|
8105
8239
|
const accepted = res && res.version && res.version.approval && res.version.approval.acceptedImportFindings;
|
|
8106
8240
|
const headline = accepted ? importFindingsCopy(accepted).approved(version) : `Approved${version ? ` as v${version}` : ''}.`;
|
|
8241
|
+
// #3223 rank 7: a first approval above the AI's drawing read says what the versions below it are, right after the
|
|
8242
|
+
// headline. Only for the version this result actually became.
|
|
8243
|
+
const first = version && res.firstApproval && Number(res.firstApproval.version) === version ? firstApprovalWords(res.firstApproval) : null;
|
|
8244
|
+
const reads = first ? first.result : '', readsShort = first ? first.short : '';
|
|
8107
8245
|
// #2449: an approval resting on connection assumptions (or one whose record could not be read) is never
|
|
8108
8246
|
// announced as a plain approval either; the server's own sentence, the same one History shows.
|
|
8109
8247
|
const assumed = res && res.connectionAssumptions && typeof res.connectionAssumptions.note === 'string' ? res.connectionAssumptions.note : '';
|
|
@@ -8119,7 +8257,34 @@
|
|
|
8119
8257
|
: c.state === 'part' ? `${c.brief} This approval covers only the drawing files that were read; a later read of the others covers them. `
|
|
8120
8258
|
: c.state === 'unknown' ? `${c.brief} FloLess could not tell whether this version read every drawing file; History shows what is known. `
|
|
8121
8259
|
: '';
|
|
8122
|
-
return { version, accepted, headline, assumed, quick, coverage, sentence: `${headline} ${quick}${coverage}${assumed}`.trim() };
|
|
8260
|
+
return { version, accepted, headline, reads, readsShort, assumed, quick, coverage, sentence: `${headline} ${reads ? `${reads} ` : ''}${quick}${coverage}${assumed}`.trim() };
|
|
8261
|
+
}
|
|
8262
|
+
|
|
8263
|
+
/**
|
|
8264
|
+
* #3223 rank 7: why a first approval is not v1, in words. A model read from drawings keeps the AI's read in History
|
|
8265
|
+
* first (v1), so a person's first approval becomes v2, and "Approved as v2" beside "the first approved version" read
|
|
8266
|
+
* as a bug or a double approval. Said from the server's `firstApproval` facts, never guessed: `card` for the review
|
|
8267
|
+
* dialog's version card, `result` for the outcome notice and toasts, `short` for the subtitle a screen reader hears.
|
|
8268
|
+
* Null when there is nothing below to explain (a model approved as v1) or the facts are unreadable; empty sentences
|
|
8269
|
+
* when what sits below is not all drawing reads, so only the number is named.
|
|
8270
|
+
*/
|
|
8271
|
+
function firstApprovalWords(facts) {
|
|
8272
|
+
const version = facts && Number(facts.version);
|
|
8273
|
+
const before = facts && facts.before;
|
|
8274
|
+
if (!Number.isSafeInteger(version) || version < 1 || !before || typeof before !== 'object') return null;
|
|
8275
|
+
const count = Number(before.count), first = Number(before.first), last = Number(before.last);
|
|
8276
|
+
if (![count, first, last].every((value) => Number.isSafeInteger(value) && value >= 1) || first > last || last >= version) return null;
|
|
8277
|
+
if (before.drawingReads !== true) return { version, card: '', result: '', short: '' };
|
|
8278
|
+
const one = count === 1;
|
|
8279
|
+
// "v1 and v2", "v1 to v3"; a range with a gap in it is not named as one.
|
|
8280
|
+
const subject = one ? `v${first}` : count === last - first + 1 ? `v${first}${count === 2 ? ' and ' : ' to '}v${last}` : 'The earlier versions';
|
|
8281
|
+
const what = one ? 'is the AI read' : 'are AI reads';
|
|
8282
|
+
return {
|
|
8283
|
+
version,
|
|
8284
|
+
card: `${subject} in History ${what} of your drawings, not ${one ? 'an approved version' : 'approved versions'}.`,
|
|
8285
|
+
result: `${subject} ${what} of your drawings.`,
|
|
8286
|
+
short: `${subject} ${what}.`,
|
|
8287
|
+
};
|
|
8123
8288
|
}
|
|
8124
8289
|
|
|
8125
8290
|
// One receipt read. The server answers under the project's approval locks, which on a large model
|
|
@@ -8495,7 +8660,7 @@
|
|
|
8495
8660
|
$approvalSub.textContent = 'FloLess could not open this review';
|
|
8496
8661
|
} else {
|
|
8497
8662
|
$approvalSub.textContent = 'Approval status unavailable';
|
|
8498
|
-
$approvalImpact.textContent = (error
|
|
8663
|
+
$approvalImpact.textContent = errorText(error, { action: 'load the comparison', retrySafe: true });
|
|
8499
8664
|
$approvalBody.innerHTML = '<div class="approval-notice approval-notice-error"><b>Nothing was approved.</b> Try again when the model can be saved and compared.</div>';
|
|
8500
8665
|
setApprovalPhase('failed', 'Nothing was approved. Try again.');
|
|
8501
8666
|
}
|
|
@@ -8542,8 +8707,10 @@
|
|
|
8542
8707
|
const approved = Object.values(st.decisions || {}).filter((value) => value === 'approve').length;
|
|
8543
8708
|
const pending = groups.length - approved;
|
|
8544
8709
|
if (review.selective === false) {
|
|
8710
|
+
// #3223 rank 7: the same number the version card named, when versions already sit below it in History.
|
|
8711
|
+
const first = review.firstApproval && !review.base && !review.moveForward ? firstApprovalWords(review.firstApproval) : null;
|
|
8545
8712
|
return review.wholeVersionReason === 'first-approval' || !review.base
|
|
8546
|
-
? 'Approving the whole model as its first approved version.'
|
|
8713
|
+
? first ? `Approving the whole model as v${first.version}, its first approved version.` : 'Approving the whole model as its first approved version.'
|
|
8547
8714
|
: `Approving the whole model as the next approved version after v${review.base.version}.`;
|
|
8548
8715
|
}
|
|
8549
8716
|
return `Approving ${approved} change${approved === 1 ? '' : 's'}${pending > 0 ? ` · ${pending} stay${pending === 1 ? 's' : ''} pending` : ''}.`;
|
|
@@ -8648,7 +8815,8 @@
|
|
|
8648
8815
|
approvalDialogState.conflicts = decisionSnapshot.conflicts;
|
|
8649
8816
|
approvalDialogState.retryAction = 'approve';
|
|
8650
8817
|
renderApprovalReview();
|
|
8651
|
-
|
|
8818
|
+
// The recorded outcome was checked first, so nothing was approved and the same decisions can be tried again.
|
|
8819
|
+
$approvalImpact.textContent = errorText(error, { action: 'approve these changes', retrySafe: true });
|
|
8652
8820
|
$approvalBody.insertAdjacentHTML('afterbegin', '<div class="approval-notice approval-notice-error"><b>Nothing was approved.</b> Try again with the same decisions.</div>');
|
|
8653
8821
|
setApprovalPhase('failed', 'Nothing was approved. Try again.');
|
|
8654
8822
|
$approvalRetry.focus();
|
|
@@ -8674,7 +8842,7 @@
|
|
|
8674
8842
|
setApprovalPhase('ready');
|
|
8675
8843
|
($approvalBody.querySelector('[data-approval-decision]:not([disabled])') || $approvalConfirm).focus();
|
|
8676
8844
|
} catch (error) {
|
|
8677
|
-
$approvalImpact.textContent = (error
|
|
8845
|
+
$approvalImpact.textContent = errorText(error, { action: 'reload the current review', retrySafe: true });
|
|
8678
8846
|
setApprovalPhase('stale', 'The current review could not be loaded.');
|
|
8679
8847
|
$approvalReload.focus();
|
|
8680
8848
|
}
|
|
@@ -8735,7 +8903,7 @@
|
|
|
8735
8903
|
if (event.target.closest('[data-approval-workflow-update]') && approvalDialogState && approvalDismissible(approvalDialogState.phase)) {
|
|
8736
8904
|
const appId = current?.app;
|
|
8737
8905
|
closeApprovalReview();
|
|
8738
|
-
if (appId) bridge.reviewWorkflowUpdate(appId).catch((error) => showToast(error
|
|
8906
|
+
if (appId) bridge.reviewWorkflowUpdate(appId).catch((error) => showToast(errorText(error, { action: 'open the workflow update', retrySafe: true }), 'warn'));
|
|
8739
8907
|
return;
|
|
8740
8908
|
}
|
|
8741
8909
|
const openAudit = event.target.closest('[data-approval-open-audit]');
|
|
@@ -8858,10 +9026,9 @@
|
|
|
8858
9026
|
frames.model.addEventListener('load', () => {
|
|
8859
9027
|
try {
|
|
8860
9028
|
frames.model.contentWindow.addEventListener('keydown', (e) => {
|
|
8861
|
-
|
|
8862
|
-
|
|
8863
|
-
|
|
8864
|
-
}
|
|
9029
|
+
// Only take the key when Find actually opened (#3142); otherwise the browser's own Find still works.
|
|
9030
|
+
if ((e.ctrlKey || e.metaKey) && !e.shiftKey && (e.key === 'f' || e.key === 'F')
|
|
9031
|
+
&& typeof window.openFind === 'function' && window.openFind()) e.preventDefault();
|
|
8865
9032
|
});
|
|
8866
9033
|
} catch { /* not-yet-loaded / cross-origin */ }
|
|
8867
9034
|
// Chromium can make the iframe the parent's active element during navigation without a reliable
|
|
@@ -9038,7 +9205,7 @@
|
|
|
9038
9205
|
// Each read is bounded (#1604): the 3-second poll skips its ticks while a render is out, so a
|
|
9039
9206
|
// request that never answered would stop the column refreshing for good.
|
|
9040
9207
|
const bounded = () => ({ timeoutMs: 90_000 });
|
|
9041
|
-
const [status, reqs, company, designSet] = await Promise.all([
|
|
9208
|
+
const [status, reqs, company, designSet, connected] = await Promise.all([
|
|
9042
9209
|
api(kbUrl(proj.id, '/status'), bounded()),
|
|
9043
9210
|
api('/api/requests', bounded()).catch(() => []),
|
|
9044
9211
|
api(`/api/company-knowledge?projectId=${encodeURIComponent(proj.id)}`, bounded())
|
|
@@ -9046,6 +9213,8 @@
|
|
|
9046
9213
|
// #2399 slice 0b: a design set that cannot be read is said as such, never as "none".
|
|
9047
9214
|
api(`/api/projects/${encodeURIComponent(proj.id)}/design-set`, bounded())
|
|
9048
9215
|
.catch(() => ({ status: 'unknown', revision: 0, warnings: [{ code: 'unreadable', message: 'FloLess could not read the design set just now.' }] })),
|
|
9216
|
+
// #2470 R6.8: connected sources; a project without any answers with empty lists. One that cannot be read says so.
|
|
9217
|
+
api(kbUrl(proj.id, '/connected'), bounded()).catch(() => ({ unreadable: true, sources: [], removed: [] })),
|
|
9049
9218
|
]);
|
|
9050
9219
|
const list = Array.isArray(reqs) ? reqs : (reqs.requests || []);
|
|
9051
9220
|
const manifest = status.manifest || { revision: 0, currentGeneration: null, sources: [] };
|
|
@@ -9060,6 +9229,7 @@
|
|
|
9060
9229
|
queued: status.pendingRequests || list.filter((r) => r && r.type === 'knowledge-organize' && r.project === proj.id),
|
|
9061
9230
|
company,
|
|
9062
9231
|
designSet,
|
|
9232
|
+
connected,
|
|
9063
9233
|
};
|
|
9064
9234
|
}
|
|
9065
9235
|
|
|
@@ -9420,6 +9590,7 @@
|
|
|
9420
9590
|
}
|
|
9421
9591
|
|
|
9422
9592
|
function kbSourceRow(s, st, depth) {
|
|
9593
|
+
if (s.kind === 'connected') return kbConnRowHtml(s, st, depth);
|
|
9423
9594
|
const on = !!s.useAsKb;
|
|
9424
9595
|
const sel = kbSel.selected.has(s.sourceId);
|
|
9425
9596
|
const ico = kbIcon(s.mime);
|
|
@@ -9530,7 +9701,8 @@
|
|
|
9530
9701
|
`${chev}<span class="kb-cat-name">${name}</span><span class="kb-cat-count" aria-label="${item.count} reference${item.count === 1 ? '' : 's'}">(${item.count})</span></button>` +
|
|
9531
9702
|
(isU ? '' : `<button type="button" class="kb-cat-more" data-kb-cat-menu="${escapeAttr(item.id)}" aria-label="More for ${escapeAttr(item.name)}" aria-haspopup="menu" data-tip="Rename, move or delete" data-command-id="shell.kb-category-menu#${escapeAttr(item.id)}" data-command-instance-label="${escapeAttr(item.name)}">⋯</button>`) +
|
|
9532
9703
|
'</div>' +
|
|
9533
|
-
|
|
9704
|
+
// #3413: the hint under an empty category is part of its drop target: a reference dropped on it lands in the category.
|
|
9705
|
+
(item.open && item.empty ? `<div class="kb-cat-empty" style="--kb-depth:${item.depth + 1}" data-kb-drop-into="${escapeAttr(id)}">${isU ? 'Nothing here.' : 'Empty. Drag references here.'}</div>` : '');
|
|
9534
9706
|
}
|
|
9535
9707
|
|
|
9536
9708
|
/** The References list as a tree (once the first category exists), with the inline name box where it was asked for. */
|
|
@@ -9538,17 +9710,35 @@
|
|
|
9538
9710
|
const file = kbCats(st);
|
|
9539
9711
|
const folded = kbCatCollapsedFor(current);
|
|
9540
9712
|
const open = new Set(['uncategorized', ...file.categories.map((c) => c.id)].filter((id) => !folded.has(id)));
|
|
9541
|
-
|
|
9713
|
+
// #3413: a design-set drawing placed in a category counts there (the map colours it by that category), and the open
|
|
9714
|
+
// category says so in one quiet line; the drawing itself stays listed under its issue in the Design set.
|
|
9715
|
+
const drawings = st.sources.filter((s) => kbInDesignSet(s, st) && kbcPlacement(file, s.sourceId));
|
|
9716
|
+
const isDrawing = new Set(drawings.map((s) => s.sourceId));
|
|
9717
|
+
const items = kbcTreeItems(file, [...rows, ...drawings], open);
|
|
9542
9718
|
let html = '';
|
|
9719
|
+
let held = [];
|
|
9720
|
+
const flush = () => { if (held.length) html += kbCatDrawingsHtml(held.map((x) => x.row), held[0].depth); held = []; };
|
|
9543
9721
|
for (const item of items) {
|
|
9722
|
+
if (item.kind === 'row' && isDrawing.has(item.row.sourceId)) { held.push(item); continue; }
|
|
9723
|
+
flush();
|
|
9544
9724
|
if (item.kind === 'row') { html += kbSourceRow(item.row, st, item.depth); continue; }
|
|
9545
9725
|
html += kbCatRowHtml(item, file);
|
|
9546
9726
|
if (kbCatEdit && kbCatEdit.mode === 'new' && kbCatEdit.parentId && kbCatEdit.parentId === item.id && item.open) html += kbCatEditHtml(item.depth + 1);
|
|
9547
9727
|
}
|
|
9728
|
+
flush();
|
|
9548
9729
|
if (kbCatEdit && kbCatEdit.mode === 'new' && !kbCatEdit.parentId) html = kbCatEditHtml(0) + html;
|
|
9549
9730
|
return `<div class="kb-tree" role="group" aria-label="References by category">${html}</div>`;
|
|
9550
9731
|
}
|
|
9551
9732
|
|
|
9733
|
+
/** Design-set drawings placed in a category: counted there, named once, never a second draggable row. */
|
|
9734
|
+
function kbCatDrawingsHtml(rows, depth) {
|
|
9735
|
+
const names = rows.map((r) => r.filename || 'drawing');
|
|
9736
|
+
const shown = names.slice(0, 2).join(', ') + (names.length > 2 ? ` and ${names.length - 2} more` : '');
|
|
9737
|
+
const one = rows.length === 1;
|
|
9738
|
+
return `<div class="kb-cat-ds" style="--kb-depth:${depth}">${one ? '1 design-set drawing' : `${rows.length} design-set drawings`}: ` +
|
|
9739
|
+
`<span class="kb-cat-ds-names">${escapeHtml(shown)}</span>. Listed under ${one ? 'its issue' : 'their issues'} in the Design set.</div>`;
|
|
9740
|
+
}
|
|
9741
|
+
|
|
9552
9742
|
/** The bar under the list while references are selected. */
|
|
9553
9743
|
function kbSelBarHtml(st) {
|
|
9554
9744
|
const n = kbSelFor(current, st).selected.size;
|
|
@@ -10027,7 +10217,11 @@
|
|
|
10027
10217
|
return chip;
|
|
10028
10218
|
}
|
|
10029
10219
|
function kbDropTargetOf(e) {
|
|
10030
|
-
|
|
10220
|
+
// #3413: the "Empty" hint under a category stands for its header, which shows the landing highlight and label.
|
|
10221
|
+
const hint = e.target.closest && e.target.closest('.kb-cat-empty[data-kb-drop-into]');
|
|
10222
|
+
const el = hint
|
|
10223
|
+
? hint.parentElement && [...hint.parentElement.querySelectorAll('[data-kb-drop-cat]')].find((h) => h.dataset.kbDropCat === hint.dataset.kbDropInto)
|
|
10224
|
+
: e.target.closest && e.target.closest('[data-kb-drop-cat]');
|
|
10031
10225
|
return el && el.closest('.kb-refs-body') ? el : null;
|
|
10032
10226
|
}
|
|
10033
10227
|
/** Open a folded category during a drag without repainting the column (the dragged row must survive). */
|
|
@@ -10440,7 +10634,7 @@
|
|
|
10440
10634
|
// Organized again while the map was coming in: start over on the new generation (a few times at most).
|
|
10441
10635
|
if (++restarts > 3) throw new Error('the map kept changing');
|
|
10442
10636
|
generation = g.generationId; cursor = 0;
|
|
10443
|
-
kbGm.model = kbgCreate(generation); kbGm.pos = new Map(); kbGm.layoutKey = null;
|
|
10637
|
+
kbGm.model = kbgCreate(generation); kbGm.pos = new Map(); kbGm.layoutKey = null; kbGm.labels = null; kbGm.labelKey = null;
|
|
10444
10638
|
continue;
|
|
10445
10639
|
}
|
|
10446
10640
|
if (!Array.isArray(g.nodes)) throw new Error('bad graph envelope');
|
|
@@ -10487,13 +10681,47 @@
|
|
|
10487
10681
|
}
|
|
10488
10682
|
|
|
10489
10683
|
const KB_TYPE_LABEL = { source: 'Source', concept: 'Concept', person: 'Person' };
|
|
10684
|
+
const kbgNodeLabel = (n) => (n.kind === 'document' ? (n.filename || 'document') : (n.title || n.slug));
|
|
10685
|
+
/** #3413: where each drawn label goes (kbgLabelPlan), worked out once per layout, not on every repaint. */
|
|
10686
|
+
function kbGraphLabels(view, layoutKey) {
|
|
10687
|
+
const items = view.nodes.map((n) => ({ id: n.id, label: kbgNodeLabel(n), doc: n.kind === 'document', degree: (view.adj.get(n.id) || new Set()).size }));
|
|
10688
|
+
// The names are part of the key: a page renamed in a new generation with the same ids must not keep its old label.
|
|
10689
|
+
const key = `${layoutKey}|${items.map((it) => it.label).join('\n')}`;
|
|
10690
|
+
if (kbGm.labelKey === key && kbGm.labels) return kbGm.labels;
|
|
10691
|
+
kbGm.labels = kbgLabelPlan(items, kbGm.pos, { w: kbGm.w, h: kbGm.h }, kbGraphMeasure());
|
|
10692
|
+
kbGm.labelKey = key;
|
|
10693
|
+
return kbGm.labels;
|
|
10694
|
+
}
|
|
10695
|
+
/** The width of a map label in layout units, measured with the font the labels are drawn in (12px of the map's own
|
|
10696
|
+
* font), so the label plan never underestimates a wide name. No canvas (an old or headless page): the plan's estimate. */
|
|
10697
|
+
let kbGraphMeasurer = null;
|
|
10698
|
+
function kbGraphMeasure() {
|
|
10699
|
+
if (kbGraphMeasurer) return kbGraphMeasurer;
|
|
10700
|
+
const canvas = document.createElement('canvas');
|
|
10701
|
+
const ctx = canvas.getContext ? canvas.getContext('2d') : null;
|
|
10702
|
+
if (!ctx) return undefined;
|
|
10703
|
+
const host = $wsKnowledge || document.body;
|
|
10704
|
+
// Measured at 600, the weight a search match is drawn in (`.kb-g-node.match text`): the widest a label ever gets, so
|
|
10705
|
+
// one plan holds whether or not it is matched.
|
|
10706
|
+
ctx.font = `600 12px ${getComputedStyle(host).fontFamily || 'sans-serif'}`;
|
|
10707
|
+
const seen = new Map();
|
|
10708
|
+
kbGraphMeasurer = (t) => { let w = seen.get(t); if (w === undefined) { w = Math.ceil(ctx.measureText(t).width) + 1; seen.set(t, w); } return w; };
|
|
10709
|
+
return kbGraphMeasurer;
|
|
10710
|
+
}
|
|
10711
|
+
/** A label where the plan put it; a hidden one keeps its full name, shown only on point, focus, neighbour or match. */
|
|
10712
|
+
function kbGraphLabelSvg(spot, label) {
|
|
10713
|
+
if (spot.hidden) return `<text class="kb-g-quiet" x="13" y="4">${escapeHtml(label.length > 40 ? label.slice(0, 39) + '…' : label)}</text>`;
|
|
10714
|
+
const at = spot.side === 'l' ? 'x="-13" y="4" text-anchor="end"' : spot.side === 'b' ? 'x="0" y="24" text-anchor="middle"'
|
|
10715
|
+
: spot.side === 't' ? 'x="0" y="-16" text-anchor="middle"' : 'x="13" y="4"';
|
|
10716
|
+
return `<text ${at}>${escapeHtml(spot.text)}</text>`;
|
|
10717
|
+
}
|
|
10490
10718
|
function kbGraphNodeHtml(n, view, file) {
|
|
10491
10719
|
const p = kbGm.pos.get(n.id);
|
|
10492
10720
|
if (!p) return '';
|
|
10493
10721
|
const m = view.member.get(n.id) || { cats: [], grouped: false };
|
|
10494
10722
|
const cats = m.cats.slice(0, 3);
|
|
10495
10723
|
const col = kbgColour(file, cats[0] || null);
|
|
10496
|
-
const label =
|
|
10724
|
+
const label = kbgNodeLabel(n);
|
|
10497
10725
|
const where = !m.grouped ? 'Not yet grouped' : m.cats.map((c) => (c === 'uncategorized' ? 'Uncategorized' : kbcLabel(file, c))).join(', ');
|
|
10498
10726
|
const more = m.cats.length > 3 ? ` (+${m.cats.length - 3})` : '';
|
|
10499
10727
|
// A document removed since the map was loaded is shown as gone at once: the cached map keeps the old flag.
|
|
@@ -10501,7 +10729,9 @@
|
|
|
10501
10729
|
const kind = n.kind === 'document' ? (gone ? 'document, no longer in Knowledge' : 'document') : (KB_TYPE_LABEL[n.type] || 'Concept').toLowerCase() + ' page';
|
|
10502
10730
|
const tip = `${label} · ${kind} · ${where}${more}`;
|
|
10503
10731
|
const match = view.matchSet.has(n.id) ? ' match' : '';
|
|
10504
|
-
const
|
|
10732
|
+
const spot = (kbGm.labels && kbGm.labels.get(n.id)) || { side: 'r', text: label.length > 40 ? label.slice(0, 39) + '…' : label };
|
|
10733
|
+
const quiet = spot.hidden ? ' nolabel' : '';
|
|
10734
|
+
const cls = `kb-g-node ${n.kind === 'document' ? 'kb-g-doc' : 'kb-g-page kb-g-' + escapeAttr(n.type || 'concept')}${m.grouped ? '' : ' ungrouped'}${gone ? ' gone' : ''}${col.hatch ? ' hatch' : ''}${match}${quiet}`;
|
|
10505
10735
|
const act = n.kind === 'document' ? `data-kb-doc="${escapeAttr(n.sourceId)}"` : `data-kb-node="${escapeAttr(n.slug)}"`;
|
|
10506
10736
|
const shape = n.kind === 'document'
|
|
10507
10737
|
? '<rect class="kb-g-dot" x="-7" y="-7" width="14" height="14" rx="3"/>'
|
|
@@ -10509,13 +10739,13 @@
|
|
|
10509
10739
|
const rings = cats.slice(1).map((c, i) => `<circle class="kb-g-ring" r="${11 + i * 3}" style="--kbg-c:var(${kbgColour(file, c).token})"/>`).join('');
|
|
10510
10740
|
return `<g class="${cls}" tabindex="0" role="button" ${act} data-command-id="shell.kb-graph-open#${escapeAttr(n.id)}" data-command-instance-label="${escapeAttr(label)}" data-kb-gid="${escapeAttr(n.id)}" aria-label="${escapeAttr(tip)}" data-tip="${escapeAttr(tip)}"` +
|
|
10511
10741
|
` style="--kbg-c:var(${col.token})" transform="translate(${p.x.toFixed(1)},${p.y.toFixed(1)})">` +
|
|
10512
|
-
`<circle class="kb-g-hit" r="16"/>${rings}${shape}
|
|
10742
|
+
`<circle class="kb-g-hit" r="16"/>${rings}${shape}${kbGraphLabelSvg(spot, label)}</g>`;
|
|
10513
10743
|
}
|
|
10514
10744
|
|
|
10515
10745
|
function kbGraphControlsHtml(view, file) {
|
|
10516
10746
|
const legend = kbgLegend(kbGm.model, file).map((c) =>
|
|
10517
10747
|
`<button type="button" class="kb-gchip${c.hatch ? ' hatch' : ''}${c.dashed ? ' dashed' : ''}" aria-pressed="${kbGo.hiddenCats.has(c.id) ? 'false' : 'true'}" data-kb-gcat="${escapeAttr(c.id)}"` +
|
|
10518
|
-
` style="--kbg-c:var(${c.token})" data-command-id="shell.kb-graph-filter#${escapeAttr('cat-' + c.id)}" data-command-instance-label="${escapeAttr(c.name)}" data-tip="
|
|
10748
|
+
` style="--kbg-c:var(${c.token})" data-command-id="shell.kb-graph-filter#${escapeAttr('cat-' + c.id)}" data-command-instance-label="${escapeAttr(c.name)}" data-tip="${escapeAttr(kbgChipTip(c))}" aria-label="${escapeAttr(kbgChipTip(c))}"><span class="kb-gsw" aria-hidden="true"></span>${escapeHtml(c.name)} <span class="kb-gn">${c.n}</span></button>`).join('');
|
|
10519
10749
|
const types = ['source', 'concept', 'person'].map((t) =>
|
|
10520
10750
|
`<button type="button" class="kb-gchip kb-gtype" aria-pressed="${kbGo.hiddenTypes.has(t) ? 'false' : 'true'}" data-kb-gtype="${t}" data-command-id="shell.kb-graph-filter#${escapeAttr('type-' + t)}" data-command-instance-label="${escapeAttr(KB_TYPE_LABEL[t] + ' pages')}">${KB_TYPE_LABEL[t]} pages</button>`).join('');
|
|
10521
10751
|
const hidden = kbGo.hiddenCats.size || kbGo.hiddenTypes.size;
|
|
@@ -10586,11 +10816,15 @@
|
|
|
10586
10816
|
const W = Math.round(kbGm.w), H = Math.round(kbGm.h);
|
|
10587
10817
|
const lines = view.edges.map(([a, b]) => { const p = kbGm.pos.get(a), q = kbGm.pos.get(b);
|
|
10588
10818
|
return p && q ? `<line class="kb-g-edge" data-a="${escapeAttr(a)}" data-b="${escapeAttr(b)}" x1="${p.x.toFixed(1)}" y1="${p.y.toFixed(1)}" x2="${q.x.toFixed(1)}" y2="${q.y.toFixed(1)}"/>` : ''; }).join('');
|
|
10819
|
+
const labels = kbGraphLabels(view, `${kbGm.layoutKey}|${layoutKey}`);
|
|
10589
10820
|
const dots = view.nodes.map((n) => kbGraphNodeHtml(n, view, file)).join('');
|
|
10821
|
+
const drawn = view.nodes.filter((n) => kbGm.pos.get(n.id));
|
|
10822
|
+
const quiet = drawn.filter((n) => labels.get(n.id)?.hidden).length;
|
|
10823
|
+
const labelNote = quiet ? `<div class="kb-g-labelnote" role="note">Showing ${drawn.length - quiet} of ${drawn.length} labels. Point at a dot or search to see the rest.</div>` : '';
|
|
10590
10824
|
const defs = '<defs><pattern id="kbg-hatch" width="4" height="4" patternUnits="userSpaceOnUse" patternTransform="rotate(45)"><line x1="0" y1="0" x2="0" y2="4" class="kb-g-hatchline"/></pattern></defs>';
|
|
10591
10825
|
const body = kbGo.list ? kbGraphListHtml(view, file)
|
|
10592
10826
|
: `<div class="kb-graph-body"><svg viewBox="0 0 ${W} ${H}" data-vb-base="0 0 ${W} ${H}" class="kb-graph-svg" role="group" aria-label="Knowledge map, ${view.nodes.length} items">${defs}${lines}${dots}</svg>` +
|
|
10593
|
-
'<button type="button" class="kb-g-fit" data-kb-fit hidden data-tip="Zoom to fit (Home)" aria-label="Zoom to fit" data-command-id="shell.kb-graph-fit">⤢ Fit</button
|
|
10827
|
+
'<button type="button" class="kb-g-fit" data-kb-fit hidden data-tip="Zoom to fit (Home)" aria-label="Zoom to fit" data-command-id="shell.kb-graph-fit">⤢ Fit</button>' + labelNote + '</div>';
|
|
10594
10828
|
h.innerHTML = '<section class="kb-col kb-graph">' + kbGraphControlsHtml(view, file) + kbGraphNotesHtml(view, file) + body + '</section>';
|
|
10595
10829
|
kbGm.view = view;
|
|
10596
10830
|
const back = (kbGFocus || focusId) && h.querySelector(`[data-kb-gid="${CSS.escape(kbGFocus || focusId)}"]`);
|
|
@@ -11024,11 +11258,1039 @@
|
|
|
11024
11258
|
const notice = truncated
|
|
11025
11259
|
? `<div class="kb-view-note">Showing the first ${escapeHtml(kbBytes(KB_TEXT_CAP))} of ${escapeHtml(kbBytes(row.bytes))}.</div>`
|
|
11026
11260
|
: '';
|
|
11261
|
+
// #3412: a connected source's copy is markdown FloLess wrote, so it reads as text, not as its source: the escaping
|
|
11262
|
+
// renderer the Knowledge pages use, with FloLess's own markers (record ids, the evidence fence) left out.
|
|
11263
|
+
const md = row.kind === 'connected' && window.flolessChat?.markdownHtml;
|
|
11264
|
+
if (md) {
|
|
11265
|
+
kbPaintView(row, `<div class="kb-page-body kb-conn-view" tabindex="0" role="region" aria-label="Text synced into “${escapeAttr(row.filename || 'untitled')}”">` +
|
|
11266
|
+
`<div class="kb-page-body-measure kb-page-md">${kbConnPreviewHtml(text, md)}</div></div>${notice}`);
|
|
11267
|
+
return;
|
|
11268
|
+
}
|
|
11027
11269
|
kbPaintView(row, `<pre class="kb-view-pre"></pre>${notice}`);
|
|
11028
11270
|
const pre = kbViewHost() && kbViewHost().querySelector('.kb-view-pre');
|
|
11029
11271
|
if (pre) pre.textContent = text; // THE escaping guarantee — `<img src=x onerror=…>` stays literal
|
|
11030
11272
|
}
|
|
11031
11273
|
|
|
11274
|
+
// ── #2470 R6.8: connected sources ──────────────────────────────────────────────────────────────────────
|
|
11275
|
+
// A Teams chat synced into Knowledge through the Microsoft 365 account chosen in Integrations. Its row sits in the
|
|
11276
|
+
// reference list like any other (categories, the use-as-knowledge switch); what differs is drawn from
|
|
11277
|
+
// /knowledge/connected. Connect, Sync now and Erase are the person's own click (the server checks); each carries the
|
|
11278
|
+
// source revision this screen drew, so a source that synced meanwhile is shown again instead of acted on.
|
|
11279
|
+
const kbConnStops = new Map(); // sourceId → { message, choices, target, opts }: a sync that stopped and asks
|
|
11280
|
+
const kbConnSyncing = new Set(); // syncs this window has out
|
|
11281
|
+
const kbConnChanging = new Map(); // sourceId → a settings change still out: resolves to the revision it left (Sync now waits)
|
|
11282
|
+
const kbConnGapsOpen = new Set(); // gap disclosures the person opened (kept across the 3 s repaint)
|
|
11283
|
+
const KB_CONN_CHOICES = {
|
|
11284
|
+
'sync-with-current': 'Sync with the account I’m signed in with', 'confirm-target': 'Use this account', 'resume-and-sync': 'Resume and sync',
|
|
11285
|
+
'sync-anyway': 'Sync anyway', retry: 'Try again', reload: 'Refresh', pause: 'Pause', remove: 'Remove…',
|
|
11286
|
+
'open-integrations': 'Open Integrations', 'open-tools': 'Open Tools', cancel: 'Leave it for now', 'sync-now': 'Sync now',
|
|
11287
|
+
keep: 'Keep the copy',
|
|
11288
|
+
rebuild: 'Rebuild the copy',
|
|
11289
|
+
};
|
|
11290
|
+
// #2470 R6.8 slice 1b: an Outlook mail folder is the second kind. Its row adds the window, the coverage of the last listing,
|
|
11291
|
+
// what waits to be read and what was left out, all from the last sync (no message text), and asks the ceiling question.
|
|
11292
|
+
const kbConnIsMail = (c) => !!(c && c.scope === 'outlook-folder');
|
|
11293
|
+
// #2470 R6.8 slice 2: a Trimble Connect project is the third kind: its topics (coordination issues), their comments and
|
|
11294
|
+
// its ToDos. It has no window; its row says how the copy is kept up to date, from the last sync.
|
|
11295
|
+
const kbConnIsTrimble = (c) => !!(c && c.scope === 'trimble-project');
|
|
11296
|
+
|
|
11297
|
+
/**
|
|
11298
|
+
* #3412: a connected source's markdown as a person reads it. FloLess writes it (server knowledge-connected-*-render),
|
|
11299
|
+
* so its structure is known: headings, block quotes holding what people wrote with every markdown character
|
|
11300
|
+
* backslash-escaped, and HTML comments that are FloLess's own markers (`<!-- upstream-id … -->`, the untrusted-evidence
|
|
11301
|
+
* fence). Comment-only lines are left out; each escaped character is held aside while `markdownHtml` (the chat's
|
|
11302
|
+
* escaping renderer) runs and put back as plain text after, so a `\*` shows as `*` and can never become emphasis, a
|
|
11303
|
+
* tag or a link. The text is never inserted as HTML by any other route.
|
|
11304
|
+
*/
|
|
11305
|
+
function kbConnPreviewHtml(text, markdownHtml) {
|
|
11306
|
+
const BASE = 0xE100;
|
|
11307
|
+
const ESCAPABLE = '\\`*_[]<>#|!{}~+-.)=';
|
|
11308
|
+
const lines = String(text ?? '').replace(/\r\n?/g, '\n').split('\n');
|
|
11309
|
+
const kept = lines.filter((line, i) => !/^[ \t]*<!--.*-->[ \t]*$/.test(line)
|
|
11310
|
+
// The preview may stop inside a last marker (the text cap), so an unclosed one on the last line goes too.
|
|
11311
|
+
&& !(i === lines.length - 1 && /^[ \t]*<!--/.test(line)));
|
|
11312
|
+
const held = kept.join('\n')
|
|
11313
|
+
.replace(/[-]/g, '�')
|
|
11314
|
+
.replace(/\\([\\`*_[\]<>#|!{}~+\-.)=])/g, (all, ch) => String.fromCharCode(BASE + ESCAPABLE.indexOf(ch)));
|
|
11315
|
+
const entity = { '&': '&', '<': '<', '>': '>' };
|
|
11316
|
+
return String(markdownHtml(held)).replace(/[-]/g, (ch) => {
|
|
11317
|
+
const original = ESCAPABLE[ch.charCodeAt(0) - BASE] ?? '�';
|
|
11318
|
+
return entity[original] || original;
|
|
11319
|
+
});
|
|
11320
|
+
}
|
|
11321
|
+
const kbConnKindName = (c) => (kbConnIsTrimble(c) ? 'Trimble Connect project' : kbConnIsMail(c) ? 'Outlook folder' : 'Teams chat');
|
|
11322
|
+
const kbConnService = (c) => (kbConnIsTrimble(c) ? 'Trimble Connect' : 'Microsoft 365');
|
|
11323
|
+
const kbConnThing = (c) => (kbConnIsTrimble(c) ? 'project' : kbConnIsMail(c) ? 'folder' : 'chat');
|
|
11324
|
+
const kbConnGlyph = (kind) => (kind === 'trimble-project' ? '⚑︎' : kind === 'outlook-folder' ? '✉︎' : '◫');
|
|
11325
|
+
const KB_CONN_REGIONS = [['northAmerica', 'North America'], ['europe', 'Europe'], ['unitedKingdom', 'United Kingdom'], ['asia', 'Asia'], ['australia', 'Australia']];
|
|
11326
|
+
const kbConnRegionName = (r) => (KB_CONN_REGIONS.find(([v]) => v === r) || [r, r])[1];
|
|
11327
|
+
// The plan §17 #13 disclosure, word for word as the page and the action card say it.
|
|
11328
|
+
const KB_CONN_TRIMBLE_NOT_INCLUDED = 'Not included: viewpoints and their snapshots, files, document references, BCF documents, related-topic links, and ToDo comments and attachments (ToDos show their own fields only).';
|
|
11329
|
+
const kbConnDate = (iso) => { const t = Date.parse(iso || ''); return Number.isFinite(t) ? new Date(t).toLocaleDateString() : ''; };
|
|
11330
|
+
const kbConnWhen = (iso) => { const t = Date.parse(iso || ''); return Number.isFinite(t) ? new Date(t).toLocaleString() : ''; };
|
|
11331
|
+
const kbConnPlural = (n, one, many) => `${n.toLocaleString()} ${n === 1 ? one : many}`;
|
|
11332
|
+
|
|
11333
|
+
/** The Trimble lines under a row's meta line (slice 2 plan §18 #8, §19): only what needs saying shows on the row; how the
|
|
11334
|
+
* copy is kept up to date sits in one disclosure. Everything comes from the last sync; no topic text. */
|
|
11335
|
+
function kbConnTrimbleHtml(sourceId, c, name) {
|
|
11336
|
+
const t = c.trimble || {};
|
|
11337
|
+
const lines = [];
|
|
11338
|
+
const cov = t.coverage;
|
|
11339
|
+
const kindWord = (k) => (k === 'topics' ? 'topics' : 'ToDos');
|
|
11340
|
+
if (cov) {
|
|
11341
|
+
for (const k of ['topics', 'todos']) {
|
|
11342
|
+
if (cov[k] === 'over-ceiling') lines.push(`More than 5,000 ${kindWord(k)}, so this copy is partial. Nothing is removed just because Trimble stopped listing it.`);
|
|
11343
|
+
}
|
|
11344
|
+
const incomplete = ['topics', 'todos'].filter((k) => cov[k] === 'incomplete');
|
|
11345
|
+
if (incomplete.length) lines.push(`The ${incomplete.map(kindWord).join(' and ')} listing did not finish in the last sync. Nothing was removed because of it.`);
|
|
11346
|
+
}
|
|
11347
|
+
if (t.waitingReads > 0) lines.push(`${kbConnPlural(t.waitingReads, 'topic', 'topics')} waiting to be read, up to 50 per sync.`);
|
|
11348
|
+
if (t.moreComments > 0) lines.push(`Trimble returned more comments than FloLess reads in one go for ${kbConnPlural(t.moreComments, 'topic', 'topics')}. Some may not be here yet.`);
|
|
11349
|
+
if (t.missedOnce > 0) {
|
|
11350
|
+
lines.push(`${kbConnPlural(t.missedOnce, 'record was', 'records were')} not listed by Trimble in the last sync; FloLess removes ${t.missedOnce === 1 ? 'it' : 'them'} if the next full listing misses ${t.missedOnce === 1 ? 'it' : 'them'} too.`);
|
|
11351
|
+
}
|
|
11352
|
+
// The size cut, for topics and ToDos alike: a ToDo-only cut is as much a gap as a topic one.
|
|
11353
|
+
const cut = t.capacityCut;
|
|
11354
|
+
const notKeptTopics = (t.capacity && t.capacity.topics) || 0;
|
|
11355
|
+
const notKeptTodos = (t.capacity && t.capacity.todos) || 0;
|
|
11356
|
+
if (cut && (cut.topics || cut.todos)) {
|
|
11357
|
+
const counted = [notKeptTopics && kbConnPlural(notKeptTopics, 'topic', 'topics'), notKeptTodos && kbConnPlural(notKeptTodos, 'ToDo', 'ToDos')].filter(Boolean);
|
|
11358
|
+
const what = [cut.topics && 'topics', cut.todos && 'ToDos'].filter(Boolean).join(' and ');
|
|
11359
|
+
lines.push(`This project is bigger than FloLess keeps, so ${counted.length ? `${counted.join(' and ')} ${notKeptTopics + notKeptTodos === 1 ? 'is' : 'are'}` : `some ${what} are`} not in this copy. They are picked by Trimble's id, not by date, so old and new ${what} can both be missing.`);
|
|
11360
|
+
}
|
|
11361
|
+
if (t.positionLost) lines.push('FloLess lost its place in this project, so some topics may be read twice and a removal waits one more sync.');
|
|
11362
|
+
const r = t.rotation;
|
|
11363
|
+
if (r && r.failed > 0) lines.push(`The last comment check failed for ${kbConnPlural(r.failed, 'topic', 'topics')}. FloLess tries again.`);
|
|
11364
|
+
const n = t.counts || {};
|
|
11365
|
+
const details = [];
|
|
11366
|
+
if (r && r.of > 0) {
|
|
11367
|
+
details.push(`FloLess re-reads every kept topic's comments at least once every ${kbConnPlural(r.every, 'sync', 'syncs')}, as long as the topics stay the same.`);
|
|
11368
|
+
details.push(`This round: topic ${Math.min(r.at, r.of).toLocaleString()} of ${r.of.toLocaleString()}.`);
|
|
11369
|
+
if (r.oldestCheck) details.push(`Oldest comment check: ${kbConnWhen(r.oldestCheck)}.`);
|
|
11370
|
+
}
|
|
11371
|
+
if (n.noChangeTime > 0) details.push(`Trimble gave no change time for ${kbConnPlural(n.noChangeTime, 'record', 'records')}; FloLess shows ${n.noChangeTime === 1 ? 'it' : 'them'} as last listed.`);
|
|
11372
|
+
if (n.notAdmitted > 0) details.push(`${kbConnPlural(n.notAdmitted, 'answer', 'answers')} from Trimble ${n.notAdmitted === 1 ? 'was' : 'were'} older than what FloLess already had, so FloLess kept its copy.`);
|
|
11373
|
+
// Only a listing that finished is "full": the time of an incomplete one would be a claim the copy cannot back.
|
|
11374
|
+
if (t.lastCompleteAt) details.push(`Last full listing ${kbConnWhen(t.lastCompleteAt)}.`);
|
|
11375
|
+
const more = details.length
|
|
11376
|
+
? `<details class="kb-conn-gaps" data-kb-conn-gaps="${escapeAttr(`${sourceId}:kept`)}"${kbConnGapsOpen.has(`${sourceId}:kept`) ? ' open' : ''}>` +
|
|
11377
|
+
`<summary data-command-id="shell.kb-connected-kept-up#${escapeAttr(sourceId)}" data-command-instance-label="${escapeAttr(name)}">How this copy is kept up to date</summary>` +
|
|
11378
|
+
`<ul>${details.map((d) => `<li>${escapeHtml(d)}</li>`).join('')}</ul></details>` : '';
|
|
11379
|
+
return lines.map((line) => `<div class="kb-conn-note">${escapeHtml(line)}</div>`).join('') + more;
|
|
11380
|
+
}
|
|
11381
|
+
|
|
11382
|
+
/** The Outlook lines under a row's meta line (plan §5.3), each shown only when it says something. */
|
|
11383
|
+
function kbConnMailHtml(sourceId, c, name) {
|
|
11384
|
+
const o = c.outlook || {};
|
|
11385
|
+
const lines = [];
|
|
11386
|
+
// After a window change the last listing was of another window, so its coverage says nothing about this one until the
|
|
11387
|
+
// next sync (code review R12 #1).
|
|
11388
|
+
if (o.settingsPending) {
|
|
11389
|
+
lines.push(`You changed the window to the last ${o.windowDays} days. The next sync lists that window; until then, what this row says comes from the last sync, which listed the last ${o.listedWindowDays} days.`);
|
|
11390
|
+
}
|
|
11391
|
+
const cov = o.settingsPending ? null : o.coverage;
|
|
11392
|
+
// Dated by the listing itself: a later sync that stopped listed nothing (code review R13 #1).
|
|
11393
|
+
if (cov && cov.kind === 'complete') lines.push(`Last full listing ${kbConnWhen(o.listedAt || (c.lastSync && c.lastSync.at))}.`);
|
|
11394
|
+
else if (cov && cov.kind === 'partial') {
|
|
11395
|
+
lines.push(`Partial: more than 100,000 mails in the window. Outlook listed the mail received after ${kbConnWhen(cov.frontier)} and some received at that time; older mail was not listed. ` +
|
|
11396
|
+
'While the copy is partial, FloLess removes nothing that Outlook stops listing, so any message here may have left the folder.' +
|
|
11397
|
+
// Mail Outlook listed but FloLess could not identify may be missing at any date (code review R11 #1).
|
|
11398
|
+
(cov.omitted > 0 ? ` Outlook also listed ${kbConnPlural(cov.omitted, 'message', 'messages')} FloLess could not identify; ${cov.omitted === 1 ? 'it' : 'they'} may be missing here, whatever ${cov.omitted === 1 ? 'its' : 'their'} date.` : ''));
|
|
11399
|
+
} else if (cov && cov.kind === 'incomplete') lines.push(`Listing incomplete: ${cov.reason} Nothing was removed because of this listing.`);
|
|
11400
|
+
if (o.waitingReads > 0) lines.push(`${kbConnPlural(o.waitingReads, 'message', 'messages')} waiting to be read, up to 50 per sync.`);
|
|
11401
|
+
if (o.missedOnce > 0) {
|
|
11402
|
+
lines.push(`${kbConnPlural(o.missedOnce, 'message was', 'messages were')} not listed by Outlook in the last sync; FloLess removes ${o.missedOnce === 1 ? 'it' : 'them'} if the next full listing misses ${o.missedOnce === 1 ? 'it' : 'them'} too.`);
|
|
11403
|
+
}
|
|
11404
|
+
// The size-limit cut that still applies (plan §3.4), said whatever the last sync counted (code review R3 #1).
|
|
11405
|
+
if (o.capacityCutAt) lines.push(`This source reached FloLess's size limit: messages received before ${kbConnDate(o.capacityCutAt)} are not kept.`);
|
|
11406
|
+
if (o.rereadLeft > 0) {
|
|
11407
|
+
lines.push(`Reading every message again: ${o.rereadLeft.toLocaleString()} left, up to 50 per sync.` +
|
|
11408
|
+
(o.rereadMayRepeat ? ' FloLess lost track of which messages it had already read again, so some may be read twice.' : ''));
|
|
11409
|
+
}
|
|
11410
|
+
const n = o.counts || {};
|
|
11411
|
+
// Mail Outlook lists without a change time is kept, so it is never "left out" (code review R7 #2): FloLess cannot see
|
|
11412
|
+
// an edit to it until every message is read again.
|
|
11413
|
+
if (n.noChangeTime > 0) {
|
|
11414
|
+
lines.push(`Outlook gave no change time for ${kbConnPlural(n.noChangeTime, 'message', 'messages')}. FloLess keeps ${n.noChangeTime === 1 ? 'it' : 'them'}, and notices an edit to ${n.noChangeTime === 1 ? 'it' : 'them'} only when you choose Read every message again.`);
|
|
11415
|
+
}
|
|
11416
|
+
// A kept message whose newer version waits to be read is kept, not left out (convergence check 2026-11-07).
|
|
11417
|
+
if (n.newerPending > 0) {
|
|
11418
|
+
lines.push(`${kbConnPlural(n.newerPending, 'message has', 'messages have')} a newer version in Outlook that FloLess has not read yet; FloLess keeps the version it read until then.`);
|
|
11419
|
+
}
|
|
11420
|
+
// Kept mail whose text FloLess could not read is kept, so it is said on its own line too (code review R8 #1), and a
|
|
11421
|
+
// newer version too large to read says the older text is gone (code review R9 #2).
|
|
11422
|
+
if (n.keptTooLarge > 0) {
|
|
11423
|
+
lines.push(`${kbConnPlural(n.keptTooLarge, 'message has', 'messages have')} a newer version too large to read. FloLess keeps ${n.keptTooLarge === 1 ? 'its' : 'their'} sender and subject, and no longer keeps the older text.`);
|
|
11424
|
+
}
|
|
11425
|
+
if (n.noBody > 0) {
|
|
11426
|
+
lines.push(`Outlook gave no usable body for ${kbConnPlural(n.noBody, 'message', 'messages')}. FloLess keeps ${n.noBody === 1 ? 'it' : 'them'} without text, and reads ${n.noBody === 1 ? 'it' : 'them'} again when Outlook lists a newer change.`);
|
|
11427
|
+
}
|
|
11428
|
+
const onPurpose = [[n.draft, 'draft', 'drafts'], [n.noReceivedDate, 'message with no received date', 'messages with no received date']].filter(([k]) => k > 0);
|
|
11429
|
+
const unread = [[n.tooLarge, 'message too large to keep', 'messages too large to keep'],
|
|
11430
|
+
[n.notKept, 'message past the size limit', 'messages past the size limit'],
|
|
11431
|
+
[n.gone, 'message Outlook listed but could not find when FloLess read it', 'messages Outlook listed but could not find when FloLess read them'],
|
|
11432
|
+
[n.superseded, 'message Outlook offered only in an older version than FloLess had seen', 'messages Outlook offered only in an older version than FloLess had seen']].filter(([k]) => k > 0);
|
|
11433
|
+
const total = [...onPurpose, ...unread].reduce((sum, [k]) => sum + k, 0);
|
|
11434
|
+
const left = total ? `<details class="kb-conn-gaps" data-kb-conn-gaps="${escapeAttr(`${sourceId}:left`)}"${kbConnGapsOpen.has(`${sourceId}:left`) ? ' open' : ''}>` +
|
|
11435
|
+
`<summary data-command-id="shell.kb-connected-left-out#${escapeAttr(sourceId)}" data-command-instance-label="${escapeAttr(name)}">What was left out (${total.toLocaleString()})</summary>` +
|
|
11436
|
+
(onPurpose.length ? `<ul>${onPurpose.map(([k, one, many]) => `<li>${escapeHtml(kbConnPlural(k, one, many))}</li>`).join('')}</ul>` : '') +
|
|
11437
|
+
(unread.length ? `<ul>${unread.map(([k, one, many]) => `<li>${escapeHtml(kbConnPlural(k, one, many))}</li>`).join('')}</ul>` +
|
|
11438
|
+
'<div>FloLess reads these again when Outlook lists a newer change, or when you choose Read every message again.</div>' : '') +
|
|
11439
|
+
'</details>' : '';
|
|
11440
|
+
// Only a window shorter than the one listed can bring it under the ceiling, and the partial copy keeps the window the
|
|
11441
|
+
// source has; at 7 days the partial copy is the one choice (code review R13 #2).
|
|
11442
|
+
const days = o.windowDays || 90;
|
|
11443
|
+
const shorter = [30, 7].filter((d) => d < days);
|
|
11444
|
+
const ask = o.ceilingQuestion
|
|
11445
|
+
? '<div class="kb-conn-ask" role="status"><b>This folder holds more mail than one sync can list.</b> More than 100,000 mails arrived in the last ' +
|
|
11446
|
+
(shorter.length
|
|
11447
|
+
? `${escapeHtml(String(days))} days. Keep a shorter window, so FloLess can tell which mail left the folder, or keep a partial copy?`
|
|
11448
|
+
: `${escapeHtml(String(days))} days, the shortest window FloLess offers. Keep a partial copy?`) +
|
|
11449
|
+
'<div class="kb-conn-choices">' + [...shorter.map((d) => [String(d), `Keep the last ${d} days`, '']),
|
|
11450
|
+
['partial', 'Keep a partial copy', `Keeps the last ${days} days, but mail Outlook stops listing is not removed while the copy is partial`]].map(([v, label, tip], i) =>
|
|
11451
|
+
`<button type="button" class="kb-link${i === 0 ? ' kb-conn-primary' : ''}" data-kb-conn-ceiling="${escapeAttr(v)}" data-kb-conn-id="${escapeAttr(sourceId)}" data-kb-conn-rev="${escapeAttr(c.revision || '')}"` +
|
|
11452
|
+
`${tip ? ` data-tip="${escapeAttr(tip)}"` : ''} data-command-id="shell.kb-connected-ceiling#${escapeAttr(v)}" data-command-instance-label="${escapeAttr(label)}">${escapeHtml(label)}</button>`).join('') +
|
|
11453
|
+
'</div></div>' : '';
|
|
11454
|
+
return lines.map((line) => `<div class="kb-conn-note">${escapeHtml(line)}</div>`).join('') + ask + left;
|
|
11455
|
+
}
|
|
11456
|
+
// The choices a stop offers that this screen can act on; never none, so a stopped sync always has a way on.
|
|
11457
|
+
const kbConnKnownChoices = (choices) => {
|
|
11458
|
+
const known = (Array.isArray(choices) ? choices : []).filter((choice) => KB_CONN_CHOICES[choice]);
|
|
11459
|
+
return known.length ? known : ['retry', 'pause', 'remove'];
|
|
11460
|
+
};
|
|
11461
|
+
|
|
11462
|
+
const kbConnOf = (st, sourceId) => ((st && st.connected && st.connected.sources) || []).find((c) => c.sourceId === sourceId) || null;
|
|
11463
|
+
const kbConnUrl = (path) => kbUrl(current.id, `/connected${path}`);
|
|
11464
|
+
function kbConnRepaint() { kbInvalidateRefs(); if (knowledgeState) paintKnowledge(knowledgeState); }
|
|
11465
|
+
|
|
11466
|
+
function kbConnStopHtml(sourceId, stop) {
|
|
11467
|
+
const buttons = kbConnKnownChoices(stop.choices).map((choice, n) =>
|
|
11468
|
+
`<button type="button" class="kb-link${n === 0 ? ' kb-conn-primary' : ''}" data-kb-conn-choice="${escapeAttr(choice)}" data-kb-conn-id="${escapeAttr(sourceId)}"` +
|
|
11469
|
+
` data-command-id="shell.kb-connected-choice#${escapeAttr(choice)}" data-command-instance-label="${escapeAttr(KB_CONN_CHOICES[choice])}">${escapeHtml(KB_CONN_CHOICES[choice])}</button>`).join('');
|
|
11470
|
+
return `<div class="kb-conn-stop" role="status"><b>Not synced.</b> ${escapeHtml(stop.message)}${buttons ? `<div class="kb-conn-choices">${buttons}</div>` : ''}</div>`;
|
|
11471
|
+
}
|
|
11472
|
+
|
|
11473
|
+
function kbConnRowHtml(s, st, depth) {
|
|
11474
|
+
const c = kbConnOf(st, s.sourceId);
|
|
11475
|
+
const on = !!s.useAsKb;
|
|
11476
|
+
const sel = kbSel.selected.has(s.sourceId);
|
|
11477
|
+
const mail = kbConnIsMail(c);
|
|
11478
|
+
const name = (c && c.label) || s.filename || kbConnKindName(c);
|
|
11479
|
+
const isOpen = viewer.mode === 'file' && viewer.sourceId === s.sourceId;
|
|
11480
|
+
const syncing = kbConnSyncing.has(s.sourceId) || !!(c && c.syncing);
|
|
11481
|
+
// When the chat was last read: the newest version, or a later sync that found nothing new (it read the chat too).
|
|
11482
|
+
const checked = c && c.lastSync && c.lastSync.outcome !== 'stopped' ? Date.parse(c.lastSync.at || '') : NaN;
|
|
11483
|
+
const saved = Date.parse((c && c.lastSyncedAt) || '');
|
|
11484
|
+
const at = Number.isFinite(checked) && !(checked < saved) ? checked : saved;
|
|
11485
|
+
const when = Number.isFinite(at) ? `synced ${kbAgo(Date.now() - at)}` : 'not synced yet';
|
|
11486
|
+
const versions = c ? `${c.versions} version${c.versions === 1 ? '' : 's'}` : '';
|
|
11487
|
+
const since = Date.parse((c && c.windowStart) || '');
|
|
11488
|
+
const trimble = kbConnIsTrimble(c);
|
|
11489
|
+
const scope = trimble ? kbConnRegionName(c.trimble && c.trimble.region) : mail ? `last ${(c.outlook && c.outlook.windowDays) || 90} days`
|
|
11490
|
+
: Number.isFinite(since) ? `messages since ${new Date(since).toLocaleDateString()}` : '';
|
|
11491
|
+
const unread = !!(st && st.connected && st.connected.unreadable);
|
|
11492
|
+
const service = c ? kbConnService(c) : 'Connected source';
|
|
11493
|
+
// Each part its own span (#3425), so the line breaks between parts before it breaks inside one (an email address).
|
|
11494
|
+
const meta = (unread ? [service, 'FloLess could not read its sync status just now. Reopen Knowledge to try again.']
|
|
11495
|
+
: [service, c && c.account, scope, when, versions].filter(Boolean))
|
|
11496
|
+
// The dot is held to its part (kb-fmeta-sep does not wrap), so a line never ends on a lone separator.
|
|
11497
|
+
.map((part, i) => `<span class="kb-fmeta-part">${i ? '<span class="kb-fmeta-sep" aria-hidden="true">· </span>' : ''}${escapeHtml(part)}</span>`).join(' ');
|
|
11498
|
+
const chips = (syncing ? '<span class="kb-chip">syncing…</span>' : '') +
|
|
11499
|
+
(c && c.paused ? '<span class="kb-chip kb-conn-paused">paused</span>' : '') +
|
|
11500
|
+
(c && c.organizedPending ? '<span class="kb-chip new" data-tip="Organize again to use what this sync brought in">synced after the last Organize</span>' : '');
|
|
11501
|
+
const stop = kbConnStops.get(s.sourceId);
|
|
11502
|
+
const last = c && c.lastSync;
|
|
11503
|
+
const stopped = stop ? kbConnStopHtml(s.sourceId, stop)
|
|
11504
|
+
// A stop from before a reload: the same way on as a fresh one (the choices are this screen's, not stored).
|
|
11505
|
+
: last && last.outcome === 'stopped' ? kbConnStopHtml(s.sourceId, { message: `Last sync stopped: ${last.message || ''}`, choices: last.choices }) : '';
|
|
11506
|
+
const gaps = c && c.gaps === null
|
|
11507
|
+
? '<div class="kb-conn-note">FloLess could not check whether this copy holds every message. Sync again to check.</div>'
|
|
11508
|
+
: c && Array.isArray(c.gaps) && c.gaps.length
|
|
11509
|
+
? `<details class="kb-conn-gaps" data-kb-conn-gaps="${escapeAttr(s.sourceId)}"${kbConnGapsOpen.has(s.sourceId) ? ' open' : ''}>` +
|
|
11510
|
+
`<summary data-command-id="shell.kb-connected-gaps#${escapeAttr(s.sourceId)}" data-command-instance-label="${escapeAttr(name)}">Some messages may be missing (${c.gaps.length} time range${c.gaps.length === 1 ? '' : 's'})</summary>` +
|
|
11511
|
+
`<div>Microsoft 365 said more messages may have changed at these times than one sync reads, so some may not be in this copy. Sync more often to keep a busy chat complete.</div>` +
|
|
11512
|
+
`<ul>${c.gaps.map((g) => `<li>${escapeHtml(new Date(g.from).toLocaleString())} – ${escapeHtml(new Date(g.to).toLocaleString())}</li>`).join('')}</ul></details>`
|
|
11513
|
+
: '';
|
|
11514
|
+
const notes = (mail && !unread ? kbConnMailHtml(s.sourceId, c, name) : '') + (trimble && !unread ? kbConnTrimbleHtml(s.sourceId, c, name) : '') + gaps;
|
|
11515
|
+
return `<div class="kb-src kb-conn${on ? '' : ' off'}${sel ? ' selected' : ''}" draggable="true"` +
|
|
11516
|
+
(depth != null ? ` style="--kb-depth:${depth}"` : '') +
|
|
11517
|
+
` data-source-id="${escapeAttr(s.sourceId)}"${isOpen ? ' aria-current="true"' : ''}>` +
|
|
11518
|
+
`<span class="kb-fico conn" aria-hidden="true" data-tip="${kbConnKindName(c)}">${kbConnGlyph(c && c.scope)}</span>` +
|
|
11519
|
+
'<div class="kb-fbody">' +
|
|
11520
|
+
`<button type="button" class="kb-fname" data-kb-open="${escapeAttr(s.sourceId)}" data-command-id="shell.kb-reference#${escapeAttr(s.sourceId)}" data-command-instance-label="${escapeAttr(name)}" ` +
|
|
11521
|
+
`data-tip="Preview what was synced from “${escapeAttr(name)}” · Ctrl or Shift to select">${escapeHtml(name)}${sel ? '<span class="kb-sr"> (selected)</span>' : ''}</button>` +
|
|
11522
|
+
'</div>' +
|
|
11523
|
+
// #3425: the name shares the first line with the controls, one group pinned to its top; the status line and the
|
|
11524
|
+
// notes below take the width under them, so nothing is drawn over the text and a row that grows never moves its ⟳.
|
|
11525
|
+
'<span class="kb-conn-ctl">' +
|
|
11526
|
+
`<button type="button" class="kb-conn-sync" data-kb-conn-sync="${escapeAttr(s.sourceId)}" aria-label="Sync “${escapeAttr(name)}” now"${syncing ? ' aria-busy="true" disabled' : ''}` +
|
|
11527
|
+
` data-command-id="shell.kb-connected-sync#${escapeAttr(s.sourceId)}" data-command-instance-label="${escapeAttr(name)}"` +
|
|
11528
|
+
` data-tip="${syncing ? 'Syncing…' : c && c.paused ? 'Paused. Sync now asks to resume it first' : `Sync now: read what changed in this ${kbConnThing(c)}`}"><span aria-hidden="true">⟳</span></button>` +
|
|
11529
|
+
`<button type="button" class="kb-toggle" role="switch" aria-checked="${on ? 'true' : 'false'}" data-kb-toggle ` +
|
|
11530
|
+
`aria-label="Use “${escapeAttr(name)}” as knowledge" data-command-id="shell.kb-category-row-toggle#${escapeAttr(s.sourceId)}" data-command-instance-label="${escapeAttr(name)}" ` +
|
|
11531
|
+
`data-tip="${on ? 'Included in the knowledge base — click to exclude' : 'Excluded from the knowledge base — click to include'}"></button>` +
|
|
11532
|
+
`<button type="button" class="kb-cat-more kb-conn-more" data-kb-conn-menu="${escapeAttr(s.sourceId)}" aria-haspopup="menu" aria-label="More for “${escapeAttr(name)}”"` +
|
|
11533
|
+
` data-command-id="shell.kb-connected-menu#${escapeAttr(s.sourceId)}" data-command-instance-label="${escapeAttr(name)}" data-tip="Sync, pause, remove or erase">⋯</button>` +
|
|
11534
|
+
'</span>' +
|
|
11535
|
+
`<div class="kb-conn-extra kb-conn-meta"><div class="kb-fmeta"${Number.isFinite(at) || mail ? ` data-tip="${escapeAttr([mail && Number.isFinite(since) ? `Mail received since ${new Date(since).toLocaleDateString()}` : '',
|
|
11536
|
+
Number.isFinite(at) ? `Last synced ${new Date(at).toLocaleString()}` : ''].filter(Boolean).join(' · '))}"` : ''}>${meta}${chips ? ` ${chips}` : ''}</div></div>` +
|
|
11537
|
+
// A stop comes next and takes the whole width (its choices need the room); the notes line up with the name.
|
|
11538
|
+
(stopped ? `<div class="kb-conn-extra kb-conn-extra-stop">${stopped}</div>` : '') + (notes ? `<div class="kb-conn-extra">${notes}</div>` : '') +
|
|
11539
|
+
'</div>';
|
|
11540
|
+
}
|
|
11541
|
+
|
|
11542
|
+
/** Below the reference list: removed sources whose messages are still stored, and what a copied project left out. */
|
|
11543
|
+
function kbConnExtrasHtml(st) {
|
|
11544
|
+
const conn = st.connected;
|
|
11545
|
+
if (!conn) return '';
|
|
11546
|
+
if (conn.unreadable) return '<div class="kb-conn-note" role="status">FloLess could not read the connected sources just now, so removed ones that still hold messages are not listed. Reopen Knowledge to try again.</div>';
|
|
11547
|
+
let html = '';
|
|
11548
|
+
const removed = Array.isArray(conn.removed) ? conn.removed : [];
|
|
11549
|
+
if (removed.length) {
|
|
11550
|
+
html += '<div class="kb-conn-removed"><h4 class="kb-uncategorized-head">Removed connected sources</h4>' +
|
|
11551
|
+
'<div class="kb-conn-note">What they synced stays stored until you erase it.</div>' +
|
|
11552
|
+
removed.map((r) => `<div class="kb-conn-removed-row"><span class="kb-fico conn" aria-hidden="true">${kbConnGlyph(r.scopeKind)}</span><span class="kb-conn-removed-name">${escapeHtml(r.label || kbConnKindName({ scope: r.scopeKind }))}` +
|
|
11553
|
+
`${r.erasePending ? '<span class="kb-conn-removed-why">Erase did not finish yet.</span>' : ''}</span>` +
|
|
11554
|
+
`<button type="button" class="kb-link danger" data-kb-conn-erase="${escapeAttr(r.sourceId)}" data-command-id="shell.kb-connected-erase#${escapeAttr(r.sourceId)}" data-command-instance-label="${escapeAttr(r.label || 'Teams chat')}">${r.erasePending ? 'Finish erasing…' : 'Erase…'}</button></div>`).join('') +
|
|
11555
|
+
'</div>';
|
|
11556
|
+
}
|
|
11557
|
+
const notice = conn.copyNotice;
|
|
11558
|
+
if (notice && notice.knowledgeOmitted) {
|
|
11559
|
+
html += '<div class="kb-conn-note kb-conn-copy">This copy’s knowledge was left out because FloLess could not confirm that connected chat messages were left out of it. Add the files again, or copy the project again.</div>';
|
|
11560
|
+
} else if (notice && notice.connectedLeftOut) {
|
|
11561
|
+
html += `<div class="kb-conn-note kb-conn-copy">${notice.connectedLeftOut} connected source${notice.connectedLeftOut === 1 ? ' was' : 's were'} not copied. Connect ${notice.connectedLeftOut === 1 ? 'it' : 'them'} again here.</div>`;
|
|
11562
|
+
}
|
|
11563
|
+
return html;
|
|
11564
|
+
}
|
|
11565
|
+
|
|
11566
|
+
async function kbConnSync(sourceId, opts = {}) {
|
|
11567
|
+
if (kbConnSyncing.has(sourceId)) return;
|
|
11568
|
+
kbConnSyncing.add(sourceId);
|
|
11569
|
+
const changing = kbConnChanging.get(sourceId);
|
|
11570
|
+
let changed = null;
|
|
11571
|
+
if (changing) { kbConnRepaint(); changed = await changing.catch(() => null); }
|
|
11572
|
+
const c = kbConnOf(knowledgeState, sourceId);
|
|
11573
|
+
const seen = changed ?? (c ? c.revision : null);
|
|
11574
|
+
kbConnStops.delete(sourceId);
|
|
11575
|
+
kbConnRepaint();
|
|
11576
|
+
try {
|
|
11577
|
+
const res = await api(kbConnUrl(`/${encodeURIComponent(sourceId)}/sync`), { method: 'POST',
|
|
11578
|
+
body: JSON.stringify({ ...opts, ...(seen !== null ? { revision: seen } : {}) }) });
|
|
11579
|
+
kbAnnounce(res.message || 'Synced.');
|
|
11580
|
+
} catch (err) {
|
|
11581
|
+
const body = (err && err.body) || {};
|
|
11582
|
+
kbConnStops.set(sourceId, { message: err.message, choices: kbConnKnownChoices(body.choices), target: body.target || null, opts });
|
|
11583
|
+
kbAnnounce(`Not synced. ${err.message}`);
|
|
11584
|
+
} finally {
|
|
11585
|
+
kbConnSyncing.delete(sourceId);
|
|
11586
|
+
kbInvalidateRefs();
|
|
11587
|
+
await renderKnowledge();
|
|
11588
|
+
}
|
|
11589
|
+
}
|
|
11590
|
+
|
|
11591
|
+
async function kbConnSetPaused(sourceId, paused) {
|
|
11592
|
+
const c = kbConnOf(knowledgeState, sourceId);
|
|
11593
|
+
try {
|
|
11594
|
+
await api(kbConnUrl(`/${encodeURIComponent(sourceId)}`), { method: 'PATCH', body: JSON.stringify({ paused, ...(c ? { revision: c.revision } : {}) }) });
|
|
11595
|
+
kbConnStops.delete(sourceId);
|
|
11596
|
+
kbAnnounce(paused ? 'Paused. It keeps what it synced.' : 'Resumed.');
|
|
11597
|
+
} catch (err) { const said = errorText(err, { action: paused ? 'pause this source' : 'resume this source' }); kbAnnounce(said); showToast(said, 'warn'); }
|
|
11598
|
+
kbInvalidateRefs();
|
|
11599
|
+
await renderKnowledge();
|
|
11600
|
+
}
|
|
11601
|
+
|
|
11602
|
+
function kbConnShowMenu(btn) {
|
|
11603
|
+
const id = btn.dataset.kbConnMenu;
|
|
11604
|
+
const c = kbConnOf(knowledgeState, id);
|
|
11605
|
+
const name = (c && c.label) || `this ${kbConnThing(c)}`;
|
|
11606
|
+
const pop = kbCatPop(btn,
|
|
11607
|
+
`<button type="button" role="menuitem" class="kb-ds-mi" data-kb-conn-sync="${escapeAttr(id)}" data-command-id="shell.kb-connected-sync#${escapeAttr(id)}" data-command-instance-label="${escapeAttr(name)}">Sync now</button>` +
|
|
11608
|
+
`<button type="button" role="menuitem" class="kb-ds-mi" data-kb-conn-pause="${escapeAttr(id)}" data-kb-conn-paused="${c && c.paused ? 'false' : 'true'}" data-command-id="shell.kb-connected-pause#${escapeAttr(id)}" data-command-instance-label="${escapeAttr(name)}">${c && c.paused ? 'Resume syncing' : 'Pause syncing'}</button>` +
|
|
11609
|
+
(kbConnIsMail(c)
|
|
11610
|
+
? `<button type="button" role="menuitem" class="kb-ds-mi" data-kb-conn-window-menu="${escapeAttr(id)}" data-command-id="shell.kb-connected-window-menu#${escapeAttr(id)}" data-command-instance-label="${escapeAttr(name)}">${(c.outlook && c.outlook.windowDays || 90) !== 90 ? 'Change time window (use the last 90 days again)…' : 'Change time window…'}</button>` +
|
|
11611
|
+
`<button type="button" role="menuitem" class="kb-ds-mi" data-kb-conn-reread="${escapeAttr(id)}" data-command-id="shell.kb-connected-reread#${escapeAttr(id)}" data-command-instance-label="${escapeAttr(name)}">Read every message again…</button>`
|
|
11612
|
+
: kbConnIsTrimble(c)
|
|
11613
|
+
? `<button type="button" role="menuitem" class="kb-ds-mi" data-kb-conn-reread="${escapeAttr(id)}" data-command-id="shell.kb-connected-reread-topics#${escapeAttr(id)}" data-command-instance-label="${escapeAttr(name)}">Read every topic again…</button>`
|
|
11614
|
+
: '') +
|
|
11615
|
+
`<button type="button" role="menuitem" class="kb-ds-mi" data-kb-conn-remove="${escapeAttr(id)}" data-command-id="shell.kb-connected-remove#${escapeAttr(id)}" data-command-instance-label="${escapeAttr(name)}">Remove…</button>` +
|
|
11616
|
+
'<div class="kb-ds-sep" role="separator"></div>' +
|
|
11617
|
+
`<button type="button" role="menuitem" class="kb-ds-mi danger" data-kb-conn-erase="${escapeAttr(id)}" data-command-id="shell.kb-connected-erase#${escapeAttr(id)}" data-command-instance-label="${escapeAttr(name)}">Erase…</button>`,
|
|
11618
|
+
`More for ${name}`, 'menu');
|
|
11619
|
+
const first = pop && pop.querySelector('.kb-ds-mi');
|
|
11620
|
+
if (first) first.focus();
|
|
11621
|
+
}
|
|
11622
|
+
|
|
11623
|
+
/** A themed dialog on the app's modal shell; resolves with the pressed action's id, or null for Cancel and Esc. */
|
|
11624
|
+
function kbConnDialog({ title, bodyHtml, actions, labelId, onOpen }) {
|
|
11625
|
+
return new Promise((resolve) => {
|
|
11626
|
+
const previous = document.activeElement;
|
|
11627
|
+
const backdrop = document.createElement('div');
|
|
11628
|
+
backdrop.className = 'modal-backdrop show kb-conn-dialog';
|
|
11629
|
+
backdrop.setAttribute('role', 'dialog');
|
|
11630
|
+
backdrop.setAttribute('aria-modal', 'true');
|
|
11631
|
+
backdrop.setAttribute('aria-labelledby', labelId);
|
|
11632
|
+
backdrop.innerHTML = `<div class="modal"><div class="modal-title" id="${labelId}">${escapeHtml(title)}</div><div class="kb-conn-dialog-body">${bodyHtml}</div>` +
|
|
11633
|
+
`<div class="modal-actions">${actions.map((a) => `<button type="button" class="${a.tone || ''}" data-kb-conn-act="${escapeAttr(a.id)}"${a.disabled ? ' disabled' : ''}${a.tip ? ` data-tip="${escapeAttr(a.tip)}"` : ''}>${escapeHtml(a.label)}</button>`).join('')}</div></div>`;
|
|
11634
|
+
// Each action's command id is an author-written literal at its call site; set through the DOM, it needs no escaping.
|
|
11635
|
+
backdrop.querySelectorAll('.modal-actions [data-kb-conn-act]').forEach((btn, n) => { btn.dataset.commandId = actions[n].commandId; });
|
|
11636
|
+
const finish = (value) => {
|
|
11637
|
+
backdrop.remove();
|
|
11638
|
+
document.removeEventListener('keydown', onKey, true);
|
|
11639
|
+
if (previous && previous.isConnected) previous.focus({ preventScroll: true });
|
|
11640
|
+
resolve(value);
|
|
11641
|
+
};
|
|
11642
|
+
const onKey = (e) => {
|
|
11643
|
+
if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); finish(null); return; }
|
|
11644
|
+
if (e.key !== 'Tab') return;
|
|
11645
|
+
// Keep focus inside the dialog: an aria-modal dialog must not let Tab walk into the page behind it.
|
|
11646
|
+
const focusable = [...backdrop.querySelectorAll('button:not([disabled]):not([hidden]):not([tabindex="-1"]), input:not([disabled]), summary')];
|
|
11647
|
+
if (!focusable.length) return;
|
|
11648
|
+
const first = focusable[0], last = focusable[focusable.length - 1];
|
|
11649
|
+
if (e.shiftKey && document.activeElement === first) { e.preventDefault(); last.focus(); }
|
|
11650
|
+
else if (!e.shiftKey && document.activeElement === last) { e.preventDefault(); first.focus(); }
|
|
11651
|
+
};
|
|
11652
|
+
backdrop.addEventListener('click', (e) => {
|
|
11653
|
+
const act = e.target.closest('[data-kb-conn-act]');
|
|
11654
|
+
if (act) { finish(act.dataset.kbConnAct === 'cancel' ? null : { id: act.dataset.kbConnAct, form: backdrop }); return; }
|
|
11655
|
+
if (e.target === backdrop) finish(null);
|
|
11656
|
+
});
|
|
11657
|
+
// An action that waits for a choice in the body (Connect waits for a chat) turns on once one is made.
|
|
11658
|
+
backdrop.addEventListener('change', () => {
|
|
11659
|
+
for (const btn of backdrop.querySelectorAll('[data-kb-conn-act][disabled]')) {
|
|
11660
|
+
const needs = actions.find((a) => a.id === btn.dataset.kbConnAct)?.enabledWhen;
|
|
11661
|
+
if (needs && backdrop.querySelector(needs)) { btn.disabled = false; btn.removeAttribute('data-tip'); }
|
|
11662
|
+
}
|
|
11663
|
+
});
|
|
11664
|
+
document.addEventListener('keydown', onKey, true);
|
|
11665
|
+
document.body.append(backdrop);
|
|
11666
|
+
// A body that changes while open (the folder browser) wires itself here; it never resolves the dialog itself.
|
|
11667
|
+
if (onOpen) onOpen(backdrop);
|
|
11668
|
+
(backdrop.querySelector('[data-autofocus]') || backdrop.querySelector('[data-kb-conn-act="cancel"]'))?.focus();
|
|
11669
|
+
});
|
|
11670
|
+
}
|
|
11671
|
+
|
|
11672
|
+
/** The connect dialog's body: the account, the chats to choose from and how far back to read. */
|
|
11673
|
+
function kbConnPickerHtml(options) {
|
|
11674
|
+
const target = options.target || {};
|
|
11675
|
+
const chats = Array.isArray(options.chats) ? options.chats : [];
|
|
11676
|
+
const list = chats.length
|
|
11677
|
+
? `<div class="kb-conn-chats" role="radiogroup" aria-label="Teams chats">${chats.map((chat, n) =>
|
|
11678
|
+
`<label class="kb-conn-chat"><input type="radio" name="kb-conn-chat" value="${escapeAttr(chat.chatId)}" data-label="${escapeAttr(chat.label)}" data-command-id="shell.kb-connected-chat#${escapeAttr(chat.chatId)}" data-command-instance-label="${escapeAttr(chat.label)}"${chat.connected ? ' data-connected' : ''}${n === 0 ? ' data-autofocus' : ''}>` +
|
|
11679
|
+
`<span class="kb-conn-chat-name">${escapeHtml(chat.label)}</span><span class="kb-conn-chat-meta"${chat.connected ? ' data-tip="Already a source in this project. Choosing it syncs that source; it keeps its own time range."' : ''}>` +
|
|
11680
|
+
`${escapeHtml(chat.chatType === 'oneOnOne' ? 'one-on-one' : chat.chatType === 'meeting' ? 'meeting' : 'group')}${chat.connected ? ' · already connected' : ''}</span></label>`).join('')}</div>` +
|
|
11681
|
+
(options.more ? '<div class="kb-conn-note">Showing your 50 most recent chats.</div>' : '')
|
|
11682
|
+
: '<p class="kb-conn-p">This account has no Teams chats FloLess can read.</p>';
|
|
11683
|
+
const windows = [7, 30, 90].map((d) => `<label class="kb-conn-window"><input type="radio" name="kb-conn-window" value="${d}" data-command-id="shell.kb-connected-window#${escapeAttr(d)}" data-command-instance-label="${d} days"${d === 30 ? ' checked' : ''}><span>${d} days</span></label>`).join('');
|
|
11684
|
+
return `<div class="kb-conn-account">Account: <b>${escapeHtml(target.label || 'Microsoft 365 account')}</b> · the one chosen in Integrations ` +
|
|
11685
|
+
'<button type="button" class="kb-link" data-kb-conn-act="integrations" data-command-id="shell.kb-connected-open-integrations">Change</button></div>' +
|
|
11686
|
+
list +
|
|
11687
|
+
`<div class="kb-conn-field"><span class="kb-conn-field-label">Read messages from the last</span><div class="kb-conn-windows" role="radiogroup" aria-label="How far back">${windows}</div></div>` +
|
|
11688
|
+
'<ul class="kb-conn-warn">' +
|
|
11689
|
+
'<li>People’s messages are copied into this project’s knowledge and used the next time it is organized.</li>' +
|
|
11690
|
+
'<li>Each sync reads the 50 newest changes. For a busy chat, sync every day. Messages Teams delivers late may be missed.</li>' +
|
|
11691
|
+
'<li>A message can still mislead what Organize writes, so pages cite the messages they used.</li>' +
|
|
11692
|
+
'</ul>';
|
|
11693
|
+
}
|
|
11694
|
+
|
|
11695
|
+
/** Step 1 of Connect: which kind of source. Nothing is chosen for the person; Back in step 2 returns here. */
|
|
11696
|
+
async function kbConnOpenConnect() {
|
|
11697
|
+
for (;;) {
|
|
11698
|
+
const answer = await kbConnDialog({ title: 'Connect a source', labelId: 'kb-conn-title',
|
|
11699
|
+
bodyHtml: '<div class="kb-conn-kinds" role="radiogroup" aria-label="What to connect">' +
|
|
11700
|
+
[['teams-chat', 'Teams chat', 'Messages from one chat.'], ['outlook-folder', 'Outlook folder', 'Mail received in one folder.'],
|
|
11701
|
+
['trimble-project', 'Trimble Connect project', 'Topics (coordination issues), their comments and ToDos from one project.']].map(([v, label, line], n) =>
|
|
11702
|
+
`<label class="kb-conn-kind"><input type="radio" name="kb-conn-kind" value="${v}" data-command-id="shell.kb-connected-kind#${escapeAttr(v)}" data-command-instance-label="${label}"${n === 0 ? ' data-autofocus' : ''}>` +
|
|
11703
|
+
`<span><b>${label}</b>${line}</span></label>`).join('') + '</div>' +
|
|
11704
|
+
'<p class="kb-conn-p" data-kb-conn-kind-line>FloLess reads each source with the account you chose for that service in Integrations.</p>',
|
|
11705
|
+
onOpen: (box) => box.addEventListener('change', (e) => {
|
|
11706
|
+
if (e.target.name !== 'kb-conn-kind') return;
|
|
11707
|
+
const line = box.querySelector('[data-kb-conn-kind-line]');
|
|
11708
|
+
if (line) line.textContent = `FloLess reads it with the ${e.target.value === 'trimble-project' ? 'Trimble Connect' : 'Microsoft 365'} account chosen in Integrations.`;
|
|
11709
|
+
}),
|
|
11710
|
+
actions: [{ id: 'cancel', label: 'Cancel', commandId: 'shell.kb-connected-cancel' },
|
|
11711
|
+
{ id: 'next', label: 'Next', tone: 'primary', commandId: 'shell.kb-connected-next', disabled: true, tip: 'Choose what to connect first',
|
|
11712
|
+
enabledWhen: 'input[name="kb-conn-kind"]:checked' }] });
|
|
11713
|
+
if (!answer || answer.id !== 'next') return;
|
|
11714
|
+
const kind = answer.form.querySelector('input[name="kb-conn-kind"]:checked')?.value;
|
|
11715
|
+
const result = kind === 'outlook-folder' ? await kbConnOpenOutlook() : kind === 'trimble-project' ? await kbConnOpenTrimble() : await kbConnOpenTeams();
|
|
11716
|
+
if (result !== 'back') return;
|
|
11717
|
+
}
|
|
11718
|
+
}
|
|
11719
|
+
|
|
11720
|
+
/** Change an Outlook source's window, take a partial copy, or read every message again: the person's own click, against
|
|
11721
|
+
* the revision this screen drew (a source that changed meanwhile is shown again instead). */
|
|
11722
|
+
async function kbConnSetMail(sourceId, change, done, revision) {
|
|
11723
|
+
// A Sync now clicked while this change or its reload is still out waits for it, and is sent against the revision the
|
|
11724
|
+
// change answered with: the reload may be superseded by a poll before it lands, so the row alone may still hold the old
|
|
11725
|
+
// one, and the sync would be answered "changed since you looked at it" (#3332 QA).
|
|
11726
|
+
const run = (async () => {
|
|
11727
|
+
let left = null;
|
|
11728
|
+
try {
|
|
11729
|
+
// `revision` is the source as the dialog or row the person acted on showed it, never one a refresh brought in since.
|
|
11730
|
+
const res = await api(kbConnUrl(`/${encodeURIComponent(sourceId)}`), { method: 'PATCH', body: JSON.stringify({ ...change, revision }) });
|
|
11731
|
+
if (res && typeof res.revision === 'string') left = res.revision;
|
|
11732
|
+
kbAnnounce(done);
|
|
11733
|
+
} catch (err) { const said = errorText(err, { action: 'change this source' }); kbAnnounce(said); showToast(said, 'warn'); }
|
|
11734
|
+
kbInvalidateRefs();
|
|
11735
|
+
await renderKnowledge();
|
|
11736
|
+
return left;
|
|
11737
|
+
})();
|
|
11738
|
+
kbConnChanging.set(sourceId, run);
|
|
11739
|
+
try { await run; } finally { if (kbConnChanging.get(sourceId) === run) kbConnChanging.delete(sourceId); }
|
|
11740
|
+
}
|
|
11741
|
+
|
|
11742
|
+
async function kbConnWindowDialog(sourceId) {
|
|
11743
|
+
const c = kbConnOf(knowledgeState, sourceId);
|
|
11744
|
+
if (!kbConnIsMail(c)) return;
|
|
11745
|
+
const now = (c.outlook && c.outlook.windowDays) || 90;
|
|
11746
|
+
const name = c.label || 'this folder';
|
|
11747
|
+
const seen = c.revision;
|
|
11748
|
+
const day = 86_400_000;
|
|
11749
|
+
const consequence = (d) => (d === now ? 'This is the window it keeps now.'
|
|
11750
|
+
: d < now ? `Mail received before ${new Date(Date.now() - d * day).toLocaleDateString()} will be removed from this copy at the next sync.`
|
|
11751
|
+
: 'FloLess reads the older mail over the next syncs, up to 50 messages each.');
|
|
11752
|
+
const answer = await kbConnDialog({ title: `Time window for “${name}”`, labelId: 'kb-conn-window-title',
|
|
11753
|
+
bodyHtml: `<div class="kb-conn-field" style="margin-top:0"><span class="kb-conn-field-label">Keep mail received in the last</span><div class="kb-conn-windows" role="radiogroup" aria-label="Time window">` +
|
|
11754
|
+
[90, 30, 7].map((d) => `<label class="kb-conn-window"><input type="radio" name="kb-conn-window" value="${d}" data-command-id="shell.kb-connected-window-choice#${escapeAttr(d)}" data-command-instance-label="${d} days"${d === now ? ' checked data-autofocus' : ''}><span>${d} days</span></label>`).join('') +
|
|
11755
|
+
`</div></div><p class="kb-conn-p" data-kb-conn-consequence role="status">${escapeHtml(consequence(now))}</p>`,
|
|
11756
|
+
actions: [{ id: 'cancel', label: 'Cancel', commandId: 'shell.kb-connected-cancel' },
|
|
11757
|
+
{ id: 'apply', label: 'Change window', tone: 'primary', commandId: 'shell.kb-connected-window-go' }],
|
|
11758
|
+
onOpen: (box) => {
|
|
11759
|
+
const apply = box.querySelector('[data-kb-conn-act="apply"]');
|
|
11760
|
+
const sync = () => {
|
|
11761
|
+
const d = Number(box.querySelector('input[name="kb-conn-window"]:checked')?.value || now);
|
|
11762
|
+
box.querySelector('[data-kb-conn-consequence]').textContent = consequence(d);
|
|
11763
|
+
apply.hidden = d === now; // nothing to apply: the action is hidden, not disabled
|
|
11764
|
+
};
|
|
11765
|
+
box.addEventListener('change', sync);
|
|
11766
|
+
sync();
|
|
11767
|
+
} });
|
|
11768
|
+
if (!answer || answer.id !== 'apply') return;
|
|
11769
|
+
const d = Number(answer.form.querySelector('input[name="kb-conn-window"]:checked')?.value);
|
|
11770
|
+
if (d === 90 || d === 30 || d === 7) await kbConnSetMail(sourceId, { windowDays: d }, `“${name}” keeps the last ${d} days from the next sync.`, seen);
|
|
11771
|
+
}
|
|
11772
|
+
|
|
11773
|
+
async function kbConnRereadDialog(sourceId) {
|
|
11774
|
+
const c = kbConnOf(knowledgeState, sourceId);
|
|
11775
|
+
if (kbConnIsTrimble(c)) {
|
|
11776
|
+
const name = c.label || 'this project';
|
|
11777
|
+
const seen = c.revision;
|
|
11778
|
+
const answer = await kbConnDialog({ title: `Read every topic in “${name}” again?`, labelId: 'kb-conn-reread-title',
|
|
11779
|
+
bodyHtml: '<p class="kb-conn-p">FloLess reads every topic and its comments again, up to 50 per sync, so it can take many syncs. ' +
|
|
11780
|
+
'It also works out the size limit again, once. Use it when the copy looks wrong or topics are missing.</p>',
|
|
11781
|
+
actions: [{ id: 'cancel', label: 'Cancel', commandId: 'shell.kb-connected-cancel' },
|
|
11782
|
+
{ id: 'reread', label: 'Read again', tone: 'primary', commandId: 'shell.kb-connected-reread-topics-go' }] });
|
|
11783
|
+
if (answer && answer.id === 'reread') await kbConnSetMail(sourceId, { reread: true }, `“${name}” is read again from the next sync, up to 50 topics each.`, seen);
|
|
11784
|
+
return;
|
|
11785
|
+
}
|
|
11786
|
+
if (!kbConnIsMail(c)) return;
|
|
11787
|
+
const name = c.label || 'this folder';
|
|
11788
|
+
const seen = c.revision;
|
|
11789
|
+
const answer = await kbConnDialog({ title: `Read every message in “${name}” again?`, labelId: 'kb-conn-reread-title',
|
|
11790
|
+
bodyHtml: '<p class="kb-conn-p">FloLess reads every message in the window again, up to 50 per sync, so it can take many syncs. ' +
|
|
11791
|
+
'Use it when a copy looks wrong or messages were left out.</p>',
|
|
11792
|
+
actions: [{ id: 'cancel', label: 'Cancel', commandId: 'shell.kb-connected-cancel' },
|
|
11793
|
+
{ id: 'reread', label: 'Read again', tone: 'primary', commandId: 'shell.kb-connected-reread-go' }] });
|
|
11794
|
+
if (answer && answer.id === 'reread') await kbConnSetMail(sourceId, { reread: true }, `“${name}” is read again from the next sync, up to 50 messages each.`, seen);
|
|
11795
|
+
}
|
|
11796
|
+
|
|
11797
|
+
/** When the options cannot be listed: the reason, and the way on it names. */
|
|
11798
|
+
/** The dialog when the first list could not be read. Returns 'retry' when the person asked to try again. */
|
|
11799
|
+
async function kbConnOptionsFailed(err, title, library = 'microsoft-365') {
|
|
11800
|
+
const body = (err && err.body) || {};
|
|
11801
|
+
const choices = Array.isArray(body.choices) ? body.choices : [];
|
|
11802
|
+
const answer = await kbConnDialog({ title, labelId: 'kb-conn-title',
|
|
11803
|
+
bodyHtml: `<p class="kb-conn-p">${escapeHtml(errorText(err, { action: 'list what can be connected', retrySafe: true }))}</p>`,
|
|
11804
|
+
actions: [{ id: 'cancel', label: 'Close', commandId: 'shell.kb-connected-cancel' },
|
|
11805
|
+
...(choices.includes('retry') ? [{ id: 'retry', label: 'Try again', tone: 'primary', commandId: 'shell.kb-connected-options-retry' }] : []),
|
|
11806
|
+
...(choices.includes('open-integrations') ? [{ id: 'integrations', label: 'Open Integrations', tone: 'primary', commandId: 'shell.kb-connected-open-integrations' }] : []),
|
|
11807
|
+
...(choices.includes('open-tools') ? [{ id: 'tools', label: 'Open Tools', tone: 'primary', commandId: 'shell.kb-connected-open-tools' }] : [])] });
|
|
11808
|
+
if (answer && answer.id === 'integrations' && typeof openIntegrations === 'function') openIntegrations();
|
|
11809
|
+
if (answer && answer.id === 'tools' && typeof openLibrary === 'function') openLibrary(library, { tab: 'available' });
|
|
11810
|
+
return answer && answer.id === 'retry' ? 'retry' : null;
|
|
11811
|
+
}
|
|
11812
|
+
|
|
11813
|
+
const KB_CONN_ROOT = { id: 'msgfolderroot', label: 'Mailbox' };
|
|
11814
|
+
const kbConnFolderUrl = (parent, skip, target) => kbConnUrl(`/options?${new URLSearchParams({ kind: 'outlook-folder', parent, skip: String(skip),
|
|
11815
|
+
...(target && target.principal ? { expectedPrincipal: target.principal } : {}), ...(target && target.tenant ? { expectedTenant: target.tenant } : {}) })}`);
|
|
11816
|
+
|
|
11817
|
+
const kbConnProjectsUrl = (region, skip, target) => kbConnUrl(`/options?${new URLSearchParams({ kind: 'trimble-project', region, skip: String(skip),
|
|
11818
|
+
...(target && target.principal ? { expectedPrincipal: target.principal } : {}) })}`);
|
|
11819
|
+
const kbConnRegionEmpty = () => ({ projects: [], nextSkip: null, failed: null, omitted: 0, loading: true });
|
|
11820
|
+
|
|
11821
|
+
/** Step 2 for Trimble Connect (slice 2 plan §18 #5): every published region is asked for its first page, and the projects
|
|
11822
|
+
* are grouped by region; each region pages and retries on its own. A region with nothing to say is not shown. */
|
|
11823
|
+
async function kbConnOpenTrimble() {
|
|
11824
|
+
const proj = current;
|
|
11825
|
+
if (!proj) return null;
|
|
11826
|
+
// The first region verifies the account and says which regions exist; a stop here (not signed in) ends the dialog.
|
|
11827
|
+
let first;
|
|
11828
|
+
for (;;) {
|
|
11829
|
+
try { first = await api(kbConnProjectsUrl('europe', 0, null), { timeoutMs: 60_000 }); break; }
|
|
11830
|
+
catch (err) { if (await kbConnOptionsFailed(err, 'Connect a Trimble Connect project', 'trimble-connect') !== 'retry') return null; }
|
|
11831
|
+
}
|
|
11832
|
+
const view = { target: first.target, regions: {}, notice: null, picked: null };
|
|
11833
|
+
const order = KB_CONN_REGIONS.map(([r]) => r).filter((r) => (first.regions || []).includes(r));
|
|
11834
|
+
for (const r of order) view.regions[r] = kbConnRegionEmpty();
|
|
11835
|
+
const take = (r, res, append) => {
|
|
11836
|
+
const reg = view.regions[r];
|
|
11837
|
+
reg.loading = false;
|
|
11838
|
+
reg.failed = res.failed || null;
|
|
11839
|
+
reg.projects = append ? reg.projects.concat(res.projects || []) : (res.projects || []);
|
|
11840
|
+
reg.nextSkip = res.nextSkip == null ? null : res.nextSkip;
|
|
11841
|
+
reg.omitted = (append ? reg.omitted : 0) + (res.omitted || 0);
|
|
11842
|
+
};
|
|
11843
|
+
if (view.regions.europe) take('europe', first, false);
|
|
11844
|
+
const shown = () => order.filter((r) => { const g = view.regions[r]; return g.projects.length || g.failed || g.loading; });
|
|
11845
|
+
const picker = () => {
|
|
11846
|
+
if (view.notice) {
|
|
11847
|
+
return `<div class="kb-conn-stop" role="alert"><b>${escapeHtml(view.notice.title)}</b> ${escapeHtml(view.notice.text)}` +
|
|
11848
|
+
'<div class="kb-conn-choices"><button type="button" class="kb-link kb-conn-primary" data-kb-conn-restart data-command-id="shell.kb-connected-restart">Start again</button></div></div>';
|
|
11849
|
+
}
|
|
11850
|
+
const regions = shown();
|
|
11851
|
+
const loading = order.some((r) => view.regions[r].loading);
|
|
11852
|
+
if (!order.length) {
|
|
11853
|
+
// No region was asked: an AWARE that publishes none FloLess knows is not "no projects".
|
|
11854
|
+
return '<p class="kb-conn-p">The installed AWARE lists no Trimble Connect region FloLess can read, so no region was asked for projects. Update AWARE when FloLess offers it.</p>';
|
|
11855
|
+
}
|
|
11856
|
+
if (!regions.length) {
|
|
11857
|
+
return '<p class="kb-conn-p">No Trimble Connect projects found for this account in any region. ' +
|
|
11858
|
+
'<button type="button" class="kb-link" data-kb-conn-act="integrations" data-command-id="shell.kb-connected-open-integrations">Check the account in Integrations</button></p>';
|
|
11859
|
+
}
|
|
11860
|
+
// One region with projects and nothing else to say needs no heading: a lone heading is noise.
|
|
11861
|
+
const headed = !(regions.length === 1 && !loading && !view.regions[regions[0]].failed);
|
|
11862
|
+
const block = (r) => {
|
|
11863
|
+
const g = view.regions[r];
|
|
11864
|
+
const name = kbConnRegionName(r);
|
|
11865
|
+
const rows = g.projects.map((p) => `<label class="kb-conn-chat"><input type="radio" name="kb-conn-project" value="${escapeAttr(p.projectId)}" data-region="${escapeAttr(r)}" data-label="${escapeAttr(p.label)}"` +
|
|
11866
|
+
`${p.connected ? ' data-connected' : ''}${view.picked === `${r}:${p.projectId}` ? ' checked' : ''} data-command-id="shell.kb-connected-project#${escapeAttr(`${r}:${p.projectId}`)}" data-command-instance-label="${escapeAttr(p.label)}">` +
|
|
11867
|
+
`<span class="kb-conn-chat-name" data-tip="${escapeAttr(p.label)}">${escapeHtml(p.label)}</span>` +
|
|
11868
|
+
`<span class="kb-conn-chat-meta"${p.connected ? ' data-tip="Already a source in this project. Choosing it syncs that source."' : ''}>${p.connected ? 'already connected' : ''}</span></label>`).join('');
|
|
11869
|
+
const busy = g.loading ? ' aria-busy="true" disabled' : '';
|
|
11870
|
+
const tail = (g.failed ? `<div class="kb-conn-note">${escapeHtml(g.failed)} <button type="button" class="kb-link" data-kb-conn-region-retry="${escapeAttr(r)}"${busy} data-command-id="shell.kb-connected-region-retry#${escapeAttr(r)}" data-command-instance-label="${escapeAttr(name)}">${g.loading ? 'Loading…' : 'Retry'}</button></div>` : '') +
|
|
11871
|
+
(g.nextSkip != null ? `<button type="button" class="kb-link kb-conn-more-folders" data-kb-conn-region-more="${escapeAttr(r)}"${busy} data-command-id="shell.kb-connected-region-more#${escapeAttr(r)}" data-command-instance-label="${escapeAttr(name)}">${g.loading ? 'Loading…' : 'Show more projects'}</button>` : '') +
|
|
11872
|
+
(g.omitted > 0 ? `<div class="kb-conn-note">${escapeHtml(kbConnPlural(g.omitted, 'project', 'projects'))} could not be listed by Trimble and ${g.omitted === 1 ? 'is' : 'are'} not shown.</div>` : '') +
|
|
11873
|
+
(g.loading && !g.failed && !g.projects.length ? '<div class="kb-conn-note">Loading…</div>' : '');
|
|
11874
|
+
return `<div class="kb-conn-region" role="group" aria-label="${escapeAttr(name)}">${headed ? `<h4 class="kb-uncategorized-head kb-conn-region-head">${escapeHtml(name)}</h4>` : ''}${rows}${tail}</div>`;
|
|
11875
|
+
};
|
|
11876
|
+
return `<div class="kb-conn-chats kb-conn-regions" role="radiogroup" aria-label="Trimble Connect projects"${loading ? ' aria-busy="true"' : ''}>${regions.map(block).join('')}</div>` +
|
|
11877
|
+
(loading ? '<div class="kb-conn-note" role="status">Looking in every Trimble region…</div>' : '');
|
|
11878
|
+
};
|
|
11879
|
+
const answer = await kbConnDialog({ title: 'Connect a Trimble Connect project', labelId: 'kb-conn-title',
|
|
11880
|
+
bodyHtml: `<div class="kb-conn-account">Account: <b>${escapeHtml(view.target.label || 'Trimble Connect account')}</b> · the one chosen in Integrations ` +
|
|
11881
|
+
'<button type="button" class="kb-link" data-kb-conn-act="integrations" data-command-id="shell.kb-connected-open-integrations">Change</button></div>' +
|
|
11882
|
+
`<div data-kb-conn-picker>${picker()}</div>` +
|
|
11883
|
+
'<ul class="kb-conn-warn">' +
|
|
11884
|
+
'<li>The project’s topics (coordination issues), their comments and its ToDos are copied into this project’s knowledge as text and used the next time it is organized.</li>' +
|
|
11885
|
+
`<li>${escapeHtml(KB_CONN_TRIMBLE_NOT_INCLUDED)}</li>` +
|
|
11886
|
+
'<li>Anyone in the Trimble project can write a topic or a comment, and it can mislead what Organize writes, so pages cite what they used.</li>' +
|
|
11887
|
+
'</ul>' +
|
|
11888
|
+
'<details class="kb-conn-gaps"><summary data-command-id="shell.kb-connected-more-about">More about what is copied</summary><ul>' +
|
|
11889
|
+
'<li>Closed topics stay in the copy, with their status.</li>' +
|
|
11890
|
+
'<li>Each sync reads at most 50 topics, so a large project takes several syncs at first.</li>' +
|
|
11891
|
+
'<li>The newest 200 comments of a topic are kept; the topic says how many older ones are not.</li>' +
|
|
11892
|
+
'<li>A project with more than 5,000 topics or ToDos is kept as a partial copy, and the row says so.</li>' +
|
|
11893
|
+
'<li>A topic Trimble stops listing leaves after two syncs, and the page says so.</li>' +
|
|
11894
|
+
'</ul></details>',
|
|
11895
|
+
actions: [{ id: 'back', label: 'Back', commandId: 'shell.kb-connected-back' }, { id: 'cancel', label: 'Cancel', commandId: 'shell.kb-connected-cancel' },
|
|
11896
|
+
{ id: 'connect', label: 'Connect and sync', tone: 'primary', commandId: 'shell.kb-connected-connect', disabled: true, tip: 'Choose a project first' }],
|
|
11897
|
+
onOpen: (box) => {
|
|
11898
|
+
const host = box.querySelector('[data-kb-conn-picker]');
|
|
11899
|
+
const connect = box.querySelector('.modal-actions [data-kb-conn-act="connect"]');
|
|
11900
|
+
// A repaint keeps focus on the same project, Show more or Retry (by what it stands for, not by node).
|
|
11901
|
+
const keyOf = (el) => (!el || !el.dataset ? null : el.name === 'kb-conn-project' ? `p:${el.dataset.region}:${el.value}`
|
|
11902
|
+
: el.dataset.kbConnRegionMore ? `m:${el.dataset.kbConnRegionMore}` : el.dataset.kbConnRegionRetry ? `r:${el.dataset.kbConnRegionRetry}` : null);
|
|
11903
|
+
const paint = () => {
|
|
11904
|
+
const focused = document.activeElement && host.contains(document.activeElement) ? keyOf(document.activeElement) : null;
|
|
11905
|
+
host.innerHTML = picker();
|
|
11906
|
+
// A choice whose radio is no longer drawn is no choice: Connect never sends a project the person cannot see.
|
|
11907
|
+
if (view.picked && ![...host.querySelectorAll('input[name="kb-conn-project"]')].some((el) => `${el.dataset.region}:${el.value}` === view.picked)) view.picked = null;
|
|
11908
|
+
const ok = !!view.picked && !view.notice;
|
|
11909
|
+
connect.disabled = !ok;
|
|
11910
|
+
if (ok) connect.removeAttribute('data-tip'); else connect.dataset.tip = 'Choose a project first';
|
|
11911
|
+
if (focused) {
|
|
11912
|
+
const back = [...host.querySelectorAll('input[name="kb-conn-project"], [data-kb-conn-region-more], [data-kb-conn-region-retry]')].find((el) => keyOf(el) === focused);
|
|
11913
|
+
(back && !back.disabled ? back : host.querySelector('input[name="kb-conn-project"]'))?.focus();
|
|
11914
|
+
}
|
|
11915
|
+
};
|
|
11916
|
+
let epoch = 0; // Start again drops every answer that was still on its way
|
|
11917
|
+
const load = async (r, append) => {
|
|
11918
|
+
if (view.notice || !view.regions[r]) return;
|
|
11919
|
+
const mine = epoch;
|
|
11920
|
+
try {
|
|
11921
|
+
view.regions[r].loading = true;
|
|
11922
|
+
paint();
|
|
11923
|
+
let res;
|
|
11924
|
+
try { res = await api(kbConnProjectsUrl(r, append ? view.regions[r].nextSkip : 0, view.target), { timeoutMs: 60_000 }); }
|
|
11925
|
+
catch (err) {
|
|
11926
|
+
// The server's own sentence when it wrote one; a network failure or a timeout in plain words, never raw (errorText).
|
|
11927
|
+
res = { failed: errorText(err, { action: `list your ${kbConnRegionName(r)} projects`, retrySafe: true }), projects: [] };
|
|
11928
|
+
}
|
|
11929
|
+
if (mine !== epoch || view.notice || !box.isConnected) return;
|
|
11930
|
+
settle(r, res, append);
|
|
11931
|
+
} catch (err) {
|
|
11932
|
+
// Anything else leaves the region answerable, never stuck on Loading.
|
|
11933
|
+
console.warn('kb-conn: a Trimble region could not be drawn', err);
|
|
11934
|
+
if (mine !== epoch || !box.isConnected || !view.regions[r]) return;
|
|
11935
|
+
view.regions[r].loading = false;
|
|
11936
|
+
view.regions[r].failed = 'FloLess could not show this region. Retry in a moment.';
|
|
11937
|
+
paint();
|
|
11938
|
+
}
|
|
11939
|
+
};
|
|
11940
|
+
const settle = (r, res, append) => {
|
|
11941
|
+
if (res.targetChanged) {
|
|
11942
|
+
view.notice = { title: 'The Trimble Connect account changed while this was open.', text: 'The projects shown may belong to the other account, so start again.' };
|
|
11943
|
+
view.target = res.target || view.target;
|
|
11944
|
+
view.picked = null;
|
|
11945
|
+
box.querySelector('.kb-conn-account b').textContent = view.target.label || 'Trimble Connect account';
|
|
11946
|
+
paint();
|
|
11947
|
+
return;
|
|
11948
|
+
}
|
|
11949
|
+
take(r, res, append);
|
|
11950
|
+
paint();
|
|
11951
|
+
};
|
|
11952
|
+
host.addEventListener('change', (e) => {
|
|
11953
|
+
if (e.target.name !== 'kb-conn-project') return;
|
|
11954
|
+
view.picked = `${e.target.dataset.region}:${e.target.value}`;
|
|
11955
|
+
connect.disabled = false;
|
|
11956
|
+
connect.removeAttribute('data-tip');
|
|
11957
|
+
});
|
|
11958
|
+
host.addEventListener('click', (e) => {
|
|
11959
|
+
const more = e.target.closest('[data-kb-conn-region-more]');
|
|
11960
|
+
if (more) { void load(more.dataset.kbConnRegionMore, true); return; }
|
|
11961
|
+
const retry = e.target.closest('[data-kb-conn-region-retry]');
|
|
11962
|
+
if (retry) { void load(retry.dataset.kbConnRegionRetry, false); return; }
|
|
11963
|
+
if (e.target.closest('[data-kb-conn-restart]')) {
|
|
11964
|
+
epoch += 1;
|
|
11965
|
+
view.notice = null;
|
|
11966
|
+
view.picked = null;
|
|
11967
|
+
for (const r of order) view.regions[r] = kbConnRegionEmpty();
|
|
11968
|
+
paint();
|
|
11969
|
+
for (const r of order) void load(r, false);
|
|
11970
|
+
}
|
|
11971
|
+
});
|
|
11972
|
+
for (const r of order) if (r !== 'europe') void load(r, false);
|
|
11973
|
+
} });
|
|
11974
|
+
if (answer && answer.id === 'back') return 'back';
|
|
11975
|
+
if (answer && answer.id === 'integrations') { if (typeof openIntegrations === 'function') openIntegrations(); return null; }
|
|
11976
|
+
if (!answer || answer.id !== 'connect' || !current || current.id !== proj.id) return null;
|
|
11977
|
+
const picked = answer.form.querySelector('input[name="kb-conn-project"]:checked');
|
|
11978
|
+
if (!picked) return null;
|
|
11979
|
+
try {
|
|
11980
|
+
const res = await api(kbConnUrl(''), { method: 'POST', body: JSON.stringify({ kind: 'trimble-project', projectId: picked.value, region: picked.dataset.region,
|
|
11981
|
+
label: picked.dataset.label, expected: view.target }) });
|
|
11982
|
+
kbAnnounce(picked.hasAttribute('data-connected') ? `“${picked.dataset.label}” is already connected. Syncing it…` : `Connected “${picked.dataset.label}”. Syncing…`);
|
|
11983
|
+
await renderKnowledge();
|
|
11984
|
+
if (res.source && res.source.sourceId) await kbConnSync(res.source.sourceId);
|
|
11985
|
+
} catch (err) {
|
|
11986
|
+
const said = errorText(err, { action: 'connect that project' });
|
|
11987
|
+
kbAnnounce(said);
|
|
11988
|
+
showToast(said, 'warn');
|
|
11989
|
+
await renderKnowledge();
|
|
11990
|
+
}
|
|
11991
|
+
return null;
|
|
11992
|
+
}
|
|
11993
|
+
|
|
11994
|
+
/** Step 2 for Outlook: one level of folders at a time. Only the chosen folder is connected, never its subfolders. */
|
|
11995
|
+
async function kbConnOpenOutlook() {
|
|
11996
|
+
const proj = current;
|
|
11997
|
+
if (!proj) return null;
|
|
11998
|
+
let first;
|
|
11999
|
+
for (;;) {
|
|
12000
|
+
try { first = await api(kbConnFolderUrl('msgfolderroot', 0, null), { timeoutMs: 60_000 }); break; }
|
|
12001
|
+
catch (err) { if (await kbConnOptionsFailed(err, 'Connect an Outlook folder') !== 'retry') return null; }
|
|
12002
|
+
}
|
|
12003
|
+
const view = { target: first.target, path: [KB_CONN_ROOT], page: first, folders: first.folders || [], notice: null, loading: false };
|
|
12004
|
+
const browser = () => {
|
|
12005
|
+
const level = view.path[view.path.length - 1];
|
|
12006
|
+
const crumbs = view.path.map((p, i) => (i === view.path.length - 1
|
|
12007
|
+
? `<span aria-current="location" data-tip="${escapeAttr(p.label)}">${escapeHtml(p.label)}</span>`
|
|
12008
|
+
: `<button type="button" class="kb-link" data-kb-conn-crumb="${i}" data-tip="${escapeAttr(p.label)}" data-command-id="shell.kb-connected-crumb#${escapeAttr(i)}" data-command-instance-label="${escapeAttr(p.label)}">${escapeHtml(p.label)}</button>`))
|
|
12009
|
+
.join('<span class="kb-conn-crumb-sep" aria-hidden="true">›</span>');
|
|
12010
|
+
if (view.notice) {
|
|
12011
|
+
return `<nav class="kb-conn-crumbs" aria-label="Folder path">${crumbs}</nav><div class="kb-conn-stop" role="alert"><b>${escapeHtml(view.notice.title)}</b> ${escapeHtml(view.notice.text)}` +
|
|
12012
|
+
`<div class="kb-conn-choices"><button type="button" class="kb-link kb-conn-primary" data-kb-conn-restart data-command-id="shell.kb-connected-restart">${escapeHtml(view.notice.button)}</button></div></div>`;
|
|
12013
|
+
}
|
|
12014
|
+
const checked = view.picked;
|
|
12015
|
+
const row = (f, isThis) => {
|
|
12016
|
+
const meta = isThis ? 'this folder itself'
|
|
12017
|
+
: [kbConnPlural(f.totalCount, 'mail', 'mails'), f.childCount ? kbConnPlural(f.childCount, 'subfolder', 'subfolders') : '', f.connected ? 'already connected' : ''].filter(Boolean).join(' · ');
|
|
12018
|
+
const open = !isThis && f.childCount > 0
|
|
12019
|
+
? `<button type="button" class="kb-link kb-conn-folder-open" data-kb-conn-open="${escapeAttr(f.folderId)}" data-label="${escapeAttr(f.label)}" tabindex="${checked === f.folderId ? '0' : '-1'}"` +
|
|
12020
|
+
` aria-label="Open subfolders of ${escapeAttr(f.label)}" data-tip="Browse inside this folder. Only the folder you choose is connected, not its subfolders."` +
|
|
12021
|
+
` data-command-id="shell.kb-connected-folder-open#${escapeAttr(f.folderId)}" data-command-instance-label="${escapeAttr(f.label)}">Open subfolders ›</button>` : '';
|
|
12022
|
+
return `<div class="kb-conn-folder${isThis ? ' this' : ''}"><label class="kb-conn-chat"><input type="radio" name="kb-conn-folder" value="${escapeAttr(f.folderId)}" data-label="${escapeAttr(f.label)}"` +
|
|
12023
|
+
`${f.connected ? ' data-connected' : ''}${checked === f.folderId ? ' checked' : ''}${view.loading ? ' disabled' : ''} data-command-id="shell.kb-connected-folder#${escapeAttr(f.folderId)}" data-command-instance-label="${escapeAttr(f.label)}">` +
|
|
12024
|
+
`<span class="kb-conn-chat-name" data-tip="${escapeAttr(f.label)}">${escapeHtml(isThis ? `This folder (${f.label})` : f.label)}</span>` +
|
|
12025
|
+
`<span class="kb-conn-chat-meta"${f.connected ? ' data-tip="Already a source in this project. Choosing it syncs that source."' : ''}>${escapeHtml(meta)}</span></label>${open}</div>`;
|
|
12026
|
+
};
|
|
12027
|
+
const here = level.id === 'msgfolderroot' ? '' : row({ folderId: level.id, label: level.label, totalCount: 0, childCount: 0 }, true);
|
|
12028
|
+
const list = view.folders.length || here
|
|
12029
|
+
? `<div class="kb-conn-folders" role="radiogroup" aria-label="Outlook folders in ${escapeAttr(level.label)}"${view.loading ? ' aria-busy="true"' : ''}>${here}${view.folders.map((f) => row(f, false)).join('')}` +
|
|
12030
|
+
(view.folders.length ? '' : '<div class="kb-conn-note" style="padding:4px 8px">No subfolders here. Choose this folder, or go back.</div>') + '</div>'
|
|
12031
|
+
: `<p class="kb-conn-p">${level.id === 'msgfolderroot' ? 'This account has no mail folders FloLess can read.' : 'No subfolders here.'}</p>`;
|
|
12032
|
+
const notes = [view.page.omitted > 0 ? `${kbConnPlural(view.page.omitted, 'folder', 'folders')} could not be listed by Outlook and ${view.page.omitted === 1 ? 'is' : 'are'} not shown.` : '',
|
|
12033
|
+
view.page.limitReached ? 'Outlook stopped listing here, so more folders may exist. Open a parent folder to narrow it down.' : ''].filter(Boolean);
|
|
12034
|
+
return `<nav class="kb-conn-crumbs" aria-label="Folder path">${crumbs}</nav>${list}` +
|
|
12035
|
+
(view.page.nextSkip != null ? `<button type="button" class="kb-link kb-conn-more-folders" data-kb-conn-more${view.loading ? ' aria-busy="true"' : ''} data-command-id="shell.kb-connected-more-folders">${view.loading ? 'Loading…' : 'Show more folders'}</button>` : '') +
|
|
12036
|
+
notes.map((n) => `<div class="kb-conn-note">${escapeHtml(n)}</div>`).join('') +
|
|
12037
|
+
(view.loading ? '<div class="kb-sr" role="status">Loading folders…</div>' : '');
|
|
12038
|
+
};
|
|
12039
|
+
const answer = await kbConnDialog({ title: 'Connect an Outlook folder', labelId: 'kb-conn-title',
|
|
12040
|
+
bodyHtml: `<div class="kb-conn-account">Account: <b>${escapeHtml(view.target.label || 'Microsoft 365 account')}</b> · the one chosen in Integrations ` +
|
|
12041
|
+
'<button type="button" class="kb-link" data-kb-conn-act="integrations" data-command-id="shell.kb-connected-open-integrations">Change</button></div>' +
|
|
12042
|
+
`<div data-kb-conn-browser>${browser()}</div>` +
|
|
12043
|
+
'<p class="kb-conn-fixed">FloLess keeps the mail received in the last 90 days, and older mail drops off as the window moves.</p>' +
|
|
12044
|
+
'<ul class="kb-conn-warn">' +
|
|
12045
|
+
'<li>Mail in this folder is copied into this project’s knowledge and used the next time it is organized.</li>' +
|
|
12046
|
+
'<li>Anyone can send you a mail, and a mail can mislead what Organize writes, so pages cite the mail they used.</li>' +
|
|
12047
|
+
'<li>A folder with more than 100,000 mails in 90 days asks you to keep a shorter window or a partial copy.</li>' +
|
|
12048
|
+
'</ul>' +
|
|
12049
|
+
'<details class="kb-conn-gaps"><summary data-command-id="shell.kb-connected-more-about">More about what is copied</summary><ul>' +
|
|
12050
|
+
'<li>Attachments are listed by name only.</li>' +
|
|
12051
|
+
'<li>Mail deleted in Outlook leaves this copy at the next sync.</li>' +
|
|
12052
|
+
'<li>Mail Outlook stops listing leaves after two syncs, and the page says so.</li>' +
|
|
12053
|
+
'<li>Each sync reads at most 50 messages; drafts and undated mail are left out.</li>' +
|
|
12054
|
+
'</ul></details>',
|
|
12055
|
+
actions: [{ id: 'back', label: 'Back', commandId: 'shell.kb-connected-back' }, { id: 'cancel', label: 'Cancel', commandId: 'shell.kb-connected-cancel' },
|
|
12056
|
+
{ id: 'connect', label: 'Connect and sync', tone: 'primary', commandId: 'shell.kb-connected-connect', disabled: true, tip: 'Choose a folder first' }],
|
|
12057
|
+
onOpen: (box) => {
|
|
12058
|
+
const host = box.querySelector('[data-kb-conn-browser]');
|
|
12059
|
+
const connect = box.querySelector('[data-kb-conn-act="connect"]');
|
|
12060
|
+
const paint = (focusFirst) => {
|
|
12061
|
+
host.innerHTML = browser();
|
|
12062
|
+
const ok = !!view.picked && !view.notice && !view.loading;
|
|
12063
|
+
connect.disabled = !ok;
|
|
12064
|
+
if (ok) connect.removeAttribute('data-tip'); else connect.dataset.tip = 'Choose a folder first';
|
|
12065
|
+
if (focusFirst) host.querySelector('input[name="kb-conn-folder"]')?.focus();
|
|
12066
|
+
};
|
|
12067
|
+
const load = async (path, append) => {
|
|
12068
|
+
if (view.loading) return;
|
|
12069
|
+
const level = path[path.length - 1];
|
|
12070
|
+
view.loading = true;
|
|
12071
|
+
paint(false);
|
|
12072
|
+
let res;
|
|
12073
|
+
try { res = await api(kbConnFolderUrl(level.id, append ? view.page.nextSkip : 0, view.target), { timeoutMs: 60_000 }); }
|
|
12074
|
+
catch (err) {
|
|
12075
|
+
view.loading = false;
|
|
12076
|
+
view.notice = { title: 'Folders not listed.', text: err.message, button: 'Start again from the mailbox' };
|
|
12077
|
+
paint(false);
|
|
12078
|
+
return;
|
|
12079
|
+
}
|
|
12080
|
+
view.loading = false;
|
|
12081
|
+
if (res.targetChanged) {
|
|
12082
|
+
view.target = res.target;
|
|
12083
|
+
// The listed folders and the path belong to the other account: none of them may stay selectable.
|
|
12084
|
+
view.picked = null;
|
|
12085
|
+
view.path = [KB_CONN_ROOT];
|
|
12086
|
+
view.folders = [];
|
|
12087
|
+
view.page = { nextSkip: null, omitted: 0, limitReached: false };
|
|
12088
|
+
view.notice = { title: 'The Microsoft 365 account changed while this was open.', text: 'The folders shown may belong to the other account, so start again.', button: 'Start again' };
|
|
12089
|
+
box.querySelector('.kb-conn-account b').textContent = res.target.label || 'Microsoft 365 account';
|
|
12090
|
+
paint(false);
|
|
12091
|
+
return;
|
|
12092
|
+
}
|
|
12093
|
+
// A level that listed replaces any earlier failure; the account-change reset never reaches here (code review R2 #3).
|
|
12094
|
+
view.notice = null;
|
|
12095
|
+
view.path = path;
|
|
12096
|
+
view.page = res;
|
|
12097
|
+
view.folders = append ? view.folders.concat(res.folders || []) : (res.folders || []);
|
|
12098
|
+
if (!append) view.picked = null;
|
|
12099
|
+
paint(!append);
|
|
12100
|
+
if (!append) kbAnnounce(`${level.label}: ${kbConnPlural(view.folders.length, 'folder', 'folders')}.`);
|
|
12101
|
+
};
|
|
12102
|
+
host.addEventListener('change', (e) => {
|
|
12103
|
+
if (e.target.name !== 'kb-conn-folder' || view.loading) return;
|
|
12104
|
+
view.picked = e.target.value;
|
|
12105
|
+
// Roving Tab stop: only the chosen row's Open subfolders button is in the Tab order.
|
|
12106
|
+
host.querySelectorAll('[data-kb-conn-open]').forEach((b) => { b.tabIndex = b.dataset.kbConnOpen === view.picked ? 0 : -1; });
|
|
12107
|
+
connect.disabled = false;
|
|
12108
|
+
connect.removeAttribute('data-tip');
|
|
12109
|
+
});
|
|
12110
|
+
host.addEventListener('click', (e) => {
|
|
12111
|
+
const open = e.target.closest('[data-kb-conn-open]');
|
|
12112
|
+
if (open) { e.preventDefault(); void load([...view.path, { id: open.dataset.kbConnOpen, label: open.dataset.label }], false); return; }
|
|
12113
|
+
const crumb = e.target.closest('[data-kb-conn-crumb]');
|
|
12114
|
+
if (crumb) { void load(view.path.slice(0, Number(crumb.dataset.kbConnCrumb) + 1), false); return; }
|
|
12115
|
+
if (e.target.closest('[data-kb-conn-more]')) { void load(view.path, true); return; }
|
|
12116
|
+
if (e.target.closest('[data-kb-conn-restart]')) {
|
|
12117
|
+
view.notice = null;
|
|
12118
|
+
view.picked = null;
|
|
12119
|
+
view.path = [KB_CONN_ROOT];
|
|
12120
|
+
view.folders = [];
|
|
12121
|
+
view.page = { nextSkip: null, omitted: 0, limitReached: false };
|
|
12122
|
+
void load([KB_CONN_ROOT], false);
|
|
12123
|
+
}
|
|
12124
|
+
});
|
|
12125
|
+
} });
|
|
12126
|
+
if (answer && answer.id === 'back') return 'back';
|
|
12127
|
+
if (answer && answer.id === 'integrations') { if (typeof openIntegrations === 'function') openIntegrations(); return null; }
|
|
12128
|
+
if (!answer || answer.id !== 'connect' || !current || current.id !== proj.id) return null;
|
|
12129
|
+
const picked = answer.form.querySelector('input[name="kb-conn-folder"]:checked');
|
|
12130
|
+
if (!picked) return null;
|
|
12131
|
+
try {
|
|
12132
|
+
const res = await api(kbConnUrl(''), { method: 'POST', body: JSON.stringify({ kind: 'outlook-folder', folderId: picked.value, label: picked.dataset.label, expected: view.target }) });
|
|
12133
|
+
kbAnnounce(picked.hasAttribute('data-connected') ? `“${picked.dataset.label}” is already connected. Syncing it…` : `Connected “${picked.dataset.label}”. Syncing…`);
|
|
12134
|
+
await renderKnowledge();
|
|
12135
|
+
if (res.source && res.source.sourceId) await kbConnSync(res.source.sourceId);
|
|
12136
|
+
} catch (err) {
|
|
12137
|
+
const said = errorText(err, { action: 'connect that folder' });
|
|
12138
|
+
kbAnnounce(said);
|
|
12139
|
+
showToast(said, 'warn');
|
|
12140
|
+
await renderKnowledge();
|
|
12141
|
+
}
|
|
12142
|
+
return null;
|
|
12143
|
+
}
|
|
12144
|
+
|
|
12145
|
+
async function kbConnOpenTeams() {
|
|
12146
|
+
const proj = current;
|
|
12147
|
+
if (!proj) return null;
|
|
12148
|
+
let options;
|
|
12149
|
+
for (;;) {
|
|
12150
|
+
try { options = await api(kbConnUrl('/options'), { timeoutMs: 60_000 }); break; }
|
|
12151
|
+
catch (err) { if (await kbConnOptionsFailed(err, 'Connect a Teams chat') !== 'retry') return null; }
|
|
12152
|
+
}
|
|
12153
|
+
const target = options.target;
|
|
12154
|
+
const chats = Array.isArray(options.chats) ? options.chats : [];
|
|
12155
|
+
const answer = await kbConnDialog({ title: 'Connect a Teams chat', labelId: 'kb-conn-title',
|
|
12156
|
+
bodyHtml: kbConnPickerHtml(options),
|
|
12157
|
+
// No chat is picked for the person: connecting copies people's messages, so the chat is always their own choice.
|
|
12158
|
+
actions: [{ id: 'back', label: 'Back', commandId: 'shell.kb-connected-back' }, { id: 'cancel', label: chats.length ? 'Cancel' : 'Close', commandId: 'shell.kb-connected-cancel' },
|
|
12159
|
+
...(chats.length ? [{ id: 'connect', label: 'Connect and sync', tone: 'primary', commandId: 'shell.kb-connected-connect',
|
|
12160
|
+
disabled: true, tip: 'Choose a chat first', enabledWhen: 'input[name="kb-conn-chat"]:checked' }] : [])] });
|
|
12161
|
+
if (answer && answer.id === 'back') return 'back';
|
|
12162
|
+
if (answer && answer.id === 'integrations') { if (typeof openIntegrations === 'function') openIntegrations(); return null; }
|
|
12163
|
+
if (!answer || answer.id !== 'connect' || !current || current.id !== proj.id) return null;
|
|
12164
|
+
const picked = answer.form.querySelector('input[name="kb-conn-chat"]:checked');
|
|
12165
|
+
const windowDays = Number(answer.form.querySelector('input[name="kb-conn-window"]:checked')?.value || 30);
|
|
12166
|
+
if (!picked) return;
|
|
12167
|
+
try {
|
|
12168
|
+
const res = await api(kbConnUrl(''), { method: 'POST', body: JSON.stringify({ chatId: picked.value, label: picked.dataset.label, windowDays, expected: target }) });
|
|
12169
|
+
kbAnnounce(picked.hasAttribute('data-connected')
|
|
12170
|
+
? `“${picked.dataset.label}” is already connected. Syncing it…` : `Connected “${picked.dataset.label}”. Syncing…`);
|
|
12171
|
+
await renderKnowledge();
|
|
12172
|
+
if (res.source && res.source.sourceId) await kbConnSync(res.source.sourceId);
|
|
12173
|
+
} catch (err) {
|
|
12174
|
+
const said = errorText(err, { action: 'connect that source' });
|
|
12175
|
+
kbAnnounce(said);
|
|
12176
|
+
showToast(said, 'warn');
|
|
12177
|
+
await renderKnowledge();
|
|
12178
|
+
}
|
|
12179
|
+
}
|
|
12180
|
+
|
|
12181
|
+
async function kbConnErase(sourceId) {
|
|
12182
|
+
const st = knowledgeState;
|
|
12183
|
+
const c = kbConnOf(st, sourceId);
|
|
12184
|
+
const removed = ((st && st.connected && st.connected.removed) || []).find((r) => r.sourceId === sourceId);
|
|
12185
|
+
const name = (c && c.label) || (removed && removed.label) || (kbConnIsMail(c) ? 'this folder' : 'this source');
|
|
12186
|
+
// Each source names what its own service keeps (a Trimble project keeps its topics), a removed one too: the
|
|
12187
|
+
// project-wide list is a Teams chat's, so it is only the last resort for a server that sends neither.
|
|
12188
|
+
const notReached = (c && Array.isArray(c.notReached) && c.notReached)
|
|
12189
|
+
|| (removed && Array.isArray(removed.notReached) && removed.notReached)
|
|
12190
|
+
|| (st && st.connected && st.connected.notReached) || [];
|
|
12191
|
+
const what = kbConnIsTrimble(c) || (removed && removed.scopeKind === 'trimble-project') ? 'its topics and ToDos' : 'its messages';
|
|
12192
|
+
const revision = c ? c.revision : 'removed';
|
|
12193
|
+
const answer = await kbConnDialog({ title: `Erase “${name}”?`, labelId: 'kb-conn-erase-title',
|
|
12194
|
+
bodyHtml: '<div class="kb-conn-h">This removes</div><ul class="kb-conn-list">' +
|
|
12195
|
+
`<li>${c ? `${c.versions} saved version${c.versions === 1 ? '' : 's'} of ${what}` : `the saved versions of ${what}`}</li>` +
|
|
12196
|
+
'<li>the knowledge pages organized from it</li><li>any quotes from it saved with workflow Agent steps and pinned pages</li>' +
|
|
12197
|
+
(c ? `<li>this ${kbConnThing(c)} as a source, so it stops syncing</li>` : '') + '</ul>' +
|
|
12198
|
+
`<div class="kb-conn-h">This cannot reach</div><ul class="kb-conn-list">${(notReached.length ? notReached
|
|
12199
|
+
: ['AI Chat conversations and reports already made, which may quote this source.']).map((line) => `<li>${escapeHtml(line)}</li>`).join('')}</ul>` +
|
|
12200
|
+
'<p class="kb-conn-p">It cannot be undone.</p>',
|
|
12201
|
+
actions: [{ id: 'cancel', label: 'Cancel', commandId: 'shell.kb-connected-cancel' },
|
|
12202
|
+
{ id: 'erase', label: 'Erase permanently', tone: 'danger', commandId: 'shell.kb-connected-erase-go' }] });
|
|
12203
|
+
if (!answer || answer.id !== 'erase') return;
|
|
12204
|
+
await kbConnEraseGo(sourceId, name, { revision });
|
|
12205
|
+
}
|
|
12206
|
+
|
|
12207
|
+
async function kbConnEraseGo(sourceId, name, body) {
|
|
12208
|
+
let res;
|
|
12209
|
+
try { res = await api(kbConnUrl(`/${encodeURIComponent(sourceId)}/erase`), { method: 'POST', body: JSON.stringify(body) }); }
|
|
12210
|
+
catch (err) { const said = errorText(err, { action: 'erase this source' }); kbAnnounce(said); showToast(said, 'warn'); kbInvalidateRefs(); await renderKnowledge(); return; }
|
|
12211
|
+
if (res.state === 'waiting') {
|
|
12212
|
+
const answer = await kbConnDialog({ title: `Stop the Organize and erase “${name}”?`, labelId: 'kb-conn-stop-title',
|
|
12213
|
+
bodyHtml: `<p class="kb-conn-p">${escapeHtml(res.message)} Its messages are already left out of everything new; stopping the Organize lets the Erase finish now. Organize again afterwards.</p>`,
|
|
12214
|
+
actions: [{ id: 'cancel', label: 'Wait for it', commandId: 'shell.kb-connected-cancel' },
|
|
12215
|
+
{ id: 'stop', label: 'Stop and erase', tone: 'danger', commandId: 'shell.kb-connected-stop-organize' }] });
|
|
12216
|
+
if (answer && answer.id === 'stop') return kbConnEraseGo(sourceId, name, { stopOrganize: res.organizeRequestId });
|
|
12217
|
+
kbAnnounce('Erasing as soon as the Organize ends.');
|
|
12218
|
+
} else if (res.state === 'incomplete') {
|
|
12219
|
+
// The page words this itself from the count; the server's list of what stayed is kept in the console.
|
|
12220
|
+
const left = Array.isArray(res.failures) ? res.failures.length : 0;
|
|
12221
|
+
if (left) console.warn('[knowledge] erase left items behind', res.failures);
|
|
12222
|
+
const said = left ? `Erase did not finish: ${left} item${left === 1 ? '' : 's'} could not be removed. Erase again.` : 'Erase did not finish. Erase again.';
|
|
12223
|
+
kbAnnounce(said);
|
|
12224
|
+
showToast(said, 'warn');
|
|
12225
|
+
} else {
|
|
12226
|
+
kbConnStops.delete(sourceId);
|
|
12227
|
+
kbAnnounce(`Erased “${name}”.`);
|
|
12228
|
+
}
|
|
12229
|
+
kbInvalidateRefs();
|
|
12230
|
+
await renderKnowledge();
|
|
12231
|
+
// The row the dialog returned focus to may be gone now; keep focus in the list rather than lose it to the page.
|
|
12232
|
+
if (!$wsKnowledge.contains(document.activeElement)) $wsKnowledge.querySelector('[data-kb-conn-new]')?.focus({ preventScroll: true });
|
|
12233
|
+
}
|
|
12234
|
+
|
|
12235
|
+
/** The click handler's connected-source half; true when it handled the click. */
|
|
12236
|
+
function kbConnClick(e) {
|
|
12237
|
+
const t = e.target;
|
|
12238
|
+
if (t.closest('[data-kb-conn-new]')) { kbCloseConfirm(); void kbConnOpenConnect(); return true; }
|
|
12239
|
+
const sync = t.closest('[data-kb-conn-sync]');
|
|
12240
|
+
if (sync) { kbCloseConfirm(); void kbConnSync(sync.dataset.kbConnSync); return true; }
|
|
12241
|
+
const menu = t.closest('[data-kb-conn-menu]');
|
|
12242
|
+
if (menu) { kbConnShowMenu(menu); return true; }
|
|
12243
|
+
const pause = t.closest('[data-kb-conn-pause]');
|
|
12244
|
+
if (pause) { kbCloseConfirm(); void kbConnSetPaused(pause.dataset.kbConnPause, pause.dataset.kbConnPaused === 'true'); return true; }
|
|
12245
|
+
const remove = t.closest('[data-kb-conn-remove]');
|
|
12246
|
+
if (remove) { kbConnRemove(remove.dataset.kbConnRemove); return true; }
|
|
12247
|
+
const erase = t.closest('[data-kb-conn-erase]');
|
|
12248
|
+
if (erase) { kbCloseConfirm(); void kbConnErase(erase.dataset.kbConnErase); return true; }
|
|
12249
|
+
const choice = t.closest('[data-kb-conn-choice]');
|
|
12250
|
+
if (choice) { kbConnChoose(choice.dataset.kbConnId, choice.dataset.kbConnChoice); return true; }
|
|
12251
|
+
const windowMenu = t.closest('[data-kb-conn-window-menu]');
|
|
12252
|
+
if (windowMenu) { kbCloseConfirm(); void kbConnWindowDialog(windowMenu.dataset.kbConnWindowMenu); return true; }
|
|
12253
|
+
const reread = t.closest('[data-kb-conn-reread]');
|
|
12254
|
+
if (reread) { kbCloseConfirm(); void kbConnRereadDialog(reread.dataset.kbConnReread); return true; }
|
|
12255
|
+
const ceiling = t.closest('[data-kb-conn-ceiling]');
|
|
12256
|
+
if (ceiling) {
|
|
12257
|
+
const id = ceiling.dataset.kbConnId, v = ceiling.dataset.kbConnCeiling;
|
|
12258
|
+
const name = kbConnOf(knowledgeState, id)?.label || 'This folder';
|
|
12259
|
+
void kbConnSetMail(id, v === 'partial' ? { beyondCeiling: 'partial' } : { windowDays: Number(v) },
|
|
12260
|
+
v === 'partial' ? `“${name}” keeps a partial copy.` : `“${name}” keeps the last ${v} days from the next sync.`, ceiling.dataset.kbConnRev);
|
|
12261
|
+
return true;
|
|
12262
|
+
}
|
|
12263
|
+
return false;
|
|
12264
|
+
}
|
|
12265
|
+
|
|
12266
|
+
function kbConnRemove(sourceId) {
|
|
12267
|
+
const anchor = $wsKnowledge.querySelector(`[data-kb-conn-menu="${CSS.escape(sourceId)}"]`);
|
|
12268
|
+
const c = kbConnOf(knowledgeState, sourceId);
|
|
12269
|
+
if (anchor) kbShowRemoveConfirm(anchor, sourceId, (c && c.label) || `this ${kbConnThing(c)}`,
|
|
12270
|
+
'FloLess stops syncing it and leaves it out of future Organize runs. What it synced stays stored until you erase it, from Removed connected sources.',
|
|
12271
|
+
`shell.kb-connected-remove-go#${sourceId}`);
|
|
12272
|
+
}
|
|
12273
|
+
|
|
12274
|
+
function kbConnChoose(sourceId, choice) {
|
|
12275
|
+
const stop = kbConnStops.get(sourceId) || { opts: {}, target: null };
|
|
12276
|
+
// Keep the copy answers a stop by leaving the copy as it is, until the person syncs again.
|
|
12277
|
+
if (choice === 'cancel' || choice === 'keep') { kbConnStops.delete(sourceId); kbConnRepaint(); return; }
|
|
12278
|
+
if (choice === 'pause') { void kbConnSetPaused(sourceId, true); return; }
|
|
12279
|
+
if (choice === 'remove') { kbConnRemove(sourceId); return; }
|
|
12280
|
+
if (choice === 'open-integrations') { if (typeof openIntegrations === 'function') openIntegrations(); return; }
|
|
12281
|
+
if (choice === 'open-tools') {
|
|
12282
|
+
if (typeof openLibrary === 'function') openLibrary(kbConnIsTrimble(kbConnOf(knowledgeState, sourceId)) ? 'trimble-connect' : 'microsoft-365', { tab: 'available' });
|
|
12283
|
+
return;
|
|
12284
|
+
}
|
|
12285
|
+
if (choice === 'reload') { kbConnStops.delete(sourceId); kbInvalidateRefs(); void renderKnowledge(); return; }
|
|
12286
|
+
if (choice === 'sync-with-current') { void kbConnSync(sourceId, { account: 'current-signin', ...(stop.target ? { expected: stop.target } : {}) }); return; }
|
|
12287
|
+
if (choice === 'confirm-target') { void kbConnSync(sourceId, { ...stop.opts, ...(stop.target ? { expected: stop.target } : {}) }); return; }
|
|
12288
|
+
if (choice === 'resume-and-sync') { void kbConnSync(sourceId, { ...stop.opts, resume: true }); return; }
|
|
12289
|
+
if (choice === 'sync-anyway') { void kbConnSync(sourceId, { ...stop.opts, overBudget: true }); return; }
|
|
12290
|
+
if (choice === 'rebuild') { void kbConnSync(sourceId, { ...stop.opts, rebuild: true }); return; }
|
|
12291
|
+
void kbConnSync(sourceId, stop.opts || {});
|
|
12292
|
+
}
|
|
12293
|
+
|
|
11032
12294
|
function kbColumn(st) {
|
|
11033
12295
|
// One collection: issued drawings, reference groups, then upload. Presentation never changes membership.
|
|
11034
12296
|
const loose = st.sources.filter((source) => !kbInDesignSet(source, st));
|
|
@@ -11037,13 +12299,16 @@
|
|
|
11037
12299
|
// make one. A categories file that cannot be read shows every reference flat and says so.
|
|
11038
12300
|
kbSelFor(current, st);
|
|
11039
12301
|
const tree = kbCatUsable(st) && kbCats(st).categories.length > 0;
|
|
12302
|
+
// #3413: design-set drawings sorted into categories keep the tree (and its counts) even when nothing else is loose.
|
|
12303
|
+
const placedDrawings = tree && st.sources.some((s) => kbInDesignSet(s, st) && kbcPlacement(kbCats(st), s.sourceId));
|
|
11040
12304
|
const newCat = kbCatUsable(st) && loose.length && !(kbCatEdit && kbCatEdit.mode === 'new' && !kbCatEdit.parentId)
|
|
11041
12305
|
? '<button type="button" class="kb-link kb-cat-new" data-kb-cat-new data-command-id="shell.kb-category-new" data-tip="Group references into categories">+ New category</button>' : '';
|
|
11042
12306
|
const flatEdit = !tree && kbCatEdit && kbCatEdit.mode === 'new' ? kbCatEditHtml(0) : '';
|
|
11043
|
-
const
|
|
11044
|
-
|
|
12307
|
+
const connect = '<button type="button" class="kb-link kb-conn-new" data-kb-conn-new data-command-id="shell.kb-connected-new" data-tip="Sync a Teams chat, an Outlook folder or a Trimble Connect project into this project’s knowledge, with the account chosen in Integrations">+ Connect a source</button>';
|
|
12308
|
+
const body = '<div class="kb-reference-head"><h3>Reference files</h3><span class="kb-reference-actions">' + newCat + connect + '</span></div>' +
|
|
12309
|
+
kbCatUnavailableHtml(st) + (loose.length || placedDrawings
|
|
11045
12310
|
? (tree ? kbTreeHtml(st, loose) : flatEdit + '<h4 class="kb-uncategorized-head">Uncategorized references</h4>' + loose.map((source) => kbSourceRow(source, st)).join(''))
|
|
11046
|
-
: '<div class="kb-empty">' + (inSet ? 'Other reference files will appear here. Drawings are listed in the Design set above.' : 'No references added yet. Add files below to get started.') + '</div>') + kbSelBarHtml(st);
|
|
12311
|
+
: '<div class="kb-empty">' + (inSet ? 'Other reference files will appear here. Drawings are listed in the Design set above.' : 'No references added yet. Add files below to get started.') + '</div>') + kbConnExtrasHtml(st) + kbSelBarHtml(st);
|
|
11047
12312
|
const selected = st.sources.filter((s) => s.useAsKb).length;
|
|
11048
12313
|
return '<section class="kb-col">' +
|
|
11049
12314
|
'<div class="kb-refs-body">' + `<div class="kb-source-summary">${st.sources.length} source${st.sources.length === 1 ? '' : 's'} · ${selected} selected for Organize</div>` + kbDesignSetStrip(st) + body +
|
|
@@ -12207,7 +13472,7 @@
|
|
|
12207
13472
|
}
|
|
12208
13473
|
// Anchored to the SCROLL container (.kb-refs-body, position:relative) — .kb-col is overflow:hidden
|
|
12209
13474
|
// and would clip the popover. Same anchoring as .ws-history's rollback confirm.
|
|
12210
|
-
function kbShowRemoveConfirm(btn, sourceId, name) {
|
|
13475
|
+
function kbShowRemoveConfirm(btn, sourceId, name, bodyText, goCommandId) {
|
|
12211
13476
|
kbCloseConfirm();
|
|
12212
13477
|
const box = btn.closest('.kb-refs-body');
|
|
12213
13478
|
if (!box) return;
|
|
@@ -12217,10 +13482,15 @@
|
|
|
12217
13482
|
// from it — only the next Organize rebuilds the wiki without it.
|
|
12218
13483
|
pop.innerHTML =
|
|
12219
13484
|
`<div class="hc-title">Remove “${escapeHtml(name)}”?</div>` +
|
|
12220
|
-
|
|
12221
|
-
'stay in the knowledge base until you Organize again.</div>' +
|
|
13485
|
+
`<div class="hc-body">${escapeHtml(bodyText || 'It won’t be included in future Organize runs. Notes already compiled from it stay in the knowledge base until you Organize again.')}</div>` +
|
|
12222
13486
|
'<div class="hc-act"><button type="button" class="hc-cancel">Cancel</button>' +
|
|
12223
13487
|
`<button type="button" class="hc-go danger" data-kb-remove-go="${escapeAttr(sourceId)}">✕ Remove</button></div>`;
|
|
13488
|
+
// A caller that names its go button (the connected Remove) passes a literal id; set through the DOM, it needs no escaping.
|
|
13489
|
+
if (goCommandId) {
|
|
13490
|
+
const go = pop.querySelector('.hc-go');
|
|
13491
|
+
go.dataset.commandId = goCommandId;
|
|
13492
|
+
go.dataset.commandInstanceLabel = name;
|
|
13493
|
+
}
|
|
12224
13494
|
box.appendChild(pop);
|
|
12225
13495
|
const cr = box.getBoundingClientRect();
|
|
12226
13496
|
const br = btn.getBoundingClientRect();
|
|
@@ -12616,6 +13886,12 @@
|
|
|
12616
13886
|
// Which issues are open is the person's choice and survives repaints. `toggle` does not bubble, so this listens in capture.
|
|
12617
13887
|
$wsKnowledge.addEventListener('toggle', (e) => {
|
|
12618
13888
|
const d = e.target;
|
|
13889
|
+
// #2470 R6.8: a connected source's gap disclosure, likewise.
|
|
13890
|
+
if (d && d.dataset && d.dataset.kbConnGaps) {
|
|
13891
|
+
if (d.open) kbConnGapsOpen.add(d.dataset.kbConnGaps); else kbConnGapsOpen.delete(d.dataset.kbConnGaps);
|
|
13892
|
+
kbInvalidateRefs();
|
|
13893
|
+
return;
|
|
13894
|
+
}
|
|
12619
13895
|
if (!d || !d.classList || !d.classList.contains('kb-ds-issue')) return;
|
|
12620
13896
|
const issue = kbDsIssueById(d.dataset.kbDsIssueId);
|
|
12621
13897
|
if (!issue) return;
|
|
@@ -12635,6 +13911,7 @@
|
|
|
12635
13911
|
const rowAct = e.target.closest('[data-kb-row-act]');
|
|
12636
13912
|
if (rowAct) { kbRowAct(rowAct); return; }
|
|
12637
13913
|
if (kbCatClick(e)) return;
|
|
13914
|
+
if (kbConnClick(e)) return;
|
|
12638
13915
|
if (e.target.closest('.kb-ds') || e.target.closest('.kb-ds-menu') || e.target.closest('[data-kb-ds-jump]') || e.target.closest('[data-kb-ds-fremove], [data-kb-ds-fwithdraw]')) {
|
|
12639
13916
|
if (kbDsClick(e)) return;
|
|
12640
13917
|
}
|
|
@@ -12833,7 +14110,14 @@
|
|
|
12833
14110
|
$wsKnowledge.addEventListener('input', (e) => { if (e.target && e.target.id === 'kb-adjust-input') kbSyncAdjustSubmit(); });
|
|
12834
14111
|
// #2491 R6.9: the map's search highlights matches (it hides nothing); hover and focus light a node's neighbours.
|
|
12835
14112
|
$wsKnowledge.addEventListener('input', (e) => { if (e.target && e.target.classList && e.target.classList.contains('kb-gsearch')) { kbGo.search = e.target.value; kbGraphRender(true); } });
|
|
12836
|
-
$wsKnowledge.addEventListener('mouseover', (e) => {
|
|
14113
|
+
$wsKnowledge.addEventListener('mouseover', (e) => {
|
|
14114
|
+
const n = e.target.closest && e.target.closest('.kb-g-node[data-kb-gid]');
|
|
14115
|
+
if (!n) return;
|
|
14116
|
+
kbGraphHighlight(n.dataset.kbGid);
|
|
14117
|
+
// #3413: SVG draws in document order, so a pointed-at node whose label was hidden goes last and its label reads over
|
|
14118
|
+
// its neighbours. Only for the pointer: moving a focused node would take its keyboard focus away.
|
|
14119
|
+
if (n.classList.contains('nolabel') && n.nextElementSibling && !n.contains(document.activeElement)) n.parentNode.appendChild(n);
|
|
14120
|
+
});
|
|
12837
14121
|
$wsKnowledge.addEventListener('mouseout', (e) => { if (e.target.closest && e.target.closest('.kb-g-node') && !(e.relatedTarget && e.relatedTarget.closest && e.relatedTarget.closest('.kb-g-node'))) kbGraphHighlight(null); });
|
|
12838
14122
|
$wsKnowledge.addEventListener('focusin', (e) => { const n = e.target.closest && e.target.closest('.kb-g-node[data-kb-gid]'); if (n) kbGraphHighlight(n.dataset.kbGid); });
|
|
12839
14123
|
// #2491 R6.3: Replace file… picks exactly one file.
|
|
@@ -12867,10 +14151,13 @@
|
|
|
12867
14151
|
// No cache invalidation here: a repaint during the drag would destroy this row and the browser would cancel the drop.
|
|
12868
14152
|
// The paint guard holds repaints while a drag is in flight; the end of the drag catches the column up.
|
|
12869
14153
|
row.classList.add('dragging');
|
|
14154
|
+
// #3413: every empty category shows where a reference can land while one is being dragged.
|
|
14155
|
+
$wsKnowledge.classList.add('kb-refs-dragging');
|
|
12870
14156
|
});
|
|
12871
14157
|
$wsKnowledge.addEventListener('dragend', () => {
|
|
12872
14158
|
kbDragIds = null;
|
|
12873
14159
|
kbClearDropHover();
|
|
14160
|
+
$wsKnowledge.classList.remove('kb-refs-dragging');
|
|
12874
14161
|
$wsKnowledge.querySelectorAll('.kb-src.dragging').forEach((el) => el.classList.remove('dragging'));
|
|
12875
14162
|
kbInvalidateRefs();
|
|
12876
14163
|
if (knowledgeState) paintKnowledge(knowledgeState);
|
|
@@ -12914,6 +14201,7 @@
|
|
|
12914
14201
|
$wsKnowledge.addEventListener('drop', (e) => {
|
|
12915
14202
|
e.preventDefault();
|
|
12916
14203
|
kbClearDrag();
|
|
14204
|
+
$wsKnowledge.classList.remove('kb-refs-dragging'); // the dragged row may be repainted away before its dragend
|
|
12917
14205
|
const cat = kbDropTargetOf(e);
|
|
12918
14206
|
kbClearDropHover();
|
|
12919
14207
|
const to = cat ? (cat.dataset.kbDropCat === 'uncategorized' ? null : cat.dataset.kbDropCat) : undefined;
|
|
@@ -13175,7 +14463,7 @@
|
|
|
13175
14463
|
];
|
|
13176
14464
|
};
|
|
13177
14465
|
/** The units this project's bill is written in: the server's answer, else the client's own copy. */
|
|
13178
|
-
const bomUnits = () => exportUnits ?? (current
|
|
14466
|
+
const bomUnits = () => exportUnits ?? shownUnits(current);
|
|
13179
14467
|
const BOM_DESCRIPTIVE = ['profile', 'grade', 'type'];
|
|
13180
14468
|
const DEFAULT_BOM_FORMATS = ['csv', 'xlsx'];
|
|
13181
14469
|
const DEFAULT_BOM_COLUMNS = ['profile', 'qty', 'length', 'lbft', 'weight'];
|
|
@@ -13471,6 +14759,9 @@
|
|
|
13471
14759
|
details: [
|
|
13472
14760
|
...(Array.isArray(receipt.unsupported) ? receipt.unsupported.map((row) => receiptItemText('Unsupported', row)) : []),
|
|
13473
14761
|
...(Array.isArray(receipt.warnings) ? receipt.warnings.map((warning) => receiptItemText('Warning', warning)) : []),
|
|
14762
|
+
...(receipt.profileMapping && Array.isArray(receipt.profileMapping.mapped)
|
|
14763
|
+
? receipt.profileMapping.mapped.map((row) => `Profile: ${row.from} was sent as ${row.to} (${row.memberCount} member${row.memberCount === 1 ? '' : 's'}). The model and bill of materials keep ${row.from}.`)
|
|
14764
|
+
: []),
|
|
13474
14765
|
].join('\n'),
|
|
13475
14766
|
};
|
|
13476
14767
|
}
|
|
@@ -13526,6 +14817,30 @@
|
|
|
13526
14817
|
*
|
|
13527
14818
|
* Amber, like `.e-receipt.partial`, because it is the same news: this file is not the whole model.
|
|
13528
14819
|
*/
|
|
14820
|
+
/**
|
|
14821
|
+
* Add-ons S1a: the custom sections the IFC file carries on an assumption, read from its receipt so the card still
|
|
14822
|
+
* says so after the export toast is gone (a bounding box standing in for a shape the file cannot carry, or a
|
|
14823
|
+
* section FloLess could not verify that the person accepted).
|
|
14824
|
+
*/
|
|
14825
|
+
function customSectionAssumedHtml(approved) {
|
|
14826
|
+
const entry = approved && exportState ? exportState.ifc : null;
|
|
14827
|
+
const record = entry && entry.customSections && typeof entry.customSections === 'object' ? entry.customSections : null;
|
|
14828
|
+
const total = record && Number.isSafeInteger(record.total) ? record.total : 0;
|
|
14829
|
+
if (!total) return '';
|
|
14830
|
+
// The counts cover every member; the rows only name the ones the receipt could store.
|
|
14831
|
+
const rows = Array.isArray(record.rows) ? record.rows : [];
|
|
14832
|
+
const boxes = Number(record.boundingBox) || 0;
|
|
14833
|
+
const accepted = Number(record.assumed) || 0;
|
|
14834
|
+
const parts = [
|
|
14835
|
+
boxes ? `${boxes} sent as ${boxes === 1 ? 'its' : 'their'} bounding box` : '',
|
|
14836
|
+
accepted ? `${accepted} accepted as an assumption` : '',
|
|
14837
|
+
].filter(Boolean);
|
|
14838
|
+
const names = [...new Set(rows.map((row) => row && row.designation).filter(Boolean))].join(', ');
|
|
14839
|
+
return `<div class="e-receipt partial"><span>` +
|
|
14840
|
+
escapeHtml(`${total} custom section${total === 1 ? '' : 's'} in this file rest${total === 1 ? 's' : ''} on an assumption: ${parts.join(', ')}${names ? ` (${names}${rows.length < total ? ', and others' : ''})` : ''}.`) +
|
|
14841
|
+
`</span></div>`;
|
|
14842
|
+
}
|
|
14843
|
+
|
|
13529
14844
|
function omittedHtml(kind, approved) {
|
|
13530
14845
|
if (!approved || !exportState) return '';
|
|
13531
14846
|
const byMember = new Map();
|
|
@@ -13560,6 +14875,8 @@
|
|
|
13560
14875
|
'view-scale-invalid': 'a source view with no valid drawing scale',
|
|
13561
14876
|
'cross-view-conflict': 'source views that disagree on placement',
|
|
13562
14877
|
'placement-evidence-conflict': 'invalid scale and conflicting placement evidence',
|
|
14878
|
+
'custom-section-unverified': 'a custom section that cannot be checked',
|
|
14879
|
+
'custom-section-not-exported': 'a custom section this export does not carry',
|
|
13563
14880
|
};
|
|
13564
14881
|
const parts = Object.keys(byReason).sort().map((r) => `${byReason[r]} with ${WORDS[r] || r}`);
|
|
13565
14882
|
// The stored rows are capped, so the parts can add up to less than the total. Say so rather than
|
|
@@ -13739,6 +15056,8 @@
|
|
|
13739
15056
|
await api(`/api/projects/${encodeURIComponent(projectId)}/host-bake-consent?appId=${encodeURIComponent(appId)}`, {
|
|
13740
15057
|
method: 'DELETE',
|
|
13741
15058
|
headers: { 'content-type': 'application/json', 'x-floless-host-bake-consent': token },
|
|
15059
|
+
// #3273: a send's busy claim waits for this cleanup, so a request that never answers must not hold it.
|
|
15060
|
+
timeoutMs: SEND_CLEANUP_MS,
|
|
13742
15061
|
});
|
|
13743
15062
|
} catch (_) { /* best effort; consent and its source lease also expire server-side */ }
|
|
13744
15063
|
finally { activeProjectHostBakeConsents.delete(token); }
|
|
@@ -13751,6 +15070,7 @@
|
|
|
13751
15070
|
method: 'POST',
|
|
13752
15071
|
headers: { 'content-type': 'application/json', 'x-floless-host-bake-consent': token },
|
|
13753
15072
|
body: '{}',
|
|
15073
|
+
signal: AbortSignal.timeout(SEND_CLEANUP_MS),
|
|
13754
15074
|
});
|
|
13755
15075
|
} catch (_) { /* a lost acknowledgement deliberately leaves the replay tombstone in place */ }
|
|
13756
15076
|
finally { activeProjectHostBakeConsents.delete(token); }
|
|
@@ -13759,14 +15079,391 @@
|
|
|
13759
15079
|
async function releaseCapturedSources(projectId, handles) {
|
|
13760
15080
|
await Promise.allSettled(handles.map((handleId) => api(
|
|
13761
15081
|
`/api/projects/${encodeURIComponent(projectId)}/export-captures/${encodeURIComponent(handleId)}/release`,
|
|
13762
|
-
{ method: 'POST' },
|
|
15082
|
+
{ method: 'POST', timeoutMs: SEND_CLEANUP_MS },
|
|
13763
15083
|
)));
|
|
13764
15084
|
}
|
|
13765
15085
|
|
|
13766
|
-
|
|
15086
|
+
// ── #3312: profile mapping before a Tekla send ──────────────────────────────────────────────────────────
|
|
15087
|
+
// Before a Tekla send FloLess asks Tekla (or an imported Tekla catalogue) which of the model's profiles it has,
|
|
15088
|
+
// suggests a match for each missing one, and lets the person decide. The model and the bill of materials keep
|
|
15089
|
+
// their own names: the table applies only to what is sent. Whatever is left unmapped is still sent, as written,
|
|
15090
|
+
// and Tekla makes a profile-less line the person gives a profile to there.
|
|
15091
|
+
const $pmModal = document.getElementById('profilemap-modal');
|
|
15092
|
+
const PM_CHIP = {
|
|
15093
|
+
name: ['Same name', 'is-sure'],
|
|
15094
|
+
exact: ['Same section', 'is-sure'],
|
|
15095
|
+
close: ['Within 1 mm', 'is-check'],
|
|
15096
|
+
check: ['Check orientation', 'is-check'],
|
|
15097
|
+
none: ['No match', ''],
|
|
15098
|
+
};
|
|
15099
|
+
const PM_LINE_LABEL = 'Leave unmapped — sent as a line';
|
|
15100
|
+
const PM_POOL_SHOWN = 60;
|
|
15101
|
+
const pmFileAsDataUrl = (file) => new Promise((resolve, reject) => {
|
|
15102
|
+
const reader = new FileReader();
|
|
15103
|
+
reader.onload = () => resolve(String(reader.result));
|
|
15104
|
+
reader.onerror = () => reject(reader.error || new Error('unreadable'));
|
|
15105
|
+
reader.readAsDataURL(file);
|
|
15106
|
+
});
|
|
15107
|
+
|
|
15108
|
+
async function checkTeklaProfiles(projectId, app, catalogueId, sourceHandle) {
|
|
15109
|
+
try {
|
|
15110
|
+
return await api(`/api/contract/${encodeURIComponent(app)}/host-profiles?project=${encodeURIComponent(projectId)}${sourceHandle ? `&sourceHandle=${encodeURIComponent(sourceHandle)}` : ''}`, {
|
|
15111
|
+
method: 'POST',
|
|
15112
|
+
body: JSON.stringify({ host: 'tekla', ...(catalogueId ? { catalogueId } : {}) }),
|
|
15113
|
+
timeoutMs: 150000,
|
|
15114
|
+
});
|
|
15115
|
+
} catch (error) {
|
|
15116
|
+
return {
|
|
15117
|
+
ok: true, supported: false, host: 'tekla', imported: [], revision: 0,
|
|
15118
|
+
reason: personText(error && error.body)
|
|
15119
|
+
|| 'FloLess could not check Tekla’s profiles just now. You can import a Tekla catalogue to check against, or continue without checking.',
|
|
15120
|
+
};
|
|
15121
|
+
}
|
|
15122
|
+
}
|
|
15123
|
+
|
|
15124
|
+
/**
|
|
15125
|
+
* The mapping window. Resolves { action: 'apply', profileMap, modelPath, revision } | { action: 'skip' } | null (cancelled).
|
|
15126
|
+
* It re-checks in place when the person switches the catalogue it checks against or imports one.
|
|
15127
|
+
*/
|
|
15128
|
+
function openProfileMapWindow({ projectId, app, first, returnFocus, sourceHandle }) {
|
|
15129
|
+
return new Promise((resolve) => {
|
|
15130
|
+
if (!$pmModal) { resolve({ action: 'skip' }); return; }
|
|
15131
|
+
const $title = document.getElementById('profilemap-title');
|
|
15132
|
+
const $sub = document.getElementById('profilemap-sub');
|
|
15133
|
+
const $source = document.getElementById('profilemap-source');
|
|
15134
|
+
const $sources = document.getElementById('profilemap-sources');
|
|
15135
|
+
const $import = document.getElementById('profilemap-import');
|
|
15136
|
+
const $file = document.getElementById('profilemap-file');
|
|
15137
|
+
const $body = document.getElementById('profilemap-body');
|
|
15138
|
+
const $note = document.getElementById('profilemap-note');
|
|
15139
|
+
const $apply = document.getElementById('profilemap-apply');
|
|
15140
|
+
const $cancel = document.getElementById('profilemap-cancel');
|
|
15141
|
+
const dialog = $pmModal.querySelector('.profilemap');
|
|
15142
|
+
let check = first;
|
|
15143
|
+
let choices = new Map();
|
|
15144
|
+
let initial = new Map();
|
|
15145
|
+
let poolIndex = new Map();
|
|
15146
|
+
let openRow = null;
|
|
15147
|
+
let busy = false;
|
|
15148
|
+
let done = false;
|
|
15149
|
+
|
|
15150
|
+
const seed = () => {
|
|
15151
|
+
initial = new Map((check.rows || []).map((row) => [row.profile, row.choice]));
|
|
15152
|
+
choices = new Map(initial);
|
|
15153
|
+
poolIndex = new Map((check.pool || []).map((entry) => [entry[0], entry]));
|
|
15154
|
+
};
|
|
15155
|
+
const plural = (n, one, many) => `${n} ${n === 1 ? one : many}`;
|
|
15156
|
+
const labelOf = (name) => {
|
|
15157
|
+
if (name == null) return PM_LINE_LABEL;
|
|
15158
|
+
const entry = poolIndex.get(name);
|
|
15159
|
+
return entry && entry[2] ? `${name} · ${entry[2]} mm` : name;
|
|
15160
|
+
};
|
|
15161
|
+
const sourceName = () => (check.source === 'imported' && check.catalogue
|
|
15162
|
+
? `the imported catalogue “${check.catalogue.name}” (${plural(check.catalogue.count, 'profile', 'profiles')})`
|
|
15163
|
+
: check.modelPath ? `the open Tekla model (${check.modelPath})` : 'the open Tekla model');
|
|
15164
|
+
|
|
15165
|
+
const rowHtml = (row) => {
|
|
15166
|
+
const [chipText, chipClass] = PM_CHIP[row.suggestion.confidence] || PM_CHIP.none;
|
|
15167
|
+
const chosen = choices.get(row.profile);
|
|
15168
|
+
const instance = escapeAttr(row.profile);
|
|
15169
|
+
const stale = row.staleSaved ? ` Your saved choice “${escapeHtml(row.staleSaved)}” is not in this catalogue, so it was not applied.` : '';
|
|
15170
|
+
return `<div class="pm-row${chosen !== initial.get(row.profile) ? ' changed' : ''}" data-pm-row="${instance}">
|
|
15171
|
+
<div class="pm-from"><span class="pm-name">${escapeHtml(row.profile)}</span><span class="pm-count">${escapeHtml(plural(row.memberCount, 'member', 'members'))}${row.choiceFrom === 'saved' ? (row.choice == null ? ' · your saved choice: a profile-less line' : ' · your saved choice') : ''}</span></div>
|
|
15172
|
+
<div class="pm-sugg"><span class="pm-chip ${chipClass}">${escapeHtml(chipText)}</span>
|
|
15173
|
+
<span class="pm-why">${row.suggestion.to ? `<strong>${escapeHtml(row.suggestion.to)}</strong> — ` : ''}${escapeHtml(row.suggestion.note)}${stale}</span></div>
|
|
15174
|
+
<div class="pm-pick wf-combo fm-select">
|
|
15175
|
+
<button type="button" class="wf-trigger pm-trigger" aria-haspopup="listbox" aria-expanded="${openRow === row.profile ? 'true' : 'false'}" data-command-id="shell.profile-map-choice" data-command-instance="${instance}" data-command-instance-label="${instance}" aria-label="Tekla profile for ${escapeAttr(row.profile)}: ${escapeAttr(labelOf(chosen))}">
|
|
15176
|
+
<span class="wf-trigger-label">${escapeHtml(labelOf(chosen))}</span>
|
|
15177
|
+
<svg class="wf-caret" width="10" height="6" viewBox="0 0 10 6" aria-hidden="true"><path fill="currentColor" d="M0 0l5 6 5-6z"/></svg>
|
|
15178
|
+
</button>
|
|
15179
|
+
${openRow === row.profile ? popoverHtml(row, '') : ''}
|
|
15180
|
+
</div>
|
|
15181
|
+
<div class="pm-caution" ${chosen != null && !(row.suggestion.safeNames || []).includes(chosen) ? '' : 'hidden'}>This is not the section the model draws. The member keeps its drawn position, so its faces and connections may not line up. Check the fit in Tekla.</div>
|
|
15182
|
+
</div>`;
|
|
15183
|
+
};
|
|
15184
|
+
|
|
15185
|
+
const optionsFor = (row, query) => {
|
|
15186
|
+
const q = query.trim().toLowerCase();
|
|
15187
|
+
const picked = new Set();
|
|
15188
|
+
const out = [{ value: '', label: PM_LINE_LABEL, meta: 'Tekla makes a line you give a profile to', line: true }];
|
|
15189
|
+
const add = (name, meta) => {
|
|
15190
|
+
if (picked.has(name)) return;
|
|
15191
|
+
picked.add(name);
|
|
15192
|
+
const entry = poolIndex.get(name);
|
|
15193
|
+
out.push({ value: name, label: name, meta: meta || (entry && entry[2] ? `${entry[2]} mm` : '') });
|
|
15194
|
+
};
|
|
15195
|
+
if (!q) {
|
|
15196
|
+
if (row.suggestion.to) add(row.suggestion.to, `suggested · ${(PM_CHIP[row.suggestion.confidence] || PM_CHIP.none)[0].toLowerCase()}`);
|
|
15197
|
+
(row.suggestion.alternatives || []).forEach((name) => add(name));
|
|
15198
|
+
}
|
|
15199
|
+
let shown = 0;
|
|
15200
|
+
for (const entry of check.pool || []) {
|
|
15201
|
+
if (shown >= PM_POOL_SHOWN) break;
|
|
15202
|
+
if (q && !(entry[0].toLowerCase().includes(q) || String(entry[2] || '').includes(q))) continue;
|
|
15203
|
+
if (!q && picked.has(entry[0])) continue;
|
|
15204
|
+
add(entry[0]);
|
|
15205
|
+
shown += 1;
|
|
15206
|
+
}
|
|
15207
|
+
return out;
|
|
15208
|
+
};
|
|
15209
|
+
|
|
15210
|
+
const popoverHtml = (row, query) => {
|
|
15211
|
+
const chosen = choices.get(row.profile);
|
|
15212
|
+
const options = optionsFor(row, query);
|
|
15213
|
+
const listId = `pm-list-${escapeAttr(row.profile).replace(/[^A-Za-z0-9_-]/g, '_')}`;
|
|
15214
|
+
return `<div class="wf-popover pm-popover" role="presentation">
|
|
15215
|
+
<div class="wf-search-wrap"><input class="wf-search pm-search" type="text" placeholder="Search Tekla’s profiles…" autocomplete="off" aria-label="Search Tekla’s profiles" aria-controls="${listId}" value="${escapeAttr(query)}"></div>
|
|
15216
|
+
<div class="wf-list pm-list" id="${listId}" role="listbox" aria-label="Tekla profiles for ${escapeAttr(row.profile)}">${options.map((o) => {
|
|
15217
|
+
const on = o.line ? chosen == null : chosen === o.value;
|
|
15218
|
+
return `<div class="wf-option${on ? ' selected' : ''}" role="option" tabindex="-1" aria-selected="${on ? 'true' : 'false'}" data-pm-value="${escapeAttr(o.value)}"><span class="wf-option-name">${escapeHtml(o.label)}</span>${o.meta ? `<span class="wf-option-meta">${escapeHtml(o.meta)}</span>` : ''}</div>`;
|
|
15219
|
+
}).join('')}${options.length === 1 && query ? '<div class="wf-empty-search">No profile in Tekla matches that.</div>' : ''}</div>
|
|
15220
|
+
</div>`;
|
|
15221
|
+
};
|
|
15222
|
+
|
|
15223
|
+
// #3418: a re-send whose every missing profile already has the person's saved choice says so,
|
|
15224
|
+
// instead of reading like a new problem each time. Still shown (it decides what the send replaces in Tekla), and
|
|
15225
|
+
// it goes back to the ordinary wording the moment the person changes a choice here. Only the words change: the
|
|
15226
|
+
// button keeps its label and the window its focus, so Instructor narrates exactly what is on screen.
|
|
15227
|
+
const savedCount = () => (check.rows || []).filter((row) => row.choiceFrom === 'saved').length;
|
|
15228
|
+
const allSaved = () => check.supported !== false && (check.rows || []).length > 0
|
|
15229
|
+
&& savedCount() === check.rows.length
|
|
15230
|
+
&& check.rows.every((row) => choices.get(row.profile) === initial.get(row.profile));
|
|
15231
|
+
const render = () => {
|
|
15232
|
+
const rows = check.rows || [];
|
|
15233
|
+
const saved = allSaved();
|
|
15234
|
+
$title.textContent = check.supported === false ? 'Check the profiles before sending'
|
|
15235
|
+
: saved ? 'Your saved Tekla profile choices'
|
|
15236
|
+
: rows.length ? 'Profiles Tekla does not have' : 'Every profile is in Tekla';
|
|
15237
|
+
$sources.hidden = true;
|
|
15238
|
+
if (check.supported === false) {
|
|
15239
|
+
$sub.textContent = check.reason || '';
|
|
15240
|
+
$source.textContent = '';
|
|
15241
|
+
$body.innerHTML = '<div class="pm-empty">Without a check, FloLess sends every member as the model names it. Any profile Tekla does not have still arrives, as a profile-less line you give a profile to in Tekla. The model and the bill of materials do not change.</div>';
|
|
15242
|
+
$note.textContent = '';
|
|
15243
|
+
$apply.textContent = 'Continue without checking';
|
|
15244
|
+
} else {
|
|
15245
|
+
const members = plural(rows.reduce((sum, row) => sum + row.memberCount, 0), 'member', 'members');
|
|
15246
|
+
const kept = savedCount();
|
|
15247
|
+
const keptText = kept && kept < rows.length
|
|
15248
|
+
? `${kept} of them already ${kept === 1 ? 'has' : 'have'} your saved choice; the other ${rows.length - kept} ${rows.length - kept === 1 ? 'needs' : 'need'} your review. `
|
|
15249
|
+
: '';
|
|
15250
|
+
$sub.textContent = saved
|
|
15251
|
+
? `${rows.length === 1 ? 'The profile Tekla does not have' : rows.length === 2 ? 'Both profiles Tekla does not have' : `All ${rows.length} profiles Tekla does not have`} (${members}) already ${rows.length === 1 ? 'has' : 'have'} your saved choice. Choose Apply and continue to use ${rows.length === 1 ? 'it, or change it first' : 'them, or change any of them first'}.`
|
|
15252
|
+
: rows.length
|
|
15253
|
+
? `${rows.length} of the ${plural(check.counts.profiles, 'profile', 'profiles')} in this model (${members}) ${rows.length === 1 ? 'is' : 'are'} not in Tekla. ${keptText}FloLess suggests a match; you can change any of them. Whatever you leave unmapped is still sent, and Tekla makes a line you give a profile to there. The model and the bill of materials keep their own names.`
|
|
15254
|
+
: `All ${plural(check.counts.profiles, 'profile', 'profiles')} in this model are in ${sourceName()}. Nothing needs mapping.`;
|
|
15255
|
+
$source.textContent = `Checked against ${sourceName()}.`;
|
|
15256
|
+
$body.innerHTML = rows.length
|
|
15257
|
+
? `<div class="pm-head" aria-hidden="true"><span>In the model</span><span>Suggestion</span><span>Send to Tekla as</span></div>${rows.map(rowHtml).join('')}`
|
|
15258
|
+
: '<div class="pm-empty">Nothing to map for this catalogue.</div>';
|
|
15259
|
+
$note.textContent = 'Sending replaces the parts FloLess sent to this Tekla model before, including any you gave a profile to by hand.'
|
|
15260
|
+
+ (saved ? '' : ' Your choices are kept with the project for the next send.');
|
|
15261
|
+
$apply.textContent = rows.length ? 'Apply and continue' : 'Continue';
|
|
15262
|
+
}
|
|
15263
|
+
const imported = check.imported || [];
|
|
15264
|
+
$sources.hidden = imported.length === 0;
|
|
15265
|
+
// Built with DOM APIs, never markup: a saved catalogue is data from disk, and nothing in it may become HTML.
|
|
15266
|
+
const sourceButton = (id, label, pressed) => {
|
|
15267
|
+
const b = document.createElement('button');
|
|
15268
|
+
b.type = 'button';
|
|
15269
|
+
b.dataset.pmSource = id;
|
|
15270
|
+
b.setAttribute('aria-pressed', pressed ? 'true' : 'false');
|
|
15271
|
+
b.dataset.commandId = 'shell.profile-map-source';
|
|
15272
|
+
b.dataset.commandInstance = label;
|
|
15273
|
+
b.dataset.commandInstanceLabel = label;
|
|
15274
|
+
b.textContent = label;
|
|
15275
|
+
return b;
|
|
15276
|
+
};
|
|
15277
|
+
const sourceButtons = [];
|
|
15278
|
+
if (imported.length) {
|
|
15279
|
+
const open = sourceButton('', 'Open Tekla model', check.source !== 'imported');
|
|
15280
|
+
sourceButtons.push(open);
|
|
15281
|
+
for (const c of imported) {
|
|
15282
|
+
const count = Number.isInteger(c.count) && c.count >= 0 ? c.count : 0;
|
|
15283
|
+
const b = sourceButton(String(c.id), `${c.name} · ${count}`, check.source === 'imported' && !!check.catalogue && check.catalogue.id === c.id);
|
|
15284
|
+
b.dataset.commandInstance = String(c.name);
|
|
15285
|
+
b.dataset.commandInstanceLabel = String(c.name);
|
|
15286
|
+
sourceButtons.push(b);
|
|
15287
|
+
}
|
|
15288
|
+
}
|
|
15289
|
+
$sources.replaceChildren(...sourceButtons);
|
|
15290
|
+
$apply.disabled = busy;
|
|
15291
|
+
$import.disabled = busy;
|
|
15292
|
+
$import.toggleAttribute('aria-busy', busy);
|
|
15293
|
+
};
|
|
15294
|
+
|
|
15295
|
+
const recheck = async (catalogueId, keepNote) => {
|
|
15296
|
+
busy = true; render();
|
|
15297
|
+
if (!keepNote) $note.textContent = '';
|
|
15298
|
+
const next = await checkTeklaProfiles(projectId, app, catalogueId, sourceHandle);
|
|
15299
|
+
busy = false;
|
|
15300
|
+
// A check that failed in transit says nothing about which catalogues the project holds: keep the switcher.
|
|
15301
|
+
if (!next.supported && !(next.imported || []).length) next.imported = check.imported || [];
|
|
15302
|
+
check = next; openRow = null; seed(); render();
|
|
15303
|
+
return next;
|
|
15304
|
+
};
|
|
15305
|
+
|
|
15306
|
+
const close = (value) => {
|
|
15307
|
+
if (done) return;
|
|
15308
|
+
done = true;
|
|
15309
|
+
$pmModal.classList.remove('show');
|
|
15310
|
+
$pmModal.removeEventListener('click', onClick);
|
|
15311
|
+
$pmModal.removeEventListener('input', onInput);
|
|
15312
|
+
$pmModal.removeEventListener('keydown', onKey);
|
|
15313
|
+
$pmModal.removeEventListener('mousedown', onBackdrop);
|
|
15314
|
+
$file.removeEventListener('change', onFile);
|
|
15315
|
+
const back = typeof returnFocus === 'function' ? returnFocus() : returnFocus;
|
|
15316
|
+
if (back && back.isConnected) back.focus();
|
|
15317
|
+
resolve(value);
|
|
15318
|
+
};
|
|
15319
|
+
|
|
15320
|
+
const choose = (profile, value) => {
|
|
15321
|
+
choices.set(profile, value === '' ? null : value);
|
|
15322
|
+
openRow = null;
|
|
15323
|
+
render();
|
|
15324
|
+
const trigger = $body.querySelector(`[data-pm-row="${CSS.escape(profile)}"] .pm-trigger`);
|
|
15325
|
+
if (trigger) trigger.focus();
|
|
15326
|
+
};
|
|
15327
|
+
|
|
15328
|
+
function onClick(event) {
|
|
15329
|
+
const target = event.target instanceof Element ? event.target : null;
|
|
15330
|
+
if (!target) return;
|
|
15331
|
+
if (target.closest('#profilemap-apply')) {
|
|
15332
|
+
if (busy) return;
|
|
15333
|
+
if (check.supported === false) { close({ action: 'skip' }); return; }
|
|
15334
|
+
close({ action: 'apply', profileMap: Object.fromEntries(choices), modelPath: check.modelPath || null, revision: check.revision || 0 });
|
|
15335
|
+
return;
|
|
15336
|
+
}
|
|
15337
|
+
if (target.closest('#profilemap-cancel')) { close(null); return; }
|
|
15338
|
+
if (target.closest('#profilemap-import')) { if (!busy) $file.click(); return; }
|
|
15339
|
+
const source = target.closest('[data-pm-source]');
|
|
15340
|
+
if (source) { if (!busy) void recheck(source.dataset.pmSource || undefined); return; }
|
|
15341
|
+
const option = target.closest('[data-pm-value]');
|
|
15342
|
+
const row = target.closest('[data-pm-row]');
|
|
15343
|
+
if (option && row) { choose(row.dataset.pmRow, option.dataset.pmValue); return; }
|
|
15344
|
+
const trigger = target.closest('.pm-trigger');
|
|
15345
|
+
if (trigger && row) {
|
|
15346
|
+
openRow = openRow === row.dataset.pmRow ? null : row.dataset.pmRow;
|
|
15347
|
+
render();
|
|
15348
|
+
const search = $body.querySelector('.pm-search');
|
|
15349
|
+
if (search) search.focus();
|
|
15350
|
+
}
|
|
15351
|
+
}
|
|
15352
|
+
function onInput(event) {
|
|
15353
|
+
const search = event.target instanceof Element ? event.target.closest('.pm-search') : null;
|
|
15354
|
+
if (!search || !openRow) return;
|
|
15355
|
+
const row = (check.rows || []).find((candidate) => candidate.profile === openRow);
|
|
15356
|
+
const list = search.closest('.pm-popover')?.querySelector('.pm-list');
|
|
15357
|
+
if (!row || !list) return;
|
|
15358
|
+
const holder = document.createElement('div');
|
|
15359
|
+
holder.innerHTML = popoverHtml(row, search.value);
|
|
15360
|
+
list.innerHTML = holder.querySelector('.pm-list').innerHTML;
|
|
15361
|
+
}
|
|
15362
|
+
function onKey(event) {
|
|
15363
|
+
if (event.key === 'Escape') {
|
|
15364
|
+
event.preventDefault();
|
|
15365
|
+
event.stopPropagation();
|
|
15366
|
+
if (openRow) { const profile = openRow; openRow = null; render(); const t = $body.querySelector(`[data-pm-row="${CSS.escape(profile)}"] .pm-trigger`); if (t) t.focus(); }
|
|
15367
|
+
else if (!busy) close(null);
|
|
15368
|
+
return;
|
|
15369
|
+
}
|
|
15370
|
+
const target = event.target instanceof Element ? event.target : null;
|
|
15371
|
+
if (target && openRow && (event.key === 'ArrowDown' || event.key === 'ArrowUp')) {
|
|
15372
|
+
const options = Array.from($body.querySelectorAll('.pm-popover [role="option"]'));
|
|
15373
|
+
const at = options.indexOf(document.activeElement);
|
|
15374
|
+
const next = event.key === 'ArrowDown' ? options[Math.min(options.length - 1, at + 1)] : (at <= 0 ? $body.querySelector('.pm-search') : options[at - 1]);
|
|
15375
|
+
if (next) { event.preventDefault(); next.focus(); }
|
|
15376
|
+
return;
|
|
15377
|
+
}
|
|
15378
|
+
if (target && (event.key === 'Enter' || event.key === ' ') && target.matches('[role="option"]')) {
|
|
15379
|
+
event.preventDefault();
|
|
15380
|
+
const row = target.closest('[data-pm-row]');
|
|
15381
|
+
if (row) choose(row.dataset.pmRow, target.dataset.pmValue);
|
|
15382
|
+
return;
|
|
15383
|
+
}
|
|
15384
|
+
if (event.key !== 'Tab') return;
|
|
15385
|
+
const focusable = Array.from($pmModal.querySelectorAll('button:not([disabled]), input:not([hidden]):not([disabled]), [tabindex="0"], [role="option"]')).filter((node) => !node.hidden && node.offsetParent !== null && node.getAttribute('tabindex') !== '-1');
|
|
15386
|
+
if (!focusable.length) return;
|
|
15387
|
+
const firstNode = focusable[0], lastNode = focusable[focusable.length - 1];
|
|
15388
|
+
if (event.shiftKey && document.activeElement === firstNode) { event.preventDefault(); lastNode.focus(); }
|
|
15389
|
+
else if (!event.shiftKey && document.activeElement === lastNode) { event.preventDefault(); firstNode.focus(); }
|
|
15390
|
+
}
|
|
15391
|
+
function onBackdrop(event) { if (event.target === $pmModal && !busy) close(null); }
|
|
15392
|
+
async function onFile() {
|
|
15393
|
+
const file = ($file.files || [])[0];
|
|
15394
|
+
$file.value = '';
|
|
15395
|
+
if (!file || busy) return;
|
|
15396
|
+
busy = true; render();
|
|
15397
|
+
try {
|
|
15398
|
+
const dataUrl = await pmFileAsDataUrl(file);
|
|
15399
|
+
const saved = await api(`/api/projects/${encodeURIComponent(projectId)}/host-profile-catalogues?appId=${encodeURIComponent(app)}`, {
|
|
15400
|
+
method: 'POST', body: JSON.stringify({ name: file.name, dataUrl }), timeoutMs: 120000,
|
|
15401
|
+
});
|
|
15402
|
+
busy = false;
|
|
15403
|
+
const next = await recheck(saved.catalogue && saved.catalogue.id, true);
|
|
15404
|
+
$note.textContent = next && next.supported && next.source === 'imported'
|
|
15405
|
+
? `Imported ${file.name}. The profiles are now checked against it.`
|
|
15406
|
+
: `Imported ${file.name}, but FloLess could not check the profiles against it. ${next && next.reason ? next.reason : 'Pick it from the list above to try again.'}`;
|
|
15407
|
+
} catch (error) {
|
|
15408
|
+
busy = false; render();
|
|
15409
|
+
$note.textContent = personText(error && error.body) || 'FloLess could not read that file. Choose a Tekla .profilecatalog or .lis file exported from Tekla and try again.';
|
|
15410
|
+
}
|
|
15411
|
+
}
|
|
15412
|
+
|
|
15413
|
+
seed();
|
|
15414
|
+
render();
|
|
15415
|
+
$pmModal.addEventListener('click', onClick);
|
|
15416
|
+
$pmModal.addEventListener('input', onInput);
|
|
15417
|
+
$pmModal.addEventListener('keydown', onKey);
|
|
15418
|
+
$pmModal.addEventListener('mousedown', onBackdrop);
|
|
15419
|
+
$file.addEventListener('change', onFile);
|
|
15420
|
+
$pmModal.classList.add('show');
|
|
15421
|
+
dialog.focus();
|
|
15422
|
+
});
|
|
15423
|
+
}
|
|
15424
|
+
|
|
15425
|
+
/**
|
|
15426
|
+
* The send's profile review. Resolves null when the person cancels; {} when the profiles were not checked
|
|
15427
|
+
* (the send then goes as before); else the fields the preflight and the send carry.
|
|
15428
|
+
*/
|
|
15429
|
+
async function reviewTeklaProfiles(projectId, app, sourceHandle, returnFocus) {
|
|
15430
|
+
showToast('Checking which profiles Tekla has…', 'info');
|
|
15431
|
+
const first = await checkTeklaProfiles(projectId, app, undefined, sourceHandle);
|
|
15432
|
+
if (first.supported && (first.rows || []).length === 0) {
|
|
15433
|
+
return { profileMap: {}, ...(first.modelPath ? { modelPath: first.modelPath } : {}), profileMapRevision: first.revision || 0 };
|
|
15434
|
+
}
|
|
15435
|
+
const answer = await openProfileMapWindow({ projectId, app, first, returnFocus, sourceHandle });
|
|
15436
|
+
if (!answer) return null;
|
|
15437
|
+
if (answer.action === 'skip') return {};
|
|
15438
|
+
let revision = answer.revision;
|
|
15439
|
+
try {
|
|
15440
|
+
const saved = await api(`/api/projects/${encodeURIComponent(projectId)}/host-profile-map?appId=${encodeURIComponent(app)}`, {
|
|
15441
|
+
method: 'PUT', body: JSON.stringify({ host: 'tekla', entries: answer.profileMap, baseRevision: answer.revision }),
|
|
15442
|
+
});
|
|
15443
|
+
revision = saved.revision;
|
|
15444
|
+
} catch (error) {
|
|
15445
|
+
// Keeping the table is a courtesy and never blocks the send, but the person is told it was not kept.
|
|
15446
|
+
console.warn('[workspaces] could not save the profile table', error);
|
|
15447
|
+
showToast('Your profile choices apply to this send, but FloLess could not remember them for next time.', 'warn');
|
|
15448
|
+
}
|
|
15449
|
+
return { profileMap: answer.profileMap, ...(answer.modelPath ? { modelPath: answer.modelPath } : {}), profileMapRevision: revision };
|
|
15450
|
+
}
|
|
15451
|
+
|
|
15452
|
+
/** What the table did, in a sentence for the send's summary. */
|
|
15453
|
+
function profileMappingText(mapping, counts) {
|
|
15454
|
+
if (!mapping || !mapping.reviewed) return '';
|
|
15455
|
+
const parts = [];
|
|
15456
|
+
const mapped = Array.isArray(mapping.mapped) ? mapping.mapped : [];
|
|
15457
|
+
if (mapped.length) parts.push(`${mapped.length} profile${mapped.length === 1 ? '' : 's'} renamed for Tekla`);
|
|
15458
|
+
const lines = Number(mapping.lines) || 0;
|
|
15459
|
+
if (lines) parts.push(`${lines} member${lines === 1 ? '' : 's'} arrived as profile-less lines — select them in Tekla and give them a profile`);
|
|
15460
|
+
return parts.join(', ');
|
|
15461
|
+
}
|
|
15462
|
+
|
|
15463
|
+
async function preflightHostSends(hosts, projectId, appId, sourceHandles, hostBodies = {}) {
|
|
13767
15464
|
const results = await Promise.allSettled(hosts.map((host, index) => api(
|
|
13768
15465
|
hostSendUrl(host, projectId, appId, sourceHandles[index]),
|
|
13769
|
-
{ method: 'POST', body: JSON.stringify({ preflight: true }) },
|
|
15466
|
+
{ method: 'POST', body: JSON.stringify({ preflight: true, ...(hostBodies[host] || {}) }) },
|
|
13770
15467
|
)));
|
|
13771
15468
|
const reviews = results.filter((result) => result.status === 'fulfilled').map((result) => result.value);
|
|
13772
15469
|
reviews.forEach((review) => activeProjectHostBakeConsents.set(review.consent, { projectId, appId }));
|
|
@@ -13863,6 +15560,8 @@
|
|
|
13863
15560
|
'view-scale-invalid': 'no valid drawing scale',
|
|
13864
15561
|
'cross-view-conflict': 'conflicting drawing views',
|
|
13865
15562
|
'placement-evidence-conflict': 'conflicting placement evidence',
|
|
15563
|
+
'custom-section-unverified': 'a custom section that cannot be checked',
|
|
15564
|
+
'custom-section-not-exported': 'a custom section this export does not carry',
|
|
13866
15565
|
};
|
|
13867
15566
|
const grouped = {};
|
|
13868
15567
|
rows.forEach((row) => { grouped[row.reason] = (grouped[row.reason] || 0) + 1; });
|
|
@@ -13881,13 +15580,14 @@
|
|
|
13881
15580
|
* be minutes old by the time a third host's turn comes round, and an application closed since
|
|
13882
15581
|
* then must be reported rather than sent into.
|
|
13883
15582
|
*/
|
|
13884
|
-
async function sendToHosts(hosts, projectId, app, approvedAt, sourceHandles, sourceKind, reviews) {
|
|
15583
|
+
async function sendToHosts(hosts, projectId, app, approvedAt, sourceHandles, sourceKind, reviews, hostBodies = {}) {
|
|
13885
15584
|
const done = [];
|
|
13886
15585
|
const failed = [];
|
|
13887
15586
|
const uncertain = [];
|
|
13888
15587
|
const aborted = [];
|
|
13889
15588
|
let uncertainHost = null;
|
|
13890
15589
|
let staleReview = false;
|
|
15590
|
+
let modelChanged = false;
|
|
13891
15591
|
/** Has the sign-off this batch was aimed at moved on? Only answerable while it is still open. */
|
|
13892
15592
|
const approvalMoved = () => !!current && current.id === projectId && current.approvedAt !== approvedAt;
|
|
13893
15593
|
try {
|
|
@@ -13914,7 +15614,7 @@
|
|
|
13914
15614
|
const res = await api(hostSendUrl(host, projectId, app, sourceHandles[i]), {
|
|
13915
15615
|
method: 'POST',
|
|
13916
15616
|
headers: { 'content-type': 'application/json', 'x-floless-host-bake-consent': reviews[i].consent },
|
|
13917
|
-
body: JSON.stringify({}),
|
|
15617
|
+
body: JSON.stringify(hostBodies[host] || {}),
|
|
13918
15618
|
});
|
|
13919
15619
|
await acknowledgeProjectHostBakeConsent(projectId, app, reviews[i].consent);
|
|
13920
15620
|
track('workspace_export', { app, kind: `send:${host}`, sourceKind });
|
|
@@ -13924,22 +15624,26 @@
|
|
|
13924
15624
|
counts: res.counts,
|
|
13925
15625
|
warnings: res.warnings || [],
|
|
13926
15626
|
unsupported: res.receipt && Array.isArray(res.receipt.unsupported) ? res.receipt.unsupported : [],
|
|
15627
|
+
profileMapping: res.profileMapping || null,
|
|
13927
15628
|
approvedAt,
|
|
13928
15629
|
});
|
|
13929
15630
|
summary = receiptSummary(exportReceipts.get(`${projectId}:send:${host}`), `send:${host}`);
|
|
13930
15631
|
}
|
|
13931
15632
|
hostSends.set(`${projectId}:${host}`, { at: new Date().toISOString(), approvedAt });
|
|
13932
15633
|
const omissionText = hostBakeOmissionSummary(res);
|
|
15634
|
+
const mappingText = profileMappingText(res.profileMapping);
|
|
13933
15635
|
done.push({
|
|
13934
15636
|
host,
|
|
13935
|
-
partial: !!omissionText || !!(summary && summary.partial),
|
|
13936
|
-
text: omissionText || (summary && summary.text),
|
|
15637
|
+
partial: !!omissionText || !!mappingText || !!(summary && summary.partial),
|
|
15638
|
+
text: [omissionText || (summary && summary.text), mappingText].filter(Boolean).join(' · '),
|
|
13937
15639
|
});
|
|
13938
15640
|
} catch (err) {
|
|
13939
15641
|
if (err && err.body && ['host-bake-dispatch-uncertain', 'host-bake-result-unverified'].includes(err.body.code)) {
|
|
13940
15642
|
const detail = err.body.error || (err && err.message) || String(err);
|
|
13941
15643
|
uncertain.push({ host, error: detail });
|
|
13942
15644
|
uncertainHost = host;
|
|
15645
|
+
// #3273: the card says so too, long after the toast is gone, and offers "Send again".
|
|
15646
|
+
hostSends.set(`${projectId}:${host}`, { at: new Date().toISOString(), approvedAt, unconfirmed: true });
|
|
13943
15647
|
aborted.push(...hosts.slice(i + 1));
|
|
13944
15648
|
break;
|
|
13945
15649
|
}
|
|
@@ -13947,16 +15651,20 @@
|
|
|
13947
15651
|
|| (err && err.body && err.body.code === 'response-unreadable')) {
|
|
13948
15652
|
uncertain.push({ host, error: `FloLess lost the ${hostLabel(host)} response after dispatch. Check the open model before sending again.` });
|
|
13949
15653
|
uncertainHost = host;
|
|
15654
|
+
hostSends.set(`${projectId}:${host}`, { at: new Date().toISOString(), approvedAt, unconfirmed: true });
|
|
13950
15655
|
aborted.push(...hosts.slice(i + 1));
|
|
13951
15656
|
break;
|
|
13952
15657
|
}
|
|
13953
|
-
if (err && err.body && ['host-bake-confirmation-stale', 'host-bake-preflight-required', 'stale-selection'].includes(err.body.code)) {
|
|
15658
|
+
if (err && err.body && ['host-bake-confirmation-stale', 'host-bake-preflight-required', 'stale-selection', 'host-profile-model-changed'].includes(err.body.code)) {
|
|
13954
15659
|
staleReview = true;
|
|
15660
|
+
// A different Tekla model is open now: the table must be checked against it, so the window opens again.
|
|
15661
|
+
if (err.body.code === 'host-profile-model-changed') modelChanged = true;
|
|
13955
15662
|
aborted.push(...hosts.slice(i));
|
|
13956
15663
|
break;
|
|
13957
15664
|
}
|
|
13958
15665
|
const detail = personText(err && err.body) || (err && err.message) || String(err);
|
|
13959
|
-
|
|
15666
|
+
// A refusal Tekla made and undid is a definite answer (#3312): say what it was and that nothing changed.
|
|
15667
|
+
failed.push({ host, error: detail, rejected: !!(err && err.body && err.body.code === 'host-bake-rejected') });
|
|
13960
15668
|
}
|
|
13961
15669
|
}
|
|
13962
15670
|
} finally {
|
|
@@ -13980,7 +15688,9 @@
|
|
|
13980
15688
|
clean.length ? `Sent to ${sequenceText(clean.map((d) => d.host))}.` : '',
|
|
13981
15689
|
...partial.map((d) => `${hostLabel(d.host)} took it with gaps — ${d.text}.`),
|
|
13982
15690
|
...uncertain.map((row) => row.error),
|
|
13983
|
-
...failed.map((f) =>
|
|
15691
|
+
...failed.map((f) => (f.rejected
|
|
15692
|
+
? `${f.error} Choose Send again to review the profiles.`
|
|
15693
|
+
: `${hostLabel(f.host)} didn’t — ${reasonFragment(humanSendError(f.error))}.`)),
|
|
13984
15694
|
// The abort rides in the SAME sentence rather than firing its own toast: two toasts about
|
|
13985
15695
|
// one action is exactly the storm this single-line report replaced.
|
|
13986
15696
|
aborted.length
|
|
@@ -13993,13 +15703,9 @@
|
|
|
13993
15703
|
].filter(Boolean).join(' ');
|
|
13994
15704
|
showToast(sentence, partial.length || failed.length || uncertain.length || aborted.length ? 'warn' : 'ok');
|
|
13995
15705
|
}
|
|
13996
|
-
|
|
13997
|
-
|
|
13998
|
-
|
|
13999
|
-
await safeRenderExports('after that send finished', 'send-host',
|
|
14000
|
-
() => paintExports(approvedAt, 'send-host'));
|
|
14001
|
-
}
|
|
14002
|
-
return { staleReview, remainingHosts: staleReview ? [...aborted] : [] };
|
|
15706
|
+
// No repaint here (#3273): chooseAndSend refreshes the pane once it has released the send's busy claim, so a
|
|
15707
|
+
// refresh that is slow or never answers cannot keep the card on "Sending…".
|
|
15708
|
+
return { staleReview, modelChanged, remainingHosts: staleReview ? [...aborted] : [] };
|
|
14003
15709
|
}
|
|
14004
15710
|
|
|
14005
15711
|
/** The Send card's whole action: ask, then send. */
|
|
@@ -14014,6 +15720,7 @@
|
|
|
14014
15720
|
const busyKey = `${projectId}:send-host`;
|
|
14015
15721
|
if (exportBusy.has(busyKey)) { showToast(sendBusyText(), 'info'); return; }
|
|
14016
15722
|
exportBusy.add(busyKey);
|
|
15723
|
+
let sent = false; // a send reached the destinations, so the pane re-reads the listing once the claim is released
|
|
14017
15724
|
try {
|
|
14018
15725
|
const picked = await askSendDestinations(projectId);
|
|
14019
15726
|
if (current && current.id === projectId && !$wsExports.hidden) paintExports(current.approvedAt);
|
|
@@ -14023,6 +15730,8 @@
|
|
|
14023
15730
|
if (!sourceOption) { showToast('Choose an export source first.', 'warn'); return; }
|
|
14024
15731
|
const sourceSelector = JSON.parse(JSON.stringify(sourceOption.selector));
|
|
14025
15732
|
let remainingHosts = [...picked];
|
|
15733
|
+
let hostBodies = {};
|
|
15734
|
+
let teklaReviewed = false; // the mapping window is shown once per send, not again on a stale-review retry
|
|
14026
15735
|
// The user may have switched projects while the dialog was open — the send must not land on
|
|
14027
15736
|
// whatever is open NOW. Everything below is keyed to the captured project. One stale
|
|
14028
15737
|
// continuation is rebuilt and re-reviewed; a second fails closed instead of looping forever.
|
|
@@ -14034,7 +15743,24 @@
|
|
|
14034
15743
|
let reviews;
|
|
14035
15744
|
try {
|
|
14036
15745
|
showToast(attempt ? 'Checking the latest approved model…' : 'Checking what will be sent…', 'info');
|
|
14037
|
-
|
|
15746
|
+
// Tekla only (#3312): ask which profiles it has and let the person decide what the missing ones become.
|
|
15747
|
+
if (remainingHosts.includes('tekla') && !teklaReviewed) {
|
|
15748
|
+
const reviewed = await reviewTeklaProfiles(projectId, app, handles[remainingHosts.indexOf('tekla')], () => $wsExports.querySelector('[data-export="send-host"]'));
|
|
15749
|
+
if (reviewed === null) {
|
|
15750
|
+
await releaseCapturedSources(projectId, handles);
|
|
15751
|
+
exportBusy.delete(busyKey);
|
|
15752
|
+
if (current && current.id === projectId && !$wsExports.hidden) {
|
|
15753
|
+
paintExports(current.approvedAt, 'send-host');
|
|
15754
|
+
const sendCard = $wsExports.querySelector('[data-export="send-host"]');
|
|
15755
|
+
if (sendCard instanceof HTMLElement && !sendCard.matches(':disabled,[aria-disabled="true"]')) sendCard.focus();
|
|
15756
|
+
}
|
|
15757
|
+
showToast('CAD send cancelled.', 'info');
|
|
15758
|
+
return;
|
|
15759
|
+
}
|
|
15760
|
+
teklaReviewed = true;
|
|
15761
|
+
if (reviewed.profileMap) hostBodies.tekla = reviewed;
|
|
15762
|
+
}
|
|
15763
|
+
reviews = await preflightHostSends(remainingHosts, projectId, app, handles, hostBodies);
|
|
14038
15764
|
const confirmed = await confirmAggregateHostSend(remainingHosts, reviews[0], attempt > 0 && reviews[0].kind === 'clean');
|
|
14039
15765
|
if (!confirmed) {
|
|
14040
15766
|
await Promise.allSettled(reviews.map((review) => cancelProjectHostBakeConsent(projectId, app, review.consent)));
|
|
@@ -14073,15 +15799,29 @@
|
|
|
14073
15799
|
const attemptApprovedAt = attempt > 0 && current && current.id === projectId
|
|
14074
15800
|
? current.approvedAt
|
|
14075
15801
|
: approvedAt;
|
|
14076
|
-
const result = await sendToHosts(remainingHosts, projectId, app, attemptApprovedAt, handles, sources[0].kind, reviews);
|
|
15802
|
+
const result = await sendToHosts(remainingHosts, projectId, app, attemptApprovedAt, handles, sources[0].kind, reviews, hostBodies);
|
|
15803
|
+
sent = true;
|
|
14077
15804
|
if (attempt === 0 && result && result.staleReview && result.remainingHosts.length) {
|
|
14078
15805
|
remainingHosts = result.remainingHosts;
|
|
15806
|
+
if (result.modelChanged) { teklaReviewed = false; delete hostBodies.tekla; }
|
|
15807
|
+
// The retry anchors to the approval this refresh reads, so it waits for it (every refresh is bounded).
|
|
15808
|
+
if (current && current.id === projectId && !$wsExports.hidden) {
|
|
15809
|
+
await safeRenderExports('after that send finished', 'send-host', () => paintExports(approvedAt, 'send-host'));
|
|
15810
|
+
}
|
|
14079
15811
|
continue;
|
|
14080
15812
|
}
|
|
14081
15813
|
return;
|
|
14082
15814
|
}
|
|
14083
15815
|
} finally {
|
|
14084
15816
|
exportBusy.delete(busyKey);
|
|
15817
|
+
// #3273: the card leaves its busy state the moment the claim is released, whatever the outcome. It used to repaint
|
|
15818
|
+
// only while the claim was still held, so an exit that did not repaint again (or a refresh that never finished)
|
|
15819
|
+
// left "Sending…" up for good. After a send the pane then re-reads the listing, so it reflects the project as it
|
|
15820
|
+
// is now; that refresh runs with the claim already released, so it cannot hold the card either.
|
|
15821
|
+
if (current && current.id === projectId && !$wsExports.hidden) {
|
|
15822
|
+
paintExports(current.approvedAt, sent ? 'send-host' : undefined);
|
|
15823
|
+
if (sent) await safeRenderExports('after that send finished', 'send-host', () => paintExports(approvedAt, 'send-host'));
|
|
15824
|
+
}
|
|
14085
15825
|
}
|
|
14086
15826
|
}
|
|
14087
15827
|
|
|
@@ -14385,6 +16125,16 @@
|
|
|
14385
16125
|
const rows = sent.length
|
|
14386
16126
|
? `<div class="e-renders e-sent-list" role="group" aria-label="Sent to">` +
|
|
14387
16127
|
sent.map((r) => {
|
|
16128
|
+
// #3273: a send FloLess could not confirm is never a ✓. The row keeps "sent" (it may well have landed), names
|
|
16129
|
+
// why it is unconfirmed, and carries no receipt: whatever receipt is held is from an earlier send.
|
|
16130
|
+
if (r.rec.unconfirmed) {
|
|
16131
|
+
return `<div class="e-render-entry">` +
|
|
16132
|
+
`<div class="e-render-row">` +
|
|
16133
|
+
`<span class="e-done unconfirmed"><span class="chk" aria-hidden="true">!</span> sent to ${escapeHtml(hostLabel(r.host))} – not confirmed <span class="t">${escapeHtml(hhmm(r.rec.at))}</span></span>` +
|
|
16134
|
+
`</div>` +
|
|
16135
|
+
`<div class="e-receipt partial"><span>FloLess couldn’t confirm what changed in ${escapeHtml(hostLabel(r.host))}. Check the open model before sending again.</span></div>` +
|
|
16136
|
+
`</div>`;
|
|
16137
|
+
}
|
|
14388
16138
|
// Asked of the receipt HERE rather than remembered as a flag at send time. The two
|
|
14389
16139
|
// drifted: a clean send stored "has details" and then opened an empty dialog, because
|
|
14390
16140
|
// what the button offers and what the dialog can show must be the same question.
|
|
@@ -14603,6 +16353,7 @@
|
|
|
14603
16353
|
// says what the producer could not emit from what it was given, this says what was never
|
|
14604
16354
|
// given to it. A model missing three heights and an AWARE weld failure are not one fact.
|
|
14605
16355
|
(c.kind === 'send-host' ? '' : omittedHtml(c.kind, approved)) +
|
|
16356
|
+
(c.kind === 'ifc' ? customSectionAssumedHtml(approved) : '') +
|
|
14606
16357
|
(c.kind === 'send-host' ? '' : exportProvenanceHtml(c.kind, approved)) +
|
|
14607
16358
|
// REGISTERED, because #1156a changed what this button DOES. It used to refuse an export outright
|
|
14608
16359
|
// when any member's endpoint elevation was unresolved; now the file exports build what they can
|
|
@@ -15085,12 +16836,13 @@
|
|
|
15085
16836
|
console.error('[workspaces] exports refresh threw ' + (reason || '(no reason given)'), err);
|
|
15086
16837
|
// `err`, NOT `warn`, and the reason is in `showToast`'s own table rather than in taste: a `warn`
|
|
15087
16838
|
// auto-dismisses after 5 s while an `err` stays until it is closed. This message is long — the
|
|
15088
|
-
// trigger, the
|
|
16839
|
+
// trigger, the cause, and a two-clause recovery instruction — and it reports a programming
|
|
15089
16840
|
// error the reader can do nothing about except reopen the step. Five seconds is not enough to
|
|
15090
16841
|
// read it, and losing it leaves them looking at the half-painted card the bug just produced with
|
|
15091
16842
|
// no explanation at all, which is the silence this whole change removes. (Design review.)
|
|
15092
16843
|
showToast(
|
|
15093
|
-
|
|
16844
|
+
// #3097: the raw error is in the console line above, never in the toast.
|
|
16845
|
+
'Couldn’t refresh the exports view ' + (reason || 'just now') + ' because of a problem inside FloLess'
|
|
15094
16846
|
+ ' — leave the Exports step and open it again to retry.',
|
|
15095
16847
|
'err',
|
|
15096
16848
|
);
|
|
@@ -15212,12 +16964,15 @@
|
|
|
15212
16964
|
// `checkpointPromise`, reintroduced one line up by the wait itself. The `return` on the line
|
|
15213
16965
|
// above made it worse: it abandoned the promise outright.
|
|
15214
16966
|
const sourcesRefused = !!approvalRefusalNote();
|
|
15215
|
-
|
|
15216
|
-
|
|
16967
|
+
// #3273: each with a deadline, because a request that never answers is not an error and would never reach the
|
|
16968
|
+
// failure branches below: the pane would sit on "Loading export sources…" for good.
|
|
16969
|
+
const bounded = { timeoutMs: EXPORTS_REFRESH_MS };
|
|
16970
|
+
const exportPromise = api(`/api/contract/${encodeURIComponent(app)}/exports?project=${encodeURIComponent(id)}`, bounded);
|
|
16971
|
+
const sourcePromise = sourcesRefused ? null : api(`/api/projects/${encodeURIComponent(id)}/export-sources`, bounded);
|
|
15217
16972
|
// Host readiness is intentionally not probed while painting Exports. A send preflight first
|
|
15218
16973
|
// establishes what the reviewed model would omit; only an authorized continuation may contact
|
|
15219
16974
|
// AWARE or a CAD bridge.
|
|
15220
|
-
const renderReadyPromise = hasRender ? api('/api/render/readiness') : Promise.resolve(null);
|
|
16975
|
+
const renderReadyPromise = hasRender ? api('/api/render/readiness', bounded) : Promise.resolve(null);
|
|
15221
16976
|
const [exportResult, renderReadyResult, sourceResult] = await Promise.allSettled([
|
|
15222
16977
|
exportPromise, renderReadyPromise, sourcePromise,
|
|
15223
16978
|
]);
|
|
@@ -15263,7 +17018,8 @@
|
|
|
15263
17018
|
// Prefer the server's own words, as the Tekla branch below already does. The route-gate
|
|
15264
17019
|
// 409s this endpoint while AWARE is still installing and says so actionably; replacing
|
|
15265
17020
|
// that with the generic line threw away the only sentence that told the user to wait.
|
|
15266
|
-
|
|
17021
|
+
// A deadline that ran out has no sentence for a person, so it takes the generic line.
|
|
17022
|
+
message: (renderReadyResult.reason && renderReadyResult.reason.name !== 'TimeoutError' && renderReadyResult.reason.message)
|
|
15267
17023
|
|| 'Could not check whether rendering is available.',
|
|
15268
17024
|
recovery: { action: 'retry', label: 'Check again' },
|
|
15269
17025
|
};
|
|
@@ -15481,7 +17237,7 @@
|
|
|
15481
17237
|
code === 'aware_too_old' ? (awareVersion
|
|
15482
17238
|
? `AWARE v${awareVersion} is too old to share a faithful model — Realistic and Shadowed need v${awareFloor} or later. Click ↑ Upgrade AWARE in the footer, then share again.`
|
|
15483
17239
|
: `Your installed AWARE is too old to share a faithful model — Realistic and Shadowed need v${awareFloor} or later. Click ↑ Upgrade AWARE in the footer, then share again.`) :
|
|
15484
|
-
(err
|
|
17240
|
+
errorText(err, { action: 'create the share link', unsure: 'Check the card for a share link before trying again.' }),
|
|
15485
17241
|
'warn');
|
|
15486
17242
|
} finally {
|
|
15487
17243
|
exportBusy.delete(busyKey);
|
|
@@ -15500,8 +17256,11 @@
|
|
|
15500
17256
|
const body = renderOptions || bomOptions;
|
|
15501
17257
|
// #2521 row 5b: a render of a Quick model may ask how to continue (the caption). Answered here, so the render
|
|
15502
17258
|
// proceeds only once the person has chosen; a cancelled question ends it, having said what was saved.
|
|
17259
|
+
// Add-ons S1a: an IFC export may ask about custom sections with no IFC shape. Answered here the same way.
|
|
15503
17260
|
const res = kind === 'render'
|
|
15504
17261
|
? await postRenderAnsweringCaption(projectId, app, capturedSource.handleId, body)
|
|
17262
|
+
: kind === 'ifc'
|
|
17263
|
+
? await postIfcAnsweringCustomSections(projectId, app, capturedSource.handleId)
|
|
15505
17264
|
: await api(exportUrl(kind, projectId, app, capturedSource.handleId), body
|
|
15506
17265
|
? { method: 'POST', body: JSON.stringify(body), headers: { 'content-type': 'application/json' } }
|
|
15507
17266
|
: { method: 'POST' });
|
|
@@ -15556,9 +17315,12 @@
|
|
|
15556
17315
|
// toast is raised. `showToast` appends rather than replaces, so emitting a clean "Exported"
|
|
15557
17316
|
// and then a warning would leave the user reading two contradictory messages at once.
|
|
15558
17317
|
const omittedNow = Array.isArray(res.skippedDetail) ? res.skippedDetail.length : 0;
|
|
17318
|
+
const boxedNow = Array.isArray(res.customSections) ? res.customSections.filter((row) => row && row.sent === 'bounding-box').length : 0;
|
|
15559
17319
|
const gaps = [
|
|
15560
17320
|
summary && summary.partial ? summary.text : null,
|
|
15561
17321
|
omittedNow ? `${omittedNow} member${omittedNow === 1 ? '' : 's'} left out — see the card for why` : null,
|
|
17322
|
+
// Add-ons S1a: a custom section sent as its bounding box is in the file, but not as itself.
|
|
17323
|
+
boxedNow ? `${boxedNow} sent as a bounding box, named in the file as an assumption` : null,
|
|
15562
17324
|
].filter(Boolean);
|
|
15563
17325
|
// #2521 row 5b: a file made from a Quick (or possibly Quick) model says so here too; the file carries it as well.
|
|
15564
17326
|
const quickBit = res.quick && res.quick.label ? ` — ${res.quick.label}, named in the file` : '';
|
|
@@ -15589,10 +17351,13 @@
|
|
|
15589
17351
|
const got = kind === 'render' && err && err.body && Array.isArray(err.body.rendered)
|
|
15590
17352
|
? err.body.rendered.length : 0;
|
|
15591
17353
|
publishedDespiteFailure = got > 0;
|
|
17354
|
+
// #3097: the server's sentence or the shared one (errorText), never the error's own text.
|
|
17355
|
+
const exportAction = kind === 'render' ? 'finish the render' : 'finish that export';
|
|
17356
|
+
if (got > 0 && !personText(err && err.body)) console.warn('[exports] the render stopped partway', err);
|
|
15592
17357
|
showToast(
|
|
15593
17358
|
got > 0
|
|
15594
|
-
? `${err && err.
|
|
15595
|
-
: (err
|
|
17359
|
+
? `${personText(err && err.body) || 'Rendering didn’t finish'} — ${got} viewpoint${got === 1 ? '' : 's'} did finish and ${got === 1 ? 'is' : 'are'} saved.`
|
|
17360
|
+
: errorText(err, { action: exportAction, unsure: 'Check the exports list before trying again.' }),
|
|
15596
17361
|
'warn');
|
|
15597
17362
|
} finally {
|
|
15598
17363
|
exportBusy.delete(busyKey);
|
|
@@ -15648,6 +17413,58 @@
|
|
|
15648
17413
|
}
|
|
15649
17414
|
}
|
|
15650
17415
|
|
|
17416
|
+
/**
|
|
17417
|
+
* Add-ons S1a: POST an IFC export, answering the question it asks when members use a custom section whose shape an
|
|
17418
|
+
* IFC file cannot carry as itself. The question is asked before the source is spent, so the answer exports the same
|
|
17419
|
+
* frozen version. Resolves the export's answer, or null when the person cancelled (the source is released).
|
|
17420
|
+
*/
|
|
17421
|
+
async function postIfcAnsweringCustomSections(projectId, app, handleId) {
|
|
17422
|
+
let request = null;
|
|
17423
|
+
for (;;) {
|
|
17424
|
+
try {
|
|
17425
|
+
return await api(exportUrl('ifc', projectId, app, handleId), request
|
|
17426
|
+
? { method: 'POST', body: JSON.stringify(request), headers: { 'content-type': 'application/json' } }
|
|
17427
|
+
: { method: 'POST' });
|
|
17428
|
+
} catch (err) {
|
|
17429
|
+
const ask = err && err.body && err.body.needsChoice === 'custom-sections' ? err.body : null;
|
|
17430
|
+
// Asked once: a second question for the same click means the model changed under it, which the next click asks about.
|
|
17431
|
+
if (!ask || request) throw err;
|
|
17432
|
+
const choice = await askIfcCustomSections(ask, projectId);
|
|
17433
|
+
if (!choice) {
|
|
17434
|
+
try { await releaseCapturedSources(projectId, [handleId]); } catch { /* it expires on its own */ }
|
|
17435
|
+
showToast('IFC export stopped. Nothing was exported.', 'info');
|
|
17436
|
+
return null;
|
|
17437
|
+
}
|
|
17438
|
+
request = { customSections: { choice, key: ask.key } };
|
|
17439
|
+
}
|
|
17440
|
+
}
|
|
17441
|
+
}
|
|
17442
|
+
|
|
17443
|
+
/** The custom-section question itself. Resolves 'leave-out', 'bounding-box', or null when cancelled. */
|
|
17444
|
+
async function askIfcCustomSections(ask, projectId) {
|
|
17445
|
+
if (!bridge.formModal) return null;
|
|
17446
|
+
const members = Array.isArray(ask.members) ? ask.members : [];
|
|
17447
|
+
const named = members.slice(0, 6).map((m) => `${m.id} (${m.designation})`).join(', ') + (members.length > 6 ? `, and ${members.length - 6} more` : '');
|
|
17448
|
+
const chosen = await bridge.formModal({
|
|
17449
|
+
title: 'Custom sections in this IFC file',
|
|
17450
|
+
sub: `${ask.message}${named ? ` Members: ${named}.` : ''} Nothing is exported until you choose.`,
|
|
17451
|
+
okLabel: 'Export',
|
|
17452
|
+
returnFocusTo: $wsExports.querySelector('[data-export="ifc"]'),
|
|
17453
|
+
returnFocusFallback: () => (current && current.id === projectId
|
|
17454
|
+
? $wsExports.querySelector('[data-export="ifc"]')
|
|
17455
|
+
: null),
|
|
17456
|
+
fields: [{
|
|
17457
|
+
name: 'choice', label: 'For these members', type: 'select', value: 'leave-out', commandId: 'shell.ifc-custom-section-choice',
|
|
17458
|
+
options: [
|
|
17459
|
+
{ value: 'leave-out', label: 'Leave them out', meta: 'Recommended · listed as left out' },
|
|
17460
|
+
{ value: 'bounding-box', label: 'Send their bounding box', meta: 'Named as an assumption' },
|
|
17461
|
+
],
|
|
17462
|
+
}],
|
|
17463
|
+
});
|
|
17464
|
+
if (!chosen) return null;
|
|
17465
|
+
return chosen.choice === 'bounding-box' ? 'bounding-box' : 'leave-out';
|
|
17466
|
+
}
|
|
17467
|
+
|
|
15651
17468
|
/** The caption question itself. Resolves 'update', 'without-caption', or null when cancelled. */
|
|
15652
17469
|
async function askRenderCaption(ask, projectId, saved) {
|
|
15653
17470
|
if (!bridge.formModal) return null;
|
|
@@ -17120,7 +18937,7 @@
|
|
|
17120
18937
|
// into test harnesses, where a free name it assigns would not exist. A review opened before this
|
|
17121
18938
|
// settles (a fresh page, a slow disk) reads in millimetres, never in nothing.
|
|
17122
18939
|
import('./display-units.js').then((m) => { reviewUnitsModule = m; }, () => {});
|
|
17123
|
-
const reviewUnits = () => (current
|
|
18940
|
+
const reviewUnits = () => shownUnits(current);
|
|
17124
18941
|
const reviewElevation = (mm) => (reviewUnitsModule ? reviewUnitsModule.formatElevation(mm, reviewUnits()) : `${Math.round(mm)} mm`);
|
|
17125
18942
|
const reviewLength = (mm) => (reviewUnitsModule ? reviewUnitsModule.formatLength(mm, reviewUnits()) : `${Math.round(mm)} mm`);
|
|
17126
18943
|
const isEndpointValue = (v) => !!v && typeof v === 'object' && !Array.isArray(v)
|
|
@@ -18609,8 +20426,10 @@
|
|
|
18609
20426
|
return `<span class="gate-badge model findings-accepted" data-tip="${escapeAttr(`Sign-off gate. ${acceptedNote}`)}">Model</span>`;
|
|
18610
20427
|
if (gate === 'model')
|
|
18611
20428
|
return '<span class="gate-badge model" data-tip="Sign-off gate — this version was approved">Model</span>';
|
|
20429
|
+
// #3223 rank 7: never "Approve to sign it off" here. Approving does not sign off this row; it saves the reviewed model
|
|
20430
|
+
// as a new version above it, and reading the badge as the thing approved is what made "Approved as v2" look doubled.
|
|
18612
20431
|
if (kind === 'revision-read')
|
|
18613
|
-
return `<span class="gate-badge ai-read" data-tip="AI read
|
|
20432
|
+
return `<span class="gate-badge ai-read" data-tip="AI read: what the AI composed from ${Number(n) <= 1 ? 'the initial' : 'a revised'} drawing set. It is not an approved version. Approving saves the model you reviewed as a new version.">AI read</span>`;
|
|
18614
20433
|
return '<span class="gate-badge" data-tip="Unsigned — a working-tree restore, not a sign-off">unsigned</span>';
|
|
18615
20434
|
};
|
|
18616
20435
|
|
|
@@ -19679,7 +21498,10 @@
|
|
|
19679
21498
|
const box = el('div', 'hd-err');
|
|
19680
21499
|
box.setAttribute('role', 'status');
|
|
19681
21500
|
box.setAttribute('aria-live', 'polite');
|
|
19682
|
-
|
|
21501
|
+
// #3097: the server's own sentence when it wrote one; a malformed reply or a lost answer stays in the console.
|
|
21502
|
+
const said = personText(err && err.body);
|
|
21503
|
+
if (!said) console.warn('[history] the comparison did not load', err);
|
|
21504
|
+
box.appendChild(document.createTextNode('Couldn’t load the comparison' + (said ? ` — ${said}` : '') + ' — '));
|
|
19683
21505
|
const retry = el('button', null, 'try again');
|
|
19684
21506
|
retry.type = 'button';
|
|
19685
21507
|
retry.dataset.diffRetry = String(n);
|
|
@@ -20148,9 +21970,8 @@
|
|
|
20148
21970
|
} catch (err) {
|
|
20149
21971
|
finishProgress();
|
|
20150
21972
|
const inUse = projectFolderInUseMessage(err);
|
|
20151
|
-
showToast(inUse || (action === 'duplicate'
|
|
20152
|
-
|
|
20153
|
-
: 'Action failed: ' + (err && err.message || err)), 'warn', inUse ? { persistent: true } : undefined);
|
|
21973
|
+
showToast(inUse || errorText(err, { action: action === 'duplicate' ? 'duplicate this project' : 'finish that',
|
|
21974
|
+
unsure: 'Check the project list before trying again.' }), 'warn', inUse ? { persistent: true } : undefined);
|
|
20154
21975
|
}
|
|
20155
21976
|
finally { finishProgress(); projActionBusy = false; }
|
|
20156
21977
|
loadProjects();
|
|
@@ -20408,8 +22229,9 @@
|
|
|
20408
22229
|
finishProgress();
|
|
20409
22230
|
const body = err && err.body;
|
|
20410
22231
|
// A choice made for a project that was replaced while the person chose, or a refused choice: the server's sentence.
|
|
20411
|
-
|
|
20412
|
-
|
|
22232
|
+
const said = body && (body.code === 'archive-project-changed' || body.code === 'invalid-export-choice') ? personText(body) : '';
|
|
22233
|
+
if (said) {
|
|
22234
|
+
showToast(said, 'warn');
|
|
20413
22235
|
return;
|
|
20414
22236
|
}
|
|
20415
22237
|
showToast(`We couldn’t export “${label}” because FloLess could not finish preparing it. Try again.`, 'warn');
|
|
@@ -20709,16 +22531,24 @@
|
|
|
20709
22531
|
renderKnowledge();
|
|
20710
22532
|
}
|
|
20711
22533
|
|
|
22534
|
+
/**
|
|
22535
|
+
* #3097: an error whose message is a sentence this page wrote for the person. Callers in other modules (chat, agents,
|
|
22536
|
+
* Project access) show it through errorText, which trusts only this marker.
|
|
22537
|
+
*/
|
|
22538
|
+
function personError(text) {
|
|
22539
|
+
return Object.assign(new Error(text), { forPerson: true });
|
|
22540
|
+
}
|
|
22541
|
+
|
|
20712
22542
|
/**
|
|
20713
22543
|
* #2106: open a project on its Knowledge step — where a person sees FloLess organizing its knowledge, the work a busy
|
|
20714
22544
|
* card's "Open it" leads to. Throws a plain sentence when the project can't be opened, so the caller can say so.
|
|
20715
22545
|
*/
|
|
20716
22546
|
async function openKnowledgeStep(projectId) {
|
|
20717
|
-
if (typeof projectId !== 'string' || !projectId) throw
|
|
22547
|
+
if (typeof projectId !== 'string' || !projectId) throw personError('That project could not be opened. Open it from Workspaces.');
|
|
20718
22548
|
await setMode('workspaces');
|
|
20719
22549
|
const opened = await openProject(projectId, 'knowledge');
|
|
20720
|
-
if (opened === STAYED_IN_PROJECT) throw
|
|
20721
|
-
if (current?.id !== projectId) throw
|
|
22550
|
+
if (opened === STAYED_IN_PROJECT) throw personError('You stayed in this project, so the other one was not opened.');
|
|
22551
|
+
if (current?.id !== projectId) throw personError('That project could not be opened. Open it from Workspaces.');
|
|
20722
22552
|
}
|
|
20723
22553
|
|
|
20724
22554
|
// #2470 R6.2: a project's Workflows step, where the workflows it owns are listed (Project access links here).
|
|
@@ -20798,16 +22628,16 @@
|
|
|
20798
22628
|
async function openLinkedProject(projectId) {
|
|
20799
22629
|
await setMode('workspaces');
|
|
20800
22630
|
const opened = await openProject(projectId);
|
|
20801
|
-
if (opened === STAYED_IN_PROJECT) throw
|
|
20802
|
-
if (current?.id !== projectId) throw
|
|
22631
|
+
if (opened === STAYED_IN_PROJECT) throw personError('You stayed in this project, so the other one was not opened.');
|
|
22632
|
+
if (current?.id !== projectId) throw personError('That project could not be opened. Open it from Workspaces.');
|
|
20803
22633
|
}
|
|
20804
22634
|
|
|
20805
22635
|
/** A General project's Modules step: where Back to … after an Add a module returns to. */
|
|
20806
22636
|
async function openModulesStep(projectId) {
|
|
20807
22637
|
await setMode('workspaces');
|
|
20808
22638
|
const opened = await openProject(projectId, 'modules');
|
|
20809
|
-
if (opened === STAYED_IN_PROJECT) throw
|
|
20810
|
-
if (current?.id !== projectId) throw
|
|
22639
|
+
if (opened === STAYED_IN_PROJECT) throw personError('You stayed in this project, so the other one was not opened.');
|
|
22640
|
+
if (current?.id !== projectId) throw personError('That project could not be opened. Open it from Workspaces.');
|
|
20811
22641
|
}
|
|
20812
22642
|
|
|
20813
22643
|
/** Show the archived projects on the Workspaces page, where Restore is, with this one in view. */
|
|
@@ -20822,11 +22652,11 @@
|
|
|
20822
22652
|
}
|
|
20823
22653
|
|
|
20824
22654
|
async function openWorkflowsStep(projectId) {
|
|
20825
|
-
if (typeof projectId !== 'string' || !projectId) throw
|
|
22655
|
+
if (typeof projectId !== 'string' || !projectId) throw personError('That project could not be opened. Open it from Workspaces.');
|
|
20826
22656
|
await setMode('workspaces');
|
|
20827
22657
|
const opened = await openProject(projectId, 'workflows');
|
|
20828
|
-
if (opened === STAYED_IN_PROJECT) throw
|
|
20829
|
-
if (current?.id !== projectId) throw
|
|
22658
|
+
if (opened === STAYED_IN_PROJECT) throw personError('You stayed in this project, so the other one was not opened.');
|
|
22659
|
+
if (current?.id !== projectId) throw personError('That project could not be opened. Open it from Workspaces.');
|
|
20830
22660
|
}
|
|
20831
22661
|
|
|
20832
22662
|
/**
|
|
@@ -20911,11 +22741,11 @@
|
|
|
20911
22741
|
|
|
20912
22742
|
// The Drawing Filter step of a project, where a drawing read's exclusions are saved and signed off.
|
|
20913
22743
|
async function openDrawingsStep(projectId) {
|
|
20914
|
-
if (typeof projectId !== 'string' || !projectId) throw
|
|
22744
|
+
if (typeof projectId !== 'string' || !projectId) throw personError('That project could not be opened. Open it from Workspaces.');
|
|
20915
22745
|
await setMode('workspaces');
|
|
20916
22746
|
const opened = await openProject(projectId, 'drawings');
|
|
20917
|
-
if (opened === STAYED_IN_PROJECT) throw
|
|
20918
|
-
if (current?.id !== projectId) throw
|
|
22747
|
+
if (opened === STAYED_IN_PROJECT) throw personError('You stayed in this project, so the other one was not opened.');
|
|
22748
|
+
if (current?.id !== projectId) throw personError('That project could not be opened. Open it from Workspaces.');
|
|
20919
22749
|
}
|
|
20920
22750
|
|
|
20921
22751
|
/**
|
|
@@ -21228,20 +23058,20 @@
|
|
|
21228
23058
|
const validId = (id) => typeof id === 'string' && !!id && id.length <= 200;
|
|
21229
23059
|
if (!owner || typeof owner !== 'object'
|
|
21230
23060
|
|| !(owner.kind === 'workspace' || owner.kind === 'project' && validId(owner.projectId)
|
|
21231
|
-
|| owner.kind === 'workflow' && validId(owner.workflowId))) throw
|
|
23061
|
+
|| owner.kind === 'workflow' && validId(owner.workflowId))) throw personError('That conversation has no valid home to open.');
|
|
21232
23062
|
if (owner.kind === 'workflow') {
|
|
21233
|
-
if (typeof bridge.openOwnedWorkflow !== 'function') throw
|
|
23063
|
+
if (typeof bridge.openOwnedWorkflow !== 'function') throw personError('Open this conversation’s workflow from Workflows, then try Show in chat again.');
|
|
21234
23064
|
await bridge.openOwnedWorkflow(owner.workflowId);
|
|
21235
23065
|
return;
|
|
21236
23066
|
}
|
|
21237
23067
|
await setMode('workspaces');
|
|
21238
23068
|
if (owner.kind === 'project') {
|
|
21239
23069
|
const opened = await openProject(owner.projectId);
|
|
21240
|
-
if (opened === STAYED_IN_PROJECT) throw
|
|
21241
|
-
if (current?.id !== owner.projectId) throw
|
|
23070
|
+
if (opened === STAYED_IN_PROJECT) throw personError('You stayed in this project, so the other one was not opened.');
|
|
23071
|
+
if (current?.id !== owner.projectId) throw personError('That project could not be opened. Try Show in chat again after opening its project in Workspaces.');
|
|
21242
23072
|
} else {
|
|
21243
23073
|
await leaveProjectToList(null);
|
|
21244
|
-
if (current) throw
|
|
23074
|
+
if (current) throw personError('You stayed in this project, so the conversation was not opened.');
|
|
21245
23075
|
}
|
|
21246
23076
|
}
|
|
21247
23077
|
|
|
@@ -21439,5 +23269,5 @@
|
|
|
21439
23269
|
// #2470 R6.2b: a project kind's name as the person sees it ("Trace", "Drawing Checker"), for labels outside this file.
|
|
21440
23270
|
kindLabelOf: (project) => (project && wsDescOf(project)?.displayName) || null,
|
|
21441
23271
|
};
|
|
21442
|
-
applyMode(); // restore persisted mode immediately
|
|
23272
|
+
applyMode(); // restore persisted mode immediately
|
|
21443
23273
|
})();
|