@floless/app 0.169.0 → 0.170.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 +71580 -59849
- package/dist/schemas/drawing-check.profile.v1.schema.json +12 -2
- package/dist/schemas/steel.model.v2.schema.json +2 -1
- package/dist/skills/floless-app-knowledge/SKILL.md +43 -13
- package/dist/skills/floless-app-new-workflow/SKILL.md +8 -1
- 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 +8 -5
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +31 -1
- 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/agent-steps.js +89 -18
- package/dist/web/agents.js +32 -22
- package/dist/web/app.css +223 -1
- package/dist/web/app.js +24 -3
- package/dist/web/aware.js +877 -189
- package/dist/web/chat.js +184 -95
- package/dist/web/checkpoint-standard.js +5 -3
- package/dist/web/commands-drawing-check.js +1 -0
- package/dist/web/commands-shell.js +440 -11
- package/dist/web/commands-steel.js +60 -1
- package/dist/web/drawing-check-editor.js +352 -88
- package/dist/web/failure-copy.js +32 -2
- package/dist/web/filter-ai-proposal.js +11 -8
- package/dist/web/flo-3d.js +1 -1
- package/dist/web/guide.js +33 -26
- package/dist/web/index.html +69 -1
- package/dist/web/instructor.js +99 -15
- 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-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-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.js +22 -8
- package/dist/web/run-history.js +12 -1
- package/dist/web/steel-3d-core.js +39 -9
- package/dist/web/steel-3d-flo.js +26 -4
- package/dist/web/steel-3d-view.js +8 -3
- package/dist/web/steel-ai-marks.js +3 -1
- package/dist/web/steel-editor.html +455 -122
- package/dist/web/steel-environments.js +297 -0
- package/dist/web/steel-filter.html +3 -2
- package/dist/web/steel-model-v2-client-validation.js +8 -1
- package/dist/web/steel-model-v2-commands.js +23 -9
- package/dist/web/steel-model-v2-projection.js +1 -1
- package/dist/web/step-rename.js +3 -2
- package/dist/web/terminal-requests.js +1 -1
- package/dist/web/tool-updates.js +7 -6
- package/dist/web/workspaces.js +1714 -119
- package/package.json +4 -1
package/dist/web/workspaces.js
CHANGED
|
@@ -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,7 +550,7 @@
|
|
|
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);
|
|
@@ -582,7 +582,7 @@
|
|
|
582
582
|
|
|
583
583
|
// One ZIP of a Tekla model as a source — shared by the ZIP picker and a ZIP dropped on the card.
|
|
584
584
|
function teklaZipSource(file) {
|
|
585
|
-
if (!/\.zip$/i.test(file.name) || file.size > 1024 * 1024 * 1024) throw
|
|
585
|
+
if (!/\.zip$/i.test(file.name) || file.size > 1024 * 1024 * 1024) throw personError('Choose one Tekla model ZIP up to 1 GB.');
|
|
586
586
|
return { label: file.name, kind: 'zip', entries: [{ path: file.name, file }] };
|
|
587
587
|
}
|
|
588
588
|
async function pickTeklaZip(fallbackInput) {
|
|
@@ -721,6 +721,14 @@
|
|
|
721
721
|
let renderTicker = null;
|
|
722
722
|
const exportReceipts = new Map(); // projectId:kind → reconciled receipt counts for this browser session
|
|
723
723
|
const exportBusy = new Set(); // projectId:kind → one in-flight export
|
|
724
|
+
// #3273: how long a send's consent and source cleanup may take before its busy claim is released anyway. The server
|
|
725
|
+
// expires both on its own, so giving up on the request loses nothing; waiting on it forever left "Sending…" up.
|
|
726
|
+
const SEND_CLEANUP_MS = 15_000;
|
|
727
|
+
// #3273: how long one Exports refresh waits on each of its answers (the approval review, the listing, the export
|
|
728
|
+
// sources, render readiness). Generous, the same 90 s as the #1604 polls, because a loaded PC answers these slowly
|
|
729
|
+
// (#3139: a CPU-starved server took 44 s for the export sources); past it the pane says what it could not load
|
|
730
|
+
// instead of waiting for good.
|
|
731
|
+
const EXPORTS_REFRESH_MS = 90_000;
|
|
724
732
|
if (!$switch || !$landing || !$app) return; // markup absent — nothing to wire
|
|
725
733
|
|
|
726
734
|
// The picker menu is a `.menu` (display:none by default; `.menu.show` → display:block, which
|
|
@@ -1449,7 +1457,9 @@
|
|
|
1449
1457
|
renderApprovalHeader();
|
|
1450
1458
|
return null;
|
|
1451
1459
|
}
|
|
1452
|
-
|
|
1460
|
+
// #3273: with a deadline, because every surface that waits for this verdict (the Exports listing among them) waits
|
|
1461
|
+
// on this request, and one that never answers is not an error: it would hold them all on "Loading…" for good.
|
|
1462
|
+
const review = await api(`/api/projects/${encodeURIComponent(projectId)}/approval-review`, { timeoutMs: EXPORTS_REFRESH_MS });
|
|
1453
1463
|
if (gen !== approvalStateGen || !current || current.id !== projectId) return null;
|
|
1454
1464
|
// NOT an error, and kept apart from one on purpose: the route answers this 200 for a project
|
|
1455
1465
|
// that legitimately has nothing to review (no model read in yet, or too old to carry the
|
|
@@ -1477,8 +1487,9 @@
|
|
|
1477
1487
|
return review;
|
|
1478
1488
|
} catch (error) {
|
|
1479
1489
|
if (gen !== approvalStateGen || !current || current.id !== projectId) return null;
|
|
1490
|
+
// A deadline that ran out has no sentence for a person, so it takes the generic one.
|
|
1480
1491
|
approvalState = { status: 'error', review: null, pendingCount: 0, headVersion: null,
|
|
1481
|
-
error: (error && error.message) || 'Approval status is unavailable — try again.' };
|
|
1492
|
+
error: (error && error.name !== 'TimeoutError' && error.message) || 'Approval status is unavailable — try again.' };
|
|
1482
1493
|
renderApprovalHeader();
|
|
1483
1494
|
if (!$wsExports.hidden) paintExports(current.approvedAt);
|
|
1484
1495
|
return null;
|
|
@@ -2094,6 +2105,7 @@
|
|
|
2094
2105
|
// A save invalidates exactly one registered display row. The event grants no authority:
|
|
2095
2106
|
// the keyed route checks the physical target and returns its current registration view.
|
|
2096
2107
|
async function refreshRegisteredProject(event) {
|
|
2108
|
+
await loadSteelEnvironments(); // units below are inferred from the project's standard; awaited BEFORE anything is captured
|
|
2097
2109
|
const root = window.flolessWorkspaceRoot?.current()?.root;
|
|
2098
2110
|
if (!root || event.rootId !== root.rootId || event.generation !== root.generation) return;
|
|
2099
2111
|
const registrationId = event.registrationId;
|
|
@@ -2121,11 +2133,11 @@
|
|
|
2121
2133
|
|| !['available', 'unavailable'].includes(registration.status)) {
|
|
2122
2134
|
throw new Error('The project view no longer matches this registration.');
|
|
2123
2135
|
}
|
|
2124
|
-
const wasUnits = (cached
|
|
2136
|
+
const wasUnits = shownUnits(cached);
|
|
2125
2137
|
const wasApproved = cached.approvedAt;
|
|
2126
2138
|
const wasSortKeys = { name: cached.name, createdAt: cached.createdAt, updatedAt: cached.updatedAt };
|
|
2127
2139
|
Object.assign(cached, fresh, {
|
|
2128
|
-
displayUnits: (fresh
|
|
2140
|
+
displayUnits: shownUnits(fresh),
|
|
2129
2141
|
registrationState: registration.status,
|
|
2130
2142
|
registrationRevision: registration.entryRevision,
|
|
2131
2143
|
registrationReason: registration.reason,
|
|
@@ -2237,6 +2249,8 @@
|
|
|
2237
2249
|
async function reconcileOpenProject() {
|
|
2238
2250
|
if (reconciling) { reconcileAgain = true; return; } // fold in, never drop — see above
|
|
2239
2251
|
reconciling = true;
|
|
2252
|
+
// Awaited BEFORE the open project is captured: waiting afterwards would act on a read that predates a project switch.
|
|
2253
|
+
await loadSteelEnvironments();
|
|
2240
2254
|
// The id this run has actually CHECKED against the server. The loop keeps going while it does not
|
|
2241
2255
|
// name the open project, so "the user switched project while we were reading" re-runs instead of
|
|
2242
2256
|
// exiting — a trailing pass conditioned only on a new EVENT arriving would leave the project they
|
|
@@ -2317,7 +2331,7 @@
|
|
|
2317
2331
|
// that never had a unit choice arrives as `undefined` — and assigning that raw made the
|
|
2318
2332
|
// `!==` test true on every `projects-changed`, discarding the server's `exportUnits` and
|
|
2319
2333
|
// repainting for nothing. (Review round 5.)
|
|
2320
|
-
const freshUnits = (mine
|
|
2334
|
+
const freshUnits = shownUnits(mine);
|
|
2321
2335
|
const freshName = typeof mine.name === 'string' ? mine.name : current.name;
|
|
2322
2336
|
if (current && current.id === id && current.name !== freshName) {
|
|
2323
2337
|
current.name = freshName;
|
|
@@ -3541,8 +3555,11 @@
|
|
|
3541
3555
|
else if (teklaSourceChoice === choice) setTeklaSourcePicking(false,
|
|
3542
3556
|
'FloLess could not open project setup. Close any other setup window, then choose the source again.');
|
|
3543
3557
|
} catch (error) {
|
|
3544
|
-
|
|
3545
|
-
|
|
3558
|
+
// #3097: the pick checks throw a sentence for the person (personError); a browser read error or a refusal is said
|
|
3559
|
+
// through errorText, never as its own message.
|
|
3560
|
+
const said = errorText(error, { action: 'read that Tekla source', retrySafe: true });
|
|
3561
|
+
if (teklaSourceChoice === choice) setTeklaSourcePicking(false, said);
|
|
3562
|
+
showToast(said, 'warn');
|
|
3546
3563
|
}
|
|
3547
3564
|
}
|
|
3548
3565
|
$teklaSourceFolder?.addEventListener('click', () => { void chooseTeklaSource('folder'); });
|
|
@@ -3785,19 +3802,19 @@
|
|
|
3785
3802
|
if (!folderCount) source = teklaZipSource(files[0]);
|
|
3786
3803
|
else {
|
|
3787
3804
|
const handle = await folder;
|
|
3788
|
-
if (handle?.kind !== 'directory') throw
|
|
3805
|
+
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
3806
|
source = await filesFromDirectoryHandle(handle);
|
|
3790
3807
|
}
|
|
3791
3808
|
// The read may have outlasted the moment: never open setup over another window or a project.
|
|
3792
3809
|
if (projectSetupState || teklaSourceChoice || $landing.hidden) {
|
|
3793
|
-
throw
|
|
3810
|
+
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
3811
|
}
|
|
3795
3812
|
await createFromTeklaSource(appId, templateId, source, zone.isConnected ? zone : null);
|
|
3796
3813
|
} 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?.
|
|
3814
|
+
// Our own checks throw a sentence for the person (personError) that already says what to do. Anything else is the
|
|
3815
|
+
// browser failing to read a file (moved, locked, unreadable), whose message is not written for people.
|
|
3816
|
+
if (error?.forPerson !== true) console.warn('[workspaces] could not read a dropped Tekla model', error);
|
|
3817
|
+
showToast(error?.forPerson === true ? errorText(error)
|
|
3801
3818
|
: '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
3819
|
} finally {
|
|
3803
3820
|
teklaDropReading = false;
|
|
@@ -3862,6 +3879,45 @@
|
|
|
3862
3879
|
return res && typeof res.name === 'string' && res.name.trim() ? res.name.trim() : null;
|
|
3863
3880
|
}
|
|
3864
3881
|
|
|
3882
|
+
/**
|
|
3883
|
+
* The steel-environment TRAIT registry (`web/steel-environments.js`), loaded the same way and for the
|
|
3884
|
+
* same reason as the label table below (`index.html` loads this file as a classic script). Started
|
|
3885
|
+
* HERE, at script evaluation, so it has long settled before a project list has been fetched and
|
|
3886
|
+
* rendered; `loadSteelEnvironments()` is what the two paths that ADOPT units from a fetched row await
|
|
3887
|
+
* (project-metadata refresh and the open-project reconcile), so an inferred unit is never written from
|
|
3888
|
+
* a registry that has not loaded. Until it has, a read answers the imperial default and claims nothing
|
|
3889
|
+
* else. A failed load is logged, not swallowed: it leaves a legacy UK project showing feet-inches.
|
|
3890
|
+
*/
|
|
3891
|
+
let steelEnvironments = null;
|
|
3892
|
+
let steelEnvironmentsPromise = null;
|
|
3893
|
+
function loadSteelEnvironments() {
|
|
3894
|
+
if (!steelEnvironmentsPromise) {
|
|
3895
|
+
steelEnvironmentsPromise = import('./steel-environments.js').then(
|
|
3896
|
+
(m) => { steelEnvironments = m; return m; },
|
|
3897
|
+
(error) => {
|
|
3898
|
+
// Not cached: a transient failure must not bar every later attempt. The caller carries on with the imperial default.
|
|
3899
|
+
steelEnvironmentsPromise = null;
|
|
3900
|
+
console.error('[workspaces] the steel-environment registry could not be loaded; units inferred from a project\u2019s standard fall back to feet-inches', error);
|
|
3901
|
+
return null;
|
|
3902
|
+
},
|
|
3903
|
+
);
|
|
3904
|
+
}
|
|
3905
|
+
return steelEnvironmentsPromise;
|
|
3906
|
+
}
|
|
3907
|
+
loadSteelEnvironments();
|
|
3908
|
+
const isRegisteredEnvironment = (id) => !!steelEnvironments?.traitsOf(id);
|
|
3909
|
+
const registeredEnvironmentIds = () => (steelEnvironments ? [...steelEnvironments.STEEL_ENVIRONMENT_IDS] : []);
|
|
3910
|
+
/**
|
|
3911
|
+
* The units a project row is shown in: its own `displayUnits`, or, where its owner never chose, what
|
|
3912
|
+
* its environment implies (the client mirror of the server's `shownUnitsOfProject`; one trait, read in
|
|
3913
|
+
* both places).
|
|
3914
|
+
*/
|
|
3915
|
+
function shownUnits(project) {
|
|
3916
|
+
return project?.displayUnits === 'mm' || project?.displayUnits === 'ft-in'
|
|
3917
|
+
? project.displayUnits
|
|
3918
|
+
: (steelEnvironments ? steelEnvironments.traitsFor(project?.environment).defaultDisplayUnits : 'ft-in');
|
|
3919
|
+
}
|
|
3920
|
+
|
|
3865
3921
|
/**
|
|
3866
3922
|
* How a steel standard names itself to a person — `US · AISC/ASTM`, `UK · BS/EN`.
|
|
3867
3923
|
*
|
|
@@ -3887,8 +3943,13 @@
|
|
|
3887
3943
|
let standardLabelsPromise = null;
|
|
3888
3944
|
function loadStandardLabels() {
|
|
3889
3945
|
if (!standardLabelsPromise) {
|
|
3890
|
-
|
|
3891
|
-
|
|
3946
|
+
// The registry rides along: the setup dialog's readiness and its button loop both read it, and
|
|
3947
|
+
// `sourceReady` is only set after this resolves.
|
|
3948
|
+
standardLabelsPromise = Promise.all([import('./checkpoint-standard.js'), loadSteelEnvironments()])
|
|
3949
|
+
.then(([m, envs]) => {
|
|
3950
|
+
if (!envs) throw new Error('the steel-environment registry did not load');
|
|
3951
|
+
return m.STANDARD_LABEL;
|
|
3952
|
+
})
|
|
3892
3953
|
.catch((err) => { standardLabelsPromise = null; throw err; });
|
|
3893
3954
|
}
|
|
3894
3955
|
return standardLabelsPromise;
|
|
@@ -3915,6 +3976,7 @@
|
|
|
3915
3976
|
const $projectSetupQuickTermsTail = document.getElementById('project-setup-quick-terms-tail');
|
|
3916
3977
|
const $projectSetupFilter = document.getElementById('project-setup-filter');
|
|
3917
3978
|
const $projectSetupExclusions = document.getElementById('project-setup-exclusions');
|
|
3979
|
+
const $projectSetupOrigin = document.getElementById('project-setup-origin');
|
|
3918
3980
|
const $projectSetupBuildLocked = document.getElementById('project-setup-build-locked');
|
|
3919
3981
|
const $projectSetupCancel = document.getElementById('project-setup-cancel');
|
|
3920
3982
|
const $projectSetupCreateOnly = document.getElementById('project-setup-create-only');
|
|
@@ -4027,7 +4089,7 @@
|
|
|
4027
4089
|
|
|
4028
4090
|
function projectSetupReady(state = projectSetupState) {
|
|
4029
4091
|
return !!state && state.sourceReady && !!state.directory && !!state.name.trim()
|
|
4030
|
-
&& (!state.askCatalogue || state.environment
|
|
4092
|
+
&& (!state.askCatalogue || isRegisteredEnvironment(state.environment));
|
|
4031
4093
|
}
|
|
4032
4094
|
|
|
4033
4095
|
function setProjectSetupBusy(busy, label) {
|
|
@@ -4224,7 +4286,19 @@
|
|
|
4224
4286
|
}
|
|
4225
4287
|
}
|
|
4226
4288
|
if ($projectSetupQuickTermsTail) {
|
|
4227
|
-
|
|
4289
|
+
// #2909 (code review): the terms say what the person keeps, so a person-picked origin is said here too.
|
|
4290
|
+
$projectSetupQuickTermsTail.textContent = PROJECT_SETUP_TERMS_TAIL[filter === 'ai' && exclusions === 'person' ? 'aiKeep' : filter]
|
|
4291
|
+
+ (mode === 'quick' && projectSetupOriginChoice(state) === 'person' ? ' ' + PROJECT_SETUP_TERMS_ORIGIN : '');
|
|
4292
|
+
}
|
|
4293
|
+
// #2909: who chooses the model origin, asked only with Quick (Precise always asks it on the read's setup card).
|
|
4294
|
+
const origin = projectSetupOriginChoice(state);
|
|
4295
|
+
if ($projectSetupOrigin) {
|
|
4296
|
+
$projectSetupOrigin.hidden = mode !== 'quick';
|
|
4297
|
+
for (const button of $projectSetupOrigin.querySelectorAll('[data-origin-choice]')) {
|
|
4298
|
+
button.setAttribute('aria-pressed', String(button.dataset.originChoice === origin));
|
|
4299
|
+
if (locked) button.setAttribute('aria-disabled', 'true');
|
|
4300
|
+
else button.removeAttribute('aria-disabled');
|
|
4301
|
+
}
|
|
4228
4302
|
}
|
|
4229
4303
|
$projectSetupBuildLocked.hidden = !locked;
|
|
4230
4304
|
if (shown && mode === 'quick') $projectSetupCreateOnly.setAttribute('aria-describedby', 'project-setup-quick-create-only');
|
|
@@ -4254,6 +4328,20 @@
|
|
|
4254
4328
|
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
4329
|
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
4330
|
};
|
|
4331
|
+
const PROJECT_SETUP_TERMS_ORIGIN = 'You also choose the model origin, on the read’s setup card.';
|
|
4332
|
+
/**
|
|
4333
|
+
* #2909: who chooses the model origin with Quick: 'person' only when the person pressed "I'll choose it myself", else
|
|
4334
|
+
* the AI (the default, owner ruling 2026-11-08). Once sent it is the sent one, as for the Model choice.
|
|
4335
|
+
*/
|
|
4336
|
+
function projectSetupOriginChoice(state) {
|
|
4337
|
+
const value = state.submissionId ? state.sentOriginChoice : state.originChoice;
|
|
4338
|
+
return value === 'person' ? 'person' : 'ai';
|
|
4339
|
+
}
|
|
4340
|
+
function chooseProjectSetupOrigin(button) {
|
|
4341
|
+
if (!button || !projectSetupState || projectSetupState.busy || projectSetupState.submissionId) return;
|
|
4342
|
+
projectSetupState.originChoice = button.dataset.originChoice === 'person' ? 'person' : 'ai';
|
|
4343
|
+
renderProjectSetup();
|
|
4344
|
+
}
|
|
4257
4345
|
function chooseProjectSetupFilter(button) {
|
|
4258
4346
|
if (!button || !projectSetupState || projectSetupState.busy || projectSetupState.submissionId) return;
|
|
4259
4347
|
projectSetupState.filterChoice = button.dataset.filterChoice === 'ai' ? 'ai' : 'person';
|
|
@@ -4271,7 +4359,8 @@
|
|
|
4271
4359
|
if (!button || !projectSetupState || projectSetupState.busy || projectSetupState.submissionId) return;
|
|
4272
4360
|
projectSetupState.buildMode = button.dataset.buildMode === 'quick' ? 'quick' : 'precise';
|
|
4273
4361
|
// #2521 row 2c: the Filter choice belongs to Quick: Precise drops it, and Quick again starts from the person's Save.
|
|
4274
|
-
|
|
4362
|
+
// #2909: likewise the origin choice: Precise drops it, and Quick again starts from the AI's choice.
|
|
4363
|
+
if (projectSetupState.buildMode === 'precise') { projectSetupState.filterChoice = 'person'; projectSetupState.exclusionsChoice = 'ai'; projectSetupState.originChoice = 'ai'; }
|
|
4275
4364
|
renderProjectSetup();
|
|
4276
4365
|
if (projectSetupState.buildMode === 'quick') $projectSetupQuickTerms.scrollIntoView?.({ block: 'nearest' });
|
|
4277
4366
|
}
|
|
@@ -4469,6 +4558,8 @@
|
|
|
4469
4558
|
// #2521 row 2c: the Filter choice is sent only with Quick, and fixed with the first send like the Model choice.
|
|
4470
4559
|
if (!state.submissionId) state.sentFilterChoice = state.sentBuildMode === 'quick' && state.filterChoice === 'ai' ? 'ai' : null;
|
|
4471
4560
|
if (!state.submissionId) state.sentExclusionsChoice = state.sentFilterChoice === 'ai' ? (state.exclusionsChoice === 'person' ? 'person' : 'ai') : null;
|
|
4561
|
+
// #2909: the origin choice likewise, sent only with Quick and only when the person keeps it.
|
|
4562
|
+
if (!state.submissionId) state.sentOriginChoice = state.sentBuildMode === 'quick' && state.originChoice === 'person' ? 'person' : null;
|
|
4472
4563
|
const submissionId = state.submissionId || crypto.randomUUID();
|
|
4473
4564
|
state.submissionId = submissionId;
|
|
4474
4565
|
rememberProjectChatIntake(submissionId);
|
|
@@ -4482,6 +4573,7 @@
|
|
|
4482
4573
|
...(state.sentBuildMode === 'quick' ? { buildMode: 'quick' } : {}),
|
|
4483
4574
|
...(state.sentBuildMode === 'quick' && state.sentFilterChoice === 'ai' ? { quickFilterByAi: true } : {}),
|
|
4484
4575
|
...(state.sentBuildMode === 'quick' && state.sentFilterChoice === 'ai' && state.sentExclusionsChoice === 'ai' ? { quickFilterExclusionsByAi: true } : {}),
|
|
4576
|
+
...(state.sentBuildMode === 'quick' && state.sentOriginChoice === 'person' ? { quickOriginByPerson: true } : {}),
|
|
4485
4577
|
// #2470 R6.7b: added from a General project's Modules step, the project is made already linked there.
|
|
4486
4578
|
...(state.linkFrom ? { linkFrom: { projectId: state.linkFrom.projectId, sourceUuid: state.linkFrom.sourceUuid, rootId: state.linkFrom.rootId } } : {}),
|
|
4487
4579
|
...(state.linkFrom && state.withoutLink ? { withoutLink: true } : {}),
|
|
@@ -4512,7 +4604,7 @@
|
|
|
4512
4604
|
const outsideWorkspace = code === 'project-directory-outside-root';
|
|
4513
4605
|
// #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
4606
|
const linkChoice = startChat && state.linkFrom && error?.linkChoice === true;
|
|
4515
|
-
setProjectSetupError(linkChoice ? projectSetupLinkChoiceMessage(state, code, error
|
|
4607
|
+
setProjectSetupError(linkChoice ? projectSetupLinkChoiceMessage(state, code, personText(error?.body)) : projectSetupErrorMessage(error), {
|
|
4516
4608
|
workspaceAction: outsideWorkspace,
|
|
4517
4609
|
withoutLinkAction: linkChoice ? () => { state.withoutLink = true; void createProjectFromSetup(true); } : null,
|
|
4518
4610
|
});
|
|
@@ -4571,7 +4663,7 @@
|
|
|
4571
4663
|
// It stays until the person acts on it; a choice that fails is offered again.
|
|
4572
4664
|
if (!projectChatIntakeLinkChoiceShown.has(submissionId)) {
|
|
4573
4665
|
projectChatIntakeLinkChoiceShown.add(submissionId);
|
|
4574
|
-
showToast(`A project you started from a General project wasn’t created yet. ${projectSetupLinkChoiceMessage({}, code, error
|
|
4666
|
+
showToast(`A project you started from a General project wasn’t created yet. ${projectSetupLinkChoiceMessage({}, code, personText(error?.body))}`, 'warn', {
|
|
4575
4667
|
persistent: true,
|
|
4576
4668
|
action: { label: 'Create without linking', commandId: 'shell.project-setup-recover-without-link',
|
|
4577
4669
|
onClick: () => recoverProjectChatIntake(submissionId, { withoutLink: true }).catch((retryError) => {
|
|
@@ -4631,6 +4723,8 @@
|
|
|
4631
4723
|
filterChoice: 'person',
|
|
4632
4724
|
// Revision 3: with "Let the AI choose", the AI also approves what the read leaves out unless the person keeps it.
|
|
4633
4725
|
exclusionsChoice: 'ai',
|
|
4726
|
+
// #2909: the AI chooses the model origin unless the person presses "I'll choose it myself" (with Quick only).
|
|
4727
|
+
originChoice: 'ai',
|
|
4634
4728
|
directory: null,
|
|
4635
4729
|
name: '',
|
|
4636
4730
|
nameDirty: false,
|
|
@@ -4654,7 +4748,7 @@
|
|
|
4654
4748
|
if (state.askCatalogue) {
|
|
4655
4749
|
const standards = await loadStandardLabels();
|
|
4656
4750
|
if (projectSetupState !== state) return;
|
|
4657
|
-
for (const env of
|
|
4751
|
+
for (const env of registeredEnvironmentIds()) {
|
|
4658
4752
|
const label = standards.get(env);
|
|
4659
4753
|
if (!label) throw new Error(`the shared label table names no standard for ${env}`);
|
|
4660
4754
|
$projectSetupStandard.querySelector(`[data-standard-label="${env}"]`).textContent = label;
|
|
@@ -4690,6 +4784,8 @@
|
|
|
4690
4784
|
$projectSetupBuild?.addEventListener('click', (event) => {
|
|
4691
4785
|
const exclusionsButton = event.target.closest('[data-exclusions-choice]');
|
|
4692
4786
|
if (exclusionsButton) { chooseProjectSetupExclusions(exclusionsButton); return; }
|
|
4787
|
+
const originButton = event.target.closest('[data-origin-choice]');
|
|
4788
|
+
if (originButton) { chooseProjectSetupOrigin(originButton); return; }
|
|
4693
4789
|
const filterButton = event.target.closest('[data-filter-choice]');
|
|
4694
4790
|
if (filterButton) chooseProjectSetupFilter(filterButton);
|
|
4695
4791
|
else chooseProjectSetupBuildMode(event.target.closest('[data-build-mode]'));
|
|
@@ -4862,8 +4958,20 @@
|
|
|
4862
4958
|
if (detailNode) detailNode.textContent = detail;
|
|
4863
4959
|
}
|
|
4864
4960
|
|
|
4961
|
+
/**
|
|
4962
|
+
* #3097: the server's own text for a Tekla source refusal. A ModelSnapshotError reply says diagnostic: true, so the
|
|
4963
|
+
* shared request helper does not put its `error` in the Error's message; it is matched below against reviewed
|
|
4964
|
+
* patterns only, and shown as written only by the branches that say so.
|
|
4965
|
+
*/
|
|
4966
|
+
function teklaRefusalText(error) {
|
|
4967
|
+
const raw = error?.body?.error;
|
|
4968
|
+
return typeof raw === 'string' && raw.trim() ? raw.trim() : error?.message || String(error || '');
|
|
4969
|
+
}
|
|
4865
4970
|
function teklaAdmissionMessage(error) {
|
|
4866
|
-
|
|
4971
|
+
// A sentence the server proved was written for the person (ModelSnapshotError.userMessage) is said as written.
|
|
4972
|
+
const written = error?.body?.userMessage;
|
|
4973
|
+
if (typeof written === 'string' && written.trim()) return written.trim();
|
|
4974
|
+
const message = teklaRefusalText(error);
|
|
4867
4975
|
// The server's copy-limit refusals (tekla-source-upload.ts / tekla-source-package.ts): sizes and counts.
|
|
4868
4976
|
const TEKLA_COPY_LIMIT = /^Tekla (?:ZIP|folder upload|source package)\b[^.]*\bexceeds? (?:its|their) (?:limit|compressed byte limit|total byte limit)$/;
|
|
4869
4977
|
// #1849: reading without some catalogue files needs a newer AWARE; the server names the version.
|
|
@@ -4889,7 +4997,7 @@
|
|
|
4889
4997
|
return 'FloLess could not read this Tekla source. Choose the model folder or ZIP again. The source model was not changed.';
|
|
4890
4998
|
}
|
|
4891
4999
|
function teklaAdmissionTitle(error) {
|
|
4892
|
-
const message =
|
|
5000
|
+
const message = teklaRefusalText(error);
|
|
4893
5001
|
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
5002
|
if (TEKLA_COPY_LIMIT.test(message)) return 'This Tekla source is too large for one read';
|
|
4895
5003
|
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 +5194,12 @@
|
|
|
5086
5194
|
// #3097: the server's own sentence when it wrote one, else the shared one; never "(<status>)".
|
|
5087
5195
|
if (!upload.ok || uploaded.ok === false) {
|
|
5088
5196
|
console.warn('[rvt] upload refused', upload.status, uploaded);
|
|
5089
|
-
|
|
5090
|
-
|
|
5091
|
-
{
|
|
5197
|
+
// #3097: this route's `error` is a machine code and its `message` a developer's sentence; only `userMessage` is
|
|
5198
|
+
// written for the person. Marking the reply diagnostic lets personText / errorText read exactly that.
|
|
5199
|
+
const body = { ...uploaded, diagnostic: true };
|
|
5200
|
+
throw Object.assign(new Error(personText(body)
|
|
5201
|
+
|| failureCopy({ status: upload.status, body }, { action: 'copy the RVT file to FloLess', unsure: 'Choose the RVT file again.' }).text),
|
|
5202
|
+
{ status: upload.status, body });
|
|
5092
5203
|
}
|
|
5093
5204
|
const receipt = uploaded.receipt;
|
|
5094
5205
|
const started = await api('/api/model-imports', { method: 'POST', body: JSON.stringify({
|
|
@@ -5116,7 +5227,7 @@
|
|
|
5116
5227
|
headers: { 'content-type': 'application/octet-stream', 'x-floless-upload-offset': String(offset),
|
|
5117
5228
|
'x-floless-upload-total': String(file.size) } });
|
|
5118
5229
|
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})`);
|
|
5230
|
+
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
5231
|
onProgress(Math.min(file.size, offset + blob.size), file.size);
|
|
5121
5232
|
return body;
|
|
5122
5233
|
} catch (error) {
|
|
@@ -5170,7 +5281,7 @@
|
|
|
5170
5281
|
try { return JSON.parse(xhr.responseText || '{}'); } catch { return {}; }
|
|
5171
5282
|
})();
|
|
5172
5283
|
if (xhr.status < 200 || xhr.status >= 300 || body.ok === false) {
|
|
5173
|
-
finish(new Error(body.message || body.error || `source copy failed (${xhr.status})`));
|
|
5284
|
+
finish(Object.assign(new Error(body.message || body.error || `source copy failed (${xhr.status})`), { body, status: xhr.status }));
|
|
5174
5285
|
return;
|
|
5175
5286
|
}
|
|
5176
5287
|
finish(null, body);
|
|
@@ -5416,10 +5527,15 @@
|
|
|
5416
5527
|
} catch (err) {
|
|
5417
5528
|
const removed = await archiveEmptyProject(project.id);
|
|
5418
5529
|
// #2470 R6.7: the empty project is not kept linked either; the Modules step says what happened (spec §6.3).
|
|
5419
|
-
|
|
5530
|
+
// #3097: why, from the server's own sentence for the person, else the shared sentence's why-and-what-to-do (its
|
|
5531
|
+
// "Couldn’t …" lead is already said below); never the error's own text, which goes to the console.
|
|
5532
|
+
const said = err && err.body && typeof err.body === 'object' ? personText(err.body) : '';
|
|
5533
|
+
if (!said) console.warn('[rvt] import failed', err);
|
|
5534
|
+
const why = said || failureParts(err, { action: 'import the RVT', unsure: 'Choose the RVT file again.' }).detail;
|
|
5535
|
+
if (link) { await globalThis.flolessProjectModules?.afterCreate?.({ project, ...link, outcome: removed ? 'archived-empty' : 'left-empty', error: why }); return; }
|
|
5420
5536
|
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. ${
|
|
5537
|
+
? `Couldn’t import the RVT — the empty project was removed. ${why}`
|
|
5538
|
+
: `Couldn’t import the RVT. An empty project was left behind; archive it from the ⋯ menu. ${why}`, 'warn');
|
|
5423
5539
|
}
|
|
5424
5540
|
}
|
|
5425
5541
|
|
|
@@ -6537,13 +6653,13 @@
|
|
|
6537
6653
|
if (action === 'chat') {
|
|
6538
6654
|
Promise.resolve().then(() => {
|
|
6539
6655
|
if (typeof window.flolessChat?.startNewChat !== 'function') {
|
|
6540
|
-
throw
|
|
6656
|
+
throw personError('AI Chat is still loading. Try Start new chat again in a moment.');
|
|
6541
6657
|
}
|
|
6542
6658
|
return window.flolessChat.startNewChat(notice.projectId);
|
|
6543
6659
|
}).catch((err) => {
|
|
6544
6660
|
// A reason AI Chat wrote for the person is shown as it is; anything else is an unexpected failure. Opening a
|
|
6545
6661
|
// new chat changes nothing, so it is always safe to try again.
|
|
6546
|
-
if (err?.
|
|
6662
|
+
if (err?.forPerson === true) showToast(`Couldn’t start a new chat. ${errorText(err)}`, 'warn');
|
|
6547
6663
|
else showFailureToast(err, { action: 'start a new chat', retrySafe: true });
|
|
6548
6664
|
});
|
|
6549
6665
|
return;
|
|
@@ -7696,11 +7812,15 @@
|
|
|
7696
7812
|
/** The answer to "what does approving do": which version this becomes and what it replaces. */
|
|
7697
7813
|
function approvalVersionCardHtml(review) {
|
|
7698
7814
|
const mf = review.moveForward;
|
|
7815
|
+
// #3223 rank 7: a first approval that lands above versions already in History names its number and, when everything
|
|
7816
|
+
// below is an AI drawing read, says so, so "the first approved version" and the "v2" it becomes agree.
|
|
7817
|
+
const first = review.firstApproval && !mf && !review.base ? firstApprovalWords(review.firstApproval) : null;
|
|
7699
7818
|
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
7819
|
: review.base ? `This becomes the next approved version, after approved v${review.base.version}.`
|
|
7701
|
-
:
|
|
7820
|
+
: first ? `This becomes v${first.version}, the first approved version of this model.`
|
|
7821
|
+
: 'This becomes the first approved version of this model.';
|
|
7702
7822
|
return `<div class="approval-version-card"><b>${escapeHtml(lead)}</b>`
|
|
7703
|
-
+ '
|
|
7823
|
+
+ `<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
7824
|
}
|
|
7705
7825
|
|
|
7706
7826
|
const review = approvalDialogState.review;
|
|
@@ -8048,7 +8168,7 @@
|
|
|
8048
8168
|
const ownsDialog = () => !!dialog && approvalDialogState === dialog && onProject();
|
|
8049
8169
|
if (ownsDialog() && $approvalRevisionNoteText) $approvalRevisionNoteText.value = '';
|
|
8050
8170
|
if (res && res.approvedAt) project.approvedAt = res.approvedAt;
|
|
8051
|
-
const { version: n, accepted, headline, assumed, quick, coverage } = approvalOutcomeWords(res);
|
|
8171
|
+
const { version: n, accepted, headline, reads, readsShort, assumed, quick, coverage } = approvalOutcomeWords(res);
|
|
8052
8172
|
if (n) expandDiffOnce = { projectId: project.id, n };
|
|
8053
8173
|
// An outcome can land while the person is editing this project again: a background check, or a dialog
|
|
8054
8174
|
// closed while the note above was saving. Reloading the editor then would discard edits not yet saved, so
|
|
@@ -8078,7 +8198,7 @@
|
|
|
8078
8198
|
// Edits still unsaved in the editor are not in any count FloLess read, so with them on screen no pending
|
|
8079
8199
|
// count is claimed at all: the sentence says what is known instead.
|
|
8080
8200
|
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');
|
|
8201
|
+
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
8202
|
track('workspace_project_approved', { app: project.app });
|
|
8083
8203
|
if (onProject() && !$wsExports.hidden) safeRenderExports('after approving this version');
|
|
8084
8204
|
if (onProject() && !$wsHistory.hidden) await renderHistory();
|
|
@@ -8088,8 +8208,10 @@
|
|
|
8088
8208
|
: 'No changes remain pending.';
|
|
8089
8209
|
// The footer described the decision ("…will be approved…"); the decision has happened.
|
|
8090
8210
|
$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
|
-
|
|
8211
|
+
$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>`;
|
|
8212
|
+
// The subtitle doubles as what a screen reader hears, so it carries the short form of the same sentence.
|
|
8213
|
+
const approvedPhase = accepted ? headline : `Approved${n ? ` as v${n}` : ''}`;
|
|
8214
|
+
setApprovalPhase('approved', readsShort ? `${accepted ? approvedPhase : `${approvedPhase}.`} ${readsShort}` : approvedPhase);
|
|
8093
8215
|
$approvalClose.focus();
|
|
8094
8216
|
}
|
|
8095
8217
|
|
|
@@ -8104,6 +8226,10 @@
|
|
|
8104
8226
|
// #1840: an approval that accepted open import findings is never announced as a plain "Approved".
|
|
8105
8227
|
const accepted = res && res.version && res.version.approval && res.version.approval.acceptedImportFindings;
|
|
8106
8228
|
const headline = accepted ? importFindingsCopy(accepted).approved(version) : `Approved${version ? ` as v${version}` : ''}.`;
|
|
8229
|
+
// #3223 rank 7: a first approval above the AI's drawing read says what the versions below it are, right after the
|
|
8230
|
+
// headline. Only for the version this result actually became.
|
|
8231
|
+
const first = version && res.firstApproval && Number(res.firstApproval.version) === version ? firstApprovalWords(res.firstApproval) : null;
|
|
8232
|
+
const reads = first ? first.result : '', readsShort = first ? first.short : '';
|
|
8107
8233
|
// #2449: an approval resting on connection assumptions (or one whose record could not be read) is never
|
|
8108
8234
|
// announced as a plain approval either; the server's own sentence, the same one History shows.
|
|
8109
8235
|
const assumed = res && res.connectionAssumptions && typeof res.connectionAssumptions.note === 'string' ? res.connectionAssumptions.note : '';
|
|
@@ -8119,7 +8245,34 @@
|
|
|
8119
8245
|
: c.state === 'part' ? `${c.brief} This approval covers only the drawing files that were read; a later read of the others covers them. `
|
|
8120
8246
|
: c.state === 'unknown' ? `${c.brief} FloLess could not tell whether this version read every drawing file; History shows what is known. `
|
|
8121
8247
|
: '';
|
|
8122
|
-
return { version, accepted, headline, assumed, quick, coverage, sentence: `${headline} ${quick}${coverage}${assumed}`.trim() };
|
|
8248
|
+
return { version, accepted, headline, reads, readsShort, assumed, quick, coverage, sentence: `${headline} ${reads ? `${reads} ` : ''}${quick}${coverage}${assumed}`.trim() };
|
|
8249
|
+
}
|
|
8250
|
+
|
|
8251
|
+
/**
|
|
8252
|
+
* #3223 rank 7: why a first approval is not v1, in words. A model read from drawings keeps the AI's read in History
|
|
8253
|
+
* first (v1), so a person's first approval becomes v2, and "Approved as v2" beside "the first approved version" read
|
|
8254
|
+
* as a bug or a double approval. Said from the server's `firstApproval` facts, never guessed: `card` for the review
|
|
8255
|
+
* dialog's version card, `result` for the outcome notice and toasts, `short` for the subtitle a screen reader hears.
|
|
8256
|
+
* Null when there is nothing below to explain (a model approved as v1) or the facts are unreadable; empty sentences
|
|
8257
|
+
* when what sits below is not all drawing reads, so only the number is named.
|
|
8258
|
+
*/
|
|
8259
|
+
function firstApprovalWords(facts) {
|
|
8260
|
+
const version = facts && Number(facts.version);
|
|
8261
|
+
const before = facts && facts.before;
|
|
8262
|
+
if (!Number.isSafeInteger(version) || version < 1 || !before || typeof before !== 'object') return null;
|
|
8263
|
+
const count = Number(before.count), first = Number(before.first), last = Number(before.last);
|
|
8264
|
+
if (![count, first, last].every((value) => Number.isSafeInteger(value) && value >= 1) || first > last || last >= version) return null;
|
|
8265
|
+
if (before.drawingReads !== true) return { version, card: '', result: '', short: '' };
|
|
8266
|
+
const one = count === 1;
|
|
8267
|
+
// "v1 and v2", "v1 to v3"; a range with a gap in it is not named as one.
|
|
8268
|
+
const subject = one ? `v${first}` : count === last - first + 1 ? `v${first}${count === 2 ? ' and ' : ' to '}v${last}` : 'The earlier versions';
|
|
8269
|
+
const what = one ? 'is the AI read' : 'are AI reads';
|
|
8270
|
+
return {
|
|
8271
|
+
version,
|
|
8272
|
+
card: `${subject} in History ${what} of your drawings, not ${one ? 'an approved version' : 'approved versions'}.`,
|
|
8273
|
+
result: `${subject} ${what} of your drawings.`,
|
|
8274
|
+
short: `${subject} ${what}.`,
|
|
8275
|
+
};
|
|
8123
8276
|
}
|
|
8124
8277
|
|
|
8125
8278
|
// One receipt read. The server answers under the project's approval locks, which on a large model
|
|
@@ -8495,7 +8648,7 @@
|
|
|
8495
8648
|
$approvalSub.textContent = 'FloLess could not open this review';
|
|
8496
8649
|
} else {
|
|
8497
8650
|
$approvalSub.textContent = 'Approval status unavailable';
|
|
8498
|
-
$approvalImpact.textContent = (error
|
|
8651
|
+
$approvalImpact.textContent = errorText(error, { action: 'load the comparison', retrySafe: true });
|
|
8499
8652
|
$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
8653
|
setApprovalPhase('failed', 'Nothing was approved. Try again.');
|
|
8501
8654
|
}
|
|
@@ -8542,8 +8695,10 @@
|
|
|
8542
8695
|
const approved = Object.values(st.decisions || {}).filter((value) => value === 'approve').length;
|
|
8543
8696
|
const pending = groups.length - approved;
|
|
8544
8697
|
if (review.selective === false) {
|
|
8698
|
+
// #3223 rank 7: the same number the version card named, when versions already sit below it in History.
|
|
8699
|
+
const first = review.firstApproval && !review.base && !review.moveForward ? firstApprovalWords(review.firstApproval) : null;
|
|
8545
8700
|
return review.wholeVersionReason === 'first-approval' || !review.base
|
|
8546
|
-
? 'Approving the whole model as its first approved version.'
|
|
8701
|
+
? first ? `Approving the whole model as v${first.version}, its first approved version.` : 'Approving the whole model as its first approved version.'
|
|
8547
8702
|
: `Approving the whole model as the next approved version after v${review.base.version}.`;
|
|
8548
8703
|
}
|
|
8549
8704
|
return `Approving ${approved} change${approved === 1 ? '' : 's'}${pending > 0 ? ` · ${pending} stay${pending === 1 ? 's' : ''} pending` : ''}.`;
|
|
@@ -8648,7 +8803,8 @@
|
|
|
8648
8803
|
approvalDialogState.conflicts = decisionSnapshot.conflicts;
|
|
8649
8804
|
approvalDialogState.retryAction = 'approve';
|
|
8650
8805
|
renderApprovalReview();
|
|
8651
|
-
|
|
8806
|
+
// The recorded outcome was checked first, so nothing was approved and the same decisions can be tried again.
|
|
8807
|
+
$approvalImpact.textContent = errorText(error, { action: 'approve these changes', retrySafe: true });
|
|
8652
8808
|
$approvalBody.insertAdjacentHTML('afterbegin', '<div class="approval-notice approval-notice-error"><b>Nothing was approved.</b> Try again with the same decisions.</div>');
|
|
8653
8809
|
setApprovalPhase('failed', 'Nothing was approved. Try again.');
|
|
8654
8810
|
$approvalRetry.focus();
|
|
@@ -8674,7 +8830,7 @@
|
|
|
8674
8830
|
setApprovalPhase('ready');
|
|
8675
8831
|
($approvalBody.querySelector('[data-approval-decision]:not([disabled])') || $approvalConfirm).focus();
|
|
8676
8832
|
} catch (error) {
|
|
8677
|
-
$approvalImpact.textContent = (error
|
|
8833
|
+
$approvalImpact.textContent = errorText(error, { action: 'reload the current review', retrySafe: true });
|
|
8678
8834
|
setApprovalPhase('stale', 'The current review could not be loaded.');
|
|
8679
8835
|
$approvalReload.focus();
|
|
8680
8836
|
}
|
|
@@ -8735,7 +8891,7 @@
|
|
|
8735
8891
|
if (event.target.closest('[data-approval-workflow-update]') && approvalDialogState && approvalDismissible(approvalDialogState.phase)) {
|
|
8736
8892
|
const appId = current?.app;
|
|
8737
8893
|
closeApprovalReview();
|
|
8738
|
-
if (appId) bridge.reviewWorkflowUpdate(appId).catch((error) => showToast(error
|
|
8894
|
+
if (appId) bridge.reviewWorkflowUpdate(appId).catch((error) => showToast(errorText(error, { action: 'open the workflow update', retrySafe: true }), 'warn'));
|
|
8739
8895
|
return;
|
|
8740
8896
|
}
|
|
8741
8897
|
const openAudit = event.target.closest('[data-approval-open-audit]');
|
|
@@ -8858,10 +9014,9 @@
|
|
|
8858
9014
|
frames.model.addEventListener('load', () => {
|
|
8859
9015
|
try {
|
|
8860
9016
|
frames.model.contentWindow.addEventListener('keydown', (e) => {
|
|
8861
|
-
|
|
8862
|
-
|
|
8863
|
-
|
|
8864
|
-
}
|
|
9017
|
+
// Only take the key when Find actually opened (#3142); otherwise the browser's own Find still works.
|
|
9018
|
+
if ((e.ctrlKey || e.metaKey) && !e.shiftKey && (e.key === 'f' || e.key === 'F')
|
|
9019
|
+
&& typeof window.openFind === 'function' && window.openFind()) e.preventDefault();
|
|
8865
9020
|
});
|
|
8866
9021
|
} catch { /* not-yet-loaded / cross-origin */ }
|
|
8867
9022
|
// Chromium can make the iframe the parent's active element during navigation without a reliable
|
|
@@ -9038,7 +9193,7 @@
|
|
|
9038
9193
|
// Each read is bounded (#1604): the 3-second poll skips its ticks while a render is out, so a
|
|
9039
9194
|
// request that never answered would stop the column refreshing for good.
|
|
9040
9195
|
const bounded = () => ({ timeoutMs: 90_000 });
|
|
9041
|
-
const [status, reqs, company, designSet] = await Promise.all([
|
|
9196
|
+
const [status, reqs, company, designSet, connected] = await Promise.all([
|
|
9042
9197
|
api(kbUrl(proj.id, '/status'), bounded()),
|
|
9043
9198
|
api('/api/requests', bounded()).catch(() => []),
|
|
9044
9199
|
api(`/api/company-knowledge?projectId=${encodeURIComponent(proj.id)}`, bounded())
|
|
@@ -9046,6 +9201,8 @@
|
|
|
9046
9201
|
// #2399 slice 0b: a design set that cannot be read is said as such, never as "none".
|
|
9047
9202
|
api(`/api/projects/${encodeURIComponent(proj.id)}/design-set`, bounded())
|
|
9048
9203
|
.catch(() => ({ status: 'unknown', revision: 0, warnings: [{ code: 'unreadable', message: 'FloLess could not read the design set just now.' }] })),
|
|
9204
|
+
// #2470 R6.8: connected sources; a project without any answers with empty lists. One that cannot be read says so.
|
|
9205
|
+
api(kbUrl(proj.id, '/connected'), bounded()).catch(() => ({ unreadable: true, sources: [], removed: [] })),
|
|
9049
9206
|
]);
|
|
9050
9207
|
const list = Array.isArray(reqs) ? reqs : (reqs.requests || []);
|
|
9051
9208
|
const manifest = status.manifest || { revision: 0, currentGeneration: null, sources: [] };
|
|
@@ -9060,6 +9217,7 @@
|
|
|
9060
9217
|
queued: status.pendingRequests || list.filter((r) => r && r.type === 'knowledge-organize' && r.project === proj.id),
|
|
9061
9218
|
company,
|
|
9062
9219
|
designSet,
|
|
9220
|
+
connected,
|
|
9063
9221
|
};
|
|
9064
9222
|
}
|
|
9065
9223
|
|
|
@@ -9420,6 +9578,7 @@
|
|
|
9420
9578
|
}
|
|
9421
9579
|
|
|
9422
9580
|
function kbSourceRow(s, st, depth) {
|
|
9581
|
+
if (s.kind === 'connected') return kbConnRowHtml(s, st, depth);
|
|
9423
9582
|
const on = !!s.useAsKb;
|
|
9424
9583
|
const sel = kbSel.selected.has(s.sourceId);
|
|
9425
9584
|
const ico = kbIcon(s.mime);
|
|
@@ -11029,6 +11188,992 @@
|
|
|
11029
11188
|
if (pre) pre.textContent = text; // THE escaping guarantee — `<img src=x onerror=…>` stays literal
|
|
11030
11189
|
}
|
|
11031
11190
|
|
|
11191
|
+
// ── #2470 R6.8: connected sources ──────────────────────────────────────────────────────────────────────
|
|
11192
|
+
// A Teams chat synced into Knowledge through the Microsoft 365 account chosen in Integrations. Its row sits in the
|
|
11193
|
+
// reference list like any other (categories, the use-as-knowledge switch); what differs is drawn from
|
|
11194
|
+
// /knowledge/connected. Connect, Sync now and Erase are the person's own click (the server checks); each carries the
|
|
11195
|
+
// source revision this screen drew, so a source that synced meanwhile is shown again instead of acted on.
|
|
11196
|
+
const kbConnStops = new Map(); // sourceId → { message, choices, target, opts }: a sync that stopped and asks
|
|
11197
|
+
const kbConnSyncing = new Set(); // syncs this window has out
|
|
11198
|
+
const kbConnChanging = new Map(); // sourceId → a settings change still out: resolves to the revision it left (Sync now waits)
|
|
11199
|
+
const kbConnGapsOpen = new Set(); // gap disclosures the person opened (kept across the 3 s repaint)
|
|
11200
|
+
const KB_CONN_CHOICES = {
|
|
11201
|
+
'sync-with-current': 'Sync with the account I’m signed in with', 'confirm-target': 'Use this account', 'resume-and-sync': 'Resume and sync',
|
|
11202
|
+
'sync-anyway': 'Sync anyway', retry: 'Try again', reload: 'Refresh', pause: 'Pause', remove: 'Remove…',
|
|
11203
|
+
'open-integrations': 'Open Integrations', 'open-tools': 'Open Tools', cancel: 'Leave it for now', 'sync-now': 'Sync now',
|
|
11204
|
+
keep: 'Keep the copy',
|
|
11205
|
+
rebuild: 'Rebuild the copy',
|
|
11206
|
+
};
|
|
11207
|
+
// #2470 R6.8 slice 1b: an Outlook mail folder is the second kind. Its row adds the window, the coverage of the last listing,
|
|
11208
|
+
// what waits to be read and what was left out, all from the last sync (no message text), and asks the ceiling question.
|
|
11209
|
+
const kbConnIsMail = (c) => !!(c && c.scope === 'outlook-folder');
|
|
11210
|
+
// #2470 R6.8 slice 2: a Trimble Connect project is the third kind: its topics (coordination issues), their comments and
|
|
11211
|
+
// its ToDos. It has no window; its row says how the copy is kept up to date, from the last sync.
|
|
11212
|
+
const kbConnIsTrimble = (c) => !!(c && c.scope === 'trimble-project');
|
|
11213
|
+
const kbConnKindName = (c) => (kbConnIsTrimble(c) ? 'Trimble Connect project' : kbConnIsMail(c) ? 'Outlook folder' : 'Teams chat');
|
|
11214
|
+
const kbConnService = (c) => (kbConnIsTrimble(c) ? 'Trimble Connect' : 'Microsoft 365');
|
|
11215
|
+
const kbConnThing = (c) => (kbConnIsTrimble(c) ? 'project' : kbConnIsMail(c) ? 'folder' : 'chat');
|
|
11216
|
+
const kbConnGlyph = (kind) => (kind === 'trimble-project' ? '⚑︎' : kind === 'outlook-folder' ? '✉︎' : '◫');
|
|
11217
|
+
const KB_CONN_REGIONS = [['northAmerica', 'North America'], ['europe', 'Europe'], ['unitedKingdom', 'United Kingdom'], ['asia', 'Asia'], ['australia', 'Australia']];
|
|
11218
|
+
const kbConnRegionName = (r) => (KB_CONN_REGIONS.find(([v]) => v === r) || [r, r])[1];
|
|
11219
|
+
// The plan §17 #13 disclosure, word for word as the page and the action card say it.
|
|
11220
|
+
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).';
|
|
11221
|
+
const kbConnDate = (iso) => { const t = Date.parse(iso || ''); return Number.isFinite(t) ? new Date(t).toLocaleDateString() : ''; };
|
|
11222
|
+
const kbConnWhen = (iso) => { const t = Date.parse(iso || ''); return Number.isFinite(t) ? new Date(t).toLocaleString() : ''; };
|
|
11223
|
+
const kbConnPlural = (n, one, many) => `${n.toLocaleString()} ${n === 1 ? one : many}`;
|
|
11224
|
+
|
|
11225
|
+
/** 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
|
|
11226
|
+
* copy is kept up to date sits in one disclosure. Everything comes from the last sync; no topic text. */
|
|
11227
|
+
function kbConnTrimbleHtml(sourceId, c, name) {
|
|
11228
|
+
const t = c.trimble || {};
|
|
11229
|
+
const lines = [];
|
|
11230
|
+
const cov = t.coverage;
|
|
11231
|
+
const kindWord = (k) => (k === 'topics' ? 'topics' : 'ToDos');
|
|
11232
|
+
if (cov) {
|
|
11233
|
+
for (const k of ['topics', 'todos']) {
|
|
11234
|
+
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.`);
|
|
11235
|
+
}
|
|
11236
|
+
const incomplete = ['topics', 'todos'].filter((k) => cov[k] === 'incomplete');
|
|
11237
|
+
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.`);
|
|
11238
|
+
}
|
|
11239
|
+
if (t.waitingReads > 0) lines.push(`${kbConnPlural(t.waitingReads, 'topic', 'topics')} waiting to be read, up to 50 per sync.`);
|
|
11240
|
+
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.`);
|
|
11241
|
+
if (t.missedOnce > 0) {
|
|
11242
|
+
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.`);
|
|
11243
|
+
}
|
|
11244
|
+
// The size cut, for topics and ToDos alike: a ToDo-only cut is as much a gap as a topic one.
|
|
11245
|
+
const cut = t.capacityCut;
|
|
11246
|
+
const notKeptTopics = (t.capacity && t.capacity.topics) || 0;
|
|
11247
|
+
const notKeptTodos = (t.capacity && t.capacity.todos) || 0;
|
|
11248
|
+
if (cut && (cut.topics || cut.todos)) {
|
|
11249
|
+
const counted = [notKeptTopics && kbConnPlural(notKeptTopics, 'topic', 'topics'), notKeptTodos && kbConnPlural(notKeptTodos, 'ToDo', 'ToDos')].filter(Boolean);
|
|
11250
|
+
const what = [cut.topics && 'topics', cut.todos && 'ToDos'].filter(Boolean).join(' and ');
|
|
11251
|
+
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.`);
|
|
11252
|
+
}
|
|
11253
|
+
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.');
|
|
11254
|
+
const r = t.rotation;
|
|
11255
|
+
if (r && r.failed > 0) lines.push(`The last comment check failed for ${kbConnPlural(r.failed, 'topic', 'topics')}. FloLess tries again.`);
|
|
11256
|
+
const n = t.counts || {};
|
|
11257
|
+
const details = [];
|
|
11258
|
+
if (r && r.of > 0) {
|
|
11259
|
+
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.`);
|
|
11260
|
+
details.push(`This round: topic ${Math.min(r.at, r.of).toLocaleString()} of ${r.of.toLocaleString()}.`);
|
|
11261
|
+
if (r.oldestCheck) details.push(`Oldest comment check: ${kbConnWhen(r.oldestCheck)}.`);
|
|
11262
|
+
}
|
|
11263
|
+
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.`);
|
|
11264
|
+
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.`);
|
|
11265
|
+
// Only a listing that finished is "full": the time of an incomplete one would be a claim the copy cannot back.
|
|
11266
|
+
if (t.lastCompleteAt) details.push(`Last full listing ${kbConnWhen(t.lastCompleteAt)}.`);
|
|
11267
|
+
const more = details.length
|
|
11268
|
+
? `<details class="kb-conn-gaps" data-kb-conn-gaps="${escapeAttr(`${sourceId}:kept`)}"${kbConnGapsOpen.has(`${sourceId}:kept`) ? ' open' : ''}>` +
|
|
11269
|
+
`<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>` +
|
|
11270
|
+
`<ul>${details.map((d) => `<li>${escapeHtml(d)}</li>`).join('')}</ul></details>` : '';
|
|
11271
|
+
return lines.map((line) => `<div class="kb-conn-note">${escapeHtml(line)}</div>`).join('') + more;
|
|
11272
|
+
}
|
|
11273
|
+
|
|
11274
|
+
/** The Outlook lines under a row's meta line (plan §5.3), each shown only when it says something. */
|
|
11275
|
+
function kbConnMailHtml(sourceId, c, name) {
|
|
11276
|
+
const o = c.outlook || {};
|
|
11277
|
+
const lines = [];
|
|
11278
|
+
// After a window change the last listing was of another window, so its coverage says nothing about this one until the
|
|
11279
|
+
// next sync (code review R12 #1).
|
|
11280
|
+
if (o.settingsPending) {
|
|
11281
|
+
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.`);
|
|
11282
|
+
}
|
|
11283
|
+
const cov = o.settingsPending ? null : o.coverage;
|
|
11284
|
+
// Dated by the listing itself: a later sync that stopped listed nothing (code review R13 #1).
|
|
11285
|
+
if (cov && cov.kind === 'complete') lines.push(`Last full listing ${kbConnWhen(o.listedAt || (c.lastSync && c.lastSync.at))}.`);
|
|
11286
|
+
else if (cov && cov.kind === 'partial') {
|
|
11287
|
+
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. ` +
|
|
11288
|
+
'While the copy is partial, FloLess removes nothing that Outlook stops listing, so any message here may have left the folder.' +
|
|
11289
|
+
// Mail Outlook listed but FloLess could not identify may be missing at any date (code review R11 #1).
|
|
11290
|
+
(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.` : ''));
|
|
11291
|
+
} else if (cov && cov.kind === 'incomplete') lines.push(`Listing incomplete: ${cov.reason} Nothing was removed because of this listing.`);
|
|
11292
|
+
if (o.waitingReads > 0) lines.push(`${kbConnPlural(o.waitingReads, 'message', 'messages')} waiting to be read, up to 50 per sync.`);
|
|
11293
|
+
if (o.missedOnce > 0) {
|
|
11294
|
+
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.`);
|
|
11295
|
+
}
|
|
11296
|
+
// The size-limit cut that still applies (plan §3.4), said whatever the last sync counted (code review R3 #1).
|
|
11297
|
+
if (o.capacityCutAt) lines.push(`This source reached FloLess's size limit: messages received before ${kbConnDate(o.capacityCutAt)} are not kept.`);
|
|
11298
|
+
if (o.rereadLeft > 0) {
|
|
11299
|
+
lines.push(`Reading every message again: ${o.rereadLeft.toLocaleString()} left, up to 50 per sync.` +
|
|
11300
|
+
(o.rereadMayRepeat ? ' FloLess lost track of which messages it had already read again, so some may be read twice.' : ''));
|
|
11301
|
+
}
|
|
11302
|
+
const n = o.counts || {};
|
|
11303
|
+
// Mail Outlook lists without a change time is kept, so it is never "left out" (code review R7 #2): FloLess cannot see
|
|
11304
|
+
// an edit to it until every message is read again.
|
|
11305
|
+
if (n.noChangeTime > 0) {
|
|
11306
|
+
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.`);
|
|
11307
|
+
}
|
|
11308
|
+
// A kept message whose newer version waits to be read is kept, not left out (convergence check 2026-11-07).
|
|
11309
|
+
if (n.newerPending > 0) {
|
|
11310
|
+
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.`);
|
|
11311
|
+
}
|
|
11312
|
+
// 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
|
|
11313
|
+
// newer version too large to read says the older text is gone (code review R9 #2).
|
|
11314
|
+
if (n.keptTooLarge > 0) {
|
|
11315
|
+
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.`);
|
|
11316
|
+
}
|
|
11317
|
+
if (n.noBody > 0) {
|
|
11318
|
+
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.`);
|
|
11319
|
+
}
|
|
11320
|
+
const onPurpose = [[n.draft, 'draft', 'drafts'], [n.noReceivedDate, 'message with no received date', 'messages with no received date']].filter(([k]) => k > 0);
|
|
11321
|
+
const unread = [[n.tooLarge, 'message too large to keep', 'messages too large to keep'],
|
|
11322
|
+
[n.notKept, 'message past the size limit', 'messages past the size limit'],
|
|
11323
|
+
[n.gone, 'message Outlook listed but could not find when FloLess read it', 'messages Outlook listed but could not find when FloLess read them'],
|
|
11324
|
+
[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);
|
|
11325
|
+
const total = [...onPurpose, ...unread].reduce((sum, [k]) => sum + k, 0);
|
|
11326
|
+
const left = total ? `<details class="kb-conn-gaps" data-kb-conn-gaps="${escapeAttr(`${sourceId}:left`)}"${kbConnGapsOpen.has(`${sourceId}:left`) ? ' open' : ''}>` +
|
|
11327
|
+
`<summary data-command-id="shell.kb-connected-left-out#${escapeAttr(sourceId)}" data-command-instance-label="${escapeAttr(name)}">What was left out (${total.toLocaleString()})</summary>` +
|
|
11328
|
+
(onPurpose.length ? `<ul>${onPurpose.map(([k, one, many]) => `<li>${escapeHtml(kbConnPlural(k, one, many))}</li>`).join('')}</ul>` : '') +
|
|
11329
|
+
(unread.length ? `<ul>${unread.map(([k, one, many]) => `<li>${escapeHtml(kbConnPlural(k, one, many))}</li>`).join('')}</ul>` +
|
|
11330
|
+
'<div>FloLess reads these again when Outlook lists a newer change, or when you choose Read every message again.</div>' : '') +
|
|
11331
|
+
'</details>' : '';
|
|
11332
|
+
// Only a window shorter than the one listed can bring it under the ceiling, and the partial copy keeps the window the
|
|
11333
|
+
// source has; at 7 days the partial copy is the one choice (code review R13 #2).
|
|
11334
|
+
const days = o.windowDays || 90;
|
|
11335
|
+
const shorter = [30, 7].filter((d) => d < days);
|
|
11336
|
+
const ask = o.ceilingQuestion
|
|
11337
|
+
? '<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 ' +
|
|
11338
|
+
(shorter.length
|
|
11339
|
+
? `${escapeHtml(String(days))} days. Keep a shorter window, so FloLess can tell which mail left the folder, or keep a partial copy?`
|
|
11340
|
+
: `${escapeHtml(String(days))} days, the shortest window FloLess offers. Keep a partial copy?`) +
|
|
11341
|
+
'<div class="kb-conn-choices">' + [...shorter.map((d) => [String(d), `Keep the last ${d} days`, '']),
|
|
11342
|
+
['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) =>
|
|
11343
|
+
`<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 || '')}"` +
|
|
11344
|
+
`${tip ? ` data-tip="${escapeAttr(tip)}"` : ''} data-command-id="shell.kb-connected-ceiling#${escapeAttr(v)}" data-command-instance-label="${escapeAttr(label)}">${escapeHtml(label)}</button>`).join('') +
|
|
11345
|
+
'</div></div>' : '';
|
|
11346
|
+
return lines.map((line) => `<div class="kb-conn-note">${escapeHtml(line)}</div>`).join('') + ask + left;
|
|
11347
|
+
}
|
|
11348
|
+
// The choices a stop offers that this screen can act on; never none, so a stopped sync always has a way on.
|
|
11349
|
+
const kbConnKnownChoices = (choices) => {
|
|
11350
|
+
const known = (Array.isArray(choices) ? choices : []).filter((choice) => KB_CONN_CHOICES[choice]);
|
|
11351
|
+
return known.length ? known : ['retry', 'pause', 'remove'];
|
|
11352
|
+
};
|
|
11353
|
+
|
|
11354
|
+
const kbConnOf = (st, sourceId) => ((st && st.connected && st.connected.sources) || []).find((c) => c.sourceId === sourceId) || null;
|
|
11355
|
+
const kbConnUrl = (path) => kbUrl(current.id, `/connected${path}`);
|
|
11356
|
+
function kbConnRepaint() { kbInvalidateRefs(); if (knowledgeState) paintKnowledge(knowledgeState); }
|
|
11357
|
+
|
|
11358
|
+
function kbConnStopHtml(sourceId, stop) {
|
|
11359
|
+
const buttons = kbConnKnownChoices(stop.choices).map((choice, n) =>
|
|
11360
|
+
`<button type="button" class="kb-link${n === 0 ? ' kb-conn-primary' : ''}" data-kb-conn-choice="${escapeAttr(choice)}" data-kb-conn-id="${escapeAttr(sourceId)}"` +
|
|
11361
|
+
` 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('');
|
|
11362
|
+
return `<div class="kb-conn-stop" role="status"><b>Not synced.</b> ${escapeHtml(stop.message)}${buttons ? `<div class="kb-conn-choices">${buttons}</div>` : ''}</div>`;
|
|
11363
|
+
}
|
|
11364
|
+
|
|
11365
|
+
function kbConnRowHtml(s, st, depth) {
|
|
11366
|
+
const c = kbConnOf(st, s.sourceId);
|
|
11367
|
+
const on = !!s.useAsKb;
|
|
11368
|
+
const sel = kbSel.selected.has(s.sourceId);
|
|
11369
|
+
const mail = kbConnIsMail(c);
|
|
11370
|
+
const name = (c && c.label) || s.filename || kbConnKindName(c);
|
|
11371
|
+
const isOpen = viewer.mode === 'file' && viewer.sourceId === s.sourceId;
|
|
11372
|
+
const syncing = kbConnSyncing.has(s.sourceId) || !!(c && c.syncing);
|
|
11373
|
+
// When the chat was last read: the newest version, or a later sync that found nothing new (it read the chat too).
|
|
11374
|
+
const checked = c && c.lastSync && c.lastSync.outcome !== 'stopped' ? Date.parse(c.lastSync.at || '') : NaN;
|
|
11375
|
+
const saved = Date.parse((c && c.lastSyncedAt) || '');
|
|
11376
|
+
const at = Number.isFinite(checked) && !(checked < saved) ? checked : saved;
|
|
11377
|
+
const when = Number.isFinite(at) ? `synced ${kbAgo(Date.now() - at)}` : 'not synced yet';
|
|
11378
|
+
const versions = c ? `${c.versions} version${c.versions === 1 ? '' : 's'}` : '';
|
|
11379
|
+
const since = Date.parse((c && c.windowStart) || '');
|
|
11380
|
+
const trimble = kbConnIsTrimble(c);
|
|
11381
|
+
const scope = trimble ? kbConnRegionName(c.trimble && c.trimble.region) : mail ? `last ${(c.outlook && c.outlook.windowDays) || 90} days`
|
|
11382
|
+
: Number.isFinite(since) ? `messages since ${new Date(since).toLocaleDateString()}` : '';
|
|
11383
|
+
const unread = !!(st && st.connected && st.connected.unreadable);
|
|
11384
|
+
const service = c ? kbConnService(c) : 'Connected source';
|
|
11385
|
+
const meta = unread ? `${service} · FloLess could not read its sync status just now. Reopen Knowledge to try again.`
|
|
11386
|
+
: [service, c && c.account, scope, when, versions].filter(Boolean).join(' · ');
|
|
11387
|
+
const chips = (syncing ? '<span class="kb-chip">syncing…</span>' : '') +
|
|
11388
|
+
(c && c.paused ? '<span class="kb-chip kb-conn-paused">paused</span>' : '') +
|
|
11389
|
+
(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>' : '');
|
|
11390
|
+
const stop = kbConnStops.get(s.sourceId);
|
|
11391
|
+
const last = c && c.lastSync;
|
|
11392
|
+
const stopped = stop ? kbConnStopHtml(s.sourceId, stop)
|
|
11393
|
+
// A stop from before a reload: the same way on as a fresh one (the choices are this screen's, not stored).
|
|
11394
|
+
: last && last.outcome === 'stopped' ? kbConnStopHtml(s.sourceId, { message: `Last sync stopped: ${last.message || ''}`, choices: last.choices }) : '';
|
|
11395
|
+
const gaps = c && c.gaps === null
|
|
11396
|
+
? '<div class="kb-conn-note">FloLess could not check whether this copy holds every message. Sync again to check.</div>'
|
|
11397
|
+
: c && Array.isArray(c.gaps) && c.gaps.length
|
|
11398
|
+
? `<details class="kb-conn-gaps" data-kb-conn-gaps="${escapeAttr(s.sourceId)}"${kbConnGapsOpen.has(s.sourceId) ? ' open' : ''}>` +
|
|
11399
|
+
`<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>` +
|
|
11400
|
+
`<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>` +
|
|
11401
|
+
`<ul>${c.gaps.map((g) => `<li>${escapeHtml(new Date(g.from).toLocaleString())} – ${escapeHtml(new Date(g.to).toLocaleString())}</li>`).join('')}</ul></details>`
|
|
11402
|
+
: '';
|
|
11403
|
+
return `<div class="kb-src kb-conn${on ? '' : ' off'}${sel ? ' selected' : ''}" draggable="true"` +
|
|
11404
|
+
(depth != null ? ` style="--kb-depth:${depth}"` : '') +
|
|
11405
|
+
` data-source-id="${escapeAttr(s.sourceId)}"${isOpen ? ' aria-current="true"' : ''}>` +
|
|
11406
|
+
`<span class="kb-fico conn" aria-hidden="true" data-tip="${kbConnKindName(c)}">${kbConnGlyph(c && c.scope)}</span>` +
|
|
11407
|
+
'<div class="kb-fbody">' +
|
|
11408
|
+
`<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)}" ` +
|
|
11409
|
+
`data-tip="Preview what was synced from “${escapeAttr(name)}” · Ctrl or Shift to select">${escapeHtml(name)}${sel ? '<span class="kb-sr"> (selected)</span>' : ''}</button>` +
|
|
11410
|
+
`<div class="kb-fmeta"${Number.isFinite(at) || mail ? ` data-tip="${escapeAttr([mail && Number.isFinite(since) ? `Mail received since ${new Date(since).toLocaleDateString()}` : '',
|
|
11411
|
+
Number.isFinite(at) ? `Last synced ${new Date(at).toLocaleString()}` : ''].filter(Boolean).join(' · '))}"` : ''}>${escapeHtml(meta)}${chips}</div>` +
|
|
11412
|
+
(mail && !unread ? kbConnMailHtml(s.sourceId, c, name) : '') + (trimble && !unread ? kbConnTrimbleHtml(s.sourceId, c, name) : '') + stopped + gaps +
|
|
11413
|
+
'</div>' +
|
|
11414
|
+
`<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' : ''}` +
|
|
11415
|
+
` data-command-id="shell.kb-connected-sync#${escapeAttr(s.sourceId)}" data-command-instance-label="${escapeAttr(name)}"` +
|
|
11416
|
+
` 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>` +
|
|
11417
|
+
`<button type="button" class="kb-toggle" role="switch" aria-checked="${on ? 'true' : 'false'}" data-kb-toggle ` +
|
|
11418
|
+
`aria-label="Use “${escapeAttr(name)}” as knowledge" data-command-id="shell.kb-category-row-toggle#${escapeAttr(s.sourceId)}" data-command-instance-label="${escapeAttr(name)}" ` +
|
|
11419
|
+
`data-tip="${on ? 'Included in the knowledge base — click to exclude' : 'Excluded from the knowledge base — click to include'}"></button>` +
|
|
11420
|
+
`<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)}”"` +
|
|
11421
|
+
` data-command-id="shell.kb-connected-menu#${escapeAttr(s.sourceId)}" data-command-instance-label="${escapeAttr(name)}" data-tip="Sync, pause, remove or erase">⋯</button>` +
|
|
11422
|
+
'</div>';
|
|
11423
|
+
}
|
|
11424
|
+
|
|
11425
|
+
/** Below the reference list: removed sources whose messages are still stored, and what a copied project left out. */
|
|
11426
|
+
function kbConnExtrasHtml(st) {
|
|
11427
|
+
const conn = st.connected;
|
|
11428
|
+
if (!conn) return '';
|
|
11429
|
+
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>';
|
|
11430
|
+
let html = '';
|
|
11431
|
+
const removed = Array.isArray(conn.removed) ? conn.removed : [];
|
|
11432
|
+
if (removed.length) {
|
|
11433
|
+
html += '<div class="kb-conn-removed"><h4 class="kb-uncategorized-head">Removed connected sources</h4>' +
|
|
11434
|
+
'<div class="kb-conn-note">What they synced stays stored until you erase it.</div>' +
|
|
11435
|
+
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 }))}` +
|
|
11436
|
+
`${r.erasePending ? '<span class="kb-conn-removed-why">Erase did not finish yet.</span>' : ''}</span>` +
|
|
11437
|
+
`<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('') +
|
|
11438
|
+
'</div>';
|
|
11439
|
+
}
|
|
11440
|
+
const notice = conn.copyNotice;
|
|
11441
|
+
if (notice && notice.knowledgeOmitted) {
|
|
11442
|
+
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>';
|
|
11443
|
+
} else if (notice && notice.connectedLeftOut) {
|
|
11444
|
+
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>`;
|
|
11445
|
+
}
|
|
11446
|
+
return html;
|
|
11447
|
+
}
|
|
11448
|
+
|
|
11449
|
+
async function kbConnSync(sourceId, opts = {}) {
|
|
11450
|
+
if (kbConnSyncing.has(sourceId)) return;
|
|
11451
|
+
kbConnSyncing.add(sourceId);
|
|
11452
|
+
const changing = kbConnChanging.get(sourceId);
|
|
11453
|
+
let changed = null;
|
|
11454
|
+
if (changing) { kbConnRepaint(); changed = await changing.catch(() => null); }
|
|
11455
|
+
const c = kbConnOf(knowledgeState, sourceId);
|
|
11456
|
+
const seen = changed ?? (c ? c.revision : null);
|
|
11457
|
+
kbConnStops.delete(sourceId);
|
|
11458
|
+
kbConnRepaint();
|
|
11459
|
+
try {
|
|
11460
|
+
const res = await api(kbConnUrl(`/${encodeURIComponent(sourceId)}/sync`), { method: 'POST',
|
|
11461
|
+
body: JSON.stringify({ ...opts, ...(seen !== null ? { revision: seen } : {}) }) });
|
|
11462
|
+
kbAnnounce(res.message || 'Synced.');
|
|
11463
|
+
} catch (err) {
|
|
11464
|
+
const body = (err && err.body) || {};
|
|
11465
|
+
kbConnStops.set(sourceId, { message: err.message, choices: kbConnKnownChoices(body.choices), target: body.target || null, opts });
|
|
11466
|
+
kbAnnounce(`Not synced. ${err.message}`);
|
|
11467
|
+
} finally {
|
|
11468
|
+
kbConnSyncing.delete(sourceId);
|
|
11469
|
+
kbInvalidateRefs();
|
|
11470
|
+
await renderKnowledge();
|
|
11471
|
+
}
|
|
11472
|
+
}
|
|
11473
|
+
|
|
11474
|
+
async function kbConnSetPaused(sourceId, paused) {
|
|
11475
|
+
const c = kbConnOf(knowledgeState, sourceId);
|
|
11476
|
+
try {
|
|
11477
|
+
await api(kbConnUrl(`/${encodeURIComponent(sourceId)}`), { method: 'PATCH', body: JSON.stringify({ paused, ...(c ? { revision: c.revision } : {}) }) });
|
|
11478
|
+
kbConnStops.delete(sourceId);
|
|
11479
|
+
kbAnnounce(paused ? 'Paused. It keeps what it synced.' : 'Resumed.');
|
|
11480
|
+
} catch (err) { const said = errorText(err, { action: paused ? 'pause this source' : 'resume this source' }); kbAnnounce(said); showToast(said, 'warn'); }
|
|
11481
|
+
kbInvalidateRefs();
|
|
11482
|
+
await renderKnowledge();
|
|
11483
|
+
}
|
|
11484
|
+
|
|
11485
|
+
function kbConnShowMenu(btn) {
|
|
11486
|
+
const id = btn.dataset.kbConnMenu;
|
|
11487
|
+
const c = kbConnOf(knowledgeState, id);
|
|
11488
|
+
const name = (c && c.label) || `this ${kbConnThing(c)}`;
|
|
11489
|
+
const pop = kbCatPop(btn,
|
|
11490
|
+
`<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>` +
|
|
11491
|
+
`<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>` +
|
|
11492
|
+
(kbConnIsMail(c)
|
|
11493
|
+
? `<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>` +
|
|
11494
|
+
`<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>`
|
|
11495
|
+
: kbConnIsTrimble(c)
|
|
11496
|
+
? `<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>`
|
|
11497
|
+
: '') +
|
|
11498
|
+
`<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>` +
|
|
11499
|
+
'<div class="kb-ds-sep" role="separator"></div>' +
|
|
11500
|
+
`<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>`,
|
|
11501
|
+
`More for ${name}`, 'menu');
|
|
11502
|
+
const first = pop && pop.querySelector('.kb-ds-mi');
|
|
11503
|
+
if (first) first.focus();
|
|
11504
|
+
}
|
|
11505
|
+
|
|
11506
|
+
/** A themed dialog on the app's modal shell; resolves with the pressed action's id, or null for Cancel and Esc. */
|
|
11507
|
+
function kbConnDialog({ title, bodyHtml, actions, labelId, onOpen }) {
|
|
11508
|
+
return new Promise((resolve) => {
|
|
11509
|
+
const previous = document.activeElement;
|
|
11510
|
+
const backdrop = document.createElement('div');
|
|
11511
|
+
backdrop.className = 'modal-backdrop show kb-conn-dialog';
|
|
11512
|
+
backdrop.setAttribute('role', 'dialog');
|
|
11513
|
+
backdrop.setAttribute('aria-modal', 'true');
|
|
11514
|
+
backdrop.setAttribute('aria-labelledby', labelId);
|
|
11515
|
+
backdrop.innerHTML = `<div class="modal"><div class="modal-title" id="${labelId}">${escapeHtml(title)}</div><div class="kb-conn-dialog-body">${bodyHtml}</div>` +
|
|
11516
|
+
`<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>`;
|
|
11517
|
+
// Each action's command id is an author-written literal at its call site; set through the DOM, it needs no escaping.
|
|
11518
|
+
backdrop.querySelectorAll('.modal-actions [data-kb-conn-act]').forEach((btn, n) => { btn.dataset.commandId = actions[n].commandId; });
|
|
11519
|
+
const finish = (value) => {
|
|
11520
|
+
backdrop.remove();
|
|
11521
|
+
document.removeEventListener('keydown', onKey, true);
|
|
11522
|
+
if (previous && previous.isConnected) previous.focus({ preventScroll: true });
|
|
11523
|
+
resolve(value);
|
|
11524
|
+
};
|
|
11525
|
+
const onKey = (e) => {
|
|
11526
|
+
if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); finish(null); return; }
|
|
11527
|
+
if (e.key !== 'Tab') return;
|
|
11528
|
+
// Keep focus inside the dialog: an aria-modal dialog must not let Tab walk into the page behind it.
|
|
11529
|
+
const focusable = [...backdrop.querySelectorAll('button:not([disabled]):not([hidden]):not([tabindex="-1"]), input:not([disabled]), summary')];
|
|
11530
|
+
if (!focusable.length) return;
|
|
11531
|
+
const first = focusable[0], last = focusable[focusable.length - 1];
|
|
11532
|
+
if (e.shiftKey && document.activeElement === first) { e.preventDefault(); last.focus(); }
|
|
11533
|
+
else if (!e.shiftKey && document.activeElement === last) { e.preventDefault(); first.focus(); }
|
|
11534
|
+
};
|
|
11535
|
+
backdrop.addEventListener('click', (e) => {
|
|
11536
|
+
const act = e.target.closest('[data-kb-conn-act]');
|
|
11537
|
+
if (act) { finish(act.dataset.kbConnAct === 'cancel' ? null : { id: act.dataset.kbConnAct, form: backdrop }); return; }
|
|
11538
|
+
if (e.target === backdrop) finish(null);
|
|
11539
|
+
});
|
|
11540
|
+
// An action that waits for a choice in the body (Connect waits for a chat) turns on once one is made.
|
|
11541
|
+
backdrop.addEventListener('change', () => {
|
|
11542
|
+
for (const btn of backdrop.querySelectorAll('[data-kb-conn-act][disabled]')) {
|
|
11543
|
+
const needs = actions.find((a) => a.id === btn.dataset.kbConnAct)?.enabledWhen;
|
|
11544
|
+
if (needs && backdrop.querySelector(needs)) { btn.disabled = false; btn.removeAttribute('data-tip'); }
|
|
11545
|
+
}
|
|
11546
|
+
});
|
|
11547
|
+
document.addEventListener('keydown', onKey, true);
|
|
11548
|
+
document.body.append(backdrop);
|
|
11549
|
+
// A body that changes while open (the folder browser) wires itself here; it never resolves the dialog itself.
|
|
11550
|
+
if (onOpen) onOpen(backdrop);
|
|
11551
|
+
(backdrop.querySelector('[data-autofocus]') || backdrop.querySelector('[data-kb-conn-act="cancel"]'))?.focus();
|
|
11552
|
+
});
|
|
11553
|
+
}
|
|
11554
|
+
|
|
11555
|
+
/** The connect dialog's body: the account, the chats to choose from and how far back to read. */
|
|
11556
|
+
function kbConnPickerHtml(options) {
|
|
11557
|
+
const target = options.target || {};
|
|
11558
|
+
const chats = Array.isArray(options.chats) ? options.chats : [];
|
|
11559
|
+
const list = chats.length
|
|
11560
|
+
? `<div class="kb-conn-chats" role="radiogroup" aria-label="Teams chats">${chats.map((chat, n) =>
|
|
11561
|
+
`<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' : ''}>` +
|
|
11562
|
+
`<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."' : ''}>` +
|
|
11563
|
+
`${escapeHtml(chat.chatType === 'oneOnOne' ? 'one-on-one' : chat.chatType === 'meeting' ? 'meeting' : 'group')}${chat.connected ? ' · already connected' : ''}</span></label>`).join('')}</div>` +
|
|
11564
|
+
(options.more ? '<div class="kb-conn-note">Showing your 50 most recent chats.</div>' : '')
|
|
11565
|
+
: '<p class="kb-conn-p">This account has no Teams chats FloLess can read.</p>';
|
|
11566
|
+
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('');
|
|
11567
|
+
return `<div class="kb-conn-account">Account: <b>${escapeHtml(target.label || 'Microsoft 365 account')}</b> · the one chosen in Integrations ` +
|
|
11568
|
+
'<button type="button" class="kb-link" data-kb-conn-act="integrations" data-command-id="shell.kb-connected-open-integrations">Change</button></div>' +
|
|
11569
|
+
list +
|
|
11570
|
+
`<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>` +
|
|
11571
|
+
'<ul class="kb-conn-warn">' +
|
|
11572
|
+
'<li>People’s messages are copied into this project’s knowledge and used the next time it is organized.</li>' +
|
|
11573
|
+
'<li>Each sync reads the 50 newest changes. For a busy chat, sync every day. Messages Teams delivers late may be missed.</li>' +
|
|
11574
|
+
'<li>A message can still mislead what Organize writes, so pages cite the messages they used.</li>' +
|
|
11575
|
+
'</ul>';
|
|
11576
|
+
}
|
|
11577
|
+
|
|
11578
|
+
/** Step 1 of Connect: which kind of source. Nothing is chosen for the person; Back in step 2 returns here. */
|
|
11579
|
+
async function kbConnOpenConnect() {
|
|
11580
|
+
for (;;) {
|
|
11581
|
+
const answer = await kbConnDialog({ title: 'Connect a source', labelId: 'kb-conn-title',
|
|
11582
|
+
bodyHtml: '<div class="kb-conn-kinds" role="radiogroup" aria-label="What to connect">' +
|
|
11583
|
+
[['teams-chat', 'Teams chat', 'Messages from one chat.'], ['outlook-folder', 'Outlook folder', 'Mail received in one folder.'],
|
|
11584
|
+
['trimble-project', 'Trimble Connect project', 'Topics (coordination issues), their comments and ToDos from one project.']].map(([v, label, line], n) =>
|
|
11585
|
+
`<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' : ''}>` +
|
|
11586
|
+
`<span><b>${label}</b>${line}</span></label>`).join('') + '</div>' +
|
|
11587
|
+
'<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>',
|
|
11588
|
+
onOpen: (box) => box.addEventListener('change', (e) => {
|
|
11589
|
+
if (e.target.name !== 'kb-conn-kind') return;
|
|
11590
|
+
const line = box.querySelector('[data-kb-conn-kind-line]');
|
|
11591
|
+
if (line) line.textContent = `FloLess reads it with the ${e.target.value === 'trimble-project' ? 'Trimble Connect' : 'Microsoft 365'} account chosen in Integrations.`;
|
|
11592
|
+
}),
|
|
11593
|
+
actions: [{ id: 'cancel', label: 'Cancel', commandId: 'shell.kb-connected-cancel' },
|
|
11594
|
+
{ id: 'next', label: 'Next', tone: 'primary', commandId: 'shell.kb-connected-next', disabled: true, tip: 'Choose what to connect first',
|
|
11595
|
+
enabledWhen: 'input[name="kb-conn-kind"]:checked' }] });
|
|
11596
|
+
if (!answer || answer.id !== 'next') return;
|
|
11597
|
+
const kind = answer.form.querySelector('input[name="kb-conn-kind"]:checked')?.value;
|
|
11598
|
+
const result = kind === 'outlook-folder' ? await kbConnOpenOutlook() : kind === 'trimble-project' ? await kbConnOpenTrimble() : await kbConnOpenTeams();
|
|
11599
|
+
if (result !== 'back') return;
|
|
11600
|
+
}
|
|
11601
|
+
}
|
|
11602
|
+
|
|
11603
|
+
/** Change an Outlook source's window, take a partial copy, or read every message again: the person's own click, against
|
|
11604
|
+
* the revision this screen drew (a source that changed meanwhile is shown again instead). */
|
|
11605
|
+
async function kbConnSetMail(sourceId, change, done, revision) {
|
|
11606
|
+
// A Sync now clicked while this change or its reload is still out waits for it, and is sent against the revision the
|
|
11607
|
+
// change answered with: the reload may be superseded by a poll before it lands, so the row alone may still hold the old
|
|
11608
|
+
// one, and the sync would be answered "changed since you looked at it" (#3332 QA).
|
|
11609
|
+
const run = (async () => {
|
|
11610
|
+
let left = null;
|
|
11611
|
+
try {
|
|
11612
|
+
// `revision` is the source as the dialog or row the person acted on showed it, never one a refresh brought in since.
|
|
11613
|
+
const res = await api(kbConnUrl(`/${encodeURIComponent(sourceId)}`), { method: 'PATCH', body: JSON.stringify({ ...change, revision }) });
|
|
11614
|
+
if (res && typeof res.revision === 'string') left = res.revision;
|
|
11615
|
+
kbAnnounce(done);
|
|
11616
|
+
} catch (err) { const said = errorText(err, { action: 'change this source' }); kbAnnounce(said); showToast(said, 'warn'); }
|
|
11617
|
+
kbInvalidateRefs();
|
|
11618
|
+
await renderKnowledge();
|
|
11619
|
+
return left;
|
|
11620
|
+
})();
|
|
11621
|
+
kbConnChanging.set(sourceId, run);
|
|
11622
|
+
try { await run; } finally { if (kbConnChanging.get(sourceId) === run) kbConnChanging.delete(sourceId); }
|
|
11623
|
+
}
|
|
11624
|
+
|
|
11625
|
+
async function kbConnWindowDialog(sourceId) {
|
|
11626
|
+
const c = kbConnOf(knowledgeState, sourceId);
|
|
11627
|
+
if (!kbConnIsMail(c)) return;
|
|
11628
|
+
const now = (c.outlook && c.outlook.windowDays) || 90;
|
|
11629
|
+
const name = c.label || 'this folder';
|
|
11630
|
+
const seen = c.revision;
|
|
11631
|
+
const day = 86_400_000;
|
|
11632
|
+
const consequence = (d) => (d === now ? 'This is the window it keeps now.'
|
|
11633
|
+
: d < now ? `Mail received before ${new Date(Date.now() - d * day).toLocaleDateString()} will be removed from this copy at the next sync.`
|
|
11634
|
+
: 'FloLess reads the older mail over the next syncs, up to 50 messages each.');
|
|
11635
|
+
const answer = await kbConnDialog({ title: `Time window for “${name}”`, labelId: 'kb-conn-window-title',
|
|
11636
|
+
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">` +
|
|
11637
|
+
[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('') +
|
|
11638
|
+
`</div></div><p class="kb-conn-p" data-kb-conn-consequence role="status">${escapeHtml(consequence(now))}</p>`,
|
|
11639
|
+
actions: [{ id: 'cancel', label: 'Cancel', commandId: 'shell.kb-connected-cancel' },
|
|
11640
|
+
{ id: 'apply', label: 'Change window', tone: 'primary', commandId: 'shell.kb-connected-window-go' }],
|
|
11641
|
+
onOpen: (box) => {
|
|
11642
|
+
const apply = box.querySelector('[data-kb-conn-act="apply"]');
|
|
11643
|
+
const sync = () => {
|
|
11644
|
+
const d = Number(box.querySelector('input[name="kb-conn-window"]:checked')?.value || now);
|
|
11645
|
+
box.querySelector('[data-kb-conn-consequence]').textContent = consequence(d);
|
|
11646
|
+
apply.hidden = d === now; // nothing to apply: the action is hidden, not disabled
|
|
11647
|
+
};
|
|
11648
|
+
box.addEventListener('change', sync);
|
|
11649
|
+
sync();
|
|
11650
|
+
} });
|
|
11651
|
+
if (!answer || answer.id !== 'apply') return;
|
|
11652
|
+
const d = Number(answer.form.querySelector('input[name="kb-conn-window"]:checked')?.value);
|
|
11653
|
+
if (d === 90 || d === 30 || d === 7) await kbConnSetMail(sourceId, { windowDays: d }, `“${name}” keeps the last ${d} days from the next sync.`, seen);
|
|
11654
|
+
}
|
|
11655
|
+
|
|
11656
|
+
async function kbConnRereadDialog(sourceId) {
|
|
11657
|
+
const c = kbConnOf(knowledgeState, sourceId);
|
|
11658
|
+
if (kbConnIsTrimble(c)) {
|
|
11659
|
+
const name = c.label || 'this project';
|
|
11660
|
+
const seen = c.revision;
|
|
11661
|
+
const answer = await kbConnDialog({ title: `Read every topic in “${name}” again?`, labelId: 'kb-conn-reread-title',
|
|
11662
|
+
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. ' +
|
|
11663
|
+
'It also works out the size limit again, once. Use it when the copy looks wrong or topics are missing.</p>',
|
|
11664
|
+
actions: [{ id: 'cancel', label: 'Cancel', commandId: 'shell.kb-connected-cancel' },
|
|
11665
|
+
{ id: 'reread', label: 'Read again', tone: 'primary', commandId: 'shell.kb-connected-reread-topics-go' }] });
|
|
11666
|
+
if (answer && answer.id === 'reread') await kbConnSetMail(sourceId, { reread: true }, `“${name}” is read again from the next sync, up to 50 topics each.`, seen);
|
|
11667
|
+
return;
|
|
11668
|
+
}
|
|
11669
|
+
if (!kbConnIsMail(c)) return;
|
|
11670
|
+
const name = c.label || 'this folder';
|
|
11671
|
+
const seen = c.revision;
|
|
11672
|
+
const answer = await kbConnDialog({ title: `Read every message in “${name}” again?`, labelId: 'kb-conn-reread-title',
|
|
11673
|
+
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. ' +
|
|
11674
|
+
'Use it when a copy looks wrong or messages were left out.</p>',
|
|
11675
|
+
actions: [{ id: 'cancel', label: 'Cancel', commandId: 'shell.kb-connected-cancel' },
|
|
11676
|
+
{ id: 'reread', label: 'Read again', tone: 'primary', commandId: 'shell.kb-connected-reread-go' }] });
|
|
11677
|
+
if (answer && answer.id === 'reread') await kbConnSetMail(sourceId, { reread: true }, `“${name}” is read again from the next sync, up to 50 messages each.`, seen);
|
|
11678
|
+
}
|
|
11679
|
+
|
|
11680
|
+
/** When the options cannot be listed: the reason, and the way on it names. */
|
|
11681
|
+
/** The dialog when the first list could not be read. Returns 'retry' when the person asked to try again. */
|
|
11682
|
+
async function kbConnOptionsFailed(err, title, library = 'microsoft-365') {
|
|
11683
|
+
const body = (err && err.body) || {};
|
|
11684
|
+
const choices = Array.isArray(body.choices) ? body.choices : [];
|
|
11685
|
+
const answer = await kbConnDialog({ title, labelId: 'kb-conn-title',
|
|
11686
|
+
bodyHtml: `<p class="kb-conn-p">${escapeHtml(errorText(err, { action: 'list what can be connected', retrySafe: true }))}</p>`,
|
|
11687
|
+
actions: [{ id: 'cancel', label: 'Close', commandId: 'shell.kb-connected-cancel' },
|
|
11688
|
+
...(choices.includes('retry') ? [{ id: 'retry', label: 'Try again', tone: 'primary', commandId: 'shell.kb-connected-options-retry' }] : []),
|
|
11689
|
+
...(choices.includes('open-integrations') ? [{ id: 'integrations', label: 'Open Integrations', tone: 'primary', commandId: 'shell.kb-connected-open-integrations' }] : []),
|
|
11690
|
+
...(choices.includes('open-tools') ? [{ id: 'tools', label: 'Open Tools', tone: 'primary', commandId: 'shell.kb-connected-open-tools' }] : [])] });
|
|
11691
|
+
if (answer && answer.id === 'integrations' && typeof openIntegrations === 'function') openIntegrations();
|
|
11692
|
+
if (answer && answer.id === 'tools' && typeof openLibrary === 'function') openLibrary(library, { tab: 'available' });
|
|
11693
|
+
return answer && answer.id === 'retry' ? 'retry' : null;
|
|
11694
|
+
}
|
|
11695
|
+
|
|
11696
|
+
const KB_CONN_ROOT = { id: 'msgfolderroot', label: 'Mailbox' };
|
|
11697
|
+
const kbConnFolderUrl = (parent, skip, target) => kbConnUrl(`/options?${new URLSearchParams({ kind: 'outlook-folder', parent, skip: String(skip),
|
|
11698
|
+
...(target && target.principal ? { expectedPrincipal: target.principal } : {}), ...(target && target.tenant ? { expectedTenant: target.tenant } : {}) })}`);
|
|
11699
|
+
|
|
11700
|
+
const kbConnProjectsUrl = (region, skip, target) => kbConnUrl(`/options?${new URLSearchParams({ kind: 'trimble-project', region, skip: String(skip),
|
|
11701
|
+
...(target && target.principal ? { expectedPrincipal: target.principal } : {}) })}`);
|
|
11702
|
+
const kbConnRegionEmpty = () => ({ projects: [], nextSkip: null, failed: null, omitted: 0, loading: true });
|
|
11703
|
+
|
|
11704
|
+
/** Step 2 for Trimble Connect (slice 2 plan §18 #5): every published region is asked for its first page, and the projects
|
|
11705
|
+
* are grouped by region; each region pages and retries on its own. A region with nothing to say is not shown. */
|
|
11706
|
+
async function kbConnOpenTrimble() {
|
|
11707
|
+
const proj = current;
|
|
11708
|
+
if (!proj) return null;
|
|
11709
|
+
// The first region verifies the account and says which regions exist; a stop here (not signed in) ends the dialog.
|
|
11710
|
+
let first;
|
|
11711
|
+
for (;;) {
|
|
11712
|
+
try { first = await api(kbConnProjectsUrl('europe', 0, null), { timeoutMs: 60_000 }); break; }
|
|
11713
|
+
catch (err) { if (await kbConnOptionsFailed(err, 'Connect a Trimble Connect project', 'trimble-connect') !== 'retry') return null; }
|
|
11714
|
+
}
|
|
11715
|
+
const view = { target: first.target, regions: {}, notice: null, picked: null };
|
|
11716
|
+
const order = KB_CONN_REGIONS.map(([r]) => r).filter((r) => (first.regions || []).includes(r));
|
|
11717
|
+
for (const r of order) view.regions[r] = kbConnRegionEmpty();
|
|
11718
|
+
const take = (r, res, append) => {
|
|
11719
|
+
const reg = view.regions[r];
|
|
11720
|
+
reg.loading = false;
|
|
11721
|
+
reg.failed = res.failed || null;
|
|
11722
|
+
reg.projects = append ? reg.projects.concat(res.projects || []) : (res.projects || []);
|
|
11723
|
+
reg.nextSkip = res.nextSkip == null ? null : res.nextSkip;
|
|
11724
|
+
reg.omitted = (append ? reg.omitted : 0) + (res.omitted || 0);
|
|
11725
|
+
};
|
|
11726
|
+
if (view.regions.europe) take('europe', first, false);
|
|
11727
|
+
const shown = () => order.filter((r) => { const g = view.regions[r]; return g.projects.length || g.failed || g.loading; });
|
|
11728
|
+
const picker = () => {
|
|
11729
|
+
if (view.notice) {
|
|
11730
|
+
return `<div class="kb-conn-stop" role="alert"><b>${escapeHtml(view.notice.title)}</b> ${escapeHtml(view.notice.text)}` +
|
|
11731
|
+
'<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>';
|
|
11732
|
+
}
|
|
11733
|
+
const regions = shown();
|
|
11734
|
+
const loading = order.some((r) => view.regions[r].loading);
|
|
11735
|
+
if (!order.length) {
|
|
11736
|
+
// No region was asked: an AWARE that publishes none FloLess knows is not "no projects".
|
|
11737
|
+
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>';
|
|
11738
|
+
}
|
|
11739
|
+
if (!regions.length) {
|
|
11740
|
+
return '<p class="kb-conn-p">No Trimble Connect projects found for this account in any region. ' +
|
|
11741
|
+
'<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>';
|
|
11742
|
+
}
|
|
11743
|
+
// One region with projects and nothing else to say needs no heading: a lone heading is noise.
|
|
11744
|
+
const headed = !(regions.length === 1 && !loading && !view.regions[regions[0]].failed);
|
|
11745
|
+
const block = (r) => {
|
|
11746
|
+
const g = view.regions[r];
|
|
11747
|
+
const name = kbConnRegionName(r);
|
|
11748
|
+
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)}"` +
|
|
11749
|
+
`${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)}">` +
|
|
11750
|
+
`<span class="kb-conn-chat-name" data-tip="${escapeAttr(p.label)}">${escapeHtml(p.label)}</span>` +
|
|
11751
|
+
`<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('');
|
|
11752
|
+
const busy = g.loading ? ' aria-busy="true" disabled' : '';
|
|
11753
|
+
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>` : '') +
|
|
11754
|
+
(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>` : '') +
|
|
11755
|
+
(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>` : '') +
|
|
11756
|
+
(g.loading && !g.failed && !g.projects.length ? '<div class="kb-conn-note">Loading…</div>' : '');
|
|
11757
|
+
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>`;
|
|
11758
|
+
};
|
|
11759
|
+
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>` +
|
|
11760
|
+
(loading ? '<div class="kb-conn-note" role="status">Looking in every Trimble region…</div>' : '');
|
|
11761
|
+
};
|
|
11762
|
+
const answer = await kbConnDialog({ title: 'Connect a Trimble Connect project', labelId: 'kb-conn-title',
|
|
11763
|
+
bodyHtml: `<div class="kb-conn-account">Account: <b>${escapeHtml(view.target.label || 'Trimble Connect account')}</b> · the one chosen in Integrations ` +
|
|
11764
|
+
'<button type="button" class="kb-link" data-kb-conn-act="integrations" data-command-id="shell.kb-connected-open-integrations">Change</button></div>' +
|
|
11765
|
+
`<div data-kb-conn-picker>${picker()}</div>` +
|
|
11766
|
+
'<ul class="kb-conn-warn">' +
|
|
11767
|
+
'<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>' +
|
|
11768
|
+
`<li>${escapeHtml(KB_CONN_TRIMBLE_NOT_INCLUDED)}</li>` +
|
|
11769
|
+
'<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>' +
|
|
11770
|
+
'</ul>' +
|
|
11771
|
+
'<details class="kb-conn-gaps"><summary data-command-id="shell.kb-connected-more-about">More about what is copied</summary><ul>' +
|
|
11772
|
+
'<li>Closed topics stay in the copy, with their status.</li>' +
|
|
11773
|
+
'<li>Each sync reads at most 50 topics, so a large project takes several syncs at first.</li>' +
|
|
11774
|
+
'<li>The newest 200 comments of a topic are kept; the topic says how many older ones are not.</li>' +
|
|
11775
|
+
'<li>A project with more than 5,000 topics or ToDos is kept as a partial copy, and the row says so.</li>' +
|
|
11776
|
+
'<li>A topic Trimble stops listing leaves after two syncs, and the page says so.</li>' +
|
|
11777
|
+
'</ul></details>',
|
|
11778
|
+
actions: [{ id: 'back', label: 'Back', commandId: 'shell.kb-connected-back' }, { id: 'cancel', label: 'Cancel', commandId: 'shell.kb-connected-cancel' },
|
|
11779
|
+
{ id: 'connect', label: 'Connect and sync', tone: 'primary', commandId: 'shell.kb-connected-connect', disabled: true, tip: 'Choose a project first' }],
|
|
11780
|
+
onOpen: (box) => {
|
|
11781
|
+
const host = box.querySelector('[data-kb-conn-picker]');
|
|
11782
|
+
const connect = box.querySelector('.modal-actions [data-kb-conn-act="connect"]');
|
|
11783
|
+
// A repaint keeps focus on the same project, Show more or Retry (by what it stands for, not by node).
|
|
11784
|
+
const keyOf = (el) => (!el || !el.dataset ? null : el.name === 'kb-conn-project' ? `p:${el.dataset.region}:${el.value}`
|
|
11785
|
+
: el.dataset.kbConnRegionMore ? `m:${el.dataset.kbConnRegionMore}` : el.dataset.kbConnRegionRetry ? `r:${el.dataset.kbConnRegionRetry}` : null);
|
|
11786
|
+
const paint = () => {
|
|
11787
|
+
const focused = document.activeElement && host.contains(document.activeElement) ? keyOf(document.activeElement) : null;
|
|
11788
|
+
host.innerHTML = picker();
|
|
11789
|
+
// A choice whose radio is no longer drawn is no choice: Connect never sends a project the person cannot see.
|
|
11790
|
+
if (view.picked && ![...host.querySelectorAll('input[name="kb-conn-project"]')].some((el) => `${el.dataset.region}:${el.value}` === view.picked)) view.picked = null;
|
|
11791
|
+
const ok = !!view.picked && !view.notice;
|
|
11792
|
+
connect.disabled = !ok;
|
|
11793
|
+
if (ok) connect.removeAttribute('data-tip'); else connect.dataset.tip = 'Choose a project first';
|
|
11794
|
+
if (focused) {
|
|
11795
|
+
const back = [...host.querySelectorAll('input[name="kb-conn-project"], [data-kb-conn-region-more], [data-kb-conn-region-retry]')].find((el) => keyOf(el) === focused);
|
|
11796
|
+
(back && !back.disabled ? back : host.querySelector('input[name="kb-conn-project"]'))?.focus();
|
|
11797
|
+
}
|
|
11798
|
+
};
|
|
11799
|
+
let epoch = 0; // Start again drops every answer that was still on its way
|
|
11800
|
+
const load = async (r, append) => {
|
|
11801
|
+
if (view.notice || !view.regions[r]) return;
|
|
11802
|
+
const mine = epoch;
|
|
11803
|
+
try {
|
|
11804
|
+
view.regions[r].loading = true;
|
|
11805
|
+
paint();
|
|
11806
|
+
let res;
|
|
11807
|
+
try { res = await api(kbConnProjectsUrl(r, append ? view.regions[r].nextSkip : 0, view.target), { timeoutMs: 60_000 }); }
|
|
11808
|
+
catch (err) {
|
|
11809
|
+
// The server's own sentence when it wrote one; a network failure or a timeout in plain words, never raw (errorText).
|
|
11810
|
+
res = { failed: errorText(err, { action: `list your ${kbConnRegionName(r)} projects`, retrySafe: true }), projects: [] };
|
|
11811
|
+
}
|
|
11812
|
+
if (mine !== epoch || view.notice || !box.isConnected) return;
|
|
11813
|
+
settle(r, res, append);
|
|
11814
|
+
} catch (err) {
|
|
11815
|
+
// Anything else leaves the region answerable, never stuck on Loading.
|
|
11816
|
+
console.warn('kb-conn: a Trimble region could not be drawn', err);
|
|
11817
|
+
if (mine !== epoch || !box.isConnected || !view.regions[r]) return;
|
|
11818
|
+
view.regions[r].loading = false;
|
|
11819
|
+
view.regions[r].failed = 'FloLess could not show this region. Retry in a moment.';
|
|
11820
|
+
paint();
|
|
11821
|
+
}
|
|
11822
|
+
};
|
|
11823
|
+
const settle = (r, res, append) => {
|
|
11824
|
+
if (res.targetChanged) {
|
|
11825
|
+
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.' };
|
|
11826
|
+
view.target = res.target || view.target;
|
|
11827
|
+
view.picked = null;
|
|
11828
|
+
box.querySelector('.kb-conn-account b').textContent = view.target.label || 'Trimble Connect account';
|
|
11829
|
+
paint();
|
|
11830
|
+
return;
|
|
11831
|
+
}
|
|
11832
|
+
take(r, res, append);
|
|
11833
|
+
paint();
|
|
11834
|
+
};
|
|
11835
|
+
host.addEventListener('change', (e) => {
|
|
11836
|
+
if (e.target.name !== 'kb-conn-project') return;
|
|
11837
|
+
view.picked = `${e.target.dataset.region}:${e.target.value}`;
|
|
11838
|
+
connect.disabled = false;
|
|
11839
|
+
connect.removeAttribute('data-tip');
|
|
11840
|
+
});
|
|
11841
|
+
host.addEventListener('click', (e) => {
|
|
11842
|
+
const more = e.target.closest('[data-kb-conn-region-more]');
|
|
11843
|
+
if (more) { void load(more.dataset.kbConnRegionMore, true); return; }
|
|
11844
|
+
const retry = e.target.closest('[data-kb-conn-region-retry]');
|
|
11845
|
+
if (retry) { void load(retry.dataset.kbConnRegionRetry, false); return; }
|
|
11846
|
+
if (e.target.closest('[data-kb-conn-restart]')) {
|
|
11847
|
+
epoch += 1;
|
|
11848
|
+
view.notice = null;
|
|
11849
|
+
view.picked = null;
|
|
11850
|
+
for (const r of order) view.regions[r] = kbConnRegionEmpty();
|
|
11851
|
+
paint();
|
|
11852
|
+
for (const r of order) void load(r, false);
|
|
11853
|
+
}
|
|
11854
|
+
});
|
|
11855
|
+
for (const r of order) if (r !== 'europe') void load(r, false);
|
|
11856
|
+
} });
|
|
11857
|
+
if (answer && answer.id === 'back') return 'back';
|
|
11858
|
+
if (answer && answer.id === 'integrations') { if (typeof openIntegrations === 'function') openIntegrations(); return null; }
|
|
11859
|
+
if (!answer || answer.id !== 'connect' || !current || current.id !== proj.id) return null;
|
|
11860
|
+
const picked = answer.form.querySelector('input[name="kb-conn-project"]:checked');
|
|
11861
|
+
if (!picked) return null;
|
|
11862
|
+
try {
|
|
11863
|
+
const res = await api(kbConnUrl(''), { method: 'POST', body: JSON.stringify({ kind: 'trimble-project', projectId: picked.value, region: picked.dataset.region,
|
|
11864
|
+
label: picked.dataset.label, expected: view.target }) });
|
|
11865
|
+
kbAnnounce(picked.hasAttribute('data-connected') ? `“${picked.dataset.label}” is already connected. Syncing it…` : `Connected “${picked.dataset.label}”. Syncing…`);
|
|
11866
|
+
await renderKnowledge();
|
|
11867
|
+
if (res.source && res.source.sourceId) await kbConnSync(res.source.sourceId);
|
|
11868
|
+
} catch (err) {
|
|
11869
|
+
const said = errorText(err, { action: 'connect that project' });
|
|
11870
|
+
kbAnnounce(said);
|
|
11871
|
+
showToast(said, 'warn');
|
|
11872
|
+
await renderKnowledge();
|
|
11873
|
+
}
|
|
11874
|
+
return null;
|
|
11875
|
+
}
|
|
11876
|
+
|
|
11877
|
+
/** Step 2 for Outlook: one level of folders at a time. Only the chosen folder is connected, never its subfolders. */
|
|
11878
|
+
async function kbConnOpenOutlook() {
|
|
11879
|
+
const proj = current;
|
|
11880
|
+
if (!proj) return null;
|
|
11881
|
+
let first;
|
|
11882
|
+
for (;;) {
|
|
11883
|
+
try { first = await api(kbConnFolderUrl('msgfolderroot', 0, null), { timeoutMs: 60_000 }); break; }
|
|
11884
|
+
catch (err) { if (await kbConnOptionsFailed(err, 'Connect an Outlook folder') !== 'retry') return null; }
|
|
11885
|
+
}
|
|
11886
|
+
const view = { target: first.target, path: [KB_CONN_ROOT], page: first, folders: first.folders || [], notice: null, loading: false };
|
|
11887
|
+
const browser = () => {
|
|
11888
|
+
const level = view.path[view.path.length - 1];
|
|
11889
|
+
const crumbs = view.path.map((p, i) => (i === view.path.length - 1
|
|
11890
|
+
? `<span aria-current="location" data-tip="${escapeAttr(p.label)}">${escapeHtml(p.label)}</span>`
|
|
11891
|
+
: `<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>`))
|
|
11892
|
+
.join('<span class="kb-conn-crumb-sep" aria-hidden="true">›</span>');
|
|
11893
|
+
if (view.notice) {
|
|
11894
|
+
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)}` +
|
|
11895
|
+
`<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>`;
|
|
11896
|
+
}
|
|
11897
|
+
const checked = view.picked;
|
|
11898
|
+
const row = (f, isThis) => {
|
|
11899
|
+
const meta = isThis ? 'this folder itself'
|
|
11900
|
+
: [kbConnPlural(f.totalCount, 'mail', 'mails'), f.childCount ? kbConnPlural(f.childCount, 'subfolder', 'subfolders') : '', f.connected ? 'already connected' : ''].filter(Boolean).join(' · ');
|
|
11901
|
+
const open = !isThis && f.childCount > 0
|
|
11902
|
+
? `<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'}"` +
|
|
11903
|
+
` aria-label="Open subfolders of ${escapeAttr(f.label)}" data-tip="Browse inside this folder. Only the folder you choose is connected, not its subfolders."` +
|
|
11904
|
+
` data-command-id="shell.kb-connected-folder-open#${escapeAttr(f.folderId)}" data-command-instance-label="${escapeAttr(f.label)}">Open subfolders ›</button>` : '';
|
|
11905
|
+
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)}"` +
|
|
11906
|
+
`${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)}">` +
|
|
11907
|
+
`<span class="kb-conn-chat-name" data-tip="${escapeAttr(f.label)}">${escapeHtml(isThis ? `This folder (${f.label})` : f.label)}</span>` +
|
|
11908
|
+
`<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>`;
|
|
11909
|
+
};
|
|
11910
|
+
const here = level.id === 'msgfolderroot' ? '' : row({ folderId: level.id, label: level.label, totalCount: 0, childCount: 0 }, true);
|
|
11911
|
+
const list = view.folders.length || here
|
|
11912
|
+
? `<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('')}` +
|
|
11913
|
+
(view.folders.length ? '' : '<div class="kb-conn-note" style="padding:4px 8px">No subfolders here. Choose this folder, or go back.</div>') + '</div>'
|
|
11914
|
+
: `<p class="kb-conn-p">${level.id === 'msgfolderroot' ? 'This account has no mail folders FloLess can read.' : 'No subfolders here.'}</p>`;
|
|
11915
|
+
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.` : '',
|
|
11916
|
+
view.page.limitReached ? 'Outlook stopped listing here, so more folders may exist. Open a parent folder to narrow it down.' : ''].filter(Boolean);
|
|
11917
|
+
return `<nav class="kb-conn-crumbs" aria-label="Folder path">${crumbs}</nav>${list}` +
|
|
11918
|
+
(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>` : '') +
|
|
11919
|
+
notes.map((n) => `<div class="kb-conn-note">${escapeHtml(n)}</div>`).join('') +
|
|
11920
|
+
(view.loading ? '<div class="kb-sr" role="status">Loading folders…</div>' : '');
|
|
11921
|
+
};
|
|
11922
|
+
const answer = await kbConnDialog({ title: 'Connect an Outlook folder', labelId: 'kb-conn-title',
|
|
11923
|
+
bodyHtml: `<div class="kb-conn-account">Account: <b>${escapeHtml(view.target.label || 'Microsoft 365 account')}</b> · the one chosen in Integrations ` +
|
|
11924
|
+
'<button type="button" class="kb-link" data-kb-conn-act="integrations" data-command-id="shell.kb-connected-open-integrations">Change</button></div>' +
|
|
11925
|
+
`<div data-kb-conn-browser>${browser()}</div>` +
|
|
11926
|
+
'<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>' +
|
|
11927
|
+
'<ul class="kb-conn-warn">' +
|
|
11928
|
+
'<li>Mail in this folder is copied into this project’s knowledge and used the next time it is organized.</li>' +
|
|
11929
|
+
'<li>Anyone can send you a mail, and a mail can mislead what Organize writes, so pages cite the mail they used.</li>' +
|
|
11930
|
+
'<li>A folder with more than 100,000 mails in 90 days asks you to keep a shorter window or a partial copy.</li>' +
|
|
11931
|
+
'</ul>' +
|
|
11932
|
+
'<details class="kb-conn-gaps"><summary data-command-id="shell.kb-connected-more-about">More about what is copied</summary><ul>' +
|
|
11933
|
+
'<li>Attachments are listed by name only.</li>' +
|
|
11934
|
+
'<li>Mail deleted in Outlook leaves this copy at the next sync.</li>' +
|
|
11935
|
+
'<li>Mail Outlook stops listing leaves after two syncs, and the page says so.</li>' +
|
|
11936
|
+
'<li>Each sync reads at most 50 messages; drafts and undated mail are left out.</li>' +
|
|
11937
|
+
'</ul></details>',
|
|
11938
|
+
actions: [{ id: 'back', label: 'Back', commandId: 'shell.kb-connected-back' }, { id: 'cancel', label: 'Cancel', commandId: 'shell.kb-connected-cancel' },
|
|
11939
|
+
{ id: 'connect', label: 'Connect and sync', tone: 'primary', commandId: 'shell.kb-connected-connect', disabled: true, tip: 'Choose a folder first' }],
|
|
11940
|
+
onOpen: (box) => {
|
|
11941
|
+
const host = box.querySelector('[data-kb-conn-browser]');
|
|
11942
|
+
const connect = box.querySelector('[data-kb-conn-act="connect"]');
|
|
11943
|
+
const paint = (focusFirst) => {
|
|
11944
|
+
host.innerHTML = browser();
|
|
11945
|
+
const ok = !!view.picked && !view.notice && !view.loading;
|
|
11946
|
+
connect.disabled = !ok;
|
|
11947
|
+
if (ok) connect.removeAttribute('data-tip'); else connect.dataset.tip = 'Choose a folder first';
|
|
11948
|
+
if (focusFirst) host.querySelector('input[name="kb-conn-folder"]')?.focus();
|
|
11949
|
+
};
|
|
11950
|
+
const load = async (path, append) => {
|
|
11951
|
+
if (view.loading) return;
|
|
11952
|
+
const level = path[path.length - 1];
|
|
11953
|
+
view.loading = true;
|
|
11954
|
+
paint(false);
|
|
11955
|
+
let res;
|
|
11956
|
+
try { res = await api(kbConnFolderUrl(level.id, append ? view.page.nextSkip : 0, view.target), { timeoutMs: 60_000 }); }
|
|
11957
|
+
catch (err) {
|
|
11958
|
+
view.loading = false;
|
|
11959
|
+
view.notice = { title: 'Folders not listed.', text: err.message, button: 'Start again from the mailbox' };
|
|
11960
|
+
paint(false);
|
|
11961
|
+
return;
|
|
11962
|
+
}
|
|
11963
|
+
view.loading = false;
|
|
11964
|
+
if (res.targetChanged) {
|
|
11965
|
+
view.target = res.target;
|
|
11966
|
+
// The listed folders and the path belong to the other account: none of them may stay selectable.
|
|
11967
|
+
view.picked = null;
|
|
11968
|
+
view.path = [KB_CONN_ROOT];
|
|
11969
|
+
view.folders = [];
|
|
11970
|
+
view.page = { nextSkip: null, omitted: 0, limitReached: false };
|
|
11971
|
+
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' };
|
|
11972
|
+
box.querySelector('.kb-conn-account b').textContent = res.target.label || 'Microsoft 365 account';
|
|
11973
|
+
paint(false);
|
|
11974
|
+
return;
|
|
11975
|
+
}
|
|
11976
|
+
// A level that listed replaces any earlier failure; the account-change reset never reaches here (code review R2 #3).
|
|
11977
|
+
view.notice = null;
|
|
11978
|
+
view.path = path;
|
|
11979
|
+
view.page = res;
|
|
11980
|
+
view.folders = append ? view.folders.concat(res.folders || []) : (res.folders || []);
|
|
11981
|
+
if (!append) view.picked = null;
|
|
11982
|
+
paint(!append);
|
|
11983
|
+
if (!append) kbAnnounce(`${level.label}: ${kbConnPlural(view.folders.length, 'folder', 'folders')}.`);
|
|
11984
|
+
};
|
|
11985
|
+
host.addEventListener('change', (e) => {
|
|
11986
|
+
if (e.target.name !== 'kb-conn-folder' || view.loading) return;
|
|
11987
|
+
view.picked = e.target.value;
|
|
11988
|
+
// Roving Tab stop: only the chosen row's Open subfolders button is in the Tab order.
|
|
11989
|
+
host.querySelectorAll('[data-kb-conn-open]').forEach((b) => { b.tabIndex = b.dataset.kbConnOpen === view.picked ? 0 : -1; });
|
|
11990
|
+
connect.disabled = false;
|
|
11991
|
+
connect.removeAttribute('data-tip');
|
|
11992
|
+
});
|
|
11993
|
+
host.addEventListener('click', (e) => {
|
|
11994
|
+
const open = e.target.closest('[data-kb-conn-open]');
|
|
11995
|
+
if (open) { e.preventDefault(); void load([...view.path, { id: open.dataset.kbConnOpen, label: open.dataset.label }], false); return; }
|
|
11996
|
+
const crumb = e.target.closest('[data-kb-conn-crumb]');
|
|
11997
|
+
if (crumb) { void load(view.path.slice(0, Number(crumb.dataset.kbConnCrumb) + 1), false); return; }
|
|
11998
|
+
if (e.target.closest('[data-kb-conn-more]')) { void load(view.path, true); return; }
|
|
11999
|
+
if (e.target.closest('[data-kb-conn-restart]')) {
|
|
12000
|
+
view.notice = null;
|
|
12001
|
+
view.picked = null;
|
|
12002
|
+
view.path = [KB_CONN_ROOT];
|
|
12003
|
+
view.folders = [];
|
|
12004
|
+
view.page = { nextSkip: null, omitted: 0, limitReached: false };
|
|
12005
|
+
void load([KB_CONN_ROOT], false);
|
|
12006
|
+
}
|
|
12007
|
+
});
|
|
12008
|
+
} });
|
|
12009
|
+
if (answer && answer.id === 'back') return 'back';
|
|
12010
|
+
if (answer && answer.id === 'integrations') { if (typeof openIntegrations === 'function') openIntegrations(); return null; }
|
|
12011
|
+
if (!answer || answer.id !== 'connect' || !current || current.id !== proj.id) return null;
|
|
12012
|
+
const picked = answer.form.querySelector('input[name="kb-conn-folder"]:checked');
|
|
12013
|
+
if (!picked) return null;
|
|
12014
|
+
try {
|
|
12015
|
+
const res = await api(kbConnUrl(''), { method: 'POST', body: JSON.stringify({ kind: 'outlook-folder', folderId: picked.value, label: picked.dataset.label, expected: view.target }) });
|
|
12016
|
+
kbAnnounce(picked.hasAttribute('data-connected') ? `“${picked.dataset.label}” is already connected. Syncing it…` : `Connected “${picked.dataset.label}”. Syncing…`);
|
|
12017
|
+
await renderKnowledge();
|
|
12018
|
+
if (res.source && res.source.sourceId) await kbConnSync(res.source.sourceId);
|
|
12019
|
+
} catch (err) {
|
|
12020
|
+
const said = errorText(err, { action: 'connect that folder' });
|
|
12021
|
+
kbAnnounce(said);
|
|
12022
|
+
showToast(said, 'warn');
|
|
12023
|
+
await renderKnowledge();
|
|
12024
|
+
}
|
|
12025
|
+
return null;
|
|
12026
|
+
}
|
|
12027
|
+
|
|
12028
|
+
async function kbConnOpenTeams() {
|
|
12029
|
+
const proj = current;
|
|
12030
|
+
if (!proj) return null;
|
|
12031
|
+
let options;
|
|
12032
|
+
for (;;) {
|
|
12033
|
+
try { options = await api(kbConnUrl('/options'), { timeoutMs: 60_000 }); break; }
|
|
12034
|
+
catch (err) { if (await kbConnOptionsFailed(err, 'Connect a Teams chat') !== 'retry') return null; }
|
|
12035
|
+
}
|
|
12036
|
+
const target = options.target;
|
|
12037
|
+
const chats = Array.isArray(options.chats) ? options.chats : [];
|
|
12038
|
+
const answer = await kbConnDialog({ title: 'Connect a Teams chat', labelId: 'kb-conn-title',
|
|
12039
|
+
bodyHtml: kbConnPickerHtml(options),
|
|
12040
|
+
// No chat is picked for the person: connecting copies people's messages, so the chat is always their own choice.
|
|
12041
|
+
actions: [{ id: 'back', label: 'Back', commandId: 'shell.kb-connected-back' }, { id: 'cancel', label: chats.length ? 'Cancel' : 'Close', commandId: 'shell.kb-connected-cancel' },
|
|
12042
|
+
...(chats.length ? [{ id: 'connect', label: 'Connect and sync', tone: 'primary', commandId: 'shell.kb-connected-connect',
|
|
12043
|
+
disabled: true, tip: 'Choose a chat first', enabledWhen: 'input[name="kb-conn-chat"]:checked' }] : [])] });
|
|
12044
|
+
if (answer && answer.id === 'back') return 'back';
|
|
12045
|
+
if (answer && answer.id === 'integrations') { if (typeof openIntegrations === 'function') openIntegrations(); return null; }
|
|
12046
|
+
if (!answer || answer.id !== 'connect' || !current || current.id !== proj.id) return null;
|
|
12047
|
+
const picked = answer.form.querySelector('input[name="kb-conn-chat"]:checked');
|
|
12048
|
+
const windowDays = Number(answer.form.querySelector('input[name="kb-conn-window"]:checked')?.value || 30);
|
|
12049
|
+
if (!picked) return;
|
|
12050
|
+
try {
|
|
12051
|
+
const res = await api(kbConnUrl(''), { method: 'POST', body: JSON.stringify({ chatId: picked.value, label: picked.dataset.label, windowDays, expected: target }) });
|
|
12052
|
+
kbAnnounce(picked.hasAttribute('data-connected')
|
|
12053
|
+
? `“${picked.dataset.label}” is already connected. Syncing it…` : `Connected “${picked.dataset.label}”. Syncing…`);
|
|
12054
|
+
await renderKnowledge();
|
|
12055
|
+
if (res.source && res.source.sourceId) await kbConnSync(res.source.sourceId);
|
|
12056
|
+
} catch (err) {
|
|
12057
|
+
const said = errorText(err, { action: 'connect that source' });
|
|
12058
|
+
kbAnnounce(said);
|
|
12059
|
+
showToast(said, 'warn');
|
|
12060
|
+
await renderKnowledge();
|
|
12061
|
+
}
|
|
12062
|
+
}
|
|
12063
|
+
|
|
12064
|
+
async function kbConnErase(sourceId) {
|
|
12065
|
+
const st = knowledgeState;
|
|
12066
|
+
const c = kbConnOf(st, sourceId);
|
|
12067
|
+
const removed = ((st && st.connected && st.connected.removed) || []).find((r) => r.sourceId === sourceId);
|
|
12068
|
+
const name = (c && c.label) || (removed && removed.label) || (kbConnIsMail(c) ? 'this folder' : 'this source');
|
|
12069
|
+
// Each source names what its own service keeps (a Trimble project keeps its topics), a removed one too: the
|
|
12070
|
+
// project-wide list is a Teams chat's, so it is only the last resort for a server that sends neither.
|
|
12071
|
+
const notReached = (c && Array.isArray(c.notReached) && c.notReached)
|
|
12072
|
+
|| (removed && Array.isArray(removed.notReached) && removed.notReached)
|
|
12073
|
+
|| (st && st.connected && st.connected.notReached) || [];
|
|
12074
|
+
const what = kbConnIsTrimble(c) || (removed && removed.scopeKind === 'trimble-project') ? 'its topics and ToDos' : 'its messages';
|
|
12075
|
+
const revision = c ? c.revision : 'removed';
|
|
12076
|
+
const answer = await kbConnDialog({ title: `Erase “${name}”?`, labelId: 'kb-conn-erase-title',
|
|
12077
|
+
bodyHtml: '<div class="kb-conn-h">This removes</div><ul class="kb-conn-list">' +
|
|
12078
|
+
`<li>${c ? `${c.versions} saved version${c.versions === 1 ? '' : 's'} of ${what}` : `the saved versions of ${what}`}</li>` +
|
|
12079
|
+
'<li>the knowledge pages organized from it</li><li>any quotes from it saved with workflow Agent steps and pinned pages</li>' +
|
|
12080
|
+
(c ? `<li>this ${kbConnThing(c)} as a source, so it stops syncing</li>` : '') + '</ul>' +
|
|
12081
|
+
`<div class="kb-conn-h">This cannot reach</div><ul class="kb-conn-list">${(notReached.length ? notReached
|
|
12082
|
+
: ['AI Chat conversations and reports already made, which may quote this source.']).map((line) => `<li>${escapeHtml(line)}</li>`).join('')}</ul>` +
|
|
12083
|
+
'<p class="kb-conn-p">It cannot be undone.</p>',
|
|
12084
|
+
actions: [{ id: 'cancel', label: 'Cancel', commandId: 'shell.kb-connected-cancel' },
|
|
12085
|
+
{ id: 'erase', label: 'Erase permanently', tone: 'danger', commandId: 'shell.kb-connected-erase-go' }] });
|
|
12086
|
+
if (!answer || answer.id !== 'erase') return;
|
|
12087
|
+
await kbConnEraseGo(sourceId, name, { revision });
|
|
12088
|
+
}
|
|
12089
|
+
|
|
12090
|
+
async function kbConnEraseGo(sourceId, name, body) {
|
|
12091
|
+
let res;
|
|
12092
|
+
try { res = await api(kbConnUrl(`/${encodeURIComponent(sourceId)}/erase`), { method: 'POST', body: JSON.stringify(body) }); }
|
|
12093
|
+
catch (err) { const said = errorText(err, { action: 'erase this source' }); kbAnnounce(said); showToast(said, 'warn'); kbInvalidateRefs(); await renderKnowledge(); return; }
|
|
12094
|
+
if (res.state === 'waiting') {
|
|
12095
|
+
const answer = await kbConnDialog({ title: `Stop the Organize and erase “${name}”?`, labelId: 'kb-conn-stop-title',
|
|
12096
|
+
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>`,
|
|
12097
|
+
actions: [{ id: 'cancel', label: 'Wait for it', commandId: 'shell.kb-connected-cancel' },
|
|
12098
|
+
{ id: 'stop', label: 'Stop and erase', tone: 'danger', commandId: 'shell.kb-connected-stop-organize' }] });
|
|
12099
|
+
if (answer && answer.id === 'stop') return kbConnEraseGo(sourceId, name, { stopOrganize: res.organizeRequestId });
|
|
12100
|
+
kbAnnounce('Erasing as soon as the Organize ends.');
|
|
12101
|
+
} else if (res.state === 'incomplete') {
|
|
12102
|
+
// The page words this itself from the count; the server's list of what stayed is kept in the console.
|
|
12103
|
+
const left = Array.isArray(res.failures) ? res.failures.length : 0;
|
|
12104
|
+
if (left) console.warn('[knowledge] erase left items behind', res.failures);
|
|
12105
|
+
const said = left ? `Erase did not finish: ${left} item${left === 1 ? '' : 's'} could not be removed. Erase again.` : 'Erase did not finish. Erase again.';
|
|
12106
|
+
kbAnnounce(said);
|
|
12107
|
+
showToast(said, 'warn');
|
|
12108
|
+
} else {
|
|
12109
|
+
kbConnStops.delete(sourceId);
|
|
12110
|
+
kbAnnounce(`Erased “${name}”.`);
|
|
12111
|
+
}
|
|
12112
|
+
kbInvalidateRefs();
|
|
12113
|
+
await renderKnowledge();
|
|
12114
|
+
// The row the dialog returned focus to may be gone now; keep focus in the list rather than lose it to the page.
|
|
12115
|
+
if (!$wsKnowledge.contains(document.activeElement)) $wsKnowledge.querySelector('[data-kb-conn-new]')?.focus({ preventScroll: true });
|
|
12116
|
+
}
|
|
12117
|
+
|
|
12118
|
+
/** The click handler's connected-source half; true when it handled the click. */
|
|
12119
|
+
function kbConnClick(e) {
|
|
12120
|
+
const t = e.target;
|
|
12121
|
+
if (t.closest('[data-kb-conn-new]')) { kbCloseConfirm(); void kbConnOpenConnect(); return true; }
|
|
12122
|
+
const sync = t.closest('[data-kb-conn-sync]');
|
|
12123
|
+
if (sync) { kbCloseConfirm(); void kbConnSync(sync.dataset.kbConnSync); return true; }
|
|
12124
|
+
const menu = t.closest('[data-kb-conn-menu]');
|
|
12125
|
+
if (menu) { kbConnShowMenu(menu); return true; }
|
|
12126
|
+
const pause = t.closest('[data-kb-conn-pause]');
|
|
12127
|
+
if (pause) { kbCloseConfirm(); void kbConnSetPaused(pause.dataset.kbConnPause, pause.dataset.kbConnPaused === 'true'); return true; }
|
|
12128
|
+
const remove = t.closest('[data-kb-conn-remove]');
|
|
12129
|
+
if (remove) { kbConnRemove(remove.dataset.kbConnRemove); return true; }
|
|
12130
|
+
const erase = t.closest('[data-kb-conn-erase]');
|
|
12131
|
+
if (erase) { kbCloseConfirm(); void kbConnErase(erase.dataset.kbConnErase); return true; }
|
|
12132
|
+
const choice = t.closest('[data-kb-conn-choice]');
|
|
12133
|
+
if (choice) { kbConnChoose(choice.dataset.kbConnId, choice.dataset.kbConnChoice); return true; }
|
|
12134
|
+
const windowMenu = t.closest('[data-kb-conn-window-menu]');
|
|
12135
|
+
if (windowMenu) { kbCloseConfirm(); void kbConnWindowDialog(windowMenu.dataset.kbConnWindowMenu); return true; }
|
|
12136
|
+
const reread = t.closest('[data-kb-conn-reread]');
|
|
12137
|
+
if (reread) { kbCloseConfirm(); void kbConnRereadDialog(reread.dataset.kbConnReread); return true; }
|
|
12138
|
+
const ceiling = t.closest('[data-kb-conn-ceiling]');
|
|
12139
|
+
if (ceiling) {
|
|
12140
|
+
const id = ceiling.dataset.kbConnId, v = ceiling.dataset.kbConnCeiling;
|
|
12141
|
+
const name = kbConnOf(knowledgeState, id)?.label || 'This folder';
|
|
12142
|
+
void kbConnSetMail(id, v === 'partial' ? { beyondCeiling: 'partial' } : { windowDays: Number(v) },
|
|
12143
|
+
v === 'partial' ? `“${name}” keeps a partial copy.` : `“${name}” keeps the last ${v} days from the next sync.`, ceiling.dataset.kbConnRev);
|
|
12144
|
+
return true;
|
|
12145
|
+
}
|
|
12146
|
+
return false;
|
|
12147
|
+
}
|
|
12148
|
+
|
|
12149
|
+
function kbConnRemove(sourceId) {
|
|
12150
|
+
const anchor = $wsKnowledge.querySelector(`[data-kb-conn-menu="${CSS.escape(sourceId)}"]`);
|
|
12151
|
+
const c = kbConnOf(knowledgeState, sourceId);
|
|
12152
|
+
if (anchor) kbShowRemoveConfirm(anchor, sourceId, (c && c.label) || `this ${kbConnThing(c)}`,
|
|
12153
|
+
'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.',
|
|
12154
|
+
`shell.kb-connected-remove-go#${sourceId}`);
|
|
12155
|
+
}
|
|
12156
|
+
|
|
12157
|
+
function kbConnChoose(sourceId, choice) {
|
|
12158
|
+
const stop = kbConnStops.get(sourceId) || { opts: {}, target: null };
|
|
12159
|
+
// Keep the copy answers a stop by leaving the copy as it is, until the person syncs again.
|
|
12160
|
+
if (choice === 'cancel' || choice === 'keep') { kbConnStops.delete(sourceId); kbConnRepaint(); return; }
|
|
12161
|
+
if (choice === 'pause') { void kbConnSetPaused(sourceId, true); return; }
|
|
12162
|
+
if (choice === 'remove') { kbConnRemove(sourceId); return; }
|
|
12163
|
+
if (choice === 'open-integrations') { if (typeof openIntegrations === 'function') openIntegrations(); return; }
|
|
12164
|
+
if (choice === 'open-tools') {
|
|
12165
|
+
if (typeof openLibrary === 'function') openLibrary(kbConnIsTrimble(kbConnOf(knowledgeState, sourceId)) ? 'trimble-connect' : 'microsoft-365', { tab: 'available' });
|
|
12166
|
+
return;
|
|
12167
|
+
}
|
|
12168
|
+
if (choice === 'reload') { kbConnStops.delete(sourceId); kbInvalidateRefs(); void renderKnowledge(); return; }
|
|
12169
|
+
if (choice === 'sync-with-current') { void kbConnSync(sourceId, { account: 'current-signin', ...(stop.target ? { expected: stop.target } : {}) }); return; }
|
|
12170
|
+
if (choice === 'confirm-target') { void kbConnSync(sourceId, { ...stop.opts, ...(stop.target ? { expected: stop.target } : {}) }); return; }
|
|
12171
|
+
if (choice === 'resume-and-sync') { void kbConnSync(sourceId, { ...stop.opts, resume: true }); return; }
|
|
12172
|
+
if (choice === 'sync-anyway') { void kbConnSync(sourceId, { ...stop.opts, overBudget: true }); return; }
|
|
12173
|
+
if (choice === 'rebuild') { void kbConnSync(sourceId, { ...stop.opts, rebuild: true }); return; }
|
|
12174
|
+
void kbConnSync(sourceId, stop.opts || {});
|
|
12175
|
+
}
|
|
12176
|
+
|
|
11032
12177
|
function kbColumn(st) {
|
|
11033
12178
|
// One collection: issued drawings, reference groups, then upload. Presentation never changes membership.
|
|
11034
12179
|
const loose = st.sources.filter((source) => !kbInDesignSet(source, st));
|
|
@@ -11040,10 +12185,11 @@
|
|
|
11040
12185
|
const newCat = kbCatUsable(st) && loose.length && !(kbCatEdit && kbCatEdit.mode === 'new' && !kbCatEdit.parentId)
|
|
11041
12186
|
? '<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
12187
|
const flatEdit = !tree && kbCatEdit && kbCatEdit.mode === 'new' ? kbCatEditHtml(0) : '';
|
|
11043
|
-
const
|
|
12188
|
+
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>';
|
|
12189
|
+
const body = '<div class="kb-reference-head"><h3>Reference files</h3><span class="kb-reference-actions">' + newCat + connect + '</span></div>' +
|
|
11044
12190
|
kbCatUnavailableHtml(st) + (loose.length
|
|
11045
12191
|
? (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);
|
|
12192
|
+
: '<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
12193
|
const selected = st.sources.filter((s) => s.useAsKb).length;
|
|
11048
12194
|
return '<section class="kb-col">' +
|
|
11049
12195
|
'<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 +13353,7 @@
|
|
|
12207
13353
|
}
|
|
12208
13354
|
// Anchored to the SCROLL container (.kb-refs-body, position:relative) — .kb-col is overflow:hidden
|
|
12209
13355
|
// and would clip the popover. Same anchoring as .ws-history's rollback confirm.
|
|
12210
|
-
function kbShowRemoveConfirm(btn, sourceId, name) {
|
|
13356
|
+
function kbShowRemoveConfirm(btn, sourceId, name, bodyText, goCommandId) {
|
|
12211
13357
|
kbCloseConfirm();
|
|
12212
13358
|
const box = btn.closest('.kb-refs-body');
|
|
12213
13359
|
if (!box) return;
|
|
@@ -12217,10 +13363,15 @@
|
|
|
12217
13363
|
// from it — only the next Organize rebuilds the wiki without it.
|
|
12218
13364
|
pop.innerHTML =
|
|
12219
13365
|
`<div class="hc-title">Remove “${escapeHtml(name)}”?</div>` +
|
|
12220
|
-
|
|
12221
|
-
'stay in the knowledge base until you Organize again.</div>' +
|
|
13366
|
+
`<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
13367
|
'<div class="hc-act"><button type="button" class="hc-cancel">Cancel</button>' +
|
|
12223
13368
|
`<button type="button" class="hc-go danger" data-kb-remove-go="${escapeAttr(sourceId)}">✕ Remove</button></div>`;
|
|
13369
|
+
// A caller that names its go button (the connected Remove) passes a literal id; set through the DOM, it needs no escaping.
|
|
13370
|
+
if (goCommandId) {
|
|
13371
|
+
const go = pop.querySelector('.hc-go');
|
|
13372
|
+
go.dataset.commandId = goCommandId;
|
|
13373
|
+
go.dataset.commandInstanceLabel = name;
|
|
13374
|
+
}
|
|
12224
13375
|
box.appendChild(pop);
|
|
12225
13376
|
const cr = box.getBoundingClientRect();
|
|
12226
13377
|
const br = btn.getBoundingClientRect();
|
|
@@ -12616,6 +13767,12 @@
|
|
|
12616
13767
|
// Which issues are open is the person's choice and survives repaints. `toggle` does not bubble, so this listens in capture.
|
|
12617
13768
|
$wsKnowledge.addEventListener('toggle', (e) => {
|
|
12618
13769
|
const d = e.target;
|
|
13770
|
+
// #2470 R6.8: a connected source's gap disclosure, likewise.
|
|
13771
|
+
if (d && d.dataset && d.dataset.kbConnGaps) {
|
|
13772
|
+
if (d.open) kbConnGapsOpen.add(d.dataset.kbConnGaps); else kbConnGapsOpen.delete(d.dataset.kbConnGaps);
|
|
13773
|
+
kbInvalidateRefs();
|
|
13774
|
+
return;
|
|
13775
|
+
}
|
|
12619
13776
|
if (!d || !d.classList || !d.classList.contains('kb-ds-issue')) return;
|
|
12620
13777
|
const issue = kbDsIssueById(d.dataset.kbDsIssueId);
|
|
12621
13778
|
if (!issue) return;
|
|
@@ -12635,6 +13792,7 @@
|
|
|
12635
13792
|
const rowAct = e.target.closest('[data-kb-row-act]');
|
|
12636
13793
|
if (rowAct) { kbRowAct(rowAct); return; }
|
|
12637
13794
|
if (kbCatClick(e)) return;
|
|
13795
|
+
if (kbConnClick(e)) return;
|
|
12638
13796
|
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
13797
|
if (kbDsClick(e)) return;
|
|
12640
13798
|
}
|
|
@@ -13175,7 +14333,7 @@
|
|
|
13175
14333
|
];
|
|
13176
14334
|
};
|
|
13177
14335
|
/** The units this project's bill is written in: the server's answer, else the client's own copy. */
|
|
13178
|
-
const bomUnits = () => exportUnits ?? (current
|
|
14336
|
+
const bomUnits = () => exportUnits ?? shownUnits(current);
|
|
13179
14337
|
const BOM_DESCRIPTIVE = ['profile', 'grade', 'type'];
|
|
13180
14338
|
const DEFAULT_BOM_FORMATS = ['csv', 'xlsx'];
|
|
13181
14339
|
const DEFAULT_BOM_COLUMNS = ['profile', 'qty', 'length', 'lbft', 'weight'];
|
|
@@ -13471,6 +14629,9 @@
|
|
|
13471
14629
|
details: [
|
|
13472
14630
|
...(Array.isArray(receipt.unsupported) ? receipt.unsupported.map((row) => receiptItemText('Unsupported', row)) : []),
|
|
13473
14631
|
...(Array.isArray(receipt.warnings) ? receipt.warnings.map((warning) => receiptItemText('Warning', warning)) : []),
|
|
14632
|
+
...(receipt.profileMapping && Array.isArray(receipt.profileMapping.mapped)
|
|
14633
|
+
? 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}.`)
|
|
14634
|
+
: []),
|
|
13474
14635
|
].join('\n'),
|
|
13475
14636
|
};
|
|
13476
14637
|
}
|
|
@@ -13739,6 +14900,8 @@
|
|
|
13739
14900
|
await api(`/api/projects/${encodeURIComponent(projectId)}/host-bake-consent?appId=${encodeURIComponent(appId)}`, {
|
|
13740
14901
|
method: 'DELETE',
|
|
13741
14902
|
headers: { 'content-type': 'application/json', 'x-floless-host-bake-consent': token },
|
|
14903
|
+
// #3273: a send's busy claim waits for this cleanup, so a request that never answers must not hold it.
|
|
14904
|
+
timeoutMs: SEND_CLEANUP_MS,
|
|
13742
14905
|
});
|
|
13743
14906
|
} catch (_) { /* best effort; consent and its source lease also expire server-side */ }
|
|
13744
14907
|
finally { activeProjectHostBakeConsents.delete(token); }
|
|
@@ -13751,6 +14914,7 @@
|
|
|
13751
14914
|
method: 'POST',
|
|
13752
14915
|
headers: { 'content-type': 'application/json', 'x-floless-host-bake-consent': token },
|
|
13753
14916
|
body: '{}',
|
|
14917
|
+
signal: AbortSignal.timeout(SEND_CLEANUP_MS),
|
|
13754
14918
|
});
|
|
13755
14919
|
} catch (_) { /* a lost acknowledgement deliberately leaves the replay tombstone in place */ }
|
|
13756
14920
|
finally { activeProjectHostBakeConsents.delete(token); }
|
|
@@ -13759,14 +14923,373 @@
|
|
|
13759
14923
|
async function releaseCapturedSources(projectId, handles) {
|
|
13760
14924
|
await Promise.allSettled(handles.map((handleId) => api(
|
|
13761
14925
|
`/api/projects/${encodeURIComponent(projectId)}/export-captures/${encodeURIComponent(handleId)}/release`,
|
|
13762
|
-
{ method: 'POST' },
|
|
14926
|
+
{ method: 'POST', timeoutMs: SEND_CLEANUP_MS },
|
|
13763
14927
|
)));
|
|
13764
14928
|
}
|
|
13765
14929
|
|
|
13766
|
-
|
|
14930
|
+
// ── #3312: profile mapping before a Tekla send ──────────────────────────────────────────────────────────
|
|
14931
|
+
// Before a Tekla send FloLess asks Tekla (or an imported Tekla catalogue) which of the model's profiles it has,
|
|
14932
|
+
// suggests a match for each missing one, and lets the person decide. The model and the bill of materials keep
|
|
14933
|
+
// their own names: the table applies only to what is sent. Whatever is left unmapped is still sent, as written,
|
|
14934
|
+
// and Tekla makes a profile-less line the person gives a profile to there.
|
|
14935
|
+
const $pmModal = document.getElementById('profilemap-modal');
|
|
14936
|
+
const PM_CHIP = {
|
|
14937
|
+
name: ['Same name', 'is-sure'],
|
|
14938
|
+
exact: ['Same section', 'is-sure'],
|
|
14939
|
+
close: ['Within 1 mm', 'is-check'],
|
|
14940
|
+
check: ['Check orientation', 'is-check'],
|
|
14941
|
+
none: ['No match', ''],
|
|
14942
|
+
};
|
|
14943
|
+
const PM_LINE_LABEL = 'Leave unmapped — sent as a line';
|
|
14944
|
+
const PM_POOL_SHOWN = 60;
|
|
14945
|
+
const pmFileAsDataUrl = (file) => new Promise((resolve, reject) => {
|
|
14946
|
+
const reader = new FileReader();
|
|
14947
|
+
reader.onload = () => resolve(String(reader.result));
|
|
14948
|
+
reader.onerror = () => reject(reader.error || new Error('unreadable'));
|
|
14949
|
+
reader.readAsDataURL(file);
|
|
14950
|
+
});
|
|
14951
|
+
|
|
14952
|
+
async function checkTeklaProfiles(projectId, app, catalogueId, sourceHandle) {
|
|
14953
|
+
try {
|
|
14954
|
+
return await api(`/api/contract/${encodeURIComponent(app)}/host-profiles?project=${encodeURIComponent(projectId)}${sourceHandle ? `&sourceHandle=${encodeURIComponent(sourceHandle)}` : ''}`, {
|
|
14955
|
+
method: 'POST',
|
|
14956
|
+
body: JSON.stringify({ host: 'tekla', ...(catalogueId ? { catalogueId } : {}) }),
|
|
14957
|
+
timeoutMs: 150000,
|
|
14958
|
+
});
|
|
14959
|
+
} catch (error) {
|
|
14960
|
+
return {
|
|
14961
|
+
ok: true, supported: false, host: 'tekla', imported: [], revision: 0,
|
|
14962
|
+
reason: personText(error && error.body)
|
|
14963
|
+
|| 'FloLess could not check Tekla’s profiles just now. You can import a Tekla catalogue to check against, or continue without checking.',
|
|
14964
|
+
};
|
|
14965
|
+
}
|
|
14966
|
+
}
|
|
14967
|
+
|
|
14968
|
+
/**
|
|
14969
|
+
* The mapping window. Resolves { action: 'apply', profileMap, modelPath, revision } | { action: 'skip' } | null (cancelled).
|
|
14970
|
+
* It re-checks in place when the person switches the catalogue it checks against or imports one.
|
|
14971
|
+
*/
|
|
14972
|
+
function openProfileMapWindow({ projectId, app, first, returnFocus, sourceHandle }) {
|
|
14973
|
+
return new Promise((resolve) => {
|
|
14974
|
+
if (!$pmModal) { resolve({ action: 'skip' }); return; }
|
|
14975
|
+
const $title = document.getElementById('profilemap-title');
|
|
14976
|
+
const $sub = document.getElementById('profilemap-sub');
|
|
14977
|
+
const $source = document.getElementById('profilemap-source');
|
|
14978
|
+
const $sources = document.getElementById('profilemap-sources');
|
|
14979
|
+
const $import = document.getElementById('profilemap-import');
|
|
14980
|
+
const $file = document.getElementById('profilemap-file');
|
|
14981
|
+
const $body = document.getElementById('profilemap-body');
|
|
14982
|
+
const $note = document.getElementById('profilemap-note');
|
|
14983
|
+
const $apply = document.getElementById('profilemap-apply');
|
|
14984
|
+
const $cancel = document.getElementById('profilemap-cancel');
|
|
14985
|
+
const dialog = $pmModal.querySelector('.profilemap');
|
|
14986
|
+
let check = first;
|
|
14987
|
+
let choices = new Map();
|
|
14988
|
+
let initial = new Map();
|
|
14989
|
+
let poolIndex = new Map();
|
|
14990
|
+
let openRow = null;
|
|
14991
|
+
let busy = false;
|
|
14992
|
+
let done = false;
|
|
14993
|
+
|
|
14994
|
+
const seed = () => {
|
|
14995
|
+
initial = new Map((check.rows || []).map((row) => [row.profile, row.choice]));
|
|
14996
|
+
choices = new Map(initial);
|
|
14997
|
+
poolIndex = new Map((check.pool || []).map((entry) => [entry[0], entry]));
|
|
14998
|
+
};
|
|
14999
|
+
const plural = (n, one, many) => `${n} ${n === 1 ? one : many}`;
|
|
15000
|
+
const labelOf = (name) => {
|
|
15001
|
+
if (name == null) return PM_LINE_LABEL;
|
|
15002
|
+
const entry = poolIndex.get(name);
|
|
15003
|
+
return entry && entry[2] ? `${name} · ${entry[2]} mm` : name;
|
|
15004
|
+
};
|
|
15005
|
+
const sourceName = () => (check.source === 'imported' && check.catalogue
|
|
15006
|
+
? `the imported catalogue “${check.catalogue.name}” (${plural(check.catalogue.count, 'profile', 'profiles')})`
|
|
15007
|
+
: check.modelPath ? `the open Tekla model (${check.modelPath})` : 'the open Tekla model');
|
|
15008
|
+
|
|
15009
|
+
const rowHtml = (row) => {
|
|
15010
|
+
const [chipText, chipClass] = PM_CHIP[row.suggestion.confidence] || PM_CHIP.none;
|
|
15011
|
+
const chosen = choices.get(row.profile);
|
|
15012
|
+
const instance = escapeAttr(row.profile);
|
|
15013
|
+
const stale = row.staleSaved ? ` Your saved choice “${escapeHtml(row.staleSaved)}” is not in this catalogue, so it was not applied.` : '';
|
|
15014
|
+
return `<div class="pm-row${chosen !== initial.get(row.profile) ? ' changed' : ''}" data-pm-row="${instance}">
|
|
15015
|
+
<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' ? ' · from your saved table' : ''}</span></div>
|
|
15016
|
+
<div class="pm-sugg"><span class="pm-chip ${chipClass}">${escapeHtml(chipText)}</span>
|
|
15017
|
+
<span class="pm-why">${row.suggestion.to ? `<strong>${escapeHtml(row.suggestion.to)}</strong> — ` : ''}${escapeHtml(row.suggestion.note)}${stale}</span></div>
|
|
15018
|
+
<div class="pm-pick wf-combo fm-select">
|
|
15019
|
+
<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))}">
|
|
15020
|
+
<span class="wf-trigger-label">${escapeHtml(labelOf(chosen))}</span>
|
|
15021
|
+
<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>
|
|
15022
|
+
</button>
|
|
15023
|
+
${openRow === row.profile ? popoverHtml(row, '') : ''}
|
|
15024
|
+
</div>
|
|
15025
|
+
<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>
|
|
15026
|
+
</div>`;
|
|
15027
|
+
};
|
|
15028
|
+
|
|
15029
|
+
const optionsFor = (row, query) => {
|
|
15030
|
+
const q = query.trim().toLowerCase();
|
|
15031
|
+
const picked = new Set();
|
|
15032
|
+
const out = [{ value: '', label: PM_LINE_LABEL, meta: 'Tekla makes a line you give a profile to', line: true }];
|
|
15033
|
+
const add = (name, meta) => {
|
|
15034
|
+
if (picked.has(name)) return;
|
|
15035
|
+
picked.add(name);
|
|
15036
|
+
const entry = poolIndex.get(name);
|
|
15037
|
+
out.push({ value: name, label: name, meta: meta || (entry && entry[2] ? `${entry[2]} mm` : '') });
|
|
15038
|
+
};
|
|
15039
|
+
if (!q) {
|
|
15040
|
+
if (row.suggestion.to) add(row.suggestion.to, `suggested · ${(PM_CHIP[row.suggestion.confidence] || PM_CHIP.none)[0].toLowerCase()}`);
|
|
15041
|
+
(row.suggestion.alternatives || []).forEach((name) => add(name));
|
|
15042
|
+
}
|
|
15043
|
+
let shown = 0;
|
|
15044
|
+
for (const entry of check.pool || []) {
|
|
15045
|
+
if (shown >= PM_POOL_SHOWN) break;
|
|
15046
|
+
if (q && !(entry[0].toLowerCase().includes(q) || String(entry[2] || '').includes(q))) continue;
|
|
15047
|
+
if (!q && picked.has(entry[0])) continue;
|
|
15048
|
+
add(entry[0]);
|
|
15049
|
+
shown += 1;
|
|
15050
|
+
}
|
|
15051
|
+
return out;
|
|
15052
|
+
};
|
|
15053
|
+
|
|
15054
|
+
const popoverHtml = (row, query) => {
|
|
15055
|
+
const chosen = choices.get(row.profile);
|
|
15056
|
+
const options = optionsFor(row, query);
|
|
15057
|
+
const listId = `pm-list-${escapeAttr(row.profile).replace(/[^A-Za-z0-9_-]/g, '_')}`;
|
|
15058
|
+
return `<div class="wf-popover pm-popover" role="presentation">
|
|
15059
|
+
<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>
|
|
15060
|
+
<div class="wf-list pm-list" id="${listId}" role="listbox" aria-label="Tekla profiles for ${escapeAttr(row.profile)}">${options.map((o) => {
|
|
15061
|
+
const on = o.line ? chosen == null : chosen === o.value;
|
|
15062
|
+
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>`;
|
|
15063
|
+
}).join('')}${options.length === 1 && query ? '<div class="wf-empty-search">No profile in Tekla matches that.</div>' : ''}</div>
|
|
15064
|
+
</div>`;
|
|
15065
|
+
};
|
|
15066
|
+
|
|
15067
|
+
const render = () => {
|
|
15068
|
+
const rows = check.rows || [];
|
|
15069
|
+
$title.textContent = check.supported === false ? 'Check the profiles before sending'
|
|
15070
|
+
: rows.length ? 'Profiles Tekla does not have' : 'Every profile is in Tekla';
|
|
15071
|
+
$sources.hidden = true;
|
|
15072
|
+
if (check.supported === false) {
|
|
15073
|
+
$sub.textContent = check.reason || '';
|
|
15074
|
+
$source.textContent = '';
|
|
15075
|
+
$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>';
|
|
15076
|
+
$note.textContent = '';
|
|
15077
|
+
$apply.textContent = 'Continue without checking';
|
|
15078
|
+
} else {
|
|
15079
|
+
$sub.textContent = rows.length
|
|
15080
|
+
? `${rows.length} of the ${plural(check.counts.profiles, 'profile', 'profiles')} in this model (${plural(rows.reduce((sum, row) => sum + row.memberCount, 0), 'member', 'members')}) ${rows.length === 1 ? 'is' : 'are'} not in Tekla. 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.`
|
|
15081
|
+
: `All ${plural(check.counts.profiles, 'profile', 'profiles')} in this model are in ${sourceName()}. Nothing needs mapping.`;
|
|
15082
|
+
$source.textContent = `Checked against ${sourceName()}.`;
|
|
15083
|
+
$body.innerHTML = rows.length
|
|
15084
|
+
? `<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('')}`
|
|
15085
|
+
: '<div class="pm-empty">Nothing to map for this catalogue.</div>';
|
|
15086
|
+
$note.textContent = 'Sending replaces the parts FloLess sent to this Tekla model before, including any you gave a profile to by hand. Your choices are kept with the project for the next send.';
|
|
15087
|
+
$apply.textContent = rows.length ? 'Apply and continue' : 'Continue';
|
|
15088
|
+
}
|
|
15089
|
+
const imported = check.imported || [];
|
|
15090
|
+
$sources.hidden = imported.length === 0;
|
|
15091
|
+
// Built with DOM APIs, never markup: a saved catalogue is data from disk, and nothing in it may become HTML.
|
|
15092
|
+
const sourceButton = (id, label, pressed) => {
|
|
15093
|
+
const b = document.createElement('button');
|
|
15094
|
+
b.type = 'button';
|
|
15095
|
+
b.dataset.pmSource = id;
|
|
15096
|
+
b.setAttribute('aria-pressed', pressed ? 'true' : 'false');
|
|
15097
|
+
b.dataset.commandId = 'shell.profile-map-source';
|
|
15098
|
+
b.dataset.commandInstance = label;
|
|
15099
|
+
b.dataset.commandInstanceLabel = label;
|
|
15100
|
+
b.textContent = label;
|
|
15101
|
+
return b;
|
|
15102
|
+
};
|
|
15103
|
+
const sourceButtons = [];
|
|
15104
|
+
if (imported.length) {
|
|
15105
|
+
const open = sourceButton('', 'Open Tekla model', check.source !== 'imported');
|
|
15106
|
+
sourceButtons.push(open);
|
|
15107
|
+
for (const c of imported) {
|
|
15108
|
+
const count = Number.isInteger(c.count) && c.count >= 0 ? c.count : 0;
|
|
15109
|
+
const b = sourceButton(String(c.id), `${c.name} · ${count}`, check.source === 'imported' && !!check.catalogue && check.catalogue.id === c.id);
|
|
15110
|
+
b.dataset.commandInstance = String(c.name);
|
|
15111
|
+
b.dataset.commandInstanceLabel = String(c.name);
|
|
15112
|
+
sourceButtons.push(b);
|
|
15113
|
+
}
|
|
15114
|
+
}
|
|
15115
|
+
$sources.replaceChildren(...sourceButtons);
|
|
15116
|
+
$apply.disabled = busy;
|
|
15117
|
+
$import.disabled = busy;
|
|
15118
|
+
$import.toggleAttribute('aria-busy', busy);
|
|
15119
|
+
};
|
|
15120
|
+
|
|
15121
|
+
const recheck = async (catalogueId, keepNote) => {
|
|
15122
|
+
busy = true; render();
|
|
15123
|
+
if (!keepNote) $note.textContent = '';
|
|
15124
|
+
const next = await checkTeklaProfiles(projectId, app, catalogueId, sourceHandle);
|
|
15125
|
+
busy = false;
|
|
15126
|
+
// A check that failed in transit says nothing about which catalogues the project holds: keep the switcher.
|
|
15127
|
+
if (!next.supported && !(next.imported || []).length) next.imported = check.imported || [];
|
|
15128
|
+
check = next; openRow = null; seed(); render();
|
|
15129
|
+
return next;
|
|
15130
|
+
};
|
|
15131
|
+
|
|
15132
|
+
const close = (value) => {
|
|
15133
|
+
if (done) return;
|
|
15134
|
+
done = true;
|
|
15135
|
+
$pmModal.classList.remove('show');
|
|
15136
|
+
$pmModal.removeEventListener('click', onClick);
|
|
15137
|
+
$pmModal.removeEventListener('input', onInput);
|
|
15138
|
+
$pmModal.removeEventListener('keydown', onKey);
|
|
15139
|
+
$pmModal.removeEventListener('mousedown', onBackdrop);
|
|
15140
|
+
$file.removeEventListener('change', onFile);
|
|
15141
|
+
const back = typeof returnFocus === 'function' ? returnFocus() : returnFocus;
|
|
15142
|
+
if (back && back.isConnected) back.focus();
|
|
15143
|
+
resolve(value);
|
|
15144
|
+
};
|
|
15145
|
+
|
|
15146
|
+
const choose = (profile, value) => {
|
|
15147
|
+
choices.set(profile, value === '' ? null : value);
|
|
15148
|
+
openRow = null;
|
|
15149
|
+
render();
|
|
15150
|
+
const trigger = $body.querySelector(`[data-pm-row="${CSS.escape(profile)}"] .pm-trigger`);
|
|
15151
|
+
if (trigger) trigger.focus();
|
|
15152
|
+
};
|
|
15153
|
+
|
|
15154
|
+
function onClick(event) {
|
|
15155
|
+
const target = event.target instanceof Element ? event.target : null;
|
|
15156
|
+
if (!target) return;
|
|
15157
|
+
if (target.closest('#profilemap-apply')) {
|
|
15158
|
+
if (busy) return;
|
|
15159
|
+
if (check.supported === false) { close({ action: 'skip' }); return; }
|
|
15160
|
+
close({ action: 'apply', profileMap: Object.fromEntries(choices), modelPath: check.modelPath || null, revision: check.revision || 0 });
|
|
15161
|
+
return;
|
|
15162
|
+
}
|
|
15163
|
+
if (target.closest('#profilemap-cancel')) { close(null); return; }
|
|
15164
|
+
if (target.closest('#profilemap-import')) { if (!busy) $file.click(); return; }
|
|
15165
|
+
const source = target.closest('[data-pm-source]');
|
|
15166
|
+
if (source) { if (!busy) void recheck(source.dataset.pmSource || undefined); return; }
|
|
15167
|
+
const option = target.closest('[data-pm-value]');
|
|
15168
|
+
const row = target.closest('[data-pm-row]');
|
|
15169
|
+
if (option && row) { choose(row.dataset.pmRow, option.dataset.pmValue); return; }
|
|
15170
|
+
const trigger = target.closest('.pm-trigger');
|
|
15171
|
+
if (trigger && row) {
|
|
15172
|
+
openRow = openRow === row.dataset.pmRow ? null : row.dataset.pmRow;
|
|
15173
|
+
render();
|
|
15174
|
+
const search = $body.querySelector('.pm-search');
|
|
15175
|
+
if (search) search.focus();
|
|
15176
|
+
}
|
|
15177
|
+
}
|
|
15178
|
+
function onInput(event) {
|
|
15179
|
+
const search = event.target instanceof Element ? event.target.closest('.pm-search') : null;
|
|
15180
|
+
if (!search || !openRow) return;
|
|
15181
|
+
const row = (check.rows || []).find((candidate) => candidate.profile === openRow);
|
|
15182
|
+
const list = search.closest('.pm-popover')?.querySelector('.pm-list');
|
|
15183
|
+
if (!row || !list) return;
|
|
15184
|
+
const holder = document.createElement('div');
|
|
15185
|
+
holder.innerHTML = popoverHtml(row, search.value);
|
|
15186
|
+
list.innerHTML = holder.querySelector('.pm-list').innerHTML;
|
|
15187
|
+
}
|
|
15188
|
+
function onKey(event) {
|
|
15189
|
+
if (event.key === 'Escape') {
|
|
15190
|
+
event.preventDefault();
|
|
15191
|
+
event.stopPropagation();
|
|
15192
|
+
if (openRow) { const profile = openRow; openRow = null; render(); const t = $body.querySelector(`[data-pm-row="${CSS.escape(profile)}"] .pm-trigger`); if (t) t.focus(); }
|
|
15193
|
+
else if (!busy) close(null);
|
|
15194
|
+
return;
|
|
15195
|
+
}
|
|
15196
|
+
const target = event.target instanceof Element ? event.target : null;
|
|
15197
|
+
if (target && openRow && (event.key === 'ArrowDown' || event.key === 'ArrowUp')) {
|
|
15198
|
+
const options = Array.from($body.querySelectorAll('.pm-popover [role="option"]'));
|
|
15199
|
+
const at = options.indexOf(document.activeElement);
|
|
15200
|
+
const next = event.key === 'ArrowDown' ? options[Math.min(options.length - 1, at + 1)] : (at <= 0 ? $body.querySelector('.pm-search') : options[at - 1]);
|
|
15201
|
+
if (next) { event.preventDefault(); next.focus(); }
|
|
15202
|
+
return;
|
|
15203
|
+
}
|
|
15204
|
+
if (target && (event.key === 'Enter' || event.key === ' ') && target.matches('[role="option"]')) {
|
|
15205
|
+
event.preventDefault();
|
|
15206
|
+
const row = target.closest('[data-pm-row]');
|
|
15207
|
+
if (row) choose(row.dataset.pmRow, target.dataset.pmValue);
|
|
15208
|
+
return;
|
|
15209
|
+
}
|
|
15210
|
+
if (event.key !== 'Tab') return;
|
|
15211
|
+
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');
|
|
15212
|
+
if (!focusable.length) return;
|
|
15213
|
+
const firstNode = focusable[0], lastNode = focusable[focusable.length - 1];
|
|
15214
|
+
if (event.shiftKey && document.activeElement === firstNode) { event.preventDefault(); lastNode.focus(); }
|
|
15215
|
+
else if (!event.shiftKey && document.activeElement === lastNode) { event.preventDefault(); firstNode.focus(); }
|
|
15216
|
+
}
|
|
15217
|
+
function onBackdrop(event) { if (event.target === $pmModal && !busy) close(null); }
|
|
15218
|
+
async function onFile() {
|
|
15219
|
+
const file = ($file.files || [])[0];
|
|
15220
|
+
$file.value = '';
|
|
15221
|
+
if (!file || busy) return;
|
|
15222
|
+
busy = true; render();
|
|
15223
|
+
try {
|
|
15224
|
+
const dataUrl = await pmFileAsDataUrl(file);
|
|
15225
|
+
const saved = await api(`/api/projects/${encodeURIComponent(projectId)}/host-profile-catalogues?appId=${encodeURIComponent(app)}`, {
|
|
15226
|
+
method: 'POST', body: JSON.stringify({ name: file.name, dataUrl }), timeoutMs: 120000,
|
|
15227
|
+
});
|
|
15228
|
+
busy = false;
|
|
15229
|
+
const next = await recheck(saved.catalogue && saved.catalogue.id, true);
|
|
15230
|
+
$note.textContent = next && next.supported && next.source === 'imported'
|
|
15231
|
+
? `Imported ${file.name}. The profiles are now checked against it.`
|
|
15232
|
+
: `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.'}`;
|
|
15233
|
+
} catch (error) {
|
|
15234
|
+
busy = false; render();
|
|
15235
|
+
$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.';
|
|
15236
|
+
}
|
|
15237
|
+
}
|
|
15238
|
+
|
|
15239
|
+
seed();
|
|
15240
|
+
render();
|
|
15241
|
+
$pmModal.addEventListener('click', onClick);
|
|
15242
|
+
$pmModal.addEventListener('input', onInput);
|
|
15243
|
+
$pmModal.addEventListener('keydown', onKey);
|
|
15244
|
+
$pmModal.addEventListener('mousedown', onBackdrop);
|
|
15245
|
+
$file.addEventListener('change', onFile);
|
|
15246
|
+
$pmModal.classList.add('show');
|
|
15247
|
+
dialog.focus();
|
|
15248
|
+
});
|
|
15249
|
+
}
|
|
15250
|
+
|
|
15251
|
+
/**
|
|
15252
|
+
* The send's profile review. Resolves null when the person cancels; {} when the profiles were not checked
|
|
15253
|
+
* (the send then goes as before); else the fields the preflight and the send carry.
|
|
15254
|
+
*/
|
|
15255
|
+
async function reviewTeklaProfiles(projectId, app, sourceHandle, returnFocus) {
|
|
15256
|
+
showToast('Checking which profiles Tekla has…', 'info');
|
|
15257
|
+
const first = await checkTeklaProfiles(projectId, app, undefined, sourceHandle);
|
|
15258
|
+
if (first.supported && (first.rows || []).length === 0) {
|
|
15259
|
+
return { profileMap: {}, ...(first.modelPath ? { modelPath: first.modelPath } : {}), profileMapRevision: first.revision || 0 };
|
|
15260
|
+
}
|
|
15261
|
+
const answer = await openProfileMapWindow({ projectId, app, first, returnFocus, sourceHandle });
|
|
15262
|
+
if (!answer) return null;
|
|
15263
|
+
if (answer.action === 'skip') return {};
|
|
15264
|
+
let revision = answer.revision;
|
|
15265
|
+
try {
|
|
15266
|
+
const saved = await api(`/api/projects/${encodeURIComponent(projectId)}/host-profile-map?appId=${encodeURIComponent(app)}`, {
|
|
15267
|
+
method: 'PUT', body: JSON.stringify({ host: 'tekla', entries: answer.profileMap, baseRevision: answer.revision }),
|
|
15268
|
+
});
|
|
15269
|
+
revision = saved.revision;
|
|
15270
|
+
} catch (error) {
|
|
15271
|
+
// Keeping the table is a courtesy and never blocks the send, but the person is told it was not kept.
|
|
15272
|
+
console.warn('[workspaces] could not save the profile table', error);
|
|
15273
|
+
showToast('Your profile choices apply to this send, but FloLess could not remember them for next time.', 'warn');
|
|
15274
|
+
}
|
|
15275
|
+
return { profileMap: answer.profileMap, ...(answer.modelPath ? { modelPath: answer.modelPath } : {}), profileMapRevision: revision };
|
|
15276
|
+
}
|
|
15277
|
+
|
|
15278
|
+
/** What the table did, in a sentence for the send's summary. */
|
|
15279
|
+
function profileMappingText(mapping, counts) {
|
|
15280
|
+
if (!mapping || !mapping.reviewed) return '';
|
|
15281
|
+
const parts = [];
|
|
15282
|
+
const mapped = Array.isArray(mapping.mapped) ? mapping.mapped : [];
|
|
15283
|
+
if (mapped.length) parts.push(`${mapped.length} profile${mapped.length === 1 ? '' : 's'} renamed for Tekla`);
|
|
15284
|
+
const lines = Number(mapping.lines) || 0;
|
|
15285
|
+
if (lines) parts.push(`${lines} member${lines === 1 ? '' : 's'} arrived as profile-less lines — select them in Tekla and give them a profile`);
|
|
15286
|
+
return parts.join(', ');
|
|
15287
|
+
}
|
|
15288
|
+
|
|
15289
|
+
async function preflightHostSends(hosts, projectId, appId, sourceHandles, hostBodies = {}) {
|
|
13767
15290
|
const results = await Promise.allSettled(hosts.map((host, index) => api(
|
|
13768
15291
|
hostSendUrl(host, projectId, appId, sourceHandles[index]),
|
|
13769
|
-
{ method: 'POST', body: JSON.stringify({ preflight: true }) },
|
|
15292
|
+
{ method: 'POST', body: JSON.stringify({ preflight: true, ...(hostBodies[host] || {}) }) },
|
|
13770
15293
|
)));
|
|
13771
15294
|
const reviews = results.filter((result) => result.status === 'fulfilled').map((result) => result.value);
|
|
13772
15295
|
reviews.forEach((review) => activeProjectHostBakeConsents.set(review.consent, { projectId, appId }));
|
|
@@ -13881,13 +15404,14 @@
|
|
|
13881
15404
|
* be minutes old by the time a third host's turn comes round, and an application closed since
|
|
13882
15405
|
* then must be reported rather than sent into.
|
|
13883
15406
|
*/
|
|
13884
|
-
async function sendToHosts(hosts, projectId, app, approvedAt, sourceHandles, sourceKind, reviews) {
|
|
15407
|
+
async function sendToHosts(hosts, projectId, app, approvedAt, sourceHandles, sourceKind, reviews, hostBodies = {}) {
|
|
13885
15408
|
const done = [];
|
|
13886
15409
|
const failed = [];
|
|
13887
15410
|
const uncertain = [];
|
|
13888
15411
|
const aborted = [];
|
|
13889
15412
|
let uncertainHost = null;
|
|
13890
15413
|
let staleReview = false;
|
|
15414
|
+
let modelChanged = false;
|
|
13891
15415
|
/** Has the sign-off this batch was aimed at moved on? Only answerable while it is still open. */
|
|
13892
15416
|
const approvalMoved = () => !!current && current.id === projectId && current.approvedAt !== approvedAt;
|
|
13893
15417
|
try {
|
|
@@ -13914,7 +15438,7 @@
|
|
|
13914
15438
|
const res = await api(hostSendUrl(host, projectId, app, sourceHandles[i]), {
|
|
13915
15439
|
method: 'POST',
|
|
13916
15440
|
headers: { 'content-type': 'application/json', 'x-floless-host-bake-consent': reviews[i].consent },
|
|
13917
|
-
body: JSON.stringify({}),
|
|
15441
|
+
body: JSON.stringify(hostBodies[host] || {}),
|
|
13918
15442
|
});
|
|
13919
15443
|
await acknowledgeProjectHostBakeConsent(projectId, app, reviews[i].consent);
|
|
13920
15444
|
track('workspace_export', { app, kind: `send:${host}`, sourceKind });
|
|
@@ -13924,22 +15448,26 @@
|
|
|
13924
15448
|
counts: res.counts,
|
|
13925
15449
|
warnings: res.warnings || [],
|
|
13926
15450
|
unsupported: res.receipt && Array.isArray(res.receipt.unsupported) ? res.receipt.unsupported : [],
|
|
15451
|
+
profileMapping: res.profileMapping || null,
|
|
13927
15452
|
approvedAt,
|
|
13928
15453
|
});
|
|
13929
15454
|
summary = receiptSummary(exportReceipts.get(`${projectId}:send:${host}`), `send:${host}`);
|
|
13930
15455
|
}
|
|
13931
15456
|
hostSends.set(`${projectId}:${host}`, { at: new Date().toISOString(), approvedAt });
|
|
13932
15457
|
const omissionText = hostBakeOmissionSummary(res);
|
|
15458
|
+
const mappingText = profileMappingText(res.profileMapping);
|
|
13933
15459
|
done.push({
|
|
13934
15460
|
host,
|
|
13935
|
-
partial: !!omissionText || !!(summary && summary.partial),
|
|
13936
|
-
text: omissionText || (summary && summary.text),
|
|
15461
|
+
partial: !!omissionText || !!mappingText || !!(summary && summary.partial),
|
|
15462
|
+
text: [omissionText || (summary && summary.text), mappingText].filter(Boolean).join(' · '),
|
|
13937
15463
|
});
|
|
13938
15464
|
} catch (err) {
|
|
13939
15465
|
if (err && err.body && ['host-bake-dispatch-uncertain', 'host-bake-result-unverified'].includes(err.body.code)) {
|
|
13940
15466
|
const detail = err.body.error || (err && err.message) || String(err);
|
|
13941
15467
|
uncertain.push({ host, error: detail });
|
|
13942
15468
|
uncertainHost = host;
|
|
15469
|
+
// #3273: the card says so too, long after the toast is gone, and offers "Send again".
|
|
15470
|
+
hostSends.set(`${projectId}:${host}`, { at: new Date().toISOString(), approvedAt, unconfirmed: true });
|
|
13943
15471
|
aborted.push(...hosts.slice(i + 1));
|
|
13944
15472
|
break;
|
|
13945
15473
|
}
|
|
@@ -13947,16 +15475,20 @@
|
|
|
13947
15475
|
|| (err && err.body && err.body.code === 'response-unreadable')) {
|
|
13948
15476
|
uncertain.push({ host, error: `FloLess lost the ${hostLabel(host)} response after dispatch. Check the open model before sending again.` });
|
|
13949
15477
|
uncertainHost = host;
|
|
15478
|
+
hostSends.set(`${projectId}:${host}`, { at: new Date().toISOString(), approvedAt, unconfirmed: true });
|
|
13950
15479
|
aborted.push(...hosts.slice(i + 1));
|
|
13951
15480
|
break;
|
|
13952
15481
|
}
|
|
13953
|
-
if (err && err.body && ['host-bake-confirmation-stale', 'host-bake-preflight-required', 'stale-selection'].includes(err.body.code)) {
|
|
15482
|
+
if (err && err.body && ['host-bake-confirmation-stale', 'host-bake-preflight-required', 'stale-selection', 'host-profile-model-changed'].includes(err.body.code)) {
|
|
13954
15483
|
staleReview = true;
|
|
15484
|
+
// A different Tekla model is open now: the table must be checked against it, so the window opens again.
|
|
15485
|
+
if (err.body.code === 'host-profile-model-changed') modelChanged = true;
|
|
13955
15486
|
aborted.push(...hosts.slice(i));
|
|
13956
15487
|
break;
|
|
13957
15488
|
}
|
|
13958
15489
|
const detail = personText(err && err.body) || (err && err.message) || String(err);
|
|
13959
|
-
|
|
15490
|
+
// A refusal Tekla made and undid is a definite answer (#3312): say what it was and that nothing changed.
|
|
15491
|
+
failed.push({ host, error: detail, rejected: !!(err && err.body && err.body.code === 'host-bake-rejected') });
|
|
13960
15492
|
}
|
|
13961
15493
|
}
|
|
13962
15494
|
} finally {
|
|
@@ -13980,7 +15512,9 @@
|
|
|
13980
15512
|
clean.length ? `Sent to ${sequenceText(clean.map((d) => d.host))}.` : '',
|
|
13981
15513
|
...partial.map((d) => `${hostLabel(d.host)} took it with gaps — ${d.text}.`),
|
|
13982
15514
|
...uncertain.map((row) => row.error),
|
|
13983
|
-
...failed.map((f) =>
|
|
15515
|
+
...failed.map((f) => (f.rejected
|
|
15516
|
+
? `${f.error} Choose Send again to review the profiles.`
|
|
15517
|
+
: `${hostLabel(f.host)} didn’t — ${reasonFragment(humanSendError(f.error))}.`)),
|
|
13984
15518
|
// The abort rides in the SAME sentence rather than firing its own toast: two toasts about
|
|
13985
15519
|
// one action is exactly the storm this single-line report replaced.
|
|
13986
15520
|
aborted.length
|
|
@@ -13993,13 +15527,9 @@
|
|
|
13993
15527
|
].filter(Boolean).join(' ');
|
|
13994
15528
|
showToast(sentence, partial.length || failed.length || uncertain.length || aborted.length ? 'warn' : 'ok');
|
|
13995
15529
|
}
|
|
13996
|
-
|
|
13997
|
-
|
|
13998
|
-
|
|
13999
|
-
await safeRenderExports('after that send finished', 'send-host',
|
|
14000
|
-
() => paintExports(approvedAt, 'send-host'));
|
|
14001
|
-
}
|
|
14002
|
-
return { staleReview, remainingHosts: staleReview ? [...aborted] : [] };
|
|
15530
|
+
// No repaint here (#3273): chooseAndSend refreshes the pane once it has released the send's busy claim, so a
|
|
15531
|
+
// refresh that is slow or never answers cannot keep the card on "Sending…".
|
|
15532
|
+
return { staleReview, modelChanged, remainingHosts: staleReview ? [...aborted] : [] };
|
|
14003
15533
|
}
|
|
14004
15534
|
|
|
14005
15535
|
/** The Send card's whole action: ask, then send. */
|
|
@@ -14014,6 +15544,7 @@
|
|
|
14014
15544
|
const busyKey = `${projectId}:send-host`;
|
|
14015
15545
|
if (exportBusy.has(busyKey)) { showToast(sendBusyText(), 'info'); return; }
|
|
14016
15546
|
exportBusy.add(busyKey);
|
|
15547
|
+
let sent = false; // a send reached the destinations, so the pane re-reads the listing once the claim is released
|
|
14017
15548
|
try {
|
|
14018
15549
|
const picked = await askSendDestinations(projectId);
|
|
14019
15550
|
if (current && current.id === projectId && !$wsExports.hidden) paintExports(current.approvedAt);
|
|
@@ -14023,6 +15554,8 @@
|
|
|
14023
15554
|
if (!sourceOption) { showToast('Choose an export source first.', 'warn'); return; }
|
|
14024
15555
|
const sourceSelector = JSON.parse(JSON.stringify(sourceOption.selector));
|
|
14025
15556
|
let remainingHosts = [...picked];
|
|
15557
|
+
let hostBodies = {};
|
|
15558
|
+
let teklaReviewed = false; // the mapping window is shown once per send, not again on a stale-review retry
|
|
14026
15559
|
// The user may have switched projects while the dialog was open — the send must not land on
|
|
14027
15560
|
// whatever is open NOW. Everything below is keyed to the captured project. One stale
|
|
14028
15561
|
// continuation is rebuilt and re-reviewed; a second fails closed instead of looping forever.
|
|
@@ -14034,7 +15567,24 @@
|
|
|
14034
15567
|
let reviews;
|
|
14035
15568
|
try {
|
|
14036
15569
|
showToast(attempt ? 'Checking the latest approved model…' : 'Checking what will be sent…', 'info');
|
|
14037
|
-
|
|
15570
|
+
// Tekla only (#3312): ask which profiles it has and let the person decide what the missing ones become.
|
|
15571
|
+
if (remainingHosts.includes('tekla') && !teklaReviewed) {
|
|
15572
|
+
const reviewed = await reviewTeklaProfiles(projectId, app, handles[remainingHosts.indexOf('tekla')], () => $wsExports.querySelector('[data-export="send-host"]'));
|
|
15573
|
+
if (reviewed === null) {
|
|
15574
|
+
await releaseCapturedSources(projectId, handles);
|
|
15575
|
+
exportBusy.delete(busyKey);
|
|
15576
|
+
if (current && current.id === projectId && !$wsExports.hidden) {
|
|
15577
|
+
paintExports(current.approvedAt, 'send-host');
|
|
15578
|
+
const sendCard = $wsExports.querySelector('[data-export="send-host"]');
|
|
15579
|
+
if (sendCard instanceof HTMLElement && !sendCard.matches(':disabled,[aria-disabled="true"]')) sendCard.focus();
|
|
15580
|
+
}
|
|
15581
|
+
showToast('CAD send cancelled.', 'info');
|
|
15582
|
+
return;
|
|
15583
|
+
}
|
|
15584
|
+
teklaReviewed = true;
|
|
15585
|
+
if (reviewed.profileMap) hostBodies.tekla = reviewed;
|
|
15586
|
+
}
|
|
15587
|
+
reviews = await preflightHostSends(remainingHosts, projectId, app, handles, hostBodies);
|
|
14038
15588
|
const confirmed = await confirmAggregateHostSend(remainingHosts, reviews[0], attempt > 0 && reviews[0].kind === 'clean');
|
|
14039
15589
|
if (!confirmed) {
|
|
14040
15590
|
await Promise.allSettled(reviews.map((review) => cancelProjectHostBakeConsent(projectId, app, review.consent)));
|
|
@@ -14073,15 +15623,29 @@
|
|
|
14073
15623
|
const attemptApprovedAt = attempt > 0 && current && current.id === projectId
|
|
14074
15624
|
? current.approvedAt
|
|
14075
15625
|
: approvedAt;
|
|
14076
|
-
const result = await sendToHosts(remainingHosts, projectId, app, attemptApprovedAt, handles, sources[0].kind, reviews);
|
|
15626
|
+
const result = await sendToHosts(remainingHosts, projectId, app, attemptApprovedAt, handles, sources[0].kind, reviews, hostBodies);
|
|
15627
|
+
sent = true;
|
|
14077
15628
|
if (attempt === 0 && result && result.staleReview && result.remainingHosts.length) {
|
|
14078
15629
|
remainingHosts = result.remainingHosts;
|
|
15630
|
+
if (result.modelChanged) { teklaReviewed = false; delete hostBodies.tekla; }
|
|
15631
|
+
// The retry anchors to the approval this refresh reads, so it waits for it (every refresh is bounded).
|
|
15632
|
+
if (current && current.id === projectId && !$wsExports.hidden) {
|
|
15633
|
+
await safeRenderExports('after that send finished', 'send-host', () => paintExports(approvedAt, 'send-host'));
|
|
15634
|
+
}
|
|
14079
15635
|
continue;
|
|
14080
15636
|
}
|
|
14081
15637
|
return;
|
|
14082
15638
|
}
|
|
14083
15639
|
} finally {
|
|
14084
15640
|
exportBusy.delete(busyKey);
|
|
15641
|
+
// #3273: the card leaves its busy state the moment the claim is released, whatever the outcome. It used to repaint
|
|
15642
|
+
// only while the claim was still held, so an exit that did not repaint again (or a refresh that never finished)
|
|
15643
|
+
// left "Sending…" up for good. After a send the pane then re-reads the listing, so it reflects the project as it
|
|
15644
|
+
// is now; that refresh runs with the claim already released, so it cannot hold the card either.
|
|
15645
|
+
if (current && current.id === projectId && !$wsExports.hidden) {
|
|
15646
|
+
paintExports(current.approvedAt, sent ? 'send-host' : undefined);
|
|
15647
|
+
if (sent) await safeRenderExports('after that send finished', 'send-host', () => paintExports(approvedAt, 'send-host'));
|
|
15648
|
+
}
|
|
14085
15649
|
}
|
|
14086
15650
|
}
|
|
14087
15651
|
|
|
@@ -14385,6 +15949,16 @@
|
|
|
14385
15949
|
const rows = sent.length
|
|
14386
15950
|
? `<div class="e-renders e-sent-list" role="group" aria-label="Sent to">` +
|
|
14387
15951
|
sent.map((r) => {
|
|
15952
|
+
// #3273: a send FloLess could not confirm is never a ✓. The row keeps "sent" (it may well have landed), names
|
|
15953
|
+
// why it is unconfirmed, and carries no receipt: whatever receipt is held is from an earlier send.
|
|
15954
|
+
if (r.rec.unconfirmed) {
|
|
15955
|
+
return `<div class="e-render-entry">` +
|
|
15956
|
+
`<div class="e-render-row">` +
|
|
15957
|
+
`<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>` +
|
|
15958
|
+
`</div>` +
|
|
15959
|
+
`<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>` +
|
|
15960
|
+
`</div>`;
|
|
15961
|
+
}
|
|
14388
15962
|
// Asked of the receipt HERE rather than remembered as a flag at send time. The two
|
|
14389
15963
|
// drifted: a clean send stored "has details" and then opened an empty dialog, because
|
|
14390
15964
|
// what the button offers and what the dialog can show must be the same question.
|
|
@@ -15085,12 +16659,13 @@
|
|
|
15085
16659
|
console.error('[workspaces] exports refresh threw ' + (reason || '(no reason given)'), err);
|
|
15086
16660
|
// `err`, NOT `warn`, and the reason is in `showToast`'s own table rather than in taste: a `warn`
|
|
15087
16661
|
// auto-dismisses after 5 s while an `err` stays until it is closed. This message is long — the
|
|
15088
|
-
// trigger, the
|
|
16662
|
+
// trigger, the cause, and a two-clause recovery instruction — and it reports a programming
|
|
15089
16663
|
// error the reader can do nothing about except reopen the step. Five seconds is not enough to
|
|
15090
16664
|
// read it, and losing it leaves them looking at the half-painted card the bug just produced with
|
|
15091
16665
|
// no explanation at all, which is the silence this whole change removes. (Design review.)
|
|
15092
16666
|
showToast(
|
|
15093
|
-
|
|
16667
|
+
// #3097: the raw error is in the console line above, never in the toast.
|
|
16668
|
+
'Couldn’t refresh the exports view ' + (reason || 'just now') + ' because of a problem inside FloLess'
|
|
15094
16669
|
+ ' — leave the Exports step and open it again to retry.',
|
|
15095
16670
|
'err',
|
|
15096
16671
|
);
|
|
@@ -15212,12 +16787,15 @@
|
|
|
15212
16787
|
// `checkpointPromise`, reintroduced one line up by the wait itself. The `return` on the line
|
|
15213
16788
|
// above made it worse: it abandoned the promise outright.
|
|
15214
16789
|
const sourcesRefused = !!approvalRefusalNote();
|
|
15215
|
-
|
|
15216
|
-
|
|
16790
|
+
// #3273: each with a deadline, because a request that never answers is not an error and would never reach the
|
|
16791
|
+
// failure branches below: the pane would sit on "Loading export sources…" for good.
|
|
16792
|
+
const bounded = { timeoutMs: EXPORTS_REFRESH_MS };
|
|
16793
|
+
const exportPromise = api(`/api/contract/${encodeURIComponent(app)}/exports?project=${encodeURIComponent(id)}`, bounded);
|
|
16794
|
+
const sourcePromise = sourcesRefused ? null : api(`/api/projects/${encodeURIComponent(id)}/export-sources`, bounded);
|
|
15217
16795
|
// Host readiness is intentionally not probed while painting Exports. A send preflight first
|
|
15218
16796
|
// establishes what the reviewed model would omit; only an authorized continuation may contact
|
|
15219
16797
|
// AWARE or a CAD bridge.
|
|
15220
|
-
const renderReadyPromise = hasRender ? api('/api/render/readiness') : Promise.resolve(null);
|
|
16798
|
+
const renderReadyPromise = hasRender ? api('/api/render/readiness', bounded) : Promise.resolve(null);
|
|
15221
16799
|
const [exportResult, renderReadyResult, sourceResult] = await Promise.allSettled([
|
|
15222
16800
|
exportPromise, renderReadyPromise, sourcePromise,
|
|
15223
16801
|
]);
|
|
@@ -15263,7 +16841,8 @@
|
|
|
15263
16841
|
// Prefer the server's own words, as the Tekla branch below already does. The route-gate
|
|
15264
16842
|
// 409s this endpoint while AWARE is still installing and says so actionably; replacing
|
|
15265
16843
|
// that with the generic line threw away the only sentence that told the user to wait.
|
|
15266
|
-
|
|
16844
|
+
// A deadline that ran out has no sentence for a person, so it takes the generic line.
|
|
16845
|
+
message: (renderReadyResult.reason && renderReadyResult.reason.name !== 'TimeoutError' && renderReadyResult.reason.message)
|
|
15267
16846
|
|| 'Could not check whether rendering is available.',
|
|
15268
16847
|
recovery: { action: 'retry', label: 'Check again' },
|
|
15269
16848
|
};
|
|
@@ -15481,7 +17060,7 @@
|
|
|
15481
17060
|
code === 'aware_too_old' ? (awareVersion
|
|
15482
17061
|
? `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
17062
|
: `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
|
|
17063
|
+
errorText(err, { action: 'create the share link', unsure: 'Check the card for a share link before trying again.' }),
|
|
15485
17064
|
'warn');
|
|
15486
17065
|
} finally {
|
|
15487
17066
|
exportBusy.delete(busyKey);
|
|
@@ -15589,10 +17168,13 @@
|
|
|
15589
17168
|
const got = kind === 'render' && err && err.body && Array.isArray(err.body.rendered)
|
|
15590
17169
|
? err.body.rendered.length : 0;
|
|
15591
17170
|
publishedDespiteFailure = got > 0;
|
|
17171
|
+
// #3097: the server's sentence or the shared one (errorText), never the error's own text.
|
|
17172
|
+
const exportAction = kind === 'render' ? 'finish the render' : 'finish that export';
|
|
17173
|
+
if (got > 0 && !personText(err && err.body)) console.warn('[exports] the render stopped partway', err);
|
|
15592
17174
|
showToast(
|
|
15593
17175
|
got > 0
|
|
15594
|
-
? `${err && err.
|
|
15595
|
-
: (err
|
|
17176
|
+
? `${personText(err && err.body) || 'Rendering didn’t finish'} — ${got} viewpoint${got === 1 ? '' : 's'} did finish and ${got === 1 ? 'is' : 'are'} saved.`
|
|
17177
|
+
: errorText(err, { action: exportAction, unsure: 'Check the exports list before trying again.' }),
|
|
15596
17178
|
'warn');
|
|
15597
17179
|
} finally {
|
|
15598
17180
|
exportBusy.delete(busyKey);
|
|
@@ -17120,7 +18702,7 @@
|
|
|
17120
18702
|
// into test harnesses, where a free name it assigns would not exist. A review opened before this
|
|
17121
18703
|
// settles (a fresh page, a slow disk) reads in millimetres, never in nothing.
|
|
17122
18704
|
import('./display-units.js').then((m) => { reviewUnitsModule = m; }, () => {});
|
|
17123
|
-
const reviewUnits = () => (current
|
|
18705
|
+
const reviewUnits = () => shownUnits(current);
|
|
17124
18706
|
const reviewElevation = (mm) => (reviewUnitsModule ? reviewUnitsModule.formatElevation(mm, reviewUnits()) : `${Math.round(mm)} mm`);
|
|
17125
18707
|
const reviewLength = (mm) => (reviewUnitsModule ? reviewUnitsModule.formatLength(mm, reviewUnits()) : `${Math.round(mm)} mm`);
|
|
17126
18708
|
const isEndpointValue = (v) => !!v && typeof v === 'object' && !Array.isArray(v)
|
|
@@ -18609,8 +20191,10 @@
|
|
|
18609
20191
|
return `<span class="gate-badge model findings-accepted" data-tip="${escapeAttr(`Sign-off gate. ${acceptedNote}`)}">Model</span>`;
|
|
18610
20192
|
if (gate === 'model')
|
|
18611
20193
|
return '<span class="gate-badge model" data-tip="Sign-off gate — this version was approved">Model</span>';
|
|
20194
|
+
// #3223 rank 7: never "Approve to sign it off" here. Approving does not sign off this row; it saves the reviewed model
|
|
20195
|
+
// as a new version above it, and reading the badge as the thing approved is what made "Approved as v2" look doubled.
|
|
18612
20196
|
if (kind === 'revision-read')
|
|
18613
|
-
return `<span class="gate-badge ai-read" data-tip="AI read
|
|
20197
|
+
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
20198
|
return '<span class="gate-badge" data-tip="Unsigned — a working-tree restore, not a sign-off">unsigned</span>';
|
|
18615
20199
|
};
|
|
18616
20200
|
|
|
@@ -19679,7 +21263,10 @@
|
|
|
19679
21263
|
const box = el('div', 'hd-err');
|
|
19680
21264
|
box.setAttribute('role', 'status');
|
|
19681
21265
|
box.setAttribute('aria-live', 'polite');
|
|
19682
|
-
|
|
21266
|
+
// #3097: the server's own sentence when it wrote one; a malformed reply or a lost answer stays in the console.
|
|
21267
|
+
const said = personText(err && err.body);
|
|
21268
|
+
if (!said) console.warn('[history] the comparison did not load', err);
|
|
21269
|
+
box.appendChild(document.createTextNode('Couldn’t load the comparison' + (said ? ` — ${said}` : '') + ' — '));
|
|
19683
21270
|
const retry = el('button', null, 'try again');
|
|
19684
21271
|
retry.type = 'button';
|
|
19685
21272
|
retry.dataset.diffRetry = String(n);
|
|
@@ -20148,9 +21735,8 @@
|
|
|
20148
21735
|
} catch (err) {
|
|
20149
21736
|
finishProgress();
|
|
20150
21737
|
const inUse = projectFolderInUseMessage(err);
|
|
20151
|
-
showToast(inUse || (action === 'duplicate'
|
|
20152
|
-
|
|
20153
|
-
: 'Action failed: ' + (err && err.message || err)), 'warn', inUse ? { persistent: true } : undefined);
|
|
21738
|
+
showToast(inUse || errorText(err, { action: action === 'duplicate' ? 'duplicate this project' : 'finish that',
|
|
21739
|
+
unsure: 'Check the project list before trying again.' }), 'warn', inUse ? { persistent: true } : undefined);
|
|
20154
21740
|
}
|
|
20155
21741
|
finally { finishProgress(); projActionBusy = false; }
|
|
20156
21742
|
loadProjects();
|
|
@@ -20408,8 +21994,9 @@
|
|
|
20408
21994
|
finishProgress();
|
|
20409
21995
|
const body = err && err.body;
|
|
20410
21996
|
// A choice made for a project that was replaced while the person chose, or a refused choice: the server's sentence.
|
|
20411
|
-
|
|
20412
|
-
|
|
21997
|
+
const said = body && (body.code === 'archive-project-changed' || body.code === 'invalid-export-choice') ? personText(body) : '';
|
|
21998
|
+
if (said) {
|
|
21999
|
+
showToast(said, 'warn');
|
|
20413
22000
|
return;
|
|
20414
22001
|
}
|
|
20415
22002
|
showToast(`We couldn’t export “${label}” because FloLess could not finish preparing it. Try again.`, 'warn');
|
|
@@ -20709,16 +22296,24 @@
|
|
|
20709
22296
|
renderKnowledge();
|
|
20710
22297
|
}
|
|
20711
22298
|
|
|
22299
|
+
/**
|
|
22300
|
+
* #3097: an error whose message is a sentence this page wrote for the person. Callers in other modules (chat, agents,
|
|
22301
|
+
* Project access) show it through errorText, which trusts only this marker.
|
|
22302
|
+
*/
|
|
22303
|
+
function personError(text) {
|
|
22304
|
+
return Object.assign(new Error(text), { forPerson: true });
|
|
22305
|
+
}
|
|
22306
|
+
|
|
20712
22307
|
/**
|
|
20713
22308
|
* #2106: open a project on its Knowledge step — where a person sees FloLess organizing its knowledge, the work a busy
|
|
20714
22309
|
* card's "Open it" leads to. Throws a plain sentence when the project can't be opened, so the caller can say so.
|
|
20715
22310
|
*/
|
|
20716
22311
|
async function openKnowledgeStep(projectId) {
|
|
20717
|
-
if (typeof projectId !== 'string' || !projectId) throw
|
|
22312
|
+
if (typeof projectId !== 'string' || !projectId) throw personError('That project could not be opened. Open it from Workspaces.');
|
|
20718
22313
|
await setMode('workspaces');
|
|
20719
22314
|
const opened = await openProject(projectId, 'knowledge');
|
|
20720
|
-
if (opened === STAYED_IN_PROJECT) throw
|
|
20721
|
-
if (current?.id !== projectId) throw
|
|
22315
|
+
if (opened === STAYED_IN_PROJECT) throw personError('You stayed in this project, so the other one was not opened.');
|
|
22316
|
+
if (current?.id !== projectId) throw personError('That project could not be opened. Open it from Workspaces.');
|
|
20722
22317
|
}
|
|
20723
22318
|
|
|
20724
22319
|
// #2470 R6.2: a project's Workflows step, where the workflows it owns are listed (Project access links here).
|
|
@@ -20798,16 +22393,16 @@
|
|
|
20798
22393
|
async function openLinkedProject(projectId) {
|
|
20799
22394
|
await setMode('workspaces');
|
|
20800
22395
|
const opened = await openProject(projectId);
|
|
20801
|
-
if (opened === STAYED_IN_PROJECT) throw
|
|
20802
|
-
if (current?.id !== projectId) throw
|
|
22396
|
+
if (opened === STAYED_IN_PROJECT) throw personError('You stayed in this project, so the other one was not opened.');
|
|
22397
|
+
if (current?.id !== projectId) throw personError('That project could not be opened. Open it from Workspaces.');
|
|
20803
22398
|
}
|
|
20804
22399
|
|
|
20805
22400
|
/** A General project's Modules step: where Back to … after an Add a module returns to. */
|
|
20806
22401
|
async function openModulesStep(projectId) {
|
|
20807
22402
|
await setMode('workspaces');
|
|
20808
22403
|
const opened = await openProject(projectId, 'modules');
|
|
20809
|
-
if (opened === STAYED_IN_PROJECT) throw
|
|
20810
|
-
if (current?.id !== projectId) throw
|
|
22404
|
+
if (opened === STAYED_IN_PROJECT) throw personError('You stayed in this project, so the other one was not opened.');
|
|
22405
|
+
if (current?.id !== projectId) throw personError('That project could not be opened. Open it from Workspaces.');
|
|
20811
22406
|
}
|
|
20812
22407
|
|
|
20813
22408
|
/** Show the archived projects on the Workspaces page, where Restore is, with this one in view. */
|
|
@@ -20822,11 +22417,11 @@
|
|
|
20822
22417
|
}
|
|
20823
22418
|
|
|
20824
22419
|
async function openWorkflowsStep(projectId) {
|
|
20825
|
-
if (typeof projectId !== 'string' || !projectId) throw
|
|
22420
|
+
if (typeof projectId !== 'string' || !projectId) throw personError('That project could not be opened. Open it from Workspaces.');
|
|
20826
22421
|
await setMode('workspaces');
|
|
20827
22422
|
const opened = await openProject(projectId, 'workflows');
|
|
20828
|
-
if (opened === STAYED_IN_PROJECT) throw
|
|
20829
|
-
if (current?.id !== projectId) throw
|
|
22423
|
+
if (opened === STAYED_IN_PROJECT) throw personError('You stayed in this project, so the other one was not opened.');
|
|
22424
|
+
if (current?.id !== projectId) throw personError('That project could not be opened. Open it from Workspaces.');
|
|
20830
22425
|
}
|
|
20831
22426
|
|
|
20832
22427
|
/**
|
|
@@ -20911,11 +22506,11 @@
|
|
|
20911
22506
|
|
|
20912
22507
|
// The Drawing Filter step of a project, where a drawing read's exclusions are saved and signed off.
|
|
20913
22508
|
async function openDrawingsStep(projectId) {
|
|
20914
|
-
if (typeof projectId !== 'string' || !projectId) throw
|
|
22509
|
+
if (typeof projectId !== 'string' || !projectId) throw personError('That project could not be opened. Open it from Workspaces.');
|
|
20915
22510
|
await setMode('workspaces');
|
|
20916
22511
|
const opened = await openProject(projectId, 'drawings');
|
|
20917
|
-
if (opened === STAYED_IN_PROJECT) throw
|
|
20918
|
-
if (current?.id !== projectId) throw
|
|
22512
|
+
if (opened === STAYED_IN_PROJECT) throw personError('You stayed in this project, so the other one was not opened.');
|
|
22513
|
+
if (current?.id !== projectId) throw personError('That project could not be opened. Open it from Workspaces.');
|
|
20919
22514
|
}
|
|
20920
22515
|
|
|
20921
22516
|
/**
|
|
@@ -21228,20 +22823,20 @@
|
|
|
21228
22823
|
const validId = (id) => typeof id === 'string' && !!id && id.length <= 200;
|
|
21229
22824
|
if (!owner || typeof owner !== 'object'
|
|
21230
22825
|
|| !(owner.kind === 'workspace' || owner.kind === 'project' && validId(owner.projectId)
|
|
21231
|
-
|| owner.kind === 'workflow' && validId(owner.workflowId))) throw
|
|
22826
|
+
|| owner.kind === 'workflow' && validId(owner.workflowId))) throw personError('That conversation has no valid home to open.');
|
|
21232
22827
|
if (owner.kind === 'workflow') {
|
|
21233
|
-
if (typeof bridge.openOwnedWorkflow !== 'function') throw
|
|
22828
|
+
if (typeof bridge.openOwnedWorkflow !== 'function') throw personError('Open this conversation’s workflow from Workflows, then try Show in chat again.');
|
|
21234
22829
|
await bridge.openOwnedWorkflow(owner.workflowId);
|
|
21235
22830
|
return;
|
|
21236
22831
|
}
|
|
21237
22832
|
await setMode('workspaces');
|
|
21238
22833
|
if (owner.kind === 'project') {
|
|
21239
22834
|
const opened = await openProject(owner.projectId);
|
|
21240
|
-
if (opened === STAYED_IN_PROJECT) throw
|
|
21241
|
-
if (current?.id !== owner.projectId) throw
|
|
22835
|
+
if (opened === STAYED_IN_PROJECT) throw personError('You stayed in this project, so the other one was not opened.');
|
|
22836
|
+
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
22837
|
} else {
|
|
21243
22838
|
await leaveProjectToList(null);
|
|
21244
|
-
if (current) throw
|
|
22839
|
+
if (current) throw personError('You stayed in this project, so the conversation was not opened.');
|
|
21245
22840
|
}
|
|
21246
22841
|
}
|
|
21247
22842
|
|