@floless/app 0.149.1 → 0.150.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 +101814 -88311
- package/dist/schemas/drawing-check.profile.v1.schema.json +45 -2
- package/dist/schemas/steel.model.v2.schema.json +9 -0
- package/dist/skills/floless-app-approval/SKILL.md +79 -4
- package/dist/skills/floless-app-onboarding/SKILL.md +4 -4
- package/dist/skills/floless-app-onboarding/references/aware-runtime.md +1 -1
- package/dist/skills/floless-app-onboarding/references/floless-app-tour.md +15 -13
- package/dist/skills/floless-app-routines/SKILL.md +4 -1
- package/dist/skills/floless-app-routines/references/routines-api.md +14 -2
- package/dist/skills/floless-app-steel-model/SKILL.md +4 -2
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +14 -9
- package/dist/skills/floless-app-workflows/SKILL.md +2 -2
- package/dist/templates/tekla-parser.flo +13 -3
- package/dist/web/agents.js +887 -0
- package/dist/web/app.css +458 -23
- package/dist/web/app.js +20 -5
- package/dist/web/aware.js +1339 -134
- package/dist/web/chat.css +50 -1
- package/dist/web/chat.js +1582 -52
- package/dist/web/commands-drawing-check.js +15 -0
- package/dist/web/commands-revit.js +5 -0
- package/dist/web/commands-shell.js +761 -47
- package/dist/web/commands-tekla-parser.js +8 -1
- package/dist/web/connections.js +57 -14
- package/dist/web/drawing-check-editor.html +10 -2
- package/dist/web/drawing-check-editor.js +569 -40
- package/dist/web/drawing-check-overlay.js +45 -2
- package/dist/web/index.html +98 -27
- package/dist/web/instructor.js +85 -8
- package/dist/web/leave-guard.js +1 -0
- package/dist/web/left-pane.js +20 -1
- package/dist/web/local-discovery.js +12 -2
- package/dist/web/model-editor.css +32 -32
- package/dist/web/model-panel-bridge.js +11 -3
- package/dist/web/model-viewport-lighting.js +4 -2
- package/dist/web/model-viewport-revit-adapter.js +3 -0
- package/dist/web/model-viewport-toolbar.js +6 -3
- package/dist/web/model-viewport.js +11 -1
- package/dist/web/revit-editor.css +14 -14
- package/dist/web/revit-editor.js +64 -12
- package/dist/web/steel-3d-core.js +133 -0
- package/dist/web/steel-3d-view.js +10 -0
- package/dist/web/steel-editor.html +171 -39
- package/dist/web/steel-model-v2-client-validation.js +11 -0
- package/dist/web/steel-model-v2-commands.js +80 -5
- package/dist/web/tool-updates.js +367 -0
- package/dist/web/workspaces.js +679 -59
- package/package.json +1 -1
package/dist/web/workspaces.js
CHANGED
|
@@ -280,6 +280,9 @@
|
|
|
280
280
|
// mode — and the markup stays the one place that sentence is written.
|
|
281
281
|
const WORKSPACE_TAB_TIP = $workspaceTab?.getAttribute('data-tip') || '';
|
|
282
282
|
const $landing = document.getElementById('ws-landing');
|
|
283
|
+
// The landing search's query. Kept here, not only in the input, because renderLanding() rebuilds the
|
|
284
|
+
// whole landing with innerHTML on background refreshes; applyMode() empties it on each fresh visit.
|
|
285
|
+
let landingQuery = '';
|
|
283
286
|
const $project = document.getElementById('ws-project');
|
|
284
287
|
const $spine = document.getElementById('ws-spine');
|
|
285
288
|
const $projName = document.getElementById('ws-proj-name');
|
|
@@ -823,9 +826,16 @@
|
|
|
823
826
|
},
|
|
824
827
|
'setup-integrity-failure': {
|
|
825
828
|
status: 'Setup could not be verified',
|
|
826
|
-
body: 'FloLess could not verify
|
|
829
|
+
body: 'FloLess could not verify this Tekla Parser setup, so it was not used. No model files were changed.',
|
|
827
830
|
action: 'Report issue', aria: 'Tekla Parser setup could not be verified — report issue',
|
|
828
831
|
},
|
|
832
|
+
// The parser files installed with FloLess are missing, damaged or another release's: retrying
|
|
833
|
+
// setup cannot fix that, reinstalling does. One sentence true for every one of those causes.
|
|
834
|
+
'setup-repair-required': {
|
|
835
|
+
status: 'Needs repair',
|
|
836
|
+
body: 'The Tekla Parser files installed with FloLess can’t be used. Reinstall FloLess from floless.io, then check again. Existing projects were not changed.',
|
|
837
|
+
action: 'Check again', aria: 'Tekla Parser needs repair — check again',
|
|
838
|
+
},
|
|
829
839
|
'check-unavailable': {
|
|
830
840
|
status: 'Couldn’t check access', body: 'FloLess couldn’t verify Tekla Parser access. Existing projects were not changed.',
|
|
831
841
|
action: 'Check again', aria: 'Tekla Parser access check unavailable — check again',
|
|
@@ -906,7 +916,10 @@
|
|
|
906
916
|
* case where naming the live workflow on the card tells the user something they don't know. */
|
|
907
917
|
const wsRenamed = (p) => !!(p && p.templateId && p.app && p.app !== p.templateId);
|
|
908
918
|
let mode = 'workflows';
|
|
909
|
-
try {
|
|
919
|
+
try {
|
|
920
|
+
const saved = localStorage.getItem(LS_MODE);
|
|
921
|
+
if (saved === 'workspaces' || saved === 'agents') mode = saved;
|
|
922
|
+
} catch { /* private mode */ }
|
|
910
923
|
let projects = [];
|
|
911
924
|
let projectsLoadError = null; // last /api/projects failure reason, or null — an empty list means
|
|
912
925
|
// "none yet" ONLY when this is null (see the empty state in renderLanding)
|
|
@@ -961,12 +974,18 @@
|
|
|
961
974
|
byRoot.get(root).push(a.id);
|
|
962
975
|
}
|
|
963
976
|
const capabilityByRoot = new Map();
|
|
977
|
+
// The server decides when a "Needs setup" card has a remedy the person can act on (#1965 review);
|
|
978
|
+
// the card only renders that sentence, and only on the state it was written for.
|
|
979
|
+
const remedyByRoot = new Map();
|
|
964
980
|
for (const capability of capabilities || []) {
|
|
965
981
|
if (!capability || typeof capability.templateId !== 'string'
|
|
966
982
|
|| capability.appId !== capability.templateId
|
|
967
983
|
|| WORKSPACE_APPS[capability.templateId]?.serverAuthorizedOnly !== true) continue;
|
|
968
|
-
const known = ['ready', 'access-required', 'account-selection-required', 'setup-provisioning', 'setup-unavailable', 'setup-integrity-failure', 'check-unavailable'];
|
|
984
|
+
const known = ['ready', 'access-required', 'account-selection-required', 'setup-provisioning', 'setup-unavailable', 'setup-integrity-failure', 'setup-repair-required', 'check-unavailable'];
|
|
969
985
|
capabilityByRoot.set(capability.templateId, known.includes(capability.status) ? capability.status : 'check-unavailable');
|
|
986
|
+
if (capability.status === 'setup-unavailable' && typeof capability.setupRemedy === 'string' && capability.setupRemedy.trim()) {
|
|
987
|
+
remedyByRoot.set(capability.templateId, capability.setupRemedy.trim());
|
|
988
|
+
}
|
|
970
989
|
// A capability row exists only after the server positively found the canonical module. Add
|
|
971
990
|
// its presentation entry even when authorization intentionally filtered it out of `apps`.
|
|
972
991
|
if (!byRoot.has(capability.templateId)) byRoot.set(capability.templateId, [capability.templateId]);
|
|
@@ -989,11 +1008,13 @@
|
|
|
989
1008
|
// the one the user has not deliberately made a variant of.
|
|
990
1009
|
const ids = byRoot.get(root).slice().sort();
|
|
991
1010
|
const capabilityStatus = capabilityByRoot.get(root);
|
|
1011
|
+
const setupRemedy = remedyByRoot.get(root);
|
|
992
1012
|
return {
|
|
993
1013
|
appId: WORKSPACE_APPS[root]?.serverAuthorizedOnly === true ? root : ids.indexOf(root) >= 0 ? root : ids[0],
|
|
994
1014
|
templateId: root,
|
|
995
1015
|
ambiguous: WORKSPACE_APPS[root]?.serverAuthorizedOnly === true ? false : ids.length > 1,
|
|
996
1016
|
...(capabilityStatus ? { capabilityStatus } : {}),
|
|
1017
|
+
...(setupRemedy ? { setupRemedy } : {}),
|
|
997
1018
|
...(missingCoreRoots.has(root) ? { missing: true } : {}),
|
|
998
1019
|
};
|
|
999
1020
|
});
|
|
@@ -1090,14 +1111,19 @@
|
|
|
1090
1111
|
} else if (s.pendingCount > 0) {
|
|
1091
1112
|
label = s.headVersion ? `Review changes · ${s.pendingCount}` : 'Review & approve';
|
|
1092
1113
|
} else if (s.headVersion) {
|
|
1093
|
-
|
|
1094
|
-
|
|
1114
|
+
// #1840: an approved head that accepted open import findings never reads as a plain "Approved".
|
|
1115
|
+
const accepted = s.review && s.review.approvedHeadImportFindings;
|
|
1116
|
+
label = accepted ? `Approved with findings · v${s.headVersion}` : `Approved · v${s.headVersion}`;
|
|
1117
|
+
tip = accepted && accepted.note ? `${accepted.note} The working copy matches this version.`
|
|
1118
|
+
: 'The working copy matches the latest approved version.';
|
|
1095
1119
|
unavailable = true;
|
|
1096
1120
|
}
|
|
1097
1121
|
$approveBtn.textContent = label;
|
|
1098
1122
|
$approveBtn.setAttribute('aria-disabled', String(unavailable));
|
|
1099
1123
|
$approveBtn.setAttribute('data-tip', tip);
|
|
1100
1124
|
$approveBtn.classList.toggle('approval-clean', s.status === 'ready' && !!s.headVersion && s.pendingCount === 0);
|
|
1125
|
+
$approveBtn.classList.toggle('approval-findings-accepted', s.status === 'ready' && !!s.headVersion && s.pendingCount === 0
|
|
1126
|
+
&& !!(s.review && s.review.approvedHeadImportFindings));
|
|
1101
1127
|
}
|
|
1102
1128
|
|
|
1103
1129
|
/**
|
|
@@ -1309,9 +1335,20 @@
|
|
|
1309
1335
|
}
|
|
1310
1336
|
function applyMode() {
|
|
1311
1337
|
const ws = mode === 'workspaces';
|
|
1338
|
+
// #2007: the third mode. Its surface and the hiding of the workflow canvas are app.css's `mode-agents` rules;
|
|
1339
|
+
// agents.js renders the surface (and reads this class at load, since it loads after this file).
|
|
1340
|
+
const agents = mode === 'agents';
|
|
1341
|
+
$app.classList.toggle('mode-agents', agents);
|
|
1342
|
+
document.body.classList.toggle('mode-agents', agents);
|
|
1343
|
+
document.documentElement.classList.remove('mode-agents-boot');
|
|
1344
|
+
window.flolessAgents?.show(agents);
|
|
1345
|
+
// Coming back to Workflows starts its landing search empty too, as coming back here does (below).
|
|
1346
|
+
if (!ws && $app.classList.contains('mode-workspaces') && bridge.resetWorkflowsLandingSearch) bridge.resetWorkflowsLandingSearch();
|
|
1312
1347
|
$app.classList.toggle('mode-workspaces', ws);
|
|
1313
1348
|
document.body.classList.toggle('mode-workspaces', ws);
|
|
1314
1349
|
document.documentElement.classList.remove('mode-workspaces-boot');
|
|
1350
|
+
// #2007: with both mode classes set, the workflow spotlight closes off Workflows and is offered again on it.
|
|
1351
|
+
if (bridge.syncGuideSpotlight) bridge.syncGuideSpotlight();
|
|
1315
1352
|
// The provenance strip is workflow-level data. Workspaces replaces that surface (including its
|
|
1316
1353
|
// landing), so cancel any late workflow-pin paint before the project UI starts loading.
|
|
1317
1354
|
if (ws && bridge.clearKbInformed) bridge.clearKbInformed();
|
|
@@ -1329,7 +1366,11 @@
|
|
|
1329
1366
|
? 'Back to all projects — leaves this project for the project list.'
|
|
1330
1367
|
: WORKSPACE_TAB_TIP);
|
|
1331
1368
|
}
|
|
1369
|
+
// A fresh visit starts unfiltered, so a project created or opened since is never hidden by an old search.
|
|
1370
|
+
// Cleared on the cards already on screen too, not only for the repaint loadProjects() brings later.
|
|
1371
|
+
const freshVisit = $landing.hidden && ws && !current;
|
|
1332
1372
|
$landing.hidden = !ws || !!current;
|
|
1373
|
+
if (freshVisit) setLandingQuery('');
|
|
1333
1374
|
$project.hidden = !ws || !current;
|
|
1334
1375
|
$spine.hidden = !ws || !current;
|
|
1335
1376
|
if (!ws && !$projMenu.hidden) closeProjMenu();
|
|
@@ -1339,7 +1380,9 @@
|
|
|
1339
1380
|
// the combo isn't even visible in Workspaces mode. Every path that changes the open project
|
|
1340
1381
|
// (open, close, rename → openProject, mode switch, boot) ends here, so the title can't go stale.
|
|
1341
1382
|
if (bridge.setWorkspaceTitle) {
|
|
1342
|
-
|
|
1383
|
+
// #2007: the Agents tab names itself too, and tells Instructor which module is on screen.
|
|
1384
|
+
if (agents) bridge.setWorkspaceTitle('Agents', true, null, 'agents');
|
|
1385
|
+
else bridge.setWorkspaceTitle(workspaceTabSubject(ws, current), ws && !current, ws && current ? current.id : null);
|
|
1343
1386
|
}
|
|
1344
1387
|
// Scope the shared Requests window to the open project, so it stops stacking every other
|
|
1345
1388
|
// project's queued work. Three states, and the landing is NOT the same as Workflows mode:
|
|
@@ -1388,7 +1431,9 @@
|
|
|
1388
1431
|
}
|
|
1389
1432
|
}
|
|
1390
1433
|
async function setMode(m) {
|
|
1391
|
-
const next = m === 'workspaces'
|
|
1434
|
+
const next = m === 'workspaces' || m === 'agents' ? m : 'workflows';
|
|
1435
|
+
// #2007: leaving an agent with unsaved changes asks first (Save / Discard / Stay).
|
|
1436
|
+
if (mode === 'agents' && next !== 'agents' && window.flolessAgents && !(await window.flolessAgents.confirmLeave())) return;
|
|
1392
1437
|
// The still-selected Workspaces tab remains the cancellation path. Re-activating the pending
|
|
1393
1438
|
// Workflows tab would only start another read, supersede the useful one, and extend the wait.
|
|
1394
1439
|
if (next === 'workflows' && $workflowTab?.getAttribute('aria-busy') === 'true') return;
|
|
@@ -1446,6 +1491,8 @@
|
|
|
1446
1491
|
if (!pending && b.dataset.mode === 'workspaces' && mode === 'workspaces' && current) { closeProject(); return; }
|
|
1447
1492
|
// #1890: the active Workflows tab goes home to the Workflows landing, the same way.
|
|
1448
1493
|
if (!pending && b.dataset.mode === 'workflows' && mode === 'workflows' && bridge.showWorkflowsLanding) { bridge.showWorkflowsLanding(); return; }
|
|
1494
|
+
// #2007: and the active Agents tab goes home to the list of agents.
|
|
1495
|
+
if (!pending && b.dataset.mode === 'agents' && mode === 'agents' && window.flolessAgents) { void window.flolessAgents.home(); return; }
|
|
1449
1496
|
setMode(b.dataset.mode);
|
|
1450
1497
|
});
|
|
1451
1498
|
document.addEventListener('keydown', (e) => {
|
|
@@ -1540,7 +1587,9 @@
|
|
|
1540
1587
|
// Keep descriptor order for a stable card order. A load failure RE-WIDENS the entries to the
|
|
1541
1588
|
// descriptor keys (the catch assigns them): still usable, and a card for something uninstalled is
|
|
1542
1589
|
// refused by the server on click.
|
|
1543
|
-
|
|
1590
|
+
// The remedy is free text (it can hold commas and colons), so it enters the signature JSON-quoted:
|
|
1591
|
+
// a changed remedy repaints the card, and no remedy can forge another row's signature.
|
|
1592
|
+
const cardsSig = (entries) => entries.map((e) => `${e.appId}>${e.templateId}${e.ambiguous ? '?' : ''}:${e.capabilityStatus || ''}:${e.missing ? 'missing' : ''}:${JSON.stringify(e.setupRemedy || '')}`).join(',');
|
|
1544
1593
|
const cardsBefore = cardsSig(wsAppEntries);
|
|
1545
1594
|
let coreDefaults = null;
|
|
1546
1595
|
try {
|
|
@@ -2115,11 +2164,17 @@
|
|
|
2115
2164
|
};
|
|
2116
2165
|
const states = descriptor.accessCopy || revitStates;
|
|
2117
2166
|
const state = states[entry.capabilityStatus] || states['check-unavailable'];
|
|
2167
|
+
// A remedy the server wrote for this "Needs setup" replaces "setup didn’t finish"; the button
|
|
2168
|
+
// still re-runs setup, so the person can check again once they have fixed it.
|
|
2169
|
+
const body = entry.capabilityStatus === 'setup-unavailable' && entry.setupRemedy ? entry.setupRemedy : state.body;
|
|
2118
2170
|
const descriptionId = `ws-${entry.templateId}-${entry.capabilityStatus || 'check-unavailable'}`;
|
|
2119
2171
|
const actionable = !!state.action;
|
|
2120
2172
|
const provisioning = entry.capabilityStatus === 'setup-provisioning';
|
|
2121
2173
|
const teklaCommand = entry.capabilityStatus === 'setup-unavailable'
|
|
2122
2174
|
? 'data-command-id="shell.tekla-retry-setup"'
|
|
2175
|
+
: entry.capabilityStatus === 'setup-repair-required'
|
|
2176
|
+
// Its own command, so `?` explains a re-check after a reinstall, not "retry setup".
|
|
2177
|
+
? 'data-command-id="shell.tekla-check-install"'
|
|
2123
2178
|
: entry.capabilityStatus === 'setup-integrity-failure'
|
|
2124
2179
|
? 'data-command-id="shell.tekla-report-setup-issue"'
|
|
2125
2180
|
: 'data-command-id="shell.tekla-view-access"';
|
|
@@ -2144,7 +2199,7 @@
|
|
|
2144
2199
|
`<span class="ws-seed-headline">${escapeHtml(descriptor.displayName)}</span>` +
|
|
2145
2200
|
(descriptor.readOnlyLabel ? `<span class="ws-seed-readonly">${escapeHtml(descriptor.readOnlyLabel)}</span>` : '') +
|
|
2146
2201
|
`<span class="ws-seed-capability ws-seed-state">${escapeHtml(state.status)}</span>` +
|
|
2147
|
-
`<span class="ws-seed-sub" id="${escapeAttr(descriptionId)}">${escapeHtml(
|
|
2202
|
+
`<span class="ws-seed-sub" id="${escapeAttr(descriptionId)}">${escapeHtml(body)}</span>` +
|
|
2148
2203
|
(state.action ? `<span class="ws-seed-action">${escapeHtml(state.action)} →</span>` : '') +
|
|
2149
2204
|
`</${actionable ? 'button' : 'div'}>`;
|
|
2150
2205
|
}
|
|
@@ -2247,8 +2302,13 @@
|
|
|
2247
2302
|
const folderName = window.flolessWorkspaceRoot ? window.flolessWorkspaceRoot.name() : 'Workspace directory';
|
|
2248
2303
|
let html = `<div class="ws-head"><div class="ws-head-text"><h2>Workspaces</h2>` +
|
|
2249
2304
|
`<div class="ws-sub">${rootUnavailable ? 'Workspace directory unavailable. Choose another folder to continue.' : 'Open a project to view its drawings, model, Knowledge and history.'}</div></div>` +
|
|
2250
|
-
`<div class="ws-head-actions"
|
|
2251
|
-
|
|
2305
|
+
`<div class="ws-head-actions">` +
|
|
2306
|
+
// Shown only when there is a project card to search (absent, never disabled, in the empty state).
|
|
2307
|
+
(!rootUnavailable && projects.length
|
|
2308
|
+
? `<input type="search" id="ws-landing-search" class="ws-landing-search" data-command-id="shell.project-list-search" placeholder="Search projects" aria-label="Search projects by name, description, kind or workflow" autocomplete="off" spellcheck="false" value="${escapeAttr(landingQuery)}">`
|
|
2309
|
+
: '') +
|
|
2310
|
+
`<button type="button" class="ws-import-btn ws-folder-btn${rootUnavailable ? ' is-unavailable' : ''}" id="ws-workspace-folder" data-command-id="menu.workspace-folder" data-tip="${escapeAttr(rootPath || 'Choose the Workspace directory FloLess reads for projects and workflows')}">Workspace directory · ${escapeHtml(rootUnavailable ? 'unavailable' : folderName)}</button>` +
|
|
2311
|
+
`${rootUnavailable ? '' : '<button type="button" class="ws-import-btn" id="ws-import-project" data-command-id="shell.project-import" data-tip="Restore a project from an exported .zip file or a zipped project folder">↓ Import project…</button>'}</div></div>`;
|
|
2252
2312
|
if (rootUnavailable) {
|
|
2253
2313
|
html += `<div class="ws-empty-note ws-root-unavailable" role="status" aria-live="polite"><b>Workspace directory unavailable.</b> ` +
|
|
2254
2314
|
`Choose another folder to continue. ` +
|
|
@@ -2286,11 +2346,15 @@
|
|
|
2286
2346
|
thumbBandHtml(p, displayApp) +
|
|
2287
2347
|
`<span class="ws-body"><span><span class="ws-name">${escapeHtml(p.name)}</span>` +
|
|
2288
2348
|
(projectCapability ? `<span class="ws-meta">${escapeHtml(projectCapability)}</span>` : '') +
|
|
2349
|
+
(p.importedMidSave ? `<span class="ws-meta ws-unverified" data-tip="${escapeAttr(UNVERIFIED_IMPORT_TIP)}">Imported mid-save · not verified. Export again on the source computer.</span>` : '') +
|
|
2289
2350
|
`<span class="ws-meta ws-meta-app"><span class="ws-meta-kind">${escapeHtml(displayApp)}</span>${wfName}<span class="ws-sep"> · </span><span class="t">${escapeHtml(relAgo(p.updatedAt))}</span></span></span>` +
|
|
2290
|
-
`<button type="button" class="ws-kebab" data-kebab="${escapeAttr(p.id)}" aria-label="Project actions" data-tip="Rename · Thumbnail · Duplicate · Export · Archive">⋯</button>` +
|
|
2351
|
+
`<button type="button" class="ws-kebab" data-kebab="${escapeAttr(p.id)}" aria-label="Project actions" data-tip="${p.importedMidSave ? 'Rename · Thumbnail · Mark as checked · Duplicate · Export · Archive' : 'Rename · Thumbnail · Duplicate · Export · Archive'}">⋯</button>` +
|
|
2291
2352
|
`</span></div>`;
|
|
2292
2353
|
}
|
|
2293
2354
|
html += `</div>`;
|
|
2355
|
+
// The search's no-match message. Always rendered (empty) beside a search box, and filled in by
|
|
2356
|
+
// applyLandingSearch(): a live region inserted with its text already inside is announced unreliably.
|
|
2357
|
+
if (projects.length) html += `<div class="ws-empty-note ws-search-empty" id="ws-search-empty" role="status" aria-live="polite"></div>`;
|
|
2294
2358
|
// Empty state — but ONLY when the list really is empty. A failed load also leaves `projects`
|
|
2295
2359
|
// empty, and telling someone with 11 projects "No projects yet — start one" is a lie that reads
|
|
2296
2360
|
// like their work is gone. The toast alone can't carry this: it auto-dismisses, and the false
|
|
@@ -2368,12 +2432,19 @@
|
|
|
2368
2432
|
const keepFocus = landingFocusKey(document.activeElement);
|
|
2369
2433
|
const keepScroll = $landing.scrollTop;
|
|
2370
2434
|
const keepArchivedOpen = !!$landing.querySelector('.ws-archived')?.open;
|
|
2435
|
+
const search = document.activeElement?.id === 'ws-landing-search' ? document.activeElement : null;
|
|
2436
|
+
const keepCaret = search ? [search.selectionStart, search.selectionEnd] : null;
|
|
2371
2437
|
$landing.innerHTML = html;
|
|
2372
2438
|
// Reapply in this order: the disclosure changes the scrollable height, so it must land before the
|
|
2373
|
-
// offset; focus lands
|
|
2439
|
+
// offset; focus lands next, with preventScroll so its scroll-into-view can't undo that offset. The
|
|
2440
|
+
// search filter runs after both: it needs the restored focus to put the caret back, and it hides the
|
|
2441
|
+
// same cards the previous paint hid, so the height the offset was restored against barely moves.
|
|
2374
2442
|
if (keepArchivedOpen) { const d = $landing.querySelector('.ws-archived'); if (d) d.open = true; }
|
|
2375
2443
|
$landing.scrollTop = keepScroll;
|
|
2376
2444
|
if (keepFocus) $landing.querySelector(keepFocus)?.focus({ focusVisible: true, preventScroll: true });
|
|
2445
|
+
applyLandingSearch(keepCaret); // re-filter the new cards; put the caret back where the user left it
|
|
2446
|
+
// Clear search only exists once the filter has run, so focus on it is put back here, not above.
|
|
2447
|
+
if (keepFocus === '#ws-search-clear') $landing.querySelector(keepFocus)?.focus({ focusVisible: true, preventScroll: true });
|
|
2377
2448
|
paintCardThumbs();
|
|
2378
2449
|
tipTruncatedNames();
|
|
2379
2450
|
// The first-run tour link, when the empty state rendered one. app.js owns the copy behaviour so
|
|
@@ -2382,6 +2453,35 @@
|
|
|
2382
2453
|
reflashCard(); // a repaint must not swallow an in-flight confirmation glow
|
|
2383
2454
|
}
|
|
2384
2455
|
|
|
2456
|
+
/** Hide the project cards that don't match the landing search: every typed word must appear in the
|
|
2457
|
+
* card's name, capability, kind or workflow (never its "2 h ago", which every card has). The create
|
|
2458
|
+
* cards and the Archived list are not results, so they are left alone. `caret` restores the
|
|
2459
|
+
* selection a rebuild dropped. */
|
|
2460
|
+
function applyLandingSearch(caret) {
|
|
2461
|
+
const input = $landing.querySelector('#ws-landing-search');
|
|
2462
|
+
if (!input) return;
|
|
2463
|
+
const terms = landingQuery.trim().toLowerCase().split(/\s+/).filter(Boolean);
|
|
2464
|
+
let shown = 0;
|
|
2465
|
+
for (const card of $landing.querySelectorAll('.ws-grid .ws-card[data-open]')) {
|
|
2466
|
+
const hay = Array.from(card.querySelectorAll('.ws-name, .ws-meta:not(.ws-meta-app), .ws-meta-kind, .ws-meta-wf'), (el) => el.textContent).join(' ').toLowerCase();
|
|
2467
|
+
card.hidden = !terms.every((t) => hay.includes(t));
|
|
2468
|
+
if (!card.hidden) shown++;
|
|
2469
|
+
}
|
|
2470
|
+
const note = $landing.querySelector('#ws-search-empty');
|
|
2471
|
+
if (note) {
|
|
2472
|
+
note.textContent = shown ? '' : `No projects match “${landingQuery.trim()}”.${archived.length ? ' Archived projects aren’t searched.' : ''} `;
|
|
2473
|
+
if (!shown) note.insertAdjacentHTML('beforeend', '<button type="button" id="ws-search-clear" data-command-id="shell.project-list-search-clear">Clear search</button>');
|
|
2474
|
+
}
|
|
2475
|
+
tipTruncatedNames(); // a card hidden at the last measurement measured as unclipped; re-measure the shown ones
|
|
2476
|
+
if (caret) input.setSelectionRange(caret[0], caret[1]);
|
|
2477
|
+
}
|
|
2478
|
+
function setLandingQuery(q) {
|
|
2479
|
+
landingQuery = q;
|
|
2480
|
+
const input = $landing.querySelector('#ws-landing-search');
|
|
2481
|
+
if (input) input.value = q;
|
|
2482
|
+
applyLandingSearch();
|
|
2483
|
+
}
|
|
2484
|
+
|
|
2385
2485
|
/** Make a clamped project name reachable: the two-line clamp on .ws-name (see app.css) can hide the
|
|
2386
2486
|
* tail, which for a real project name is often the discriminating part. Attach the full value as a
|
|
2387
2487
|
* data-tip ONLY where something is actually hidden — MEASURED (scrollHeight past clientHeight is
|
|
@@ -2489,6 +2589,8 @@
|
|
|
2489
2589
|
const del = e.target.closest('[data-delete-archived]');
|
|
2490
2590
|
if (del) { e.stopPropagation(); deleteArchivedProject(del.dataset.deleteArchived); return; }
|
|
2491
2591
|
if (e.target.closest('#ws-retry-projects')) { e.stopPropagation(); retryProjects(); return; }
|
|
2592
|
+
// Clearing empties the message the button sits in, so focus goes back to the search box.
|
|
2593
|
+
if (e.target.closest('#ws-search-clear')) { setLandingQuery(''); $landing.querySelector('#ws-landing-search')?.focus(); return; }
|
|
2492
2594
|
if (e.target.closest('#ws-workspace-folder')) {
|
|
2493
2595
|
e.stopPropagation();
|
|
2494
2596
|
if (window.flolessWorkspaceRoot) window.flolessWorkspaceRoot.open();
|
|
@@ -2547,7 +2649,11 @@
|
|
|
2547
2649
|
'reader-release-unavailable': 'The required Revit reader version is unavailable. Report this issue.',
|
|
2548
2650
|
};
|
|
2549
2651
|
const category = setup?.category;
|
|
2550
|
-
|
|
2652
|
+
// A remedy the server wrote for this failure says what the person can fix; it wins over the category line.
|
|
2653
|
+
const remedy = typeof setup?.setupRemedy === 'string' ? setup.setupRemedy.trim() : '';
|
|
2654
|
+
const explanation = remedy || details[category] || 'Revit Parser setup still needs attention. Try setup again.';
|
|
2655
|
+
// The server wrote the remedy for the person and it names their folders, so it is toasted as written.
|
|
2656
|
+
const explanationToast = remedy ? authoredToastCopy(remedy) : explanation;
|
|
2551
2657
|
// Provisioning broadcasts can repaint the landing before this request settles. Apply the
|
|
2552
2658
|
// safe result to the live replacement instead of leaving its card and Instructor narration stale.
|
|
2553
2659
|
const settledRemedy = revitRemedy.isConnected
|
|
@@ -2555,7 +2661,7 @@
|
|
|
2555
2661
|
: document.querySelector('[data-revit-remedy="setup-unavailable"]');
|
|
2556
2662
|
if (!settledRemedy) {
|
|
2557
2663
|
window.Instructor?.clear();
|
|
2558
|
-
showToast(
|
|
2664
|
+
showToast(explanationToast, 'warn');
|
|
2559
2665
|
return;
|
|
2560
2666
|
}
|
|
2561
2667
|
const settledAction = settledRemedy.querySelector('.ws-seed-action');
|
|
@@ -2576,7 +2682,7 @@
|
|
|
2576
2682
|
if (originalBlockedReason === null) settledRemedy.removeAttribute('data-blocked-reason');
|
|
2577
2683
|
else settledRemedy.setAttribute('data-blocked-reason', originalBlockedReason);
|
|
2578
2684
|
window.Instructor?.refreshCarrier(settledRemedy);
|
|
2579
|
-
showToast(
|
|
2685
|
+
showToast(explanationToast, 'warn');
|
|
2580
2686
|
return;
|
|
2581
2687
|
}
|
|
2582
2688
|
window.dispatchEvent(new CustomEvent('floless:open-revit-access', {
|
|
@@ -2597,26 +2703,34 @@
|
|
|
2597
2703
|
}));
|
|
2598
2704
|
return;
|
|
2599
2705
|
}
|
|
2600
|
-
|
|
2706
|
+
const remedyState = moduleRemedy.dataset.moduleRemedyState;
|
|
2707
|
+
if (remedyState === 'setup-unavailable' || remedyState === 'setup-repair-required') {
|
|
2708
|
+
// A broken installation is re-CHECKED (after a reinstall), never "set up again".
|
|
2709
|
+
const repair = remedyState === 'setup-repair-required';
|
|
2601
2710
|
const originalLabel = moduleRemedy.getAttribute('aria-label');
|
|
2602
2711
|
const action = moduleRemedy.querySelector('.ws-seed-action');
|
|
2603
2712
|
const originalAction = action?.textContent || '';
|
|
2604
2713
|
moduleRemedy.disabled = true;
|
|
2605
2714
|
moduleRemedy.setAttribute('aria-busy', 'true');
|
|
2606
|
-
moduleRemedy.setAttribute('aria-label', 'Tekla Parser setup retry in progress');
|
|
2607
|
-
moduleRemedy.setAttribute('data-blocked-reason',
|
|
2608
|
-
|
|
2715
|
+
moduleRemedy.setAttribute('aria-label', repair ? 'Tekla Parser check in progress' : 'Tekla Parser setup retry in progress');
|
|
2716
|
+
moduleRemedy.setAttribute('data-blocked-reason', repair
|
|
2717
|
+
? 'Tekla Parser check is already in progress.' : 'Tekla Parser setup retry is already in progress.');
|
|
2718
|
+
if (action) action.textContent = repair ? 'Checking…' : 'Trying…';
|
|
2609
2719
|
window.Instructor?.refreshCarrier(moduleRemedy);
|
|
2610
2720
|
let status = null;
|
|
2721
|
+
let setupRemedy = '';
|
|
2611
2722
|
try {
|
|
2612
2723
|
const setup = await api('/api/tekla-defaults/retry', { method: 'POST' });
|
|
2613
2724
|
status = setup?.status || null;
|
|
2725
|
+
setupRemedy = typeof setup?.setupRemedy === 'string' ? setup.setupRemedy.trim() : '';
|
|
2614
2726
|
} catch {
|
|
2615
2727
|
// The server may have accepted the retry even when this response was lost. Reconcile from
|
|
2616
2728
|
// its authoritative catalogue; never turn a transport loss into a false setup failure.
|
|
2617
2729
|
try {
|
|
2618
2730
|
const catalogue = await api('/api/apps');
|
|
2619
|
-
|
|
2731
|
+
const capability = catalogue.workspaceCapabilities?.find((entry) => entry.templateId === 'tekla-parser');
|
|
2732
|
+
status = capability?.status || null;
|
|
2733
|
+
setupRemedy = typeof capability?.setupRemedy === 'string' ? capability.setupRemedy.trim() : '';
|
|
2620
2734
|
} catch { /* the next health/SSE refresh will reconcile */ }
|
|
2621
2735
|
}
|
|
2622
2736
|
moduleRemedy.disabled = false;
|
|
@@ -2638,6 +2752,23 @@
|
|
|
2638
2752
|
}
|
|
2639
2753
|
const liveRemedy = document.querySelector('[data-module-remedy="tekla-parser"]');
|
|
2640
2754
|
if (liveRemedy) window.Instructor?.refreshCarrier(liveRemedy);
|
|
2755
|
+
// The re-render replaced the card that had focus; keep keyboard users on it.
|
|
2756
|
+
if (liveRemedy && (document.activeElement === document.body || !document.activeElement)) liveRemedy.focus();
|
|
2757
|
+
if (status === 'setup-repair-required') {
|
|
2758
|
+
showToast('Tekla Parser still needs repair. Reinstall FloLess from floless.io, then check again.', 'warn');
|
|
2759
|
+
return;
|
|
2760
|
+
}
|
|
2761
|
+
// The server's remedy says what the person can fix (#1965 review); the card shows it too. It names
|
|
2762
|
+
// their folders and projects, so it is toasted as written, never swapped for a generic line.
|
|
2763
|
+
if (status === 'setup-unavailable' && setupRemedy) {
|
|
2764
|
+
showToast(authoredToastCopy(setupRemedy), 'warn');
|
|
2765
|
+
return;
|
|
2766
|
+
}
|
|
2767
|
+
// The card now asks for a report; a toast promising that another try helps would contradict it.
|
|
2768
|
+
if (status === 'setup-integrity-failure') {
|
|
2769
|
+
showToast('Tekla Parser setup could not be verified. Use Report issue on the card.', 'warn');
|
|
2770
|
+
return;
|
|
2771
|
+
}
|
|
2641
2772
|
showToast(status
|
|
2642
2773
|
? 'Tekla Parser setup still needs attention. Try setup again.'
|
|
2643
2774
|
: 'FloLess couldn’t confirm whether Tekla Parser setup finished. Check again.', 'warn');
|
|
@@ -2693,7 +2824,17 @@
|
|
|
2693
2824
|
}
|
|
2694
2825
|
}
|
|
2695
2826
|
});
|
|
2827
|
+
$landing.addEventListener('input', (e) => {
|
|
2828
|
+
if (e.target.id !== 'ws-landing-search') return;
|
|
2829
|
+
landingQuery = e.target.value;
|
|
2830
|
+
applyLandingSearch();
|
|
2831
|
+
});
|
|
2696
2832
|
$landing.addEventListener('keydown', (e) => {
|
|
2833
|
+
// Esc clears a search that has text (handled here, not left to the browser, so every engine
|
|
2834
|
+
// behaves the same); an empty box lets Esc through to whatever else listens for it.
|
|
2835
|
+
if (e.key === 'Escape' && e.target.id === 'ws-landing-search' && e.target.value) {
|
|
2836
|
+
e.preventDefault(); e.stopPropagation(); setLandingQuery(''); return;
|
|
2837
|
+
}
|
|
2697
2838
|
if (e.key !== 'Enter' && e.key !== ' ') return;
|
|
2698
2839
|
// The CARD ITSELF must be the focused element — never merely an ancestor of it.
|
|
2699
2840
|
//
|
|
@@ -3024,8 +3165,23 @@
|
|
|
3024
3165
|
}
|
|
3025
3166
|
|
|
3026
3167
|
function projectSetupErrorMessage(error) {
|
|
3168
|
+
// A sentence the server wrote for the person (#1965 review) — what to fix, or what restarting costs —
|
|
3169
|
+
// names their own folders, so it is shown as written rather than run through the filter below.
|
|
3170
|
+
const userMessage = error && typeof error.body?.userMessage === 'string' ? error.body.userMessage.trim() : '';
|
|
3171
|
+
if (userMessage) return userMessage;
|
|
3027
3172
|
const raw = String(error && error.body?.error || error && error.message || error || '');
|
|
3028
3173
|
const code = String(error && (error.code || error.body?.code) || '');
|
|
3174
|
+
// A setup refusal with no sentence for the person (#1965 review, round 3). The code covers several
|
|
3175
|
+
// causes — the parser's setup has not finished, or a check refused this project while its card shows
|
|
3176
|
+
// the ready state — so the sentence names none of them, only the card that shows what is left to do.
|
|
3177
|
+
// Never "check the folder": the folder is not what stopped it.
|
|
3178
|
+
if (code === 'setup-unavailable') {
|
|
3179
|
+
const product = WORKSPACE_APPS[projectSetupState?.templateId]?.displayName;
|
|
3180
|
+
return product
|
|
3181
|
+
? `${product} can’t create projects right now, so this project wasn’t created. Do what the ${product} card says, `
|
|
3182
|
+
+ 'waiting first if it is still setting up, then try again. If the card shows no problem and this keeps happening, use Report an issue.'
|
|
3183
|
+
: 'This project can’t be created right now. Try again in a moment; if this keeps happening, use Report an issue.';
|
|
3184
|
+
}
|
|
3029
3185
|
if (code === 'not-installed') return missingWorkspaceWorkflowMessage(projectSetupState?.templateId);
|
|
3030
3186
|
if (code === 'chat-provider-unavailable' || /sign in|provider .* unavailable|chat providers are not configured/i.test(raw)) {
|
|
3031
3187
|
return 'Sign in to Claude or Codex before starting this project in AI Chat. You can still create the project only.';
|
|
@@ -3677,14 +3833,25 @@
|
|
|
3677
3833
|
|
|
3678
3834
|
function teklaAdmissionMessage(error) {
|
|
3679
3835
|
const message = error?.message || String(error || '');
|
|
3836
|
+
// The server's copy-limit refusals (tekla-source-upload.ts / tekla-source-package.ts): sizes and counts.
|
|
3837
|
+
const TEKLA_COPY_LIMIT = /^Tekla (?:ZIP|folder upload|source package)\b[^.]*\bexceeds? (?:its|their) (?:limit|compressed byte limit|total byte limit)$/;
|
|
3680
3838
|
// #1849: reading without some catalogue files needs a newer AWARE; the server names the version.
|
|
3681
3839
|
const degradedAware = /needs AWARE (\d+\.\d+\.\d+) or newer/.exec(message);
|
|
3682
3840
|
if (degradedAware) return /could not check which AWARE/.test(message)
|
|
3683
3841
|
? `Reading a model without some of its catalogue files needs AWARE ${degradedAware[1]} or newer, and FloLess could not check which AWARE this computer has. Restart FloLess so it can check AWARE again, then choose the model again. Or add the missing files and read it with them. The source model was not changed.`
|
|
3684
3842
|
: `Reading a model without some of its catalogue files needs AWARE ${degradedAware[1]} or newer. Use Upgrade AWARE at the bottom of the window, then choose the model again. Or add the missing files and read it with them. The source model was not changed.`;
|
|
3843
|
+
// #1974: the server measured the model and names its size, the limit and what to do; show it as written.
|
|
3844
|
+
// The sentence is teklaModelTooLargeMessage's (server/tekla-model-size.ts); tekla-upload-ui.test.ts
|
|
3845
|
+
// drives this through that real function, so a reword there goes red here.
|
|
3846
|
+
if (/^This Tekla model is too large for Tekla Parser to read\. /.test(message)) return message;
|
|
3847
|
+
// The copy limits (file size, total size, file count) lump several causes, so one sentence names none;
|
|
3848
|
+
// choosing the same source again can never pass them.
|
|
3849
|
+
if (TEKLA_COPY_LIMIT.test(message)) return 'This Tekla source is larger than FloLess can copy for one read. Choose a smaller copy of the model, for example one with only the phases or areas you need. The source model was not changed.';
|
|
3685
3850
|
if (/No upload progress was detected for 30 seconds/i.test(message)) return 'No upload progress was detected for 30 seconds, so FloLess stopped this copy. No partial snapshot was saved, and the source ZIP was not changed.';
|
|
3686
3851
|
if (/upload made no progress for 2 minutes/i.test(message)) return 'The Tekla ZIP upload made no progress for 2 minutes, so FloLess stopped this copy. No partial snapshot was saved, and the source ZIP was not changed.';
|
|
3687
3852
|
if (/413|too large|payload too large/i.test(message)) return 'This Tekla ZIP is too large to copy in one read. Choose the model folder instead, or make a smaller ZIP and try again.';
|
|
3853
|
+
// Checked before the access branch below: its sentence mentions access, but signing in won't help.
|
|
3854
|
+
if (error?.code === 'access-renewal-unreachable') return message;
|
|
3688
3855
|
if (/401|403|sign.?in|unauthori[sz]ed|forbidden|access/i.test(message)) return 'FloLess could not confirm access for this read. Sign in again, then choose the Tekla source once more.';
|
|
3689
3856
|
if (/failed to fetch|network|browser could not copy|source copy failed/i.test(message)) return 'FloLess could not finish copying this Tekla source. Check the connection, then choose the source again.';
|
|
3690
3857
|
if (/layout|format|framing|integrity|verif|manifest|database/i.test(message)) return 'FloLess could not verify this Tekla source. Choose the model folder or ZIP again. The source model was not changed.';
|
|
@@ -3692,7 +3859,11 @@
|
|
|
3692
3859
|
}
|
|
3693
3860
|
function teklaAdmissionTitle(error) {
|
|
3694
3861
|
const message = error?.message || String(error || '');
|
|
3695
|
-
|
|
3862
|
+
const TEKLA_COPY_LIMIT = /^Tekla (?:ZIP|folder upload|source package)\b[^.]*\bexceeds? (?:its|their) (?:limit|compressed byte limit|total byte limit)$/; // as in teklaAdmissionMessage
|
|
3863
|
+
if (TEKLA_COPY_LIMIT.test(message)) return 'This Tekla source is too large for one read';
|
|
3864
|
+
const tooLarge = /^This Tekla model is too large for Tekla Parser to read\. .* Tekla Parser reads up to (\d+(?:\.\d)? [MG]B)\./.exec(message);
|
|
3865
|
+
return tooLarge ? `This Tekla model is over the ${tooLarge[1]} read limit`
|
|
3866
|
+
: /No upload progress was detected for 30 seconds/i.test(message) ? 'Tekla ZIP copy stopped'
|
|
3696
3867
|
: /needs AWARE \d+\.\d+\.\d+ or newer/.test(message) ? 'Update AWARE to read without catalogue files'
|
|
3697
3868
|
: /layout|format|framing/i.test(message)
|
|
3698
3869
|
? 'We can’t safely read this model yet' : 'Tekla source needs attention';
|
|
@@ -3783,7 +3954,26 @@
|
|
|
3783
3954
|
async function readReplacementSourceState(project) {
|
|
3784
3955
|
if (!project || current?.id !== project.id) return null;
|
|
3785
3956
|
const tekla = wsDescOf(project) === WORKSPACE_APPS['tekla-parser'];
|
|
3786
|
-
const
|
|
3957
|
+
const read = () => api(`/api/${tekla ? 'tekla' : 'revit'}-projects/${encodeURIComponent(project.id)}/source-state`);
|
|
3958
|
+
// source-state judges from the cached 15-minute access lease without renewing it, while the
|
|
3959
|
+
// upload route renews first. A lapsed copy answers canReplace:false, or refuses the read with 403
|
|
3960
|
+
// when no verified snapshot is stored yet; either would tell the person to sign in again. The
|
|
3961
|
+
// status route renews the lease, so renew once and ask again before calling access gone.
|
|
3962
|
+
let response = null;
|
|
3963
|
+
try { response = await read(); }
|
|
3964
|
+
catch (error) { if (error?.status !== 403) throw error; }
|
|
3965
|
+
if (response?.state?.canReplace !== true) {
|
|
3966
|
+
let renewal = null;
|
|
3967
|
+
try { renewal = await api('/api/license/status'); }
|
|
3968
|
+
catch (error) { console.warn('[workspaces] could not renew the access lease before a source read', error); }
|
|
3969
|
+
if (current?.id !== project.id) return null;
|
|
3970
|
+
if (!renewal || renewal.desktopAccess?.state === 'unavailable') {
|
|
3971
|
+
// `unavailable` covers several causes, so the sentence names none of them.
|
|
3972
|
+
throw Object.assign(new Error('FloLess could not renew this computer’s access just now, so nothing was read. Try again in a moment. If it keeps happening, restart FloLess.'),
|
|
3973
|
+
{ code: 'access-renewal-unreachable' });
|
|
3974
|
+
}
|
|
3975
|
+
response = await read();
|
|
3976
|
+
}
|
|
3787
3977
|
return current?.id === project.id ? response.state : null;
|
|
3788
3978
|
}
|
|
3789
3979
|
|
|
@@ -5249,6 +5439,9 @@
|
|
|
5249
5439
|
// (paintExports), and it never reads approvedAt: that field is compatibility metadata only, as
|
|
5250
5440
|
// the approvalState declaration above says.
|
|
5251
5441
|
const approvalDecisionLabel = (decision) => decision === 'approve' ? 'Approve this change' : 'Leave pending';
|
|
5442
|
+
// A whole-model review has one human sign-off in the footer, not a per-change selection.
|
|
5443
|
+
const approvalReviewDecisions = (review, decisions) => review.selective === false
|
|
5444
|
+
? Object.fromEntries((review.groups || []).map((group) => [group.id, 'approve'])) : decisions;
|
|
5252
5445
|
let modelContractSaveState = null;
|
|
5253
5446
|
window.addEventListener('message', (event) => {
|
|
5254
5447
|
const message = event.data;
|
|
@@ -5288,7 +5481,9 @@
|
|
|
5288
5481
|
$approvalReload.hidden = phase !== 'stale';
|
|
5289
5482
|
$approvalClose.hidden = !['approved', 'abandoned', 'recovery-close'].includes(phase);
|
|
5290
5483
|
$approvalConfirm.hidden = !['ready', 'abandoned'].includes(phase);
|
|
5291
|
-
|
|
5484
|
+
// Unlocking never re-enables a control the review blocked with a reason (nothing drawn, or a
|
|
5485
|
+
// refusal no new choice can fix): it stays disabled, and focus skips it.
|
|
5486
|
+
$approvalBody.querySelectorAll('[data-approval-decision],[data-approval-conflict],[data-approval-discard],[data-approval-open-audit]').forEach((node) => { node.disabled = locked || node.hasAttribute('data-blocked-reason'); });
|
|
5292
5487
|
if (phase === 'saving' || phase === 'comparing') {
|
|
5293
5488
|
const text = message || approvalPhaseText[phase];
|
|
5294
5489
|
$approvalBody.innerHTML = `<div class="approval-loading"><span class="rtn-spinner" aria-hidden="true"></span><span aria-hidden="true">${escapeHtml(text)}</span></div>`;
|
|
@@ -5303,11 +5498,121 @@
|
|
|
5303
5498
|
}
|
|
5304
5499
|
}
|
|
5305
5500
|
|
|
5501
|
+
// ── Open Tekla import findings (#1840) ──────────────────────────────────────────────────────
|
|
5502
|
+
// A Tekla copy can carry open Audit findings. Approval no longer refuses them late: the review
|
|
5503
|
+
// warns first, and approving the change IS the person's acceptance of them as stated assumptions
|
|
5504
|
+
// (the decision button says so). Nothing is preselected, so nothing can be approved by accident.
|
|
5505
|
+
// Group names and order are the Audit tab's own (web/revit-editor.js renderTeklaAudit).
|
|
5506
|
+
const IMPORT_FINDING_GROUP_LABELS = Object.freeze({
|
|
5507
|
+
'missing-source-files': 'Missing source files', 'not-shown': 'Not shown',
|
|
5508
|
+
'fit-not-confirmed': 'Fit not confirmed', 'shape-not-evaluated': 'Shape detail not evaluated',
|
|
5509
|
+
});
|
|
5510
|
+
// Refusals the server answers BEFORE anything is written for this operation. A question the person
|
|
5511
|
+
// answers by choosing again; nothing drawn and the unfixable ones lock Approve with the server's
|
|
5512
|
+
// sentence, because the same request can never succeed (no retry offer, no reconcile loop).
|
|
5513
|
+
const IMPORT_FINDINGS_QUESTION_CODES = ['import-findings-acceptance-required', 'import-findings-acceptance-stale'];
|
|
5514
|
+
const IMPORT_FINDINGS_UNFIXABLE_CODES = ['import-findings-acceptance-invalid', 'import-findings-unreadable'];
|
|
5515
|
+
const IMPORT_FINDINGS_REFUSAL_CODES = [...IMPORT_FINDINGS_QUESTION_CODES, 'tekla-nothing-drawn', ...IMPORT_FINDINGS_UNFIXABLE_CODES];
|
|
5516
|
+
function importFindingsCopy(findings) {
|
|
5517
|
+
const n = Number(findings && findings.open) || 0;
|
|
5518
|
+
const one = n === 1;
|
|
5519
|
+
const count = n.toLocaleString('en-US');
|
|
5520
|
+
const openPhrase = one ? '1 import finding is open' : `${count} import findings are open`;
|
|
5521
|
+
return {
|
|
5522
|
+
title: one ? '1 import finding is still open' : `${count} import findings are still open`,
|
|
5523
|
+
body: `FloLess could not fully check part of this Tekla model when it read it. You can leave the model pending, or approve it and record that you accepted ${one ? 'this finding' : 'these findings'} as stated assumptions. Either way, the Audit tab keeps listing ${one ? 'it' : 'them'}.`,
|
|
5524
|
+
// While Approve is locked, the warning offers only what is possible: leaving the model pending.
|
|
5525
|
+
blockedBody: `FloLess could not fully check part of this Tekla model when it read it. This copy cannot be approved as it is, so leave it pending. The Audit tab keeps listing the ${one ? 'finding' : 'findings'}.`,
|
|
5526
|
+
approve: `Approve with ${count} ${one ? 'finding' : 'findings'} accepted`,
|
|
5527
|
+
noneChosen: 'Nothing will be approved until you choose.',
|
|
5528
|
+
leave: `Nothing will be approved. The model stays pending: ${openPhrase}.`,
|
|
5529
|
+
accept: `The model will be approved with ${count} open import ${one ? 'finding' : 'findings'} accepted.`,
|
|
5530
|
+
left: `Nothing was approved. The model stays pending: ${openPhrase}.`,
|
|
5531
|
+
approved: (version) => `Approved${version ? ` as v${version}` : ''} with ${count} open import ${one ? 'finding' : 'findings'} accepted.`,
|
|
5532
|
+
};
|
|
5533
|
+
}
|
|
5534
|
+
/** The groups, only when they add up to the total the server sealed (never a partial breakdown). */
|
|
5535
|
+
function importFindingGroups(findings) {
|
|
5536
|
+
const groups = Array.isArray(findings && findings.groups) ? findings.groups.filter((group) => group && IMPORT_FINDING_GROUP_LABELS[group.key] && Number(group.count) > 0) : [];
|
|
5537
|
+
return groups.reduce((sum, group) => sum + Number(group.count), 0) === Number(findings && findings.open) ? groups : [];
|
|
5538
|
+
}
|
|
5539
|
+
function importFindingsWarningHtml(findings, blocked = false) {
|
|
5540
|
+
const copy = importFindingsCopy(findings);
|
|
5541
|
+
const groups = importFindingGroups(findings);
|
|
5542
|
+
const list = groups.length
|
|
5543
|
+
? `<ul class="approval-findings-list" aria-label="Open findings by kind">${groups.map((group) => `<li><span>${escapeHtml(IMPORT_FINDING_GROUP_LABELS[group.key])}</span><span class="approval-findings-count">${escapeHtml(Number(group.count).toLocaleString('en-US'))}</span></li>`).join('')}</ul>`
|
|
5544
|
+
: '';
|
|
5545
|
+
return '<section class="approval-notice approval-notice-warn approval-findings" aria-labelledby="approval-findings-title" aria-describedby="approval-findings-meaning">'
|
|
5546
|
+
+ `<div class="approval-findings-head"><b id="approval-findings-title">${escapeHtml(copy.title)}</b>`
|
|
5547
|
+
+ '<button type="button" class="btn-mini" data-approval-open-audit data-command-id="shell.approval-open-audit" data-tip="Close this review and show the findings in the Audit tab. Nothing is approved.">Open Audit tab</button></div>'
|
|
5548
|
+
+ `<p id="approval-findings-meaning">${escapeHtml(blocked ? copy.blockedBody : copy.body)}</p>${list}</section>`;
|
|
5549
|
+
}
|
|
5550
|
+
const NOTHING_DRAWN_BLOCKED = 'Nothing in this copy could be drawn in 3D, so it cannot be approved yet.';
|
|
5551
|
+
// An unfixable refusal whose server sentence says nothing beyond "Nothing was approved.": the lock
|
|
5552
|
+
// still needs a reason, true for every unfixable code, and never a question.
|
|
5553
|
+
const IMPORT_FINDINGS_UNFIXABLE_FALLBACK = 'FloLess cannot approve this copy as it is.';
|
|
5554
|
+
// After an unfixable refusal nothing in this review can change the answer, and reopening it gives the
|
|
5555
|
+
// same stop, so the notice offers only what is true: close it, and the model stays pending.
|
|
5556
|
+
const APPROVAL_LEAVE_PENDING_NOTE = 'Close this review to leave the model pending.';
|
|
5557
|
+
// A move-forward overlap choice the render disables follows its linked change's decision; the
|
|
5558
|
+
// Instructor says so, and the phase code keeps it disabled (it carries a blocked reason).
|
|
5559
|
+
const APPROVAL_CONFLICT_BLOCKED = 'This choice follows the decision for its linked change.';
|
|
5560
|
+
/**
|
|
5561
|
+
* One decision button. Each is its own Instructor command: approving a copy with open import
|
|
5562
|
+
* findings IS accepting them, so that button never narrates as a plain "Approve".
|
|
5563
|
+
*/
|
|
5564
|
+
function approvalDecisionButtonHtml(group, decision, picked, findingsCopy, blockedReason) {
|
|
5565
|
+
// The command id half is a literal in each branch; only the instance after "#" is data.
|
|
5566
|
+
const carrier = decision === 'leave-pending' ? `data-command-id="shell.approval-decision-leave-pending#${escapeAttr(group.id)}"`
|
|
5567
|
+
: findingsCopy ? `data-command-id="shell.approval-decision-accept-findings#${escapeAttr(group.id)}"`
|
|
5568
|
+
: `data-command-id="shell.approval-decision-approve#${escapeAttr(group.id)}"`;
|
|
5569
|
+
const blocked = decision === 'approve' && blockedReason
|
|
5570
|
+
? ` disabled data-tip="${escapeAttr(blockedReason)}" data-blocked-reason="${escapeAttr(blockedReason)}"` : '';
|
|
5571
|
+
return `<button type="button" role="radio" aria-checked="${String(picked === decision)}" class="${picked === decision ? 'selected' : ''}" data-approval-decision="${decision}" data-group-id="${escapeAttr(group.id)}" ${carrier} data-command-instance-label="${escapeAttr(String(group.headline || group.category || 'Change'))}"${blocked}>`
|
|
5572
|
+
+ `${escapeHtml(decision === 'approve' && findingsCopy ? findingsCopy.approve : approvalDecisionLabel(decision))}</button>`;
|
|
5573
|
+
}
|
|
5574
|
+
/** The kept hard stop the review can show in advance: a copy with nothing drawn in 3D. */
|
|
5575
|
+
function nothingDrawnHtml(nothingDrawn) {
|
|
5576
|
+
return '<section class="approval-notice approval-notice-warn approval-findings" aria-labelledby="approval-nothing-drawn-title">'
|
|
5577
|
+
+ '<div class="approval-findings-head"><b id="approval-nothing-drawn-title">Nothing to approve yet</b>'
|
|
5578
|
+
+ '<button type="button" class="btn-mini" data-approval-open-audit data-command-id="shell.approval-open-audit" data-tip="Close this review and show the findings in the Audit tab. Nothing is approved.">Open Audit tab</button></div>'
|
|
5579
|
+
+ `<p>${escapeHtml(String(nothingDrawn.error))}</p></section>`;
|
|
5580
|
+
}
|
|
5581
|
+
/**
|
|
5582
|
+
* The other kept hard stop the review shows in advance: a copy whose open import findings this
|
|
5583
|
+
* version of FloLess cannot read, so they can be neither shown nor accepted (the server's sentence).
|
|
5584
|
+
*/
|
|
5585
|
+
function unreadableFindingsHtml(unreadable) {
|
|
5586
|
+
return '<section class="approval-notice approval-notice-warn approval-findings" aria-labelledby="approval-unreadable-findings-title">'
|
|
5587
|
+
+ '<div class="approval-findings-head"><b id="approval-unreadable-findings-title">Import findings cannot be read</b></div>'
|
|
5588
|
+
+ `<p>${escapeHtml(approvalRefusalDetail(unreadable.error))}</p></section>`;
|
|
5589
|
+
}
|
|
5590
|
+
/** A server sentence shown under a bold "Nothing was approved." without saying it twice. */
|
|
5591
|
+
const approvalRefusalDetail = (sentence) => String(sentence || '').replace(/\s*Nothing was approved\.\s*/g, ' ').trim();
|
|
5592
|
+
/** Refusals whose sentence the server writes for people. Any other error text (a bake or compile
|
|
5593
|
+
* message, an internal conflict) stays behind the generic copy instead of reaching the screen. */
|
|
5594
|
+
const APPROVAL_REASON_CODES = ['tekla-approval-refused', 'grant-unavailable', ...IMPORT_FINDINGS_REFUSAL_CODES];
|
|
5595
|
+
function knownApprovalFailureReason(error) {
|
|
5596
|
+
const body = error && error.body;
|
|
5597
|
+
if (!body || typeof body.error !== 'string' || !body.error.trim()) return '';
|
|
5598
|
+
return APPROVAL_REASON_CODES.includes(body.code) ? body.error.trim() : '';
|
|
5599
|
+
}
|
|
5600
|
+
|
|
5306
5601
|
function renderApprovalReview() {
|
|
5307
5602
|
if (!approvalDialogState) return;
|
|
5308
5603
|
const review = approvalDialogState.review;
|
|
5309
5604
|
const groups = Array.isArray(review.groups) ? review.groups : [];
|
|
5310
|
-
const
|
|
5605
|
+
const findings = review.importFindings && Number(review.importFindings.open) > 0 ? review.importFindings : null;
|
|
5606
|
+
const findingsCopy = findings ? importFindingsCopy(findings) : null;
|
|
5607
|
+
const nothingDrawn = review.nothingDrawn && typeof review.nothingDrawn.error === 'string' ? review.nothingDrawn : null;
|
|
5608
|
+
const unreadable = !nothingDrawn && review.unreadableFindings && typeof review.unreadableFindings.error === 'string'
|
|
5609
|
+
? review.unreadableFindings : null;
|
|
5610
|
+
// Why Approve is unavailable, when it is: nothing drawn, findings this build cannot read (both
|
|
5611
|
+
// served in advance), or a refusal no new choice can fix.
|
|
5612
|
+
const blockedReason = nothingDrawn ? NOTHING_DRAWN_BLOCKED
|
|
5613
|
+
: unreadable ? approvalRefusalDetail(unreadable.error) || IMPORT_FINDINGS_UNFIXABLE_FALLBACK
|
|
5614
|
+
: approvalDialogState.unapprovable || '';
|
|
5615
|
+
const decisions = approvalReviewDecisions(review, approvalDialogState.decisions);
|
|
5311
5616
|
const conflicts = review.moveForward && Array.isArray(review.moveForward.conflicts) ? review.moveForward.conflicts : [];
|
|
5312
5617
|
const conflictDecisions = approvalDialogState.conflicts || {};
|
|
5313
5618
|
$approvalSub.textContent = review.moveForward
|
|
@@ -5322,9 +5627,9 @@
|
|
|
5322
5627
|
return `<section class="approval-group"><div class="approval-group-head"><div>`
|
|
5323
5628
|
+ `<span class="approval-risk ${escapeAttr(String(group.risk || 'low'))}">${escapeHtml(String(group.risk || 'low'))}</span><b>${escapeHtml(String(group.headline || group.category || 'Change'))}</b></div>`
|
|
5324
5629
|
+ `<span>${escapeHtml(String(group.location || ''))}</span></div><p>${escapeHtml(String(group.detail || ''))}</p>`
|
|
5325
|
-
+ `<div class="approval-decisions" role="radiogroup" aria-label="Decision for ${escapeAttr(String(group.headline || 'change'))}">`
|
|
5326
|
-
+ ['approve', 'leave-pending'].map((decision) =>
|
|
5327
|
-
+
|
|
5630
|
+
+ (review.selective === false ? '<p class="approval-whole-model">This review approves the entire model as one version. To keep working without approving, cancel this review.</p>' : `<div class="approval-decisions" role="radiogroup" aria-label="Decision for ${escapeAttr(String(group.headline || 'change'))}">`
|
|
5631
|
+
+ ['approve', 'leave-pending'].map((decision) => approvalDecisionButtonHtml(group, decision, picked, findingsCopy, blockedReason)).join('')
|
|
5632
|
+
+ '</div>') + `${facts}${discard}</section>`;
|
|
5328
5633
|
}).join('');
|
|
5329
5634
|
const requiredConflictDecision = (conflict) => {
|
|
5330
5635
|
const linked = (conflict.groupIds || []).map((id) => decisions[id]);
|
|
@@ -5332,26 +5637,45 @@
|
|
|
5332
5637
|
if (!linked.length || linked.every((value) => value === 'leave-pending')) return 'keep-latest-pending';
|
|
5333
5638
|
return null;
|
|
5334
5639
|
};
|
|
5640
|
+
const conflictBlocked = ` disabled data-tip="${escapeAttr(APPROVAL_CONFLICT_BLOCKED)}" data-blocked-reason="${escapeAttr(APPROVAL_CONFLICT_BLOCKED)}"`;
|
|
5335
5641
|
const conflictHtml = conflicts.map((conflict) => {
|
|
5336
5642
|
const picked = conflictDecisions[conflict.id];
|
|
5337
5643
|
const required = requiredConflictDecision(conflict);
|
|
5338
5644
|
return `<section class="approval-group approval-conflict"><div class="approval-group-head"><div><span class="approval-risk high">overlap</span><b>${escapeHtml(conflict.headline)}</b></div><span>${escapeHtml(conflict.path)}</span></div><p>${escapeHtml(conflict.detail)}</p>`
|
|
5339
5645
|
+ `<div class="approval-decisions" role="radiogroup" aria-label="Overlap decision for ${escapeAttr(conflict.path)}">`
|
|
5340
|
-
+ `<button type="button" role="radio" aria-checked="${String(picked === 'use-draft')}" class="${picked === 'use-draft' ? 'selected' : ''}" data-approval-conflict="use-draft" data-conflict-id="${escapeAttr(conflict.id)}"${required !== 'use-draft' ?
|
|
5341
|
-
+ `<button type="button" role="radio" aria-checked="${String(picked === 'keep-latest-pending')}" class="${picked === 'keep-latest-pending' ? 'selected' : ''}" data-approval-conflict="keep-latest-pending" data-conflict-id="${escapeAttr(conflict.id)}"${required !== 'keep-latest-pending' ?
|
|
5646
|
+
+ `<button type="button" role="radio" aria-checked="${String(picked === 'use-draft')}" class="${picked === 'use-draft' ? 'selected' : ''}" data-approval-conflict="use-draft" data-conflict-id="${escapeAttr(conflict.id)}"${required !== 'use-draft' ? conflictBlocked : ''}>Use my DRAFT value</button>`
|
|
5647
|
+
+ `<button type="button" role="radio" aria-checked="${String(picked === 'keep-latest-pending')}" class="${picked === 'keep-latest-pending' ? 'selected' : ''}" data-approval-conflict="keep-latest-pending" data-conflict-id="${escapeAttr(conflict.id)}"${required !== 'keep-latest-pending' ? conflictBlocked : ''}>Keep v${escapeHtml(String(review.moveForward.toVersion))} · save mine as pending</button></div></section>`;
|
|
5342
5648
|
}).join('');
|
|
5343
|
-
|
|
5649
|
+
// A refusal the server explained stays on screen across re-renders (every decision click rebuilds
|
|
5650
|
+
// the body), and the findings warning sits above the change it is about. An unfixable one says
|
|
5651
|
+
// its lock reason and that closing the review leaves the model pending, since nothing in this
|
|
5652
|
+
// review can change the answer.
|
|
5653
|
+
const unapprovable = approvalDialogState.unapprovable || '';
|
|
5654
|
+
const refusalHtml = approvalDialogState.refusal || unapprovable
|
|
5655
|
+
? `<div class="approval-notice approval-notice-error" role="alert"><b>Nothing was approved.</b> ${escapeHtml(unapprovable || approvalRefusalDetail(approvalDialogState.refusal))}${unapprovable ? ` ${escapeHtml(APPROVAL_LEAVE_PENDING_NOTE)}` : ''}</div>`
|
|
5656
|
+
: '';
|
|
5657
|
+
const findingsHtml = nothingDrawn ? nothingDrawnHtml(nothingDrawn) : unreadable ? unreadableFindingsHtml(unreadable)
|
|
5658
|
+
: findings ? importFindingsWarningHtml(findings, !!blockedReason) : '';
|
|
5659
|
+
$approvalBody.innerHTML = refusalHtml + findingsHtml + (groupHtml + conflictHtml || '<div class="approval-empty">No pending changes. The working copy already matches the latest approved version.</div>');
|
|
5344
5660
|
const values = Object.values(decisions);
|
|
5345
5661
|
const approved = values.filter((value) => value === 'approve').length;
|
|
5346
5662
|
const remaining = groups.length - values.length;
|
|
5347
5663
|
const remainingConflicts = conflicts.filter((conflict) => conflictDecisions[conflict.id] !== requiredConflictDecision(conflict)).length;
|
|
5348
|
-
$approvalCounts.textContent =
|
|
5664
|
+
$approvalCounts.textContent = blockedReason ? 'Nothing will be approved. The model stays pending.'
|
|
5665
|
+
: findingsCopy && values.length === 0 ? findingsCopy.noneChosen
|
|
5666
|
+
: findingsCopy && remaining === 0 && remainingConflicts === 0 ? (approved ? findingsCopy.accept : findingsCopy.leave)
|
|
5667
|
+
: remaining > 0 ? `${values.length} of ${groups.length} changes decided · ${remaining} still ${remaining === 1 ? 'needs' : 'need'} review`
|
|
5349
5668
|
: remainingConflicts > 0 ? `${remainingConflicts} overlap${remainingConflicts === 1 ? '' : 's'} still need a decision`
|
|
5350
5669
|
: approved ? `${approved} change${approved === 1 ? '' : 's'} will be approved · ${groups.length - approved} left pending`
|
|
5351
5670
|
: groups.length ? 'All changes will remain pending' : 'Nothing needs approval';
|
|
5352
|
-
$approvalConfirm.setAttribute('data-command-id', 'shell.approval-confirm');
|
|
5353
|
-
$approvalConfirm.
|
|
5354
|
-
$approvalConfirm.
|
|
5671
|
+
$approvalConfirm.setAttribute('data-command-id', findingsCopy ? 'shell.approval-confirm-with-findings' : 'shell.approval-confirm');
|
|
5672
|
+
if (blockedReason) $approvalConfirm.setAttribute('data-blocked-reason', blockedReason);
|
|
5673
|
+
else $approvalConfirm.removeAttribute('data-blocked-reason');
|
|
5674
|
+
// A whole-model review (#1990) has its one sign-off here; with open findings, this IS the acceptance (#1840).
|
|
5675
|
+
$approvalConfirm.textContent = approved && findingsCopy ? findingsCopy.approve
|
|
5676
|
+
: review.selective === false && groups.length ? 'Approve entire model'
|
|
5677
|
+
: approved ? `Approve ${approved} change${approved === 1 ? '' : 's'}` : 'Approve selected changes';
|
|
5678
|
+
$approvalConfirm.disabled = remaining !== 0 || remainingConflicts !== 0 || approved === 0 || groups.length === 0 || approvalDialogState.stale || !!blockedReason;
|
|
5355
5679
|
}
|
|
5356
5680
|
|
|
5357
5681
|
function closeApprovalReview() {
|
|
@@ -5361,7 +5685,17 @@
|
|
|
5361
5685
|
approvalDialogState = null;
|
|
5362
5686
|
$approvalModal.classList.remove('show');
|
|
5363
5687
|
$approvalModal.removeAttribute('aria-busy');
|
|
5688
|
+
// The confirm button outlives this review: a reason it was blocked for must not follow it into
|
|
5689
|
+
// the next project's dialog, where the Instructor would read it out.
|
|
5690
|
+
$approvalConfirm.removeAttribute('data-blocked-reason');
|
|
5364
5691
|
if (st && st.returnFocus && st.returnFocus.isConnected) st.returnFocus.focus();
|
|
5692
|
+
// #1840: an explicit Leave pending on a copy with open findings ends with its reason, so the
|
|
5693
|
+
// person is told why nothing was approved after the dialog has gone.
|
|
5694
|
+
const findings = st && st.phase === 'ready' && st.review && st.review.importFindings;
|
|
5695
|
+
if (findings && Number(findings.open) > 0 && Object.values(st.decisions || {}).includes('leave-pending')
|
|
5696
|
+
&& !Object.values(st.decisions || {}).includes('approve')) {
|
|
5697
|
+
showToast(importFindingsCopy(findings).left, 'info');
|
|
5698
|
+
}
|
|
5365
5699
|
}
|
|
5366
5700
|
|
|
5367
5701
|
const approvalOperationStoragePrefix = 'floless:approval-operation:v1';
|
|
@@ -5429,17 +5763,24 @@
|
|
|
5429
5763
|
await refreshApprovalState(project.id);
|
|
5430
5764
|
const pending = Number.isInteger(Number(res && res.pendingCount)) ? Number(res.pendingCount) : approvalState.pendingCount;
|
|
5431
5765
|
const saved = res && res.savedWorkCheckpoint;
|
|
5432
|
-
|
|
5766
|
+
// #1840: the outcome says what the server recorded. An approval that accepted open import
|
|
5767
|
+
// findings is never announced as a plain "Approved".
|
|
5768
|
+
const accepted = res && res.version && res.version.approval && res.version.approval.acceptedImportFindings;
|
|
5769
|
+
const headline = accepted ? importFindingsCopy(accepted).approved(Number.isInteger(n) ? n : null)
|
|
5770
|
+
: `Approved${Number.isInteger(n) ? ` as v${n}` : ''}.`;
|
|
5771
|
+
showToast(`${headline} ${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');
|
|
5433
5772
|
track('workspace_project_approved', { app: project.app });
|
|
5434
5773
|
if (bridge.markWorkspaceApproved && wsDescOf(project)?.docGuide) bridge.markWorkspaceApproved(project.app);
|
|
5435
5774
|
if (!$wsExports.hidden) safeRenderExports('after approving this version');
|
|
5436
5775
|
if (!$wsHistory.hidden) await renderHistory();
|
|
5437
5776
|
if (!approvalDialogState) return;
|
|
5438
5777
|
$approvalImpact.textContent = pending
|
|
5439
|
-
? `${pending} change${pending === 1 ? '' : 's'}
|
|
5778
|
+
? `${pending} change${pending === 1 ? ' remains' : 's remain'} pending${saved ? ' in Saved work' : ''}.`
|
|
5440
5779
|
: 'No changes remain pending.';
|
|
5441
|
-
|
|
5442
|
-
|
|
5780
|
+
// The footer described the decision ("…will be approved…"); the decision has happened.
|
|
5781
|
+
$approvalCounts.textContent = '';
|
|
5782
|
+
$approvalBody.innerHTML = `<div class="approval-notice approval-notice-success"><b>${escapeHtml(headline)}</b> The approved model and compiled workflow are ready.${accepted ? ' The findings stay listed in the Audit tab.' : ''}</div>`;
|
|
5783
|
+
setApprovalPhase('approved', accepted ? headline : `Approved${Number.isInteger(n) ? ` as v${n}` : ''}`);
|
|
5443
5784
|
$approvalClose.focus();
|
|
5444
5785
|
}
|
|
5445
5786
|
|
|
@@ -5467,7 +5808,11 @@
|
|
|
5467
5808
|
$approvalClose.focus();
|
|
5468
5809
|
}
|
|
5469
5810
|
|
|
5470
|
-
|
|
5811
|
+
// `reason` is the server's own sentence when the failed request stated one (#1840). On this path,
|
|
5812
|
+
// "Nothing was approved" is said because the reconcile answered `abandoned` (the operation was
|
|
5813
|
+
// retired with no committed row); the reason says WHY, instead of generic recovery copy. (A refusal
|
|
5814
|
+
// made before any write says it in the review itself; see confirmApprovalReview.)
|
|
5815
|
+
function showAbandonedApprovalRecovery(project, reason = '') {
|
|
5471
5816
|
const st = approvalDialogState;
|
|
5472
5817
|
if (!st) return;
|
|
5473
5818
|
rememberApprovalOperation(project, null);
|
|
@@ -5479,8 +5824,10 @@
|
|
|
5479
5824
|
$approvalSub.textContent = 'The previous approval attempt ended safely.';
|
|
5480
5825
|
$approvalImpact.textContent = '';
|
|
5481
5826
|
$approvalCounts.textContent = '';
|
|
5482
|
-
|
|
5827
|
+
const detail = approvalRefusalDetail(reason);
|
|
5828
|
+
$approvalBody.innerHTML = `<div class="approval-notice"><b>Nothing was approved.</b> ${detail ? `${escapeHtml(detail)} ` : ''}FloLess restored your working copy. That approval attempt is finished and cannot be retried.</div>`;
|
|
5483
5829
|
$approvalConfirm.setAttribute('data-command-id', 'shell.approval-start-new-review');
|
|
5830
|
+
$approvalConfirm.removeAttribute('data-blocked-reason');
|
|
5484
5831
|
$approvalConfirm.textContent = 'Start a new review';
|
|
5485
5832
|
$approvalConfirm.disabled = false;
|
|
5486
5833
|
setApprovalPhase('abandoned');
|
|
@@ -5512,6 +5859,8 @@
|
|
|
5512
5859
|
$approvalImpact.textContent = '';
|
|
5513
5860
|
$approvalCounts.textContent = '';
|
|
5514
5861
|
$approvalConfirm.disabled = true;
|
|
5862
|
+
// A fresh dialog starts with no blocked reason; the review's own render sets one if it needs it.
|
|
5863
|
+
$approvalConfirm.removeAttribute('data-blocked-reason');
|
|
5515
5864
|
approvalDialogState = { projectId: project.id, review: { groups: [] }, decisions: {}, conflicts: {}, returnFocus: document.activeElement, stale: false, phase: 'comparing' };
|
|
5516
5865
|
const dialogState = approvalDialogState;
|
|
5517
5866
|
setApprovalPhase('comparing');
|
|
@@ -5590,7 +5939,7 @@
|
|
|
5590
5939
|
$approvalRetry.focus();
|
|
5591
5940
|
} else {
|
|
5592
5941
|
setApprovalPhase('ready');
|
|
5593
|
-
($approvalBody.querySelector('[data-approval-decision]') || $approvalConfirm).focus();
|
|
5942
|
+
($approvalBody.querySelector('[data-approval-decision]:not([disabled])') || $approvalConfirm).focus();
|
|
5594
5943
|
}
|
|
5595
5944
|
} catch (error) {
|
|
5596
5945
|
if (approvalDialogState !== dialogState) return;
|
|
@@ -5608,19 +5957,49 @@
|
|
|
5608
5957
|
const st = approvalDialogState;
|
|
5609
5958
|
if (!st || $approvalConfirm.disabled || !current || current.id !== st.projectId) return;
|
|
5610
5959
|
const project = current;
|
|
5960
|
+
st.decisions = approvalReviewDecisions(st.review, st.decisions);
|
|
5611
5961
|
const decisionSnapshot = { decisions: { ...st.decisions }, conflicts: { ...st.conflicts } };
|
|
5612
5962
|
const { operationId, operationToken } = ensureApprovalOperationPair(st);
|
|
5613
5963
|
rememberApprovalOperation(project, { projectId: project.id, appId: project.app, operationId, operationToken,
|
|
5614
5964
|
reviewId: st.review.reviewId, decisions: decisionSnapshot.decisions, conflicts: decisionSnapshot.conflicts });
|
|
5965
|
+
// #1840: choosing "Approve with N findings accepted" IS the acceptance. It names exactly the
|
|
5966
|
+
// contract and audit the review served (never a remembered or derived value).
|
|
5967
|
+
const findings = st.review.importFindings;
|
|
5968
|
+
const acceptOpenImportFindings = findings && Number(findings.open) > 0 && Object.values(st.decisions).includes('approve')
|
|
5969
|
+
? { contractHash: findings.contractHash, digest: findings.digest, open: findings.open } : null;
|
|
5615
5970
|
setApprovalPhase('approving');
|
|
5616
5971
|
$approvalConfirm.disabled = true;
|
|
5972
|
+
st.refusal = null;
|
|
5617
5973
|
try {
|
|
5618
5974
|
const res = await api(`/api/contract/${encodeURIComponent(project.app)}/approve?project=${encodeURIComponent(project.id)}`, {
|
|
5619
|
-
method: 'POST', body: JSON.stringify({ mode: st.review.mode || 'head', reviewId: st.review.reviewId, decisions: st.decisions, conflicts: st.conflicts, claimedChannel: 'browser', operationId, operationToken
|
|
5975
|
+
method: 'POST', body: JSON.stringify({ mode: st.review.mode || 'head', reviewId: st.review.reviewId, decisions: st.decisions, conflicts: st.conflicts, claimedChannel: 'browser', operationId, operationToken,
|
|
5976
|
+
...(acceptOpenImportFindings ? { acceptOpenImportFindings } : {}) }),
|
|
5620
5977
|
});
|
|
5621
5978
|
await finishApprovalSuccess(res, project);
|
|
5622
5979
|
} catch (error) {
|
|
5623
|
-
if (approvalDialogState && error && error.body && error.body.code
|
|
5980
|
+
if (approvalDialogState && error && error.body && IMPORT_FINDINGS_REFUSAL_CODES.includes(error.body.code)) {
|
|
5981
|
+
// Refused BEFORE anything durable was written for this operation (no claim, no recovery), so it
|
|
5982
|
+
// is never a retry. Forget the operation pair, clear the decision, re-bind the warning to the
|
|
5983
|
+
// findings of the copy that would actually be approved, and keep the reason on screen.
|
|
5984
|
+
rememberApprovalOperation(project, null);
|
|
5985
|
+
st.operationId = null;
|
|
5986
|
+
st.operationToken = null;
|
|
5987
|
+
st.decisions = {};
|
|
5988
|
+
st.conflicts = {};
|
|
5989
|
+
if (error.body.importFindings && Number(error.body.importFindings.open) > 0) st.review.importFindings = error.body.importFindings;
|
|
5990
|
+
// Nothing drawn is not a question: its own notice replaces the warning and locks Approve.
|
|
5991
|
+
if (error.body.code === 'tekla-nothing-drawn') st.review.nothingDrawn = { error: String(error.body.error || '') };
|
|
5992
|
+
else if (IMPORT_FINDINGS_UNFIXABLE_CODES.includes(error.body.code)) {
|
|
5993
|
+
// An unfixable refusal is not a question either: any choice would be refused again, so
|
|
5994
|
+
// Approve is locked BEFORE the render, keyed on the code (never on whether the sentence
|
|
5995
|
+
// happens to say more than "Nothing was approved."), and nothing offers to retry it.
|
|
5996
|
+
st.refusal = String(error.body.error || '').trim() || IMPORT_FINDINGS_UNFIXABLE_FALLBACK;
|
|
5997
|
+
st.unapprovable = approvalRefusalDetail(st.refusal) || IMPORT_FINDINGS_UNFIXABLE_FALLBACK;
|
|
5998
|
+
} else st.refusal = error.body.error || 'The import findings need your decision before approval.';
|
|
5999
|
+
renderApprovalReview();
|
|
6000
|
+
setApprovalPhase('ready', `Nothing was approved. ${st.unapprovable ? `${st.unapprovable} ${APPROVAL_LEAVE_PENDING_NOTE}` : approvalRefusalDetail(error.body.error)}`);
|
|
6001
|
+
($approvalBody.querySelector('[data-approval-decision]:not([disabled])') || $approvalDialog).focus();
|
|
6002
|
+
} else if (approvalDialogState && error && error.body && error.body.code === 'approval-review-stale') {
|
|
5624
6003
|
rememberApprovalOperation(project, null);
|
|
5625
6004
|
st.operationId = null;
|
|
5626
6005
|
st.operationToken = null;
|
|
@@ -5636,7 +6015,7 @@
|
|
|
5636
6015
|
return;
|
|
5637
6016
|
}
|
|
5638
6017
|
if (approvalRecoveryDisposition(recovered) === 'abandoned') {
|
|
5639
|
-
showAbandonedApprovalRecovery(project);
|
|
6018
|
+
showAbandonedApprovalRecovery(project, knownApprovalFailureReason(error));
|
|
5640
6019
|
return;
|
|
5641
6020
|
}
|
|
5642
6021
|
if (approvalRecoveryDisposition(recovered) === 'locked') {
|
|
@@ -5664,14 +6043,14 @@
|
|
|
5664
6043
|
try {
|
|
5665
6044
|
const review = await api(`/api/projects/${encodeURIComponent(st.projectId)}/approval-review`);
|
|
5666
6045
|
if (!approvalDialogState || approvalDialogState !== st) return;
|
|
5667
|
-
st.review = review; st.decisions = {}; st.conflicts = {}; st.stale = false;
|
|
6046
|
+
st.review = review; st.decisions = {}; st.conflicts = {}; st.stale = false; st.refusal = null; st.unapprovable = '';
|
|
5668
6047
|
st.operationId = null;
|
|
5669
6048
|
st.operationToken = null;
|
|
5670
6049
|
rememberApprovalOperation(project, null);
|
|
5671
6050
|
$approvalImpact.textContent = '';
|
|
5672
6051
|
renderApprovalReview();
|
|
5673
6052
|
setApprovalPhase('ready');
|
|
5674
|
-
($approvalBody.querySelector('[data-approval-decision]') || $approvalConfirm).focus();
|
|
6053
|
+
($approvalBody.querySelector('[data-approval-decision]:not([disabled])') || $approvalConfirm).focus();
|
|
5675
6054
|
} catch (error) {
|
|
5676
6055
|
$approvalImpact.textContent = (error && error.message) || 'Could not reload the current review.';
|
|
5677
6056
|
setApprovalPhase('stale', 'The current review could not be loaded.');
|
|
@@ -5724,6 +6103,18 @@
|
|
|
5724
6103
|
if ((conflict.groupIds || []).some((id) => id === group.id)) delete approvalDialogState.conflicts[conflict.id];
|
|
5725
6104
|
}
|
|
5726
6105
|
renderApprovalReview();
|
|
6106
|
+
// The re-render replaced the clicked button; without this, focus fell to <body> and Esc and the
|
|
6107
|
+
// dialog's Tab trap (both on the modal) stopped working after a keyboard decision.
|
|
6108
|
+
const again = $approvalBody.querySelector(`[data-approval-decision="${CSS.escape(decision.dataset.approvalDecision)}"][data-group-id="${CSS.escape(group.id)}"]`);
|
|
6109
|
+
if (again) again.focus();
|
|
6110
|
+
return;
|
|
6111
|
+
}
|
|
6112
|
+
const openAudit = event.target.closest('[data-approval-open-audit]');
|
|
6113
|
+
if (openAudit && approvalDialogState && approvalDismissible(approvalDialogState.phase)) {
|
|
6114
|
+
// #1840: show the findings themselves. Nothing is approved; the review can be reopened.
|
|
6115
|
+
closeApprovalReview();
|
|
6116
|
+
chooseStep('model');
|
|
6117
|
+
if (window.flolessLeftPane && typeof window.flolessLeftPane.showModelTab === 'function') window.flolessLeftPane.showModelTab('audit');
|
|
5727
6118
|
return;
|
|
5728
6119
|
}
|
|
5729
6120
|
const conflict = event.target.closest('[data-approval-conflict]');
|
|
@@ -10621,7 +11012,9 @@
|
|
|
10621
11012
|
applyStageGating();
|
|
10622
11013
|
return;
|
|
10623
11014
|
}
|
|
10624
|
-
|
|
11015
|
+
// A read whose discard record cannot be read (#1874) is decided on in Requests, not here: this card's
|
|
11016
|
+
// Review/Confirm/Discard would act on a read nobody can yet say is live.
|
|
11017
|
+
const mine = reqs.filter((r) => r && r.type === 'revision-read' && r.project === proj.id && !r.discardRecordUnreadable);
|
|
10625
11018
|
// One project can retain an old failed request after the user follows its recovery instruction and
|
|
10626
11019
|
// attaches the set again. The request list is durable oldest-first; the newest lifecycle is the one
|
|
10627
11020
|
// this card must follow. Status priority hid the retry behind the old failure and stopped this poll.
|
|
@@ -11006,6 +11399,93 @@
|
|
|
11006
11399
|
try { const s = JSON.stringify(v); return s.length > 60 ? s.slice(0, 57) + '…' : s; } catch { return '…'; }
|
|
11007
11400
|
};
|
|
11008
11401
|
|
|
11402
|
+
/*
|
|
11403
|
+
* A MEMBER'S END, said the way a detailer reads it (#1903).
|
|
11404
|
+
*
|
|
11405
|
+
* A `member-changed` `from`/`to` field is a whole work point `{x, y, z}`, and `shortVal` of that is a
|
|
11406
|
+
* 57-character JSON cut — `{"x":1234.5,"y":…` — on a consent screen. Since #1903 the commonest such row
|
|
11407
|
+
* is a height the PERSON answered on a question card for a member already in the model, proposed here
|
|
11408
|
+
* rather than written straight in. So an endpoint field is drawn as its own lines: the height, and x and
|
|
11409
|
+
* y too whenever they move (accepting the row moves the whole point, so a moved point is never hidden
|
|
11410
|
+
* behind its height). Values are in the project's display units through the shared helper, loaded when
|
|
11411
|
+
* the review opens; until then they read in millimetres rather than not at all.
|
|
11412
|
+
*/
|
|
11413
|
+
let reviewUnitsModule = null;
|
|
11414
|
+
// Preloaded once, here, rather than awaited inside `openRevisionReview`: that function is lifted whole
|
|
11415
|
+
// into test harnesses, where a free name it assigns would not exist. A review opened before this
|
|
11416
|
+
// settles (a fresh page, a slow disk) reads in millimetres, never in nothing.
|
|
11417
|
+
import('./display-units.js').then((m) => { reviewUnitsModule = m; }, () => {});
|
|
11418
|
+
const reviewUnits = () => (current && current.displayUnits === 'mm' ? 'mm' : 'ft-in');
|
|
11419
|
+
const reviewElevation = (mm) => (reviewUnitsModule ? reviewUnitsModule.formatElevation(mm, reviewUnits()) : `${Math.round(mm)} mm`);
|
|
11420
|
+
const reviewLength = (mm) => (reviewUnitsModule ? reviewUnitsModule.formatLength(mm, reviewUnits()) : `${Math.round(mm)} mm`);
|
|
11421
|
+
const isEndpointValue = (v) => !!v && typeof v === 'object' && !Array.isArray(v)
|
|
11422
|
+
&& typeof v.x === 'number' && typeof v.y === 'number' && !!v.z && typeof v.z === 'object';
|
|
11423
|
+
const isEndpointField = (f) => (f.key === 'from' || f.key === 'to') && isEndpointValue(f.before) && isEndpointValue(f.after);
|
|
11424
|
+
const isAnsweredZ = (z) => !!z && typeof z === 'object' && !!z.answered && typeof z.answered === 'object' && typeof z.known === 'number';
|
|
11425
|
+
const endpointHeightText = (z) => {
|
|
11426
|
+
if (!z || typeof z.known !== 'number') return 'no height';
|
|
11427
|
+
return `${reviewElevation(z.known)}${z.assumed === true ? ' (placed, not from the drawings)' : ''}`;
|
|
11428
|
+
};
|
|
11429
|
+
const endWordOf = (key) => (key === 'from' ? 'Start' : 'End');
|
|
11430
|
+
function plainLine(key, before, after) {
|
|
11431
|
+
const row = revEl('div', 'rev-field');
|
|
11432
|
+
row.appendChild(revEl('span', 'rev-field-key', key));
|
|
11433
|
+
row.appendChild(revEl('span', 'hd-prof', before));
|
|
11434
|
+
row.appendChild(revEl('span', 'hd-arrow', '→'));
|
|
11435
|
+
row.appendChild(revEl('span', 'hd-prof', after));
|
|
11436
|
+
return row;
|
|
11437
|
+
}
|
|
11438
|
+
/** The lines for one endpoint field, plus the notes that say whose number the new height is. */
|
|
11439
|
+
function endpointFieldLines(f) {
|
|
11440
|
+
const lines = [], notes = [];
|
|
11441
|
+
const end = endWordOf(f.key);
|
|
11442
|
+
const b = f.before, a = f.after;
|
|
11443
|
+
const heightChanged = !canonicalEqual(b.z, a.z);
|
|
11444
|
+
// Only a height THIS read changes is "your answer" here. An answer recorded on an earlier read and
|
|
11445
|
+
// carried unchanged is not news, even when the point moves in x/y (code review).
|
|
11446
|
+
const answered = heightChanged && isAnsweredZ(a.z) ? a.z.answered : null;
|
|
11447
|
+
if (heightChanged) {
|
|
11448
|
+
const before = endpointHeightText(b.z);
|
|
11449
|
+
let after = endpointHeightText(a.z);
|
|
11450
|
+
// Same number, new record: the row exists because the height becomes the person's answer. Said, so
|
|
11451
|
+
// the line is not read as a change that changes nothing.
|
|
11452
|
+
if (before === after && answered) after += ' (your answer)';
|
|
11453
|
+
lines.push(plainLine(`${end} height`, before, after));
|
|
11454
|
+
}
|
|
11455
|
+
if (b.x !== a.x) lines.push(plainLine(`${end} x`, reviewLength(b.x), reviewLength(a.x)));
|
|
11456
|
+
if (b.y !== a.y) lines.push(plainLine(`${end} y`, reviewLength(b.y), reviewLength(a.y)));
|
|
11457
|
+
// The server proposed this field because SOMETHING in it differs. If it is none of x, y and the height
|
|
11458
|
+
// (a key this renderer does not know), fall back to the generic line rather than draw nothing.
|
|
11459
|
+
if (!lines.length) lines.push(diffLine(f.key, f.before, f.after));
|
|
11460
|
+
if (answered) {
|
|
11461
|
+
const note = revEl('div', 'rev-row-note');
|
|
11462
|
+
const how = answered.how === 'typed' ? `typed ${answered.typed || reviewElevation(a.z.known)}` : `confirmed ${answered.shownAs || reviewElevation(a.z.known)}`;
|
|
11463
|
+
note.appendChild(document.createTextNode(`You answered the ${end.toLowerCase()} height on a height question: `));
|
|
11464
|
+
note.appendChild(revEl('b', null, how));
|
|
11465
|
+
note.appendChild(document.createTextNode(answered.note ? ` (${answered.note}).` : '.'));
|
|
11466
|
+
notes.push(note);
|
|
11467
|
+
const over = answered.overDrawing;
|
|
11468
|
+
if (over && typeof over.low === 'number' && typeof over.high === 'number') {
|
|
11469
|
+
const stated = Math.abs(over.high - over.low) < 0.5 ? reviewElevation(over.low) : `between ${reviewElevation(over.low)} and ${reviewElevation(over.high)}`;
|
|
11470
|
+
const drawn = revEl('div', 'rev-row-note');
|
|
11471
|
+
drawn.appendChild(document.createTextNode('The drawings state '));
|
|
11472
|
+
drawn.appendChild(revEl('b', null, stated));
|
|
11473
|
+
drawn.appendChild(document.createTextNode(' here; accepting sets your answer instead of the drawings’ height.'));
|
|
11474
|
+
notes.push(drawn);
|
|
11475
|
+
}
|
|
11476
|
+
}
|
|
11477
|
+
// A move in x/y rides on the same tick as the answered height, so it counts as ANOTHER change.
|
|
11478
|
+
return { lines, notes, answered: !!answered, moved: b.x !== a.x || b.y !== a.y };
|
|
11479
|
+
}
|
|
11480
|
+
/** Key-order-blind equality, the same rule the server's `valuesDiffer` uses for every field. */
|
|
11481
|
+
function canonicalEqual(x, y) {
|
|
11482
|
+
const canon = (v) => JSON.stringify(v ?? null, (_k, val) => (
|
|
11483
|
+
val && typeof val === 'object' && !Array.isArray(val)
|
|
11484
|
+
? Object.fromEntries(Object.keys(val).sort().map((k) => [k, val[k]]))
|
|
11485
|
+
: val));
|
|
11486
|
+
return canon(x) === canon(y);
|
|
11487
|
+
}
|
|
11488
|
+
|
|
11009
11489
|
/** A before → after line, reusing History's existing transform chip rather than inventing one. */
|
|
11010
11490
|
function fieldLine(key, before, after) {
|
|
11011
11491
|
const row = revEl('div', 'rev-field');
|
|
@@ -11212,8 +11692,29 @@
|
|
|
11212
11692
|
const desc = [];
|
|
11213
11693
|
if (p.kind === 'member-changed' || p.kind === 'plan-changed') {
|
|
11214
11694
|
const fields = revEl('div', 'rev-fields');
|
|
11215
|
-
|
|
11695
|
+
const notes = [];
|
|
11696
|
+
let answeredEnds = 0, otherFields = 0;
|
|
11697
|
+
for (const f of p.fields || []) {
|
|
11698
|
+
if (p.kind === 'member-changed' && isEndpointField(f)) {
|
|
11699
|
+
const drawn = endpointFieldLines(f);
|
|
11700
|
+
for (const line of drawn.lines) fields.appendChild(line);
|
|
11701
|
+
notes.push(...drawn.notes);
|
|
11702
|
+
if (drawn.answered) answeredEnds += 1;
|
|
11703
|
+
if (!drawn.answered || drawn.moved) otherFields += 1;
|
|
11704
|
+
} else {
|
|
11705
|
+
fields.appendChild(fieldLine(f.key, f.before, f.after));
|
|
11706
|
+
otherFields += 1;
|
|
11707
|
+
}
|
|
11708
|
+
}
|
|
11216
11709
|
desc.push(fields);
|
|
11710
|
+
// ONE TICK TAKES THE WHOLE ROW (#1903 plan review). A height the person answered can share a row
|
|
11711
|
+
// with other changes the read proposes for the same member; accepting it takes those too, so the
|
|
11712
|
+
// row says so FIRST (design review: it is the most consequential note) rather than letting the
|
|
11713
|
+
// height stand for the whole decision.
|
|
11714
|
+
if (answeredEnds && otherFields) {
|
|
11715
|
+
desc.push(revEl('div', 'rev-row-note', 'Ticking this row also applies the other changes shown for this member.'));
|
|
11716
|
+
}
|
|
11717
|
+
desc.push(...notes);
|
|
11217
11718
|
} else if (p.kind === 'model-changed') {
|
|
11218
11719
|
const isGrid = p.key === 'grid';
|
|
11219
11720
|
const obj = (v) => v && typeof v === 'object' && !Array.isArray(v);
|
|
@@ -12191,7 +12692,10 @@
|
|
|
12191
12692
|
author === 'You'
|
|
12192
12693
|
? '<span class="avatar you">YOU</span>'
|
|
12193
12694
|
: `<span class="avatar ai">${escapeHtml((author || '?').replace(/[^A-Za-z0-9]/g, '').slice(0, 2).toUpperCase() || 'AI')}</span>`;
|
|
12194
|
-
const gateBadge = (gate, kind, n) => {
|
|
12695
|
+
const gateBadge = (gate, kind, n, acceptedNote = '') => {
|
|
12696
|
+
// #1840: a sign-off that accepted open Tekla import findings says so on its own badge too.
|
|
12697
|
+
if (gate === 'model' && acceptedNote)
|
|
12698
|
+
return `<span class="gate-badge model findings-accepted" data-tip="${escapeAttr(`Sign-off gate. ${acceptedNote}`)}">Model</span>`;
|
|
12195
12699
|
if (gate === 'model')
|
|
12196
12700
|
return '<span class="gate-badge model" data-tip="Sign-off gate — this version was approved">Model</span>';
|
|
12197
12701
|
if (kind === 'revision-read')
|
|
@@ -12351,7 +12855,7 @@
|
|
|
12351
12855
|
'data-tip="Show the complete member-by-member comparison">' +
|
|
12352
12856
|
'<span class="hd-caret">▸</span><span class="hd-toggle-label">View detailed changes</span></button>'
|
|
12353
12857
|
: '';
|
|
12354
|
-
const detailWarning = `${readinessHtml(v)}${detailReconciliationWarningHtml(v)}${shellAuthoredNoteHtml(v)}`;
|
|
12858
|
+
const detailWarning = `${acceptedImportFindingsHtml(v)}${readinessHtml(v)}${detailReconciliationWarningHtml(v)}${shellAuthoredNoteHtml(v)}`;
|
|
12355
12859
|
if (!s || !Array.isArray(s.bullets)) {
|
|
12356
12860
|
return `<div class="hist-event">${escapeHtml(v.message)}</div>${detailWarning}${toggle}`;
|
|
12357
12861
|
}
|
|
@@ -12366,6 +12870,17 @@
|
|
|
12366
12870
|
`<ul class="hist-change-list">${bullets}</ul>${cautions}${detailWarning}${toggle}`;
|
|
12367
12871
|
}
|
|
12368
12872
|
|
|
12873
|
+
/**
|
|
12874
|
+
* #1840: an approval that accepted open Tekla import findings carries the server's own sentence on
|
|
12875
|
+
* its History row (one source for every approved surface), in the caution register the readiness
|
|
12876
|
+
* notes use: the findings are still open and may still need action.
|
|
12877
|
+
*/
|
|
12878
|
+
function acceptedImportFindingsHtml(v) {
|
|
12879
|
+
const note = v && v.kind === 'approve' && typeof v.acceptedImportFindingsNote === 'string' ? v.acceptedImportFindingsNote : '';
|
|
12880
|
+
if (!note) return '';
|
|
12881
|
+
return `<div class="hist-change-caution" role="note"><strong>${escapeHtml(note)}</strong> FloLess could not fully check these when it read the model; the Audit tab lists each one.</div>`;
|
|
12882
|
+
}
|
|
12883
|
+
|
|
12369
12884
|
function readinessHtml(v) {
|
|
12370
12885
|
const ready = v && v.readiness;
|
|
12371
12886
|
if (!ready || typeof ready.state !== 'string') return '';
|
|
@@ -12404,7 +12919,7 @@
|
|
|
12404
12919
|
`<td><span class="ver${v.current ? ' cur' : ''}">v${escapeHtml(String(v.n))}</span></td>` +
|
|
12405
12920
|
`<td class="htime">${escapeHtml(histWhen(v.ts))}</td>` +
|
|
12406
12921
|
`<td><span class="hby">${avatarFor(v.author)}${escapeHtml(v.author)}</span></td>` +
|
|
12407
|
-
`<td>${gateBadge(v.gate, v.kind, v.n)}</td>` +
|
|
12922
|
+
`<td>${gateBadge(v.gate, v.kind, v.n, typeof v.acceptedImportFindingsNote === 'string' ? v.acceptedImportFindingsNote : '')}</td>` +
|
|
12408
12923
|
`<td class="change">${changeCellHtml(v, meta)}${diffStatus}</td>` +
|
|
12409
12924
|
`<td>${action}</td></tr>`;
|
|
12410
12925
|
// The disclosure row is always emitted (hidden) so toggling is a pure show/hide + lazy fetch.
|
|
@@ -12654,6 +13169,7 @@
|
|
|
12654
13169
|
if (!current) return;
|
|
12655
13170
|
const proj = current;
|
|
12656
13171
|
closeRollbackConfirm();
|
|
13172
|
+
let restoreRequested = false;
|
|
12657
13173
|
try {
|
|
12658
13174
|
const win = frames.model && frames.model.contentWindow;
|
|
12659
13175
|
// History owns the server-side working revision. Its hidden editor can still hold the
|
|
@@ -12668,6 +13184,7 @@
|
|
|
12668
13184
|
|| (working.epoch !== null && !Number.isInteger(Number(working.epoch)))) {
|
|
12669
13185
|
throw new Error('Working revision identity is unavailable. Reload History before starting.');
|
|
12670
13186
|
}
|
|
13187
|
+
restoreRequested = true;
|
|
12671
13188
|
const started = await api(`/api/projects/${encodeURIComponent(proj.id)}/revisions/start`, {
|
|
12672
13189
|
method: 'POST', body: JSON.stringify({ version: n, expectedEtag: working.etag, expectedEpoch: working.epoch === null ? null : Number(working.epoch) }),
|
|
12673
13190
|
});
|
|
@@ -12687,13 +13204,21 @@
|
|
|
12687
13204
|
await refreshApprovalState(proj.id);
|
|
12688
13205
|
renderHistory();
|
|
12689
13206
|
} catch (err) {
|
|
12690
|
-
|
|
13207
|
+
console.warn('[workspaces] saved-version restore did not finish', err);
|
|
13208
|
+
showToast(err && err.status === 409 && err.body && typeof err.body.error === 'string'
|
|
13209
|
+
? err.body.error : 'We couldn’t restore that version because FloLess could not save the change. Try again.', 'warn');
|
|
13210
|
+
if (restoreRequested) reloadModelFromServerTruth();
|
|
13211
|
+
// A failed publication may already have cleared the server's sign-off. Re-read it rather
|
|
13212
|
+
// than leaving the old approved badge visible while recovery is pending.
|
|
13213
|
+
try { await refreshApprovalState(proj.id); renderHistory(); }
|
|
13214
|
+
catch (refreshError) { console.warn('[workspaces] approval state could not refresh after restore', refreshError); }
|
|
12691
13215
|
}
|
|
12692
13216
|
}
|
|
12693
13217
|
|
|
12694
13218
|
async function resumeCheckpoint(checkpointId) {
|
|
12695
13219
|
if (!current) return;
|
|
12696
13220
|
const proj = current;
|
|
13221
|
+
let restoreRequested = false;
|
|
12697
13222
|
try {
|
|
12698
13223
|
const win = frames.model && frames.model.contentWindow;
|
|
12699
13224
|
// Do not write a hidden editor's stale in-memory draft over the exact checkpoint selected in
|
|
@@ -12705,6 +13230,7 @@
|
|
|
12705
13230
|
|| (working.epoch !== null && !Number.isInteger(Number(working.epoch)))) {
|
|
12706
13231
|
throw new Error('Working revision identity is unavailable. Reload Saved work.');
|
|
12707
13232
|
}
|
|
13233
|
+
restoreRequested = true;
|
|
12708
13234
|
await api(`/api/projects/${encodeURIComponent(proj.id)}/checkpoints/${encodeURIComponent(checkpointId)}/resume`, {
|
|
12709
13235
|
method: 'POST',
|
|
12710
13236
|
body: JSON.stringify({ expectedEtag: working.etag, expectedEpoch: working.epoch === null ? null : Number(working.epoch) }),
|
|
@@ -12715,7 +13241,12 @@
|
|
|
12715
13241
|
await refreshApprovalState(proj.id);
|
|
12716
13242
|
renderHistory();
|
|
12717
13243
|
} catch (err) {
|
|
12718
|
-
|
|
13244
|
+
console.warn('[workspaces] saved-work resume did not finish', err);
|
|
13245
|
+
showToast(err && err.status === 409 && err.body && typeof err.body.error === 'string'
|
|
13246
|
+
? err.body.error : 'We couldn’t resume this saved work because FloLess could not reach it. Try again.', 'warn');
|
|
13247
|
+
if (restoreRequested) reloadModelFromServerTruth();
|
|
13248
|
+
try { await refreshApprovalState(proj.id); renderHistory(); }
|
|
13249
|
+
catch (refreshError) { console.warn('[workspaces] approval state could not refresh after resume', refreshError); }
|
|
12719
13250
|
}
|
|
12720
13251
|
}
|
|
12721
13252
|
|
|
@@ -13212,6 +13743,8 @@
|
|
|
13212
13743
|
// the workflow picker). ───────────────────────────────────────────────
|
|
13213
13744
|
let menuFor = null;
|
|
13214
13745
|
const projectExportBusy = new Set();
|
|
13746
|
+
// #1922: the durable record behind the one-off import toast. Plain words: what is uncertain, why, what to do.
|
|
13747
|
+
const UNVERIFIED_IMPORT_TIP = 'This project was zipped while a save was still being written, so this copy may be missing that save or hold only part of it. To get a complete copy, use Export on the computer it came from and import that file. If you have checked this copy and it is complete, use Mark as checked in the ⋯ menu.';
|
|
13215
13748
|
function menuItem(action, label) {
|
|
13216
13749
|
return `<button class="menu-item" data-act="${action}" role="menuitem"><span class="menu-label">${escapeHtml(label)}</span></button>`;
|
|
13217
13750
|
}
|
|
@@ -13232,7 +13765,10 @@
|
|
|
13232
13765
|
const thumbItems = menuItem('thumbnail', hasThumb ? 'Replace thumbnail…' : 'Add thumbnail…')
|
|
13233
13766
|
+ (hasThumb ? menuItem('remove-thumbnail', 'Remove thumbnail') : '');
|
|
13234
13767
|
const duplicateItem = `<button class="menu-item" data-act="duplicate" data-command-id="shell.project-duplicate#${escapeAttr(id)}" data-command-instance-label="${escapeAttr(menuProj && menuProj.name)}" role="menuitem"><span class="menu-label">Duplicate</span></button>`;
|
|
13235
|
-
|
|
13768
|
+
const checkedItem = menuProj && menuProj.importedMidSave
|
|
13769
|
+
? `<button class="menu-item" data-act="clear-unverified" data-command-id="shell.project-clear-unverified#${escapeAttr(id)}" data-command-instance-label="${escapeAttr(menuProj.name)}" role="menuitem"><span class="menu-label">Mark as checked</span></button>`
|
|
13770
|
+
: '';
|
|
13771
|
+
$projMenu.innerHTML = menuItem('rename', 'Rename…') + thumbItems + checkedItem + duplicateItem +
|
|
13236
13772
|
menuItem('export', 'Export…') +
|
|
13237
13773
|
'<div class="menu-divider"></div>' + menuItem('archive', 'Archive');
|
|
13238
13774
|
// NO "Convert to the 3D model…" ITEM HERE, and its absence is a decision rather than an oversight.
|
|
@@ -13315,6 +13851,7 @@
|
|
|
13315
13851
|
function flashCard(id, opts) {
|
|
13316
13852
|
const el = $landing.querySelector(`.ws-card[data-open="${escapeAttr(id)}"]`);
|
|
13317
13853
|
if (!el) return;
|
|
13854
|
+
if (el.hidden) setLandingQuery(''); // never confirm on a card the search is hiding (an import, a rename)
|
|
13318
13855
|
if (opts && opts.scroll) el.scrollIntoView({ block: 'nearest' });
|
|
13319
13856
|
flashId = id;
|
|
13320
13857
|
armFlash(id, el);
|
|
@@ -13438,6 +13975,13 @@
|
|
|
13438
13975
|
const resultToast = formatRfiTransferToast(rfiTransfer, 'duplicate', project.name, true);
|
|
13439
13976
|
finishProgress();
|
|
13440
13977
|
showToast(resultToast.message, resultToast.tone);
|
|
13978
|
+
} else if (action === 'clear-unverified') {
|
|
13979
|
+
// No confirm: the person is saying they checked it, and the label is one Import away from
|
|
13980
|
+
// returning. The project's contents are untouched; only the marker goes.
|
|
13981
|
+
const { project } = await api(`/api/projects/${encodeURIComponent(id)}/imported-mid-save`, { method: 'DELETE' });
|
|
13982
|
+
projects = projects.map((p) => (p.id === id ? project : p));
|
|
13983
|
+
renderLanding();
|
|
13984
|
+
showToast(`Marked “${project.name}” as checked.`, 'ok');
|
|
13441
13985
|
} else if (action === 'remove-thumbnail') {
|
|
13442
13986
|
// No confirm, deliberately. A thumbnail is decorative metadata with nothing downstream of it
|
|
13443
13987
|
// and is one menu item away from being re-added — unlike the archived-project Delete, which
|
|
@@ -13608,7 +14152,7 @@
|
|
|
13608
14152
|
};
|
|
13609
14153
|
try {
|
|
13610
14154
|
const buf = await file.arrayBuffer();
|
|
13611
|
-
const { project, appInstalled, rfiTransfer } = await api('/api/projects/import', {
|
|
14155
|
+
const { project, appInstalled, rfiTransfer, leftOut } = await api('/api/projects/import', {
|
|
13612
14156
|
method: 'POST', headers: { 'content-type': 'application/zip' }, body: buf,
|
|
13613
14157
|
});
|
|
13614
14158
|
projects.unshift(project); // newest → front, matching duplicate/create
|
|
@@ -13616,15 +14160,73 @@
|
|
|
13616
14160
|
flashCard(project.id, { scroll: true });
|
|
13617
14161
|
track('workspace_project_imported', { app: project.app });
|
|
13618
14162
|
const resultToast = formatRfiTransferToast(rfiTransfer, 'import', project.name, appInstalled);
|
|
14163
|
+
const leftOutNote = importLeftOutNote(leftOut, project.name);
|
|
13619
14164
|
finishProgress();
|
|
13620
|
-
showToast(resultToast.message, resultToast.tone);
|
|
14165
|
+
showToast(leftOutNote.skipped ? `${resultToast.message} ${leftOutNote.skipped}` : resultToast.message, resultToast.tone);
|
|
14166
|
+
if (leftOutNote.warning) showToast(leftOutNote.warning, 'warn', { persistent: true });
|
|
13621
14167
|
loadProjects(); // background reconcile against the server truth (mirrors duplicate/rename/archive)
|
|
13622
14168
|
} catch (err) {
|
|
13623
14169
|
finishProgress();
|
|
13624
|
-
showToast(
|
|
14170
|
+
showToast(importRefusalMessage(err, file.name), 'err');
|
|
13625
14171
|
} finally { finishProgress(); }
|
|
13626
14172
|
}
|
|
13627
14173
|
|
|
14174
|
+
// #1887: a project FOLDER zipped by hand carries files FloLess keeps for itself on each computer (the
|
|
14175
|
+
// contract's publication journal, caches, saved checkpoints, undo steps). The server leaves them out and
|
|
14176
|
+
// classifies them in `leftOut`; this turns that into plain words that never claim more than is true:
|
|
14177
|
+
// - zipped mid-save → a persistent warning: the copy may miss that save or hold part of it;
|
|
14178
|
+
// - saved checkpoints / undo steps → a persistent warning: those stay on the source computer;
|
|
14179
|
+
// - anything else is set up fresh here → one quiet sentence on the success toast.
|
|
14180
|
+
function importLeftOutNote(leftOut, projectName) {
|
|
14181
|
+
const files = leftOut && Array.isArray(leftOut.files) ? leftOut.files.length : 0;
|
|
14182
|
+
if (!files) return { skipped: '', warning: '' };
|
|
14183
|
+
const behind = Array.isArray(leftOut.leftBehind) ? leftOut.leftBehind : [];
|
|
14184
|
+
const names = [behind.includes('checkpoints') ? 'saved checkpoints' : '', behind.includes('undo') ? 'member-end undo steps' : '']
|
|
14185
|
+
.filter(Boolean).join(' and ');
|
|
14186
|
+
const stayBehind = names ? `Its ${names} stay on the computer it came from.` : '';
|
|
14187
|
+
const checkpointStep = behind.includes('checkpoints') ? ' If you need a saved checkpoint, approve it there, then move the project again.' : '';
|
|
14188
|
+
if (leftOut.interruptedSave === true) {
|
|
14189
|
+
// No "History and current model came across" here: after a torn save that is exactly what
|
|
14190
|
+
// cannot be promised.
|
|
14191
|
+
return {
|
|
14192
|
+
skipped: '',
|
|
14193
|
+
warning: `Imported “${projectName}”, but it was zipped while a save was still being written, so this copy may be missing that save or hold only part of it. To get a complete copy, use Export on the computer it came from and import that file.${stayBehind ? ` ${stayBehind}` : ''}`,
|
|
14194
|
+
};
|
|
14195
|
+
}
|
|
14196
|
+
if (stayBehind) {
|
|
14197
|
+
return { skipped: '', warning: `Imported “${projectName}”. ${stayBehind.slice(0, -1)}; its History and current model came across.${checkpointStep}` };
|
|
14198
|
+
}
|
|
14199
|
+
return {
|
|
14200
|
+
skipped: files === 1
|
|
14201
|
+
? 'Skipped 1 file FloLess keeps for itself on each computer; it sets it up fresh here, so nothing in the project is lost.'
|
|
14202
|
+
: `Skipped ${files} files FloLess keeps for itself on each computer; it sets them up fresh here, so nothing in the project is lost.`,
|
|
14203
|
+
warning: '',
|
|
14204
|
+
};
|
|
14205
|
+
}
|
|
14206
|
+
|
|
14207
|
+
// A refused import names the file and the server's reason — never the old generic "could not read it",
|
|
14208
|
+
// which hid the one fact the person needed (#1887). A malformed archive (`invalid`) gets the few common
|
|
14209
|
+
// reasons in plain words plus the Export next step; any other refusal the server explains in a complete
|
|
14210
|
+
// sentence of its own (e.g. a module this account lacks) is shown as written. Only a dropped connection
|
|
14211
|
+
// or a server fault — no reason to show — falls back to "try again".
|
|
14212
|
+
function importRefusalMessage(err, fileName) {
|
|
14213
|
+
const body = err && err.body;
|
|
14214
|
+
const reason = body && body.ok === false && typeof body.error === 'string' && body.error.trim()
|
|
14215
|
+
&& !(typeof err.status === 'number' && err.status >= 500) ? body.error.trim() : '';
|
|
14216
|
+
const tooLarge = `Couldn’t import “${fileName}”: it is larger than FloLess can import in one go. Remove large files you don’t need from the zip, then import it again.`;
|
|
14217
|
+
if (err && err.status === 413) return tooLarge;
|
|
14218
|
+
if (!reason) return `Couldn’t import “${fileName}” because FloLess could not finish reading it. Try again.`;
|
|
14219
|
+
// A checklist made by a newer FloLess is not a damaged file: its sentence already says to update FloLess, so the
|
|
14220
|
+
// hand-zipped Export advice below would send the person looking for a fault the file does not have.
|
|
14221
|
+
if (/^This checklist was made by a newer FloLess; /.test(reason)) return `Couldn’t import “${fileName}”. ${reason}`;
|
|
14222
|
+
if (body.code !== 'invalid') return `Couldn’t import “${fileName}”. ${/[.!?]$/.test(reason) ? reason : `${reason}.`}`;
|
|
14223
|
+
if (/^archive is too large|^archive has too many entries/.test(reason)) return tooLarge;
|
|
14224
|
+
const plain = /^archive has no project\.json/.test(reason) ? 'it has no project.json, so it is not a FloLess project'
|
|
14225
|
+
: /^not a valid project archive/.test(reason) ? 'it is not a readable .zip file'
|
|
14226
|
+
: reason.replace(/\.$/, '');
|
|
14227
|
+
return `Couldn’t import “${fileName}”: ${plain}. If you zipped the project folder yourself, use Export on the computer it came from, then import that file.`;
|
|
14228
|
+
}
|
|
14229
|
+
|
|
13628
14230
|
// #1719: when another program has a file open inside the project folder, Windows refuses to move or
|
|
13629
14231
|
// remove it. The server answers with a complete plain-English sentence (what happened, why, what to do),
|
|
13630
14232
|
// so it is shown as-is instead of under a generic "Action failed:" prefix or a "could not save" guess.
|
|
@@ -13811,10 +14413,28 @@
|
|
|
13811
14413
|
renderKnowledge();
|
|
13812
14414
|
}
|
|
13813
14415
|
|
|
14416
|
+
// A cross-project object pin still belongs to its original conversation, wherever its model is shown.
|
|
14417
|
+
async function openChatOwner(owner) {
|
|
14418
|
+
const validId = (id) => typeof id === 'string' && !!id && id.length <= 200;
|
|
14419
|
+
if (!owner || typeof owner !== 'object'
|
|
14420
|
+
|| !(owner.kind === 'workspace' || owner.kind === 'project' && validId(owner.projectId)
|
|
14421
|
+
|| owner.kind === 'workflow' && validId(owner.workflowId))) throw new Error('That conversation has no valid home to open.');
|
|
14422
|
+
if (owner.kind === 'workflow') {
|
|
14423
|
+
if (typeof bridge.openOwnedWorkflow !== 'function') throw new Error('Open this conversation’s workflow from Workflows, then try Show in chat again.');
|
|
14424
|
+
await bridge.openOwnedWorkflow(owner.workflowId);
|
|
14425
|
+
return;
|
|
14426
|
+
}
|
|
14427
|
+
await setMode('workspaces');
|
|
14428
|
+
if (owner.kind === 'project') {
|
|
14429
|
+
await openProject(owner.projectId);
|
|
14430
|
+
if (current?.id !== owner.projectId) throw new Error('That project could not be opened. Try Show in chat again after opening its project in Workspaces.');
|
|
14431
|
+
} else closeProject();
|
|
14432
|
+
}
|
|
14433
|
+
|
|
13814
14434
|
window.flolessWorkspaces = {
|
|
13815
14435
|
setMode, refresh: loadProjects, findActive: wsFindActive, find: wsFind, clearFind: wsClearFind,
|
|
13816
14436
|
openHistory: wsOpenHistory, openKnowledgePage, drawingFilterCheckpointSaved,
|
|
13817
|
-
syncWorkspaceReporter,
|
|
14437
|
+
syncWorkspaceReporter, openChatOwner,
|
|
13818
14438
|
};
|
|
13819
14439
|
applyMode(); // restore persisted mode immediately (matches panels.js applyView timing)
|
|
13820
14440
|
})();
|