@floless/app 0.123.1 → 0.123.2
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 +2 -2
- package/dist/web/aware.js +25 -5
- package/dist/web/steel-editor.html +537 -14
- package/dist/web/workspaces.js +18 -0
- package/package.json +1 -1
package/dist/floless-server.cjs
CHANGED
|
@@ -54611,7 +54611,7 @@ function appVersion() {
|
|
|
54611
54611
|
return resolveVersion({
|
|
54612
54612
|
isSea: isSea2(),
|
|
54613
54613
|
sqVersionXml: readSqVersionXml(),
|
|
54614
|
-
define: true ? "0.123.
|
|
54614
|
+
define: true ? "0.123.2" : void 0,
|
|
54615
54615
|
pkgVersion: readPkgVersion()
|
|
54616
54616
|
});
|
|
54617
54617
|
}
|
|
@@ -54627,7 +54627,7 @@ function resolveChannel(s) {
|
|
|
54627
54627
|
function appChannel() {
|
|
54628
54628
|
return resolveChannel({
|
|
54629
54629
|
isSea: isSea2(),
|
|
54630
|
-
define: true ? "0.123.
|
|
54630
|
+
define: true ? "0.123.2" : void 0,
|
|
54631
54631
|
// argv[1] is the entry the runtime actually loaded (…/dist/floless-server.cjs), which is what
|
|
54632
54632
|
// carries the npx cache prefix. Absent under the SEA exe, which never reaches the npx branch.
|
|
54633
54633
|
modulePath: process.argv[1]
|
package/dist/web/aware.js
CHANGED
|
@@ -1059,13 +1059,26 @@
|
|
|
1059
1059
|
|
|
1060
1060
|
// Status placeholders that flow through setComboTriggerLabel but are NOT workflow names.
|
|
1061
1061
|
const WF_STATUS_TEXT = new Set(['loading…', 'no workflows installed', 'server unreachable', 'select workflow', '']);
|
|
1062
|
+
// App tab title — kept distinct from the marketing site's "FloLess — Workflow Automation for
|
|
1063
|
+
// AEC": "<subject> — FloLess" so parallel browser tabs are tellable apart, else the static
|
|
1064
|
+
// "FloLess Workspace" (which is also the initial <title> in index.html).
|
|
1065
|
+
//
|
|
1066
|
+
// The subject is whatever surface is ON SCREEN, which is why there are two inputs and one owner:
|
|
1067
|
+
// in Workspaces mode the workflow combo is not even visible, so naming its workflow there was
|
|
1068
|
+
// simply the wrong surface (the tab kept a workflow name while the user was in a project).
|
|
1069
|
+
// Workspaces mode wins when set; workspaces.js pushes it through bridge.setWorkspaceTitle().
|
|
1070
|
+
// Pure on purpose — the branch is pinned by tab-title.test.ts.
|
|
1071
|
+
function tabTitle(wsName, wfName) {
|
|
1072
|
+
const subject = wsName || (wfName && !WF_STATUS_TEXT.has(wfName) ? wfName : '');
|
|
1073
|
+
return subject ? `${subject} — FloLess` : 'FloLess Workspace';
|
|
1074
|
+
}
|
|
1075
|
+
let wfTitleText = ''; // last workflow-combo label (may be a WF_STATUS_TEXT placeholder)
|
|
1076
|
+
let wsTitleName = null; // open Workspaces project name, or 'Workspaces' on its landing; null = Workflows mode
|
|
1077
|
+
const syncTabTitle = () => { document.title = tabTitle(wsTitleName, wfTitleText); };
|
|
1062
1078
|
function setComboTriggerLabel(text) {
|
|
1063
1079
|
if ($wfTriggerLabel) $wfTriggerLabel.textContent = text || 'select workflow';
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
// parallel browser tabs are tellable apart, else the static "FloLess Workspace"
|
|
1067
|
-
// (which is also the initial <title> in index.html).
|
|
1068
|
-
document.title = (text && !WF_STATUS_TEXT.has(text)) ? `${text} — FloLess` : 'FloLess Workspace';
|
|
1080
|
+
wfTitleText = text || '';
|
|
1081
|
+
syncTabTitle();
|
|
1069
1082
|
}
|
|
1070
1083
|
function setComboSelected(id) {
|
|
1071
1084
|
if (!$wfList) return;
|
|
@@ -8729,6 +8742,13 @@
|
|
|
8729
8742
|
openAwareUpdate(version, returnFocusTo) {
|
|
8730
8743
|
openAwareUpgrade(version, returnFocusTo);
|
|
8731
8744
|
},
|
|
8745
|
+
// Tab title: workspaces.js owns which project is open, aware.js owns document.title (one
|
|
8746
|
+
// writer — the workflow combo keeps updating underneath in Workspaces mode). Pass the open
|
|
8747
|
+
// project's name, 'Workspaces' on the landing, or null to hand the tab back to the workflow.
|
|
8748
|
+
setWorkspaceTitle(name) {
|
|
8749
|
+
wsTitleName = name || null;
|
|
8750
|
+
syncTabTitle();
|
|
8751
|
+
},
|
|
8732
8752
|
// ── Workspaces guide beacon (the SAME #guide-beacon/#guide-modal, document variant) ──
|
|
8733
8753
|
// workspaces.js owns the open project + its lifecycle state; aware.js owns the beacon
|
|
8734
8754
|
// chrome. workspaces.js calls setWorkspaceGuide() with a small snapshot whenever the
|
|
@@ -557,16 +557,21 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
|
|
|
557
557
|
a bespoke fixed-height box here would be one more thing to theme and test for nothing. */
|
|
558
558
|
#panel .robjname{font-size:13px;color:var(--text);font-weight:600;overflow-wrap:anywhere;margin:0 0 2px}
|
|
559
559
|
#panel .psetgrp{border-top:1px solid var(--line)}
|
|
560
|
-
#panel
|
|
561
|
-
#panel
|
|
562
|
-
#panel
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
#panel .psethd
|
|
566
|
-
#panel .psethd .
|
|
567
|
-
#panel .psethd .
|
|
568
|
-
#panel .
|
|
569
|
-
#panel .
|
|
560
|
+
/* The property-set accordion. #m3dRefsBody is named alongside #panel because the reference object
|
|
561
|
+
tree (S2 Stage B) reuses this exact header in the References legend, which is a SIBLING of #panel —
|
|
562
|
+
scoped to #panel alone the header fell through to the global `button{}` pill: grey fill, rounded
|
|
563
|
+
border, a chevron that never turned and a count that was not muted. Same markup, same look, both
|
|
564
|
+
places. */
|
|
565
|
+
#panel .psethd,#m3dRefsBody .psethd{display:flex;align-items:center;gap:6px;width:100%;background:transparent;border:0;border-radius:0;box-shadow:none;color:var(--text);font:600 11px system-ui;padding:5px 2px;cursor:pointer;text-align:left}
|
|
566
|
+
#panel .psethd:hover,#m3dRefsBody .psethd:hover{color:var(--text);background:#33415580}
|
|
567
|
+
#panel .psethd[aria-expanded=true],#m3dRefsBody .psethd[aria-expanded=true]{color:var(--brand)}
|
|
568
|
+
#panel .psethd:focus-visible,#m3dRefsBody .psethd:focus-visible{outline:2px solid var(--brand);outline-offset:-2px}
|
|
569
|
+
#panel .psethd .chev,#m3dRefsBody .psethd .chev{color:var(--mut);font-size:10px;width:10px;flex:none;transition:transform .15s}
|
|
570
|
+
#panel .psethd[aria-expanded=true] .chev,#m3dRefsBody .psethd[aria-expanded=true] .chev{transform:rotate(90deg);color:var(--brand)}
|
|
571
|
+
#panel .psethd .psn,#m3dRefsBody .psethd .psn{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
572
|
+
#panel .psethd .psc,#m3dRefsBody .psethd .psc{flex:none;color:var(--mut);font-weight:400;font-variant-numeric:tabular-nums}
|
|
573
|
+
#panel .psetbody,#m3dRefsBody .psetbody{display:none;padding:2px 0 8px 16px}
|
|
574
|
+
#panel .psetbody.open,#m3dRefsBody .psetbody.open{display:block}
|
|
570
575
|
/* Label ABOVE value, not beside it: an IFC property name ("NominalRenderingHeight") and its value
|
|
571
576
|
("0055SFt0000001150") can BOTH be long, so the label-left/value-right recipe this panel uses
|
|
572
577
|
elsewhere either truncates or wraps into a ragged mess at this width. */
|
|
@@ -891,6 +896,36 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
|
|
|
891
896
|
#m3dRefsBody .refdet .seg2 button{font-size:11px;padding:0}
|
|
892
897
|
#m3dRefsBody .refdet .seg2 .swc{flex:1;width:auto;height:100%;border:0;border-radius:0;min-width:0}
|
|
893
898
|
#m3dRefsBody .refdet .seg2 .swc.on{box-shadow:inset 0 0 0 2px var(--brand)}
|
|
899
|
+
/* ── The object tree (S2 Stage B) — what is INSIDE one reference, storey → IFC type.
|
|
900
|
+
Grouping chrome is #m3dLegend's own `.cat-hdr`/`.cat-hdr.sub`/`.cat-chevron`/`.cat-count`, which
|
|
901
|
+
already exists for exactly this two-level shape (Dimensions → Base-plate); the rows sit at the
|
|
902
|
+
`.lrow.sub` indent. New here: the bounded scroll box, the row, the filter box and the cap notice.
|
|
903
|
+
The accordion HEADER is `.psethd`/`.psetbody`, whose rules had to be widened to name #m3dRefsBody —
|
|
904
|
+
they were scoped to #panel, which is a sibling of this panel, not an ancestor.
|
|
905
|
+
THE BOX IS BOUNDED, and that is a deliberate departure from the property panel's "no inner
|
|
906
|
+
scroller" rule: that reasoning ("one more thing to theme and test for nothing") holds at 31 sets
|
|
907
|
+
and does not hold at 17,460 objects, which would otherwise push every control above it off screen.
|
|
908
|
+
Same recipe as #ciList / #vgList, so it inherits the global themed scrollbar and adds no CSS. */
|
|
909
|
+
#m3dRefsBody .reftree{max-height:min(38vh,300px);overflow:auto;border:1px solid var(--line);border-radius:7px;background:var(--bg);padding:3px 2px}
|
|
910
|
+
/* The tree's own filter. It does NOT reuse #propPop's `.ppsearch` — that recipe is scoped to #propPop
|
|
911
|
+
and cannot reach this panel, so naming it here would be a class that styles nothing. The global
|
|
912
|
+
`select,input` rule already makes it dark, and `#m3dRefsBody .refdet input[type=text]` above already
|
|
913
|
+
sizes it (and outranks this rule, so height/font are deliberately not restated here). What neither
|
|
914
|
+
gives it is room for its text against the global `padding:6px`, or the branded focus ring that every
|
|
915
|
+
other input in this file has and that CLAUDE.md requires. */
|
|
916
|
+
#m3dRefsBody .reftreesearch{padding:4px 0 6px}
|
|
917
|
+
#m3dRefsBody .reftreesearch input{padding:0 8px}
|
|
918
|
+
#m3dRefsBody .reftreesearch input:focus{outline:none;border-color:var(--brand)}
|
|
919
|
+
#m3dRefsBody .reftreesearch input::placeholder{color:var(--mut)}
|
|
920
|
+
#m3dLegend .refobjrow{display:flex;align-items:center;gap:6px;padding:2px 4px 2px 34px;border-radius:5px;cursor:pointer;user-select:none;white-space:nowrap;font-size:11px;color:var(--text)}
|
|
921
|
+
#m3dLegend .refobjrow:hover{background:#33415580}
|
|
922
|
+
#m3dLegend .refobjrow:focus-visible{outline:2px solid var(--brand);outline-offset:-2px}
|
|
923
|
+
#m3dLegend .refobjrow.sel{box-shadow:inset 2px 0 0 var(--brand);background:rgba(59,130,246,.16)}
|
|
924
|
+
#m3dLegend .refobjrow.flash{background:rgba(59,130,246,.12)} /* "you just navigated here" — the same flash tint .lrow/.vwrow use, held longer (900ms) because the tree may also have scrolled */
|
|
925
|
+
#m3dLegend .refobjrow .ronm{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis}
|
|
926
|
+
#m3dLegend .refobjrow .rord{flex:none;color:var(--mut);font-size:10px;font-variant-numeric:tabular-nums}
|
|
927
|
+
#m3dRefsBody .reftree .cat-hdr:focus-visible{outline:2px solid var(--brand);outline-offset:-2px}
|
|
928
|
+
#m3dRefsBody .refcap{color:var(--mut);font-size:10px;padding:4px 4px 4px 34px;line-height:1.4}
|
|
894
929
|
#m3dRefsBody .refdet .colrow{display:flex;align-items:center;gap:6px}
|
|
895
930
|
#m3dRefsBody .refdet .colrow .seg2{flex:1;min-width:0}
|
|
896
931
|
/* ── Reference-model import modal (#refImportModal) — the #connImportModal recipe, under its own ids.
|
|
@@ -979,7 +1014,11 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
|
|
|
979
1014
|
#m3dLegend .cat-chevron{font-size:10px;color:var(--mut);width:12px;flex:none;text-align:center}
|
|
980
1015
|
#m3dLegend .cat-tog{font-size:12px;width:14px;flex:none;cursor:pointer;line-height:1;text-align:center}
|
|
981
1016
|
#m3dLegend .cat-tog[data-state=on]{color:var(--brand)} #m3dLegend .cat-tog[data-state=off]{color:var(--mut)} #m3dLegend .cat-tog[data-state=mixed]{color:#64748b}
|
|
982
|
-
|
|
1017
|
+
/* `min-width:0` + ellipsis because a flex item that cannot shrink below its content OVERFLOWS the row
|
|
1018
|
+
rather than truncating, and `.cat-hdr` is `white-space:nowrap`. The legend's own categories were
|
|
1019
|
+
always short enough to hide this; the reference tree's disambiguated headers ("Wall · IFCWALL…")
|
|
1020
|
+
are the first labels long enough to test it. Same recipe as `.refname` directly above. */
|
|
1021
|
+
#m3dLegend .cat-label{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;font-size:12px;color:var(--text)}
|
|
983
1022
|
#m3dLegend .cat-count{font-size:10px;color:var(--mut);font-variant-numeric:tabular-nums}
|
|
984
1023
|
#m3dLegend .lrow.typed{padding-left:20px}
|
|
985
1024
|
#m3dLegend .cat-hdr.sub{padding-left:20px} /* a nested (middle) category, e.g. Dimensions → Base-plate */
|
|
@@ -8080,7 +8119,9 @@ const view3dApi={
|
|
|
8080
8119
|
// that — with a marquee selection live, drilling was silently impossible.
|
|
8081
8120
|
const stole=nextIdx!==null&&(selIds.size||selDimIds.size||selGridIds.size||sel3dDimIds.size);
|
|
8082
8121
|
if(stole){selIds.clear();selDimIds.clear();selGridIds.clear();sel3dDimIds.clear();}
|
|
8083
|
-
if
|
|
8122
|
+
// The object tree, if the user has it open, comes to the object — see `revealRefTreeObject`. It
|
|
8123
|
+
// repaints the tab itself, so the ordinary repaint below is skipped when it did.
|
|
8124
|
+
if(!(nextId&&nextIdx!==null&&revealRefTreeObject(nextId,nextIdx))&&legendTab==='refs')renderRefsTab();
|
|
8084
8125
|
if(stole)render();else panel(); // render() repaints the canvas too, so our own highlight goes with the selection
|
|
8085
8126
|
},
|
|
8086
8127
|
onBasePickModeChange:()=>{}, // Mode B armed state shows via the 3D crosshair + elevation readout; nothing else to reflect
|
|
@@ -9459,6 +9500,9 @@ function buildRefDetail(r){
|
|
|
9459
9500
|
fix.addEventListener('click',()=>refMoveToOrigin(r.id));
|
|
9460
9501
|
w.appendChild(document.createElement('br'));w.appendChild(fix);wrap.appendChild(w);
|
|
9461
9502
|
}
|
|
9503
|
+
// LAST in the block, deliberately. Opening a tree of 17,460 objects must not push the "how does this
|
|
9504
|
+
// look" controls — the reason the row was expanded in the first place — off the top of the panel.
|
|
9505
|
+
buildRefTree(r,wrap);
|
|
9462
9506
|
return wrap;
|
|
9463
9507
|
}
|
|
9464
9508
|
|
|
@@ -9497,13 +9541,59 @@ function ifcTypeWords(t){
|
|
|
9497
9541
|
/**
|
|
9498
9542
|
* Is this a name, or is it the file's way of writing "nothing"?
|
|
9499
9543
|
*
|
|
9500
|
-
*
|
|
9544
|
+
* Two of the Motebello sample's nineteen objects are named `-`. Printing that as a headline reads as a
|
|
9501
9545
|
* broken template rather than as "the author did not name this", so a string with no letter and no digit
|
|
9502
9546
|
* is treated as no name at all — and what the file DID write is then stated in words underneath, because
|
|
9503
9547
|
* hiding it would be this panel telling a smaller truth than the file did.
|
|
9504
9548
|
*/
|
|
9505
9549
|
function refObjNamed(n){return typeof n==='string'&&/[\p{L}\p{N}]/u.test(n);}
|
|
9506
9550
|
|
|
9551
|
+
/**
|
|
9552
|
+
* The objects of one reference, grouped storey → IFC type, for the object tree (S2 Stage B).
|
|
9553
|
+
*
|
|
9554
|
+
* INDICES, NEVER OBJECTS. The result addresses each object by its position in the array it was built
|
|
9555
|
+
* from — the same handle the 3D layer and the Inspect panel already use, because an IFC GlobalId can be
|
|
9556
|
+
* absent or duplicated (see `xrefSubSelected` in web/steel-3d-view.js). It also means this structure
|
|
9557
|
+
* costs a few numbers per object, and nothing here has to be kept in step with the array it describes.
|
|
9558
|
+
*
|
|
9559
|
+
* ORDER IS FIRST APPEARANCE, not alphabetical. A building's storeys have an order — LG, L1, L2, ROOF —
|
|
9560
|
+
* that no sort of their names recovers ("L10" sorts before "L2", "BASEMENT" before everything), and we
|
|
9561
|
+
* are given no elevations to sort by. File order is the author's own sequence and it is the only
|
|
9562
|
+
* ordering here that is not invented. Types are ordered the same way within a storey, for the same
|
|
9563
|
+
* reason. (This preserves the order of the read it is given; it does not — and cannot — promise that two
|
|
9564
|
+
* reads of a changed file agree, which is why the tree's group state is dropped on a re-read.)
|
|
9565
|
+
*
|
|
9566
|
+
* THE STOREY-LESS GROUP GOES LAST, and is left as `null` for the renderer to name rather than labelled
|
|
9567
|
+
* here. A file that records no storeys at all — which is ordinary, though no sample file we hold does it;
|
|
9568
|
+
* Daldy contributes one such object among 17,460 — produces exactly one group, and the tree then
|
|
9569
|
+
* degrades to a flat list of types.
|
|
9570
|
+
*/
|
|
9571
|
+
function groupReferenceObjects(objects){
|
|
9572
|
+
const list=Array.isArray(objects)?objects:[];
|
|
9573
|
+
const byStorey=new Map(); // storey label (or null) -> Map<type label, number[]>
|
|
9574
|
+
for(let i=0;i<list.length;i++){
|
|
9575
|
+
const o=list[i]||{};
|
|
9576
|
+
// Trimmed, and blank counts as absent — the same rule the Inspect panel's identity line follows, and
|
|
9577
|
+
// for the same measured reason: this file family pads fields to a fixed width (it is Motebello's
|
|
9578
|
+
// MATERIAL that arrives as eighty spaces), so a padded field would otherwise head a group with nothing.
|
|
9579
|
+
const s=(typeof o.storey==='string'&&o.storey.trim())?o.storey.trim():null;
|
|
9580
|
+
const t=(typeof o.ifcType==='string'&&o.ifcType.trim())?o.ifcType.trim():null;
|
|
9581
|
+
if(!byStorey.has(s))byStorey.set(s,new Map());
|
|
9582
|
+
const types=byStorey.get(s);
|
|
9583
|
+
if(!types.has(t))types.set(t,[]);
|
|
9584
|
+
types.get(t).push(i);
|
|
9585
|
+
}
|
|
9586
|
+
const out=[];
|
|
9587
|
+
for(const [storey,types] of byStorey){
|
|
9588
|
+
const groups=[...types].map(([type,indices])=>({type,words:ifcTypeWords(type),count:indices.length,indices}));
|
|
9589
|
+
out.push({storey,count:groups.reduce((n,g)=>n+g.count,0),types:groups});
|
|
9590
|
+
}
|
|
9591
|
+
// The unlabelled storey last, wherever it appeared. It is the one group whose position carries no
|
|
9592
|
+
// information from the file, so it is the one group we may place.
|
|
9593
|
+
out.sort((a,b)=>(a.storey===null?1:0)-(b.storey===null?1:0));
|
|
9594
|
+
return out;
|
|
9595
|
+
}
|
|
9596
|
+
|
|
9507
9597
|
/** One `name: value` row. The FOUR value states are rendered differently ON PURPOSE — see the CSS. */
|
|
9508
9598
|
function buildPropRow(prop){
|
|
9509
9599
|
const row=document.createElement('div');row.className='psrow';
|
|
@@ -9680,6 +9770,433 @@ function renderPanelReferenceObject(p){
|
|
|
9680
9770
|
return true;
|
|
9681
9771
|
}
|
|
9682
9772
|
|
|
9773
|
+
// ── The object tree (S2 Stage B) ─────────────────────────────────────────────────────────────────
|
|
9774
|
+
//
|
|
9775
|
+
// What is INSIDE one reference, grouped storey → IFC type, in the row's own detail block. Selecting a
|
|
9776
|
+
// row drills into that object exactly as Ctrl+click does — it is the same call — and drilling in 3D
|
|
9777
|
+
// brings the tree to the object.
|
|
9778
|
+
|
|
9779
|
+
/**
|
|
9780
|
+
* Per-REFERENCE tree state, scoped per reference for the reason `refPsetOpen` is scoped per object.
|
|
9781
|
+
* (Its key is `refId|objIdx`; these are keyed by reference id alone, which is the level they belong to.)
|
|
9782
|
+
*
|
|
9783
|
+
* One global tree state would silently misapply reference A's open storeys to reference B's entirely
|
|
9784
|
+
* different ones — the same trap the property-set memory already avoids, one level up.
|
|
9785
|
+
*
|
|
9786
|
+
* `refTreeGroups` holds an EXPLICIT open/closed per group, not a set of "expanded" keys. A set cannot
|
|
9787
|
+
* express this: the default for a lone group is OPEN, so the set has to mean both "the user opened this"
|
|
9788
|
+
* and "the user has touched nothing", and those two cancel — clicking a lone group's header wrote the
|
|
9789
|
+
* key, which read back as still-open, and clicking again emptied the set, which re-armed the auto-open.
|
|
9790
|
+
* The header could never be closed, and worse, its click changed the OTHER level (whose default was
|
|
9791
|
+
* keyed on the same set being empty). A key that is simply absent means "no opinion — use the default".
|
|
9792
|
+
*/
|
|
9793
|
+
const refTreeOpen=new Set(); // reference ids whose tree accordion is open
|
|
9794
|
+
const refTreeGroups=new Map(); // refId -> Map<group key ('storeyIdx' / 'storeyIdx:typeIdx'), boolean open>
|
|
9795
|
+
const refTreeQuery=new Map(); // refId -> the live filter text
|
|
9796
|
+
/** The id the filter input carries, so it can be found again across the repaint its own typing causes. */
|
|
9797
|
+
const REF_TREE_SEARCH_ID='refTreeSearch';
|
|
9798
|
+
/**
|
|
9799
|
+
* How many object rows one type group will build at once.
|
|
9800
|
+
*
|
|
9801
|
+
* The DOM is bounded: a group builds rows only once it is open, and the one path that opens groups
|
|
9802
|
+
* unasked (a filter at or below this cap) can by definition not exceed it. But ONE group can still be
|
|
9803
|
+
* enormous: Daldy's IFCMEMBER is 9,210 objects. This is the last bound, and it is stated in the UI
|
|
9804
|
+
* rather than applied silently: a list that stops at 300 with no explanation reads as a broken tree,
|
|
9805
|
+
* which is worse than a limit that says what it is.
|
|
9806
|
+
*
|
|
9807
|
+
* Deliberately NOT virtualisation. Nothing in this app windows a list — `#ciList` and `#vgList` are
|
|
9808
|
+
* both plain `overflow:auto` — and introducing it for one feature is more machinery than the problem
|
|
9809
|
+
* needs once rendering is lazy. What the user gives up past the cap is scroll-hunting; the filter is
|
|
9810
|
+
* the way through, and it is right there. The one row the cap may NOT drop is the selected one — see
|
|
9811
|
+
* the window in `buildRefTree`, without which "drilling in 3D shows you the row" was false for the
|
|
9812
|
+
* 8,910 members of that group that fall past row 300.
|
|
9813
|
+
*/
|
|
9814
|
+
const REF_TREE_CAP=300;
|
|
9815
|
+
|
|
9816
|
+
/**
|
|
9817
|
+
* Does this object match the filter? Name, raw IFC type, storey, and the plain word the tree shows for
|
|
9818
|
+
* that type — the four things a row shows or sits under. `q` must arrive lowercased and trimmed; only
|
|
9819
|
+
* the haystack is lowercased here.
|
|
9820
|
+
*/
|
|
9821
|
+
function refTreeMatches(o,q){
|
|
9822
|
+
if(!q)return true;
|
|
9823
|
+
const hay=[o&&o.name,o&&o.ifcType,o&&o.storey,ifcTypeWords(o&&o.ifcType)].filter((s)=>typeof s==='string').join(' ').toLowerCase();
|
|
9824
|
+
return hay.includes(q);
|
|
9825
|
+
}
|
|
9826
|
+
|
|
9827
|
+
/**
|
|
9828
|
+
* Make a `role=button` div actually behave like one.
|
|
9829
|
+
*
|
|
9830
|
+
* `role=button` without a tab stop and a key handler is a promise to a screen reader that the element
|
|
9831
|
+
* cannot keep — it announces "button, collapsed" and then Tab never reaches it. The legend's own
|
|
9832
|
+
* `.cat-hdr` elsewhere carries no role, so it at least does not lie; these do, so they earn the rest.
|
|
9833
|
+
* `stopPropagation` because the editor's global shortcut handler eats Space and Enter.
|
|
9834
|
+
*
|
|
9835
|
+
* `ownsTabStop:false` for anything inside a roving group — see `refTreeRoving`.
|
|
9836
|
+
*/
|
|
9837
|
+
function refTreeKeyOperable(el,ownsTabStop){
|
|
9838
|
+
if(ownsTabStop!==false)el.tabIndex=0;
|
|
9839
|
+
el.addEventListener('keydown',(e)=>{
|
|
9840
|
+
if(e.key!=='Enter'&&e.key!==' ')return;
|
|
9841
|
+
e.preventDefault();e.stopPropagation();el.click();
|
|
9842
|
+
});
|
|
9843
|
+
}
|
|
9844
|
+
|
|
9845
|
+
/**
|
|
9846
|
+
* ONE tab stop for the whole list of object rows, with the arrows moving inside it.
|
|
9847
|
+
*
|
|
9848
|
+
* A capped type group is 300 rows, and several can be open at once. Giving each row a tab stop made the
|
|
9849
|
+
* tree keyboard-REACHABLE and the page keyboard-hostile: Tab had to be pressed hundreds of times to get
|
|
9850
|
+
* past the legend. This is the roving-tabindex pattern the editor already uses for its long selectable
|
|
9851
|
+
* lists — the active row is the selected one if it is on screen, else the first, and Arrow Up/Down move
|
|
9852
|
+
* both the focus and the stop. Tab then enters the list once and leaves it once.
|
|
9853
|
+
*/
|
|
9854
|
+
function refTreeRoving(rows){
|
|
9855
|
+
const isSel=(n)=>String(n.className||'').split(/\s+/).includes('sel');
|
|
9856
|
+
const active=rows.find(isSel)||rows[0];
|
|
9857
|
+
rows.forEach((n)=>{n.tabIndex=n===active?0:-1;});
|
|
9858
|
+
rows.forEach((n,i)=>n.addEventListener('keydown',(e)=>{
|
|
9859
|
+
if(e.key!=='ArrowDown'&&e.key!=='ArrowUp')return;
|
|
9860
|
+
const next=rows[i+(e.key==='ArrowDown'?1:-1)];
|
|
9861
|
+
if(!next)return;
|
|
9862
|
+
e.preventDefault();e.stopPropagation();
|
|
9863
|
+
rows.forEach((m)=>{m.tabIndex=-1;});
|
|
9864
|
+
next.tabIndex=0;next.focus();
|
|
9865
|
+
}));
|
|
9866
|
+
}
|
|
9867
|
+
|
|
9868
|
+
/**
|
|
9869
|
+
* The tree for one reference, appended to its detail block.
|
|
9870
|
+
*
|
|
9871
|
+
* Renders NOTHING but a header until the user opens it, and nothing but group headers until they open a
|
|
9872
|
+
* group. That is what makes a 17,460-object file cost the same as a 19-object one on the way IN; opening
|
|
9873
|
+
* the tree itself is then one linear pass plus a header per storey×type (192 of them, on that file).
|
|
9874
|
+
*/
|
|
9875
|
+
function buildRefTree(r,wrap){
|
|
9876
|
+
const geom=refGeom.get(r.id);
|
|
9877
|
+
const open=refTreeOpen.has(r.id);
|
|
9878
|
+
const hd=document.createElement('button');hd.type='button';hd.className='psethd';
|
|
9879
|
+
hd.setAttribute('aria-expanded',String(open));hd.setAttribute('aria-controls','reftree-'+r.id);
|
|
9880
|
+
const chev=Object.assign(document.createElement('span'),{className:'chev',textContent:'▸'});chev.setAttribute('aria-hidden','true');
|
|
9881
|
+
hd.append(chev,Object.assign(document.createElement('span'),{className:'psn',textContent:'What’s in this file'}),
|
|
9882
|
+
Object.assign(document.createElement('span'),{className:'psc',textContent:geom?String((geom.objects||[]).length):''}));
|
|
9883
|
+
hd.dataset.tip='List the objects inside this reference, grouped by storey and IFC type';
|
|
9884
|
+
wrap.appendChild(hd);
|
|
9885
|
+
const body=document.createElement('div');body.className='psetbody'+(open?' open':'');body.id='reftree-'+r.id;
|
|
9886
|
+
wrap.appendChild(body);
|
|
9887
|
+
hd.addEventListener('click',()=>{
|
|
9888
|
+
if(refTreeOpen.has(r.id))refTreeOpen.delete(r.id);else refTreeOpen.add(r.id);
|
|
9889
|
+
renderRefsTab();
|
|
9890
|
+
});
|
|
9891
|
+
if(!open)return;
|
|
9892
|
+
|
|
9893
|
+
// NOT AN EMPTY TREE — say which of the several reasons it is. A tree that renders nothing is
|
|
9894
|
+
// indistinguishable from a file with nothing in it, and only one of those is true at a time.
|
|
9895
|
+
if(!geom){
|
|
9896
|
+
const n=Object.assign(document.createElement('div'),{className:'dnote'});
|
|
9897
|
+
n.textContent=refLoading.has(r.id)?'Still reading this file…'
|
|
9898
|
+
:refUnresolved.has(r.id)?'Its file is missing from this project, so there is nothing to list.'
|
|
9899
|
+
:refFailed.has(r.id)?'Its geometry could not be loaded — use ⋯ ▸ Reload its geometry.'
|
|
9900
|
+
// The reader ANSWERED for this one and had nothing drawable to give. The row already says
|
|
9901
|
+
// "· nothing to draw"; saying "never read" three pixels below it would contradict it.
|
|
9902
|
+
:refEmpty.has(r.id)?'This file was read, but it holds nothing we can draw — so there is nothing to list.'
|
|
9903
|
+
:'This file hasn’t been read yet.';
|
|
9904
|
+
body.appendChild(n);return;
|
|
9905
|
+
}
|
|
9906
|
+
const objects=geom.objects||[];
|
|
9907
|
+
// Geometry present and empty is a FIFTH state, not a sixth branch of the one above: a cache entry that
|
|
9908
|
+
// predates the reader's own emptiness check returns ok with no objects. Without this the tree drew a
|
|
9909
|
+
// filter box over an empty bordered rectangle and said nothing at all — the exact outcome the comment
|
|
9910
|
+
// above promises to prevent.
|
|
9911
|
+
if(!objects.length){
|
|
9912
|
+
body.appendChild(Object.assign(document.createElement('div'),
|
|
9913
|
+
{className:'dnote',textContent:'Reading this file returned no objects — use ⋯ ▸ Reload its geometry to try again.'}));
|
|
9914
|
+
return;
|
|
9915
|
+
}
|
|
9916
|
+
const groups=groupReferenceObjects(objects);
|
|
9917
|
+
const q=(refTreeQuery.get(r.id)||'').trim().toLowerCase();
|
|
9918
|
+
|
|
9919
|
+
// The filter, inside the tree it filters — it is scoped to ONE reference's objects, so it is not a
|
|
9920
|
+
// peer of the tab's own controls. It reuses the property popover's SHAPE, not its CSS: every
|
|
9921
|
+
// `.ppsearch` rule is scoped to #propPop and cannot reach this panel, so the class is styled here.
|
|
9922
|
+
const sb=document.createElement('div');sb.className='reftreesearch';
|
|
9923
|
+
const inp=document.createElement('input');inp.type='text';inp.placeholder='Filter by name, type or storey…';
|
|
9924
|
+
inp.id=REF_TREE_SEARCH_ID;
|
|
9925
|
+
inp.autocomplete='off';inp.value=refTreeQuery.get(r.id)||'';
|
|
9926
|
+
inp.setAttribute('role','searchbox');inp.setAttribute('aria-label','Filter the objects in this reference');
|
|
9927
|
+
inp.addEventListener('keydown',(e)=>e.stopPropagation()); // the editor's global shortcuts must not see typing
|
|
9928
|
+
// TYPING REPAINTS THE TAB, WHICH DESTROYS THIS INPUT, so the focus has to be put back or the NEXT
|
|
9929
|
+
// character lands on the document — where `a` arms Add-member and Backspace deletes the selection.
|
|
9930
|
+
// (That is not hypothetical: the first version looked this up with a selector that could never match,
|
|
9931
|
+
// and typing "beam" into the filter armed a tool.) Found by id, because the id is the one thing that
|
|
9932
|
+
// survives the rebuild, and the whole selection is restored, so editing mid-word works.
|
|
9933
|
+
//
|
|
9934
|
+
// NOT WHILE COMPOSING. An IME builds one character out of several keystrokes and holds that state on
|
|
9935
|
+
// the INPUT ELEMENT; replacing the element mid-composition drops or mangles it. `isComposing` means
|
|
9936
|
+
// the user is mid-character, so the tree simply does not repaint until `compositionend` fires — the
|
|
9937
|
+
// filter is one keystroke stale for the duration, which nobody can see, and the character survives.
|
|
9938
|
+
//
|
|
9939
|
+
// Undo history is NOT preserved: it belongs to the element, and this rebuilds the element. Fixing that
|
|
9940
|
+
// means repainting the tree without rebuilding the whole tab, which is a larger change than this pass.
|
|
9941
|
+
const refilter=()=>{
|
|
9942
|
+
const from=inp.selectionStart,to=inp.selectionEnd,dir=inp.selectionDirection;
|
|
9943
|
+
refTreeQuery.set(r.id,inp.value);renderRefsTab();
|
|
9944
|
+
const again=document.getElementById(REF_TREE_SEARCH_ID);
|
|
9945
|
+
if(!again){console.error('[reference] the tree filter did not survive its repaint — typing would now reach the editor shortcuts');return;}
|
|
9946
|
+
again.focus();
|
|
9947
|
+
try{again.setSelectionRange(from,to,dir||'none');}catch(e){console.debug('[reference] could not restore the filter selection',e);}
|
|
9948
|
+
};
|
|
9949
|
+
inp.addEventListener('input',(e)=>{ if(e&&e.isComposing)return; refilter(); });
|
|
9950
|
+
inp.addEventListener('compositionend',refilter);
|
|
9951
|
+
sb.appendChild(inp);body.appendChild(sb);
|
|
9952
|
+
|
|
9953
|
+
const box=document.createElement('div');box.className='reftree';body.appendChild(box);
|
|
9954
|
+
const expanded=refTreeGroups.get(r.id)||new Map();
|
|
9955
|
+
|
|
9956
|
+
// MATCHED ONCE, NOT PER GROUP. Every count below is a lookup into this set. The old shape re-ran the
|
|
9957
|
+
// string work of `refTreeMatches` for each object once for its storey's count and again for its type's
|
|
9958
|
+
// count, and it measured 732 ms per keystroke — a filter you can outrun by typing.
|
|
9959
|
+
const hits=q?new Set():null;
|
|
9960
|
+
if(q)for(let i=0;i<objects.length;i++)if(refTreeMatches(objects[i],q))hits.add(i);
|
|
9961
|
+
const matched=q?hits.size:objects.length;
|
|
9962
|
+
|
|
9963
|
+
/**
|
|
9964
|
+
* A filter opens the groups it matched — UNLESS it matched more than one screenful.
|
|
9965
|
+
*
|
|
9966
|
+
* "Never hide a match behind a collapsed chevron" is the right instinct and it does not survive this
|
|
9967
|
+
* building: filtering Daldy for "mullion" matches 8,000-odd objects across ten storeys, and force-
|
|
9968
|
+
* expanding all of them built 2,795 rows and nine separate "showing 300 of …" lines — a wall, from a
|
|
9969
|
+
* rule meant to be helpful. Above the cap the groups keep whatever the user had open, and their headers
|
|
9970
|
+
* still read "N of M", so where the matches are is stated rather than dumped.
|
|
9971
|
+
*/
|
|
9972
|
+
const wide=!!q&&matched>REF_TREE_CAP;
|
|
9973
|
+
// A SINGLE GROUP AT ITS LEVEL OPENS ITSELF — with nothing to choose between, a click to reach the only
|
|
9974
|
+
// content is a toll. It is also what makes the storey-less file and the single-storey file (Motebello)
|
|
9975
|
+
// land somewhere sensible with no special case.
|
|
9976
|
+
//
|
|
9977
|
+
// A CHOICE IS REMEMBERED AGAINST THE FILTER IT WAS MADE UNDER, which is what lets both of these be
|
|
9978
|
+
// true at once: a filter opens the groups it matched, AND a header still obeys a click while filtering.
|
|
9979
|
+
// Storing the choice alone could not do that — a storey closed with no filter went on suppressing its
|
|
9980
|
+
// own matches afterwards, so a user could type a precise query, read "(2 of 6)" on the header, and be
|
|
9981
|
+
// shown nothing. Keying the choice to the query means the collapse applies when that query returns
|
|
9982
|
+
// (including when it returns to empty) and stays out of the way under a different one.
|
|
9983
|
+
const isOpen=(key,only)=>{
|
|
9984
|
+
const chose=expanded.get(key);
|
|
9985
|
+
// `q:null` is the reveal's own mark: "this group holds the selection, keep it open under ANY query".
|
|
9986
|
+
// Without it, groups opened only to show a selected object collapsed the moment the filter changed —
|
|
9987
|
+
// including clearing it — so an object picked while filtering vanished from the tree the instant the
|
|
9988
|
+
// user emptied the box, while staying selected in 3D and in the panel.
|
|
9989
|
+
if(chose&&(chose.q===null||chose.q===q))return chose.open;
|
|
9990
|
+
if(q&&!wide)return true;
|
|
9991
|
+
return !!only;
|
|
9992
|
+
};
|
|
9993
|
+
const toggle=(key,wasOpen)=>{const s=new Map(refTreeGroups.get(r.id)||[]);
|
|
9994
|
+
s.set(key,{open:!wasOpen,q});refTreeGroups.set(r.id,s);renderRefsTab();};
|
|
9995
|
+
// THE STOREY TIER IS OMITTED ENTIRELY when the file records no storeys at all — chrome around a
|
|
9996
|
+
// grouping level that carries no information. One line says so instead, once.
|
|
9997
|
+
const flat=groups.length===1&&groups[0].storey===null;
|
|
9998
|
+
const built=[]; // every object row this paint produced, in order — see `refTreeRoving` at the end
|
|
9999
|
+
if(flat){
|
|
10000
|
+
const n=Object.assign(document.createElement('div'),{className:'dnote'});n.style.margin='0 0 4px';
|
|
10001
|
+
n.textContent='This file does not record storeys — its objects are grouped by type only.';
|
|
10002
|
+
box.appendChild(n);
|
|
10003
|
+
}
|
|
10004
|
+
groups.forEach((s,si)=>{
|
|
10005
|
+
const sKey=String(si);
|
|
10006
|
+
const sMatched=q?s.types.reduce((n,t)=>n+t.indices.reduce((m,i)=>m+(hits.has(i)?1:0),0),0):s.count;
|
|
10007
|
+
if(q&&!sMatched)return; // a storey with no match is gone, not greyed
|
|
10008
|
+
const sOpen=flat||isOpen(sKey,groups.length===1);
|
|
10009
|
+
if(!flat){
|
|
10010
|
+
const h=document.createElement('div');h.className='cat-hdr';h.setAttribute('role','button');
|
|
10011
|
+
h.setAttribute('aria-expanded',String(sOpen));
|
|
10012
|
+
h.append(Object.assign(document.createElement('span'),{className:'cat-chevron',textContent:sOpen?'▼':'▶'}),
|
|
10013
|
+
Object.assign(document.createElement('span'),{className:'cat-label',textContent:s.storey||'No storey recorded'}),
|
|
10014
|
+
// "N of M" WHILE FILTERING. A count that quietly means something different depending on a text box
|
|
10015
|
+
// above it is the same class of wrong as a stale one.
|
|
10016
|
+
Object.assign(document.createElement('span'),{className:'cat-count',textContent:q?'('+sMatched+' of '+s.count+')':'('+s.count+')'}));
|
|
10017
|
+
h.dataset.tip=(s.storey||'The file records no storey for these objects')+' — '+s.count+' object'+(s.count===1?'':'s');
|
|
10018
|
+
h.addEventListener('click',()=>toggle(sKey,sOpen));
|
|
10019
|
+
refTreeKeyOperable(h);
|
|
10020
|
+
box.appendChild(h);
|
|
10021
|
+
}
|
|
10022
|
+
if(!sOpen)return;
|
|
10023
|
+
// TWO TYPES CAN SHARE A PLAIN WORD, and Daldy proves it: `IFCWALL` and `IFCWALLSTANDARDCASE` both
|
|
10024
|
+
// read "Wall", so its LG storey listed "Wall (388)" directly above "Wall (52)" — two groups a user
|
|
10025
|
+
// cannot tell apart, differing only in a number. The raw token comes back for exactly those, and only
|
|
10026
|
+
// those: showing it on every header does not fit a 340px panel sixteen times over, and showing it
|
|
10027
|
+
// never leaves the list lying about what is in the file. (Found by running it on the real building.)
|
|
10028
|
+
const words=(t)=>t.words||'No type recorded';
|
|
10029
|
+
const dup=new Set(),once=new Set();
|
|
10030
|
+
s.types.forEach((t)=>{const w=words(t);if(once.has(w))dup.add(w);else once.add(w);});
|
|
10031
|
+
s.types.forEach((t,ti)=>{
|
|
10032
|
+
const tKey=si+':'+ti;
|
|
10033
|
+
const tHits=q?t.indices.filter((i)=>hits.has(i)):t.indices;
|
|
10034
|
+
if(q&&!tHits.length)return;
|
|
10035
|
+
const tOpen=isOpen(tKey,s.types.length===1);
|
|
10036
|
+
const h=document.createElement('div');h.className='cat-hdr'+(flat?'':' sub');h.setAttribute('role','button');
|
|
10037
|
+
h.setAttribute('aria-expanded',String(tOpen));
|
|
10038
|
+
h.append(Object.assign(document.createElement('span'),{className:'cat-chevron',textContent:tOpen?'▼':'▶'}),
|
|
10039
|
+
// The PLAIN WORD only. "Generic element (IFCBUILDINGELEMENTPROXY)" does not fit a 340px panel
|
|
10040
|
+
// repeated sixteen times, and the raw token is already shown on the object itself once selected —
|
|
10041
|
+
// except where two of this storey's types share that word, when it is the only thing separating them.
|
|
10042
|
+
Object.assign(document.createElement('span'),{className:'cat-label',textContent:words(t)+(dup.has(words(t))&&t.type?' · '+t.type:'')}),
|
|
10043
|
+
Object.assign(document.createElement('span'),{className:'cat-count',textContent:q?'('+tHits.length+' of '+t.count+')':'('+t.count+')'}));
|
|
10044
|
+
h.dataset.tip=(t.type||'The file records no IFC type for these objects')+' — '+t.count+' object'+(t.count===1?'':'s');
|
|
10045
|
+
h.addEventListener('click',()=>toggle(tKey,tOpen));
|
|
10046
|
+
refTreeKeyOperable(h);
|
|
10047
|
+
box.appendChild(h);
|
|
10048
|
+
if(!tOpen)return;
|
|
10049
|
+
const list=tHits;
|
|
10050
|
+
// THE SELECTED ROW IS NEVER THE ONE THE CAP DROPS. Taking a blind first-300 made "drill in 3D and the
|
|
10051
|
+
// tree shows you the row" false for 8,910 of this group's 9,210 members — the reveal opened the right
|
|
10052
|
+
// headers and then found nothing to scroll to. When the selection sits past the cap the window slides
|
|
10053
|
+
// to hold it, and the line below says so rather than still claiming the first 300.
|
|
10054
|
+
const want=(refSelectedId===r.id&&typeof refSelectedObjIdx==='number')?list.indexOf(refSelectedObjIdx):-1;
|
|
10055
|
+
let from=0;
|
|
10056
|
+
if(want>=REF_TREE_CAP)from=Math.min(want-(REF_TREE_CAP>>1),list.length-REF_TREE_CAP);
|
|
10057
|
+
const shown=list.slice(from,from+REF_TREE_CAP);
|
|
10058
|
+
// The ordinal of every row in one pass, rather than an indexOf per row: on a 9,210-index group a
|
|
10059
|
+
// filter whose matches sit late cost ~2.8M comparisons on EVERY keystroke.
|
|
10060
|
+
const ord=new Map();t.indices.forEach((i,n)=>ord.set(i,n+1));
|
|
10061
|
+
shown.forEach((idx)=>{ const row=buildRefObjRow(r,objects[idx],idx,t,flat,ord.get(idx)); built.push(row); box.appendChild(row); });
|
|
10062
|
+
if(list.length>REF_TREE_CAP){
|
|
10063
|
+
const more=Object.assign(document.createElement('div'),{className:'refcap'});
|
|
10064
|
+
more.textContent=from
|
|
10065
|
+
?'Showing '+shown.length+' of '+list.length+', centred on the selected object — use the filter above to narrow this list.'
|
|
10066
|
+
:'Showing '+REF_TREE_CAP+' of '+list.length+' — use the filter above to narrow this list.';
|
|
10067
|
+
box.appendChild(more);
|
|
10068
|
+
}
|
|
10069
|
+
});
|
|
10070
|
+
});
|
|
10071
|
+
if(built.length)refTreeRoving(built);
|
|
10072
|
+
if(q&&!matched){
|
|
10073
|
+
const e=Object.assign(document.createElement('div'),{className:'lsempty'});
|
|
10074
|
+
e.textContent='No objects match “'+(refTreeQuery.get(r.id)||'').trim()+'”.';
|
|
10075
|
+
box.appendChild(e);
|
|
10076
|
+
}
|
|
10077
|
+
}
|
|
10078
|
+
|
|
10079
|
+
/**
|
|
10080
|
+
* Bring the tree to an object drilled into from the 3D view.
|
|
10081
|
+
*
|
|
10082
|
+
* ONLY IF THE TREE IS ALREADY OPEN. Ctrl+click in the canvas is not a request to rearrange the legend,
|
|
10083
|
+
* and opening a panel behind the user's back — expanding groups, scrolling a list they were not looking
|
|
10084
|
+
* at — is the kind of help that costs them their place. When the tree IS open the opposite is true: a
|
|
10085
|
+
* selection the tree cannot show is a tree disagreeing with the scene, so its groups open, the row
|
|
10086
|
+
* scrolls into view, and it flashes the way every other "you just navigated here" row in this panel does.
|
|
10087
|
+
*
|
|
10088
|
+
* TWO THINGS COULD HIDE THAT ROW and both are handled here rather than left to fail quietly: a filter the
|
|
10089
|
+
* object does not match (cleared, and the user is told, because a tree that silently drops the filter is
|
|
10090
|
+
* as confusing as one that silently ignores the selection), and a position past the row cap (handled by
|
|
10091
|
+
* the window in `buildRefTree`, which keys off the selection this function has already set).
|
|
10092
|
+
*
|
|
10093
|
+
* Returns false when it did nothing, so the caller can fall back to an ordinary repaint.
|
|
10094
|
+
*/
|
|
10095
|
+
function revealRefTreeObject(refId,idx){
|
|
10096
|
+
if(!refTreeOpen.has(refId)||legendTab!=='refs')return false;
|
|
10097
|
+
const geom=refGeom.get(refId);
|
|
10098
|
+
const objects=geom&&geom.objects;
|
|
10099
|
+
if(!Array.isArray(objects)||!objects[idx])return false;
|
|
10100
|
+
const q=(refTreeQuery.get(refId)||'').trim().toLowerCase();
|
|
10101
|
+
const cleared=!!q&&!refTreeMatches(objects[idx],q);
|
|
10102
|
+
if(cleared)refTreeQuery.set(refId,'');
|
|
10103
|
+
const groups=groupReferenceObjects(objects);
|
|
10104
|
+
// `q:null` — open under ANY query, not just the one in the box right now. The path to the SELECTED
|
|
10105
|
+
// object is not a filter-scoped preference: filed against the current query, these opens evaporated as
|
|
10106
|
+
// soon as the user changed or cleared the filter, and the object they had just picked dropped out of
|
|
10107
|
+
// the tree while remaining lit in 3D. A later explicit click on the same header overwrites this.
|
|
10108
|
+
const s=new Map(refTreeGroups.get(refId)||[]);
|
|
10109
|
+
groups.forEach((st,si)=>st.types.forEach((t,ti)=>{
|
|
10110
|
+
if(t.indices.indexOf(idx)<0)return;
|
|
10111
|
+
s.set(String(si),{open:true,q:null});s.set(si+':'+ti,{open:true,q:null});
|
|
10112
|
+
}));
|
|
10113
|
+
refTreeGroups.set(refId,s);
|
|
10114
|
+
renderRefsTab();
|
|
10115
|
+
// SAID BEFORE ANYTHING ELSE CAN GO WRONG. Taking the filter away is a visible change to the user's own
|
|
10116
|
+
// state, so it is announced on every path that does it — including the one below that then fails to
|
|
10117
|
+
// find the row, which is exactly when an unexplained empty filter box would be most confusing.
|
|
10118
|
+
if(cleared)toast('Cleared the object filter to show the selected object');
|
|
10119
|
+
// Scoped to THIS reference's tree. Only the selected reference renders a detail block today, so an
|
|
10120
|
+
// unscoped lookup is right by accident; this makes it right on purpose.
|
|
10121
|
+
const row=document.querySelector('#reftree-'+refId+' .refobjrow[data-idx="'+idx+'"]');
|
|
10122
|
+
if(!row){console.error('[reference] object',idx,'of',refId,'is selected but has no row in the open tree');return true;}
|
|
10123
|
+
try{row.scrollIntoView({block:'nearest'});}catch(e){console.debug('[reference] scrollIntoView unavailable',e);}
|
|
10124
|
+
row.classList.add('flash');setTimeout(()=>row.classList.remove('flash'),900);
|
|
10125
|
+
return true;
|
|
10126
|
+
}
|
|
10127
|
+
|
|
10128
|
+
/** "1st", "2nd", "3rd", "4th" — including the 11th/12th/13th exceptions, which the naive rule gets wrong. */
|
|
10129
|
+
function ordinalSuffix(n){
|
|
10130
|
+
const t=n%100;
|
|
10131
|
+
if(t>=11&&t<=13)return 'th';
|
|
10132
|
+
return ['th','st','nd','rd'][n%10]||'th';
|
|
10133
|
+
}
|
|
10134
|
+
|
|
10135
|
+
/**
|
|
10136
|
+
* One object row.
|
|
10137
|
+
*
|
|
10138
|
+
* THE NAME IS NOT ENOUGH AND THIS FILE PROVES IT: twelve of Motebello's nineteen objects are called
|
|
10139
|
+
* "Betonfertigteil" and two are called "-". So the row carries its position within its own type group as
|
|
10140
|
+
* well — `#4/19` on that file, since all nineteen share one type — which always exists and is the one
|
|
10141
|
+
* thing that distinguishes two otherwise identical rows. The caller passes the ordinal in because it can
|
|
10142
|
+
* number a whole group in one pass; finding it per row was a linear scan of up to 9,210 indices.
|
|
10143
|
+
*
|
|
10144
|
+
* THE ORDINAL IS COUNTED AGAINST THE UNFILTERED GROUP. Numbering the filtered view would renumber every
|
|
10145
|
+
* object as the user types, which is a statement about the file that changes with a text box.
|
|
10146
|
+
*/
|
|
10147
|
+
function buildRefObjRow(r,o,idx,group,flat,ordinal){
|
|
10148
|
+
const row=document.createElement('div');
|
|
10149
|
+
row.className='refobjrow'+(refSelectedId===r.id&&refSelectedObjIdx===idx?' sel':'');
|
|
10150
|
+
if(flat)row.style.paddingLeft='20px';
|
|
10151
|
+
row.dataset.idx=String(idx);
|
|
10152
|
+
// Enter/Space select, like `refTreeKeyOperable` — but selecting REPAINTS the tab, which destroys this
|
|
10153
|
+
// row, and the focus went to the document with it. A keyboard user who picks a row was then back at
|
|
10154
|
+
// the top of the panel and could not carry on arrowing. So the focus is put on the row that replaced
|
|
10155
|
+
// this one. (Rows do not own a tab stop of their own — `refTreeRoving` shares one between them.)
|
|
10156
|
+
row.setAttribute('role','button');
|
|
10157
|
+
row.addEventListener('keydown',(e)=>{
|
|
10158
|
+
if(e.key!=='Enter'&&e.key!==' ')return;
|
|
10159
|
+
e.preventDefault();e.stopPropagation();
|
|
10160
|
+
row.click();
|
|
10161
|
+
const again=document.querySelector('#reftree-'+r.id+' .refobjrow[data-idx="'+idx+'"]');
|
|
10162
|
+
if(again)again.focus();
|
|
10163
|
+
});
|
|
10164
|
+
const named=refObjNamed(o&&o.name);
|
|
10165
|
+
const label=named?String(o.name).trim():(group.words||'Object');
|
|
10166
|
+
row.appendChild(Object.assign(document.createElement('span'),{className:'ronm',textContent:label}));
|
|
10167
|
+
if(ordinal>0)row.appendChild(Object.assign(document.createElement('span'),{className:'rord',textContent:'#'+ordinal+'/'+group.count}));
|
|
10168
|
+
// The ordinal badge is the one thing on this row whose MEANING is not self-evident — `#4/19` could be
|
|
10169
|
+
// read as a date or an id — so the tooltip spells it out. It is the only place that can: the row is
|
|
10170
|
+
// already dense, and a second visible label per row on a 340px rail costs more than it explains.
|
|
10171
|
+
row.dataset.tip=(named?String(o.name).trim():'This file gives it no name')+' — '+(o&&o.ifcType||'no IFC type')
|
|
10172
|
+
+(o&&o.storey?' · '+String(o.storey).trim():'')
|
|
10173
|
+
+(ordinal>0?' — the '+ordinal+ordinalSuffix(ordinal)+' of '+group.count+' with this type in this storey':'');
|
|
10174
|
+
// THE SAME CALL Ctrl+click MAKES. Two routes into one selection, so they cannot drift into two.
|
|
10175
|
+
row.addEventListener('click',()=>{
|
|
10176
|
+
const v=window.Steel3DView;
|
|
10177
|
+
if(!v||!v.selectReferenceObject){
|
|
10178
|
+
console.error('[reference] the 3D view is not available, so a tree row cannot select',r.id,idx);
|
|
10179
|
+
toast('The 3D view isn’t ready yet — try again in a moment');return;
|
|
10180
|
+
}
|
|
10181
|
+
// Visibility is NOT what makes this fail — `setReferences` builds a mesh for every object whether the
|
|
10182
|
+
// reference is shown or not, so a hidden reference selects fine. What fails is the panel and the
|
|
10183
|
+
// renderer disagreeing about how many objects there are, and telling the user to toggle an eye icon
|
|
10184
|
+
// would send them after the wrong thing. A throw is caught for the same reason: it would otherwise
|
|
10185
|
+
// escape the listener and leave the tree half-drawn with no message at all.
|
|
10186
|
+
let ok=false;
|
|
10187
|
+
try{ok=v.selectReferenceObject(r.id,idx);}
|
|
10188
|
+
catch(e){
|
|
10189
|
+
console.error('[reference] selecting object',idx,'of',r.id,'threw',e);
|
|
10190
|
+
toast('Could not select that object — use ⋯ ▸ Reload its geometry');return;
|
|
10191
|
+
}
|
|
10192
|
+
if(!ok){
|
|
10193
|
+
console.error('[reference] object',idx,'of',r.id,'has no mesh — the panel and the 3D view disagree');
|
|
10194
|
+
toast('That object isn’t in the 3D scene — use ⋯ ▸ Reload its geometry');
|
|
10195
|
+
}
|
|
10196
|
+
});
|
|
10197
|
+
return row;
|
|
10198
|
+
}
|
|
10199
|
+
|
|
9683
10200
|
/** A file size a human recognises from their file manager. KB under a megabyte, MB above it. */
|
|
9684
10201
|
function fileSizeWords(bytes){
|
|
9685
10202
|
const n=Number(bytes)||0;
|
|
@@ -9742,7 +10259,12 @@ function openRefRowMenu(r,anchorEl){closeRefRowMenu();
|
|
|
9742
10259
|
if(nativeModelBounds())m.append(mk(REF_MOVE_LABEL,()=>refMoveToOrigin(r.id)));
|
|
9743
10260
|
m.append(mk('Reload its geometry',()=>{
|
|
9744
10261
|
if(refDisp(r).locked){toast('“'+r.name+'” is locked — unlock it to reload it');return;} // the lock freezes reload, as the schema says
|
|
9745
|
-
refGeom.delete(r.id);refFailed.delete(r.id);refEmpty.delete(r.id);refUnresolved.delete(r.id);
|
|
10262
|
+
refGeom.delete(r.id);refFailed.delete(r.id);refEmpty.delete(r.id);refUnresolved.delete(r.id);
|
|
10263
|
+
// The tree's group keys are POSITIONAL ('2:1' is the second storey's second type), so a
|
|
10264
|
+
// re-read that adds, drops or reorders anything makes them address different groups. Dropped
|
|
10265
|
+
// rather than migrated: there is no identity here to migrate them by.
|
|
10266
|
+
refTreeGroups.delete(r.id);refTreeQuery.delete(r.id);
|
|
10267
|
+
loadReferenceGeometry(r.id,{rebuild:true});}));
|
|
9746
10268
|
m.appendChild(document.createElement('hr'));
|
|
9747
10269
|
m.appendChild(mk('Remove',()=>refRemove(r),true));
|
|
9748
10270
|
document.body.appendChild(m);
|
|
@@ -9772,6 +10294,7 @@ async function refRemove(r){
|
|
|
9772
10294
|
adoptReferenceWrite(d.etag);
|
|
9773
10295
|
const i=refList().findIndex(x=>x&&x.id===r.id);if(i>=0)C.reference_models.splice(i,1);
|
|
9774
10296
|
refGeom.delete(r.id);refUnresolved.delete(r.id);refFailed.delete(r.id);refEmpty.delete(r.id);
|
|
10297
|
+
refTreeOpen.delete(r.id);refTreeGroups.delete(r.id);refTreeQuery.delete(r.id); // the tree goes with the reference
|
|
9775
10298
|
if(refSelectedId===r.id){refSelectedId=null;refSelectedObjIdx=null;} // the object drilled into goes with the reference it was inside — leaving the index behind would point the panel into a reference that no longer exists
|
|
9776
10299
|
pushReferences();renderRefsTab();panel();
|
|
9777
10300
|
}catch(_){toast('Could not remove that reference');}
|
package/dist/web/workspaces.js
CHANGED
|
@@ -546,6 +546,19 @@
|
|
|
546
546
|
}
|
|
547
547
|
|
|
548
548
|
// ── mode ────────────────────────────────────────────────────────────────────
|
|
549
|
+
// Which subject the browser tab should name. Pure and named so it can be driven over its three
|
|
550
|
+
// real states in a test rather than grepped for out of applyMode() — review found four realistic
|
|
551
|
+
// mutations (landing always winning, `.app` for `.name`, an inverted ternary, a one-shot push)
|
|
552
|
+
// that a token grep could not tell from the real thing.
|
|
553
|
+
//
|
|
554
|
+
// The `ws` guard is load-bearing, not defensive: setMode() does NOT clear `current` (only
|
|
555
|
+
// closeProject() does), so applyMode routinely runs in Workflows mode with a project still open.
|
|
556
|
+
// Without it the tab would name that project while the user is looking at a workflow — the exact
|
|
557
|
+
// inverse of the bug this fixes. `null` hands the tab back to aware.js's workflow combo.
|
|
558
|
+
function workspaceTabSubject(ws, current) {
|
|
559
|
+
if (!ws) return null;
|
|
560
|
+
return current ? current.name : 'Workspaces';
|
|
561
|
+
}
|
|
549
562
|
function applyMode() {
|
|
550
563
|
const ws = mode === 'workspaces';
|
|
551
564
|
$app.classList.toggle('mode-workspaces', ws);
|
|
@@ -560,6 +573,11 @@
|
|
|
560
573
|
$spine.hidden = !ws || !current;
|
|
561
574
|
if (!ws && !$projMenu.hidden) closeProjMenu();
|
|
562
575
|
if (ws && !current) loadProjects();
|
|
576
|
+
// Name the tab after what's actually on screen. aware.js is the single writer of
|
|
577
|
+
// document.title; left alone it names the selected WORKFLOW, which is the wrong surface here —
|
|
578
|
+
// the combo isn't even visible in Workspaces mode. Every path that changes the open project
|
|
579
|
+
// (open, close, rename → openProject, mode switch, boot) ends here, so the title can't go stale.
|
|
580
|
+
if (bridge.setWorkspaceTitle) bridge.setWorkspaceTitle(workspaceTabSubject(ws, current));
|
|
563
581
|
// Keep the shared guide beacon in step with mode: in Workflows mode (or the Workspaces
|
|
564
582
|
// landing) it must NOT show a workspace guide — clear it so aware.js reverts to the
|
|
565
583
|
// workflow beacon; in a Workspaces project it points at that project's lifecycle.
|