@floless/app 0.105.0 → 0.107.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 +5573 -5013
- package/dist/schemas/steel.model.v2.schema.json +1 -1
- package/dist/schemas/steel.takeoff.v1.schema.json +53 -3
- package/dist/web/app.css +96 -1
- package/dist/web/aware.js +138 -22
- package/dist/web/steel-editor.html +641 -12
- package/dist/web/workspaces.js +711 -72
- package/package.json +1 -1
|
@@ -289,6 +289,27 @@
|
|
|
289
289
|
.ftab-inp{background:#0f172a;color:var(--text);border:1px solid #475569;border-radius:4px;padding:4px 6px;width:100%;font:13px system-ui}
|
|
290
290
|
.ftab-inp:focus{outline:none;border-color:var(--brand)}
|
|
291
291
|
.ftab .cdel{padding:3px 7px;font-size:11px} .ftab .csrc{white-space:nowrap}
|
|
292
|
+
/* What a bound detail will BUILD — the line under a Connection detail field that turns a recorded
|
|
293
|
+
callout into an action. Existing tokens only (var(--mut)/--text/--brand/--line); no new palette. */
|
|
294
|
+
.drow{display:flex;align-items:center;gap:6px;flex-wrap:wrap;margin:5px 0 2px}
|
|
295
|
+
.dmsg{flex:1 1 100%;min-width:0;font-size:11px;line-height:1.45;color:var(--mut)}
|
|
296
|
+
.dmsg b{color:var(--text);font-weight:600}
|
|
297
|
+
.dmsg.warn{color:#fcd34d}
|
|
298
|
+
.drow button{flex:none}
|
|
299
|
+
.dnotes{margin:2px 0 0;padding:6px 8px;background:var(--bg);border:1px solid var(--line);border-radius:6px;
|
|
300
|
+
max-height:140px;overflow:auto;scrollbar-width:thin;scrollbar-color:#475569 transparent}
|
|
301
|
+
.dnotes::-webkit-scrollbar{width:8px;height:8px}
|
|
302
|
+
.dnotes::-webkit-scrollbar-thumb{background:#475569;border-radius:4px}
|
|
303
|
+
.dnotes::-webkit-scrollbar-track{background:transparent}
|
|
304
|
+
.dnotes li{font-size:11px;line-height:1.5;color:var(--mut);margin:0 0 3px 14px}
|
|
305
|
+
.dnotes li:last-child{margin-bottom:0}
|
|
306
|
+
.cbuilds{font-size:11px;line-height:1.4;color:var(--mut);margin-top:3px}
|
|
307
|
+
.cbuilds b{color:var(--text);font-weight:600}
|
|
308
|
+
.cbuilds .cundef{font-style:italic}
|
|
309
|
+
/* An authoring mistake the row itself can see — unreachable, not "waiting on you". Reuses the existing
|
|
310
|
+
.chip.fail tones rather than introducing a colour. */
|
|
311
|
+
.cbuilds .cwarn{display:inline-block;margin-left:6px;padding:0 5px;border-radius:4px;font-size:10px;
|
|
312
|
+
border:1px solid #7f1d1d;color:#fca5a5;cursor:default}
|
|
292
313
|
.connset{opacity:.55} .rfichip{display:inline-block;min-width:18px;height:18px;line-height:18px;text-align:center;background:#7f1d1d;color:#fecaca;border-radius:9px;font-size:11px;padding:0 5px}
|
|
293
314
|
.mbackdrop{position:absolute;inset:0;background:rgba(2,8,23,.62)}
|
|
294
315
|
.mpanel{position:relative;background:var(--panel);border:1px solid var(--line);border-radius:10px;width:min(880px,92vw);max-height:86vh;display:flex;flex-direction:column;box-shadow:0 20px 60px rgba(0,0,0,.6)}
|
|
@@ -860,6 +881,7 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
|
|
|
860
881
|
<div id=m3dInsertMenu class=m3dmenu role=menu></div>
|
|
861
882
|
<input id=insFile type=file accept="image/*" style="display:none">
|
|
862
883
|
</div>
|
|
884
|
+
<button id=dApplyBtn data-tip="Build the connection each detail callout describes, everywhere that callout appears. Ends someone confirmed, tuned by hand, or imported are left alone and listed.">Build from details</button>
|
|
863
885
|
<button id=bpBtn data-tip="Auto-detail base plates on every column (a plate + anchor kit + weld, shown in 3D). Tune sizes per the schedule via the AI or per-column params.">Base plates</button>
|
|
864
886
|
<button id=spBtn data-tip="Auto-detail bolted shear (fin) plates on eligible beam ends (a fin plate + bolt group + weld, shown in 3D). Tune sizes per the schedule via the AI or per-end params.">Shear plates</button>
|
|
865
887
|
<button id=framesBtn>Frames</button>
|
|
@@ -1800,7 +1822,7 @@ const autofillTOS=syncDefaults;
|
|
|
1800
1822
|
// select/delete/undo — a reader-side id-uniqueness hardening. dims3d rides its own persistence.
|
|
1801
1823
|
// dim_style (the model-global dimension-style defaults) rides every entry like details/member_types: one
|
|
1802
1824
|
// chronological stack means an undo simply walks the whole model back, so there is no cross-sheet clobber.
|
|
1803
|
-
function snapshot(){return JSON.stringify({planes:C.plans.map(p=>({sheet:p.sheet,members:p.members,dims:p.dims||[],frame:p.frame||null,grid:p.grid||null})),joints:C.joints||[],clips:(window.Steel3DView&&window.Steel3DView.clipState)?window.Steel3DView.clipState():null,details:(C.detail_placements||[]),member_types:C.member_types||[],dim_style:C.dim_style||null,member_styles:C.member_styles||{}});} // members/dims/frame/grid are all PER-SHEET → captured per sheet so a cross-sheet undo restores each sheet's OWN dims/frame/grid, never the active sheet's over another's. clips/work area are view-state riding the undo stack; details/dim_style = model-global, captured whole.
|
|
1825
|
+
function snapshot(){return JSON.stringify({planes:C.plans.map(p=>({sheet:p.sheet,members:p.members,dims:p.dims||[],frame:p.frame||null,grid:p.grid||null})),joints:C.joints||[],connections:Array.isArray(C.connections)?C.connections:null,clips:(window.Steel3DView&&window.Steel3DView.clipState)?window.Steel3DView.clipState():null,details:(C.detail_placements||[]),member_types:C.member_types||[],dim_style:C.dim_style||null,member_styles:C.member_styles||{}});} // members/dims/frame/grid are all PER-SHEET → captured per sheet so a cross-sheet undo restores each sheet's OWN dims/frame/grid, never the active sheet's over another's. clips/work area are view-state riding the undo stack; details/dim_style/connections = model-global, captured whole. connections is NOT per-plan sliced (unlike joints, keyed by a plan-local member id): the library is genuinely model-wide, referenced identically from every sheet.
|
|
1804
1826
|
// Undo/redo is a SINGLE GLOBAL stack (not per-plane): snapshot() above captures EVERY plane's
|
|
1805
1827
|
// members, so one whole-model stack is coherent — undo restores all planes at once, and a cross-
|
|
1806
1828
|
// sheet edit/delete/to-level round-trips fully. (Earlier this was per-plane — `undo=P.undo` swapped
|
|
@@ -1821,6 +1843,20 @@ function apply(json){const d=JSON.parse(json);
|
|
|
1821
1843
|
if(tp&&tp!==P)tp.members=(o.members||[]).map(ensureMeta);
|
|
1822
1844
|
else if(!tp){console.error('undo: sheet '+o.sheet+' not found — cross-plan slice skipped');toast('Undo couldn’t restore sheet '+o.sheet);}}} // restore THIS plan's joint slice: drop joints owned by this plan (old ∪ restored member ids), re-add the snapshot's — OTHER sheets' joints stay untouched. grid is per-plan (restored above); 'others' = the cross-plan slice a to-level commit captured. dims3d rides its own path.
|
|
1823
1845
|
if('details' in d)C.detail_placements=Array.isArray(d.details)?d.details:[]; // restore the model-global placed details (Slice 4)
|
|
1846
|
+
// The connection library rides the undo stack too — it holds each detail's RECIPE (what it builds, its
|
|
1847
|
+
// schedule, its notes), so "remember this as 5-S504" must undo as ONE action with the joint it created.
|
|
1848
|
+
// Before this it was mutated through edit() but never captured, so deleting a row restored every
|
|
1849
|
+
// ends[].conn while the row itself stayed deleted — dangling references, silently.
|
|
1850
|
+
// null means "there was no library at all": restore ABSENCE rather than materialising an empty array,
|
|
1851
|
+
// so an undo never adds a key the contract did not have. (The characterization baseline caught exactly
|
|
1852
|
+
// that — `$.connections` appearing at step "19 undo" — which is what these tests are for.)
|
|
1853
|
+
if('connections' in d){if(Array.isArray(d.connections))C.connections=d.connections;else delete C.connections;
|
|
1854
|
+
// The restored rows are FRESH objects from JSON.parse, so an open Connections table is still showing —
|
|
1855
|
+
// and its cell handlers are still closed over — the discarded ones. Without this, undo under the open
|
|
1856
|
+
// library looks like it did nothing, and the next cell edit writes to an orphan: the field updates, the
|
|
1857
|
+
// save does not, and the change vanishes on the next re-render. Only possible now that `connections`
|
|
1858
|
+
// rides the undo stack, so it is this change's regression to close.
|
|
1859
|
+
if(typeof connLibOpen==='function'&&connLibOpen())renderConnTable();}
|
|
1824
1860
|
if('dim_style' in d){C.dim_style=d.dim_style||{};sanitizeDimStyle();} // model-global dimension-style defaults ride the undo stack too (changing them repaints every non-overriding dim)
|
|
1825
1861
|
updCS();
|
|
1826
1862
|
selIds=new Set([...selIds].filter(id=>byId(id)||/^det:/.test(id))); // keep a selected placed-detail id (det:…) — it isn't a member
|
|
@@ -1878,7 +1914,7 @@ function sanitizeViews(arr){return ViewGen.sanitizeViews(arr);}
|
|
|
1878
1914
|
// draft on top of it, masking the other write. See restampDraftBase() for why reading the CURRENT
|
|
1879
1915
|
// serverEtag here is right, and why it must be re-stamped when a write lands.
|
|
1880
1916
|
function persist(){try{localStorage.setItem(LSKEY,JSON.stringify({sig:dataSig(),baseEtag:serverEtag,ts:Date.now(),active:C.active,
|
|
1881
|
-
custom_details:C.custom_details, profile_colors:C.profile_colors, member_styles:C.member_styles, member_types:C.member_types, target_confidence:C.target_confidence, dims3d:C.dims3d, dim_overlays:C.dim_overlays, dim_style:C.dim_style, prop_labels:C.prop_labels, joints:C.joints, detail_placements:C.detail_placements, views:C.views,
|
|
1917
|
+
custom_details:C.custom_details, profile_colors:C.profile_colors, member_styles:C.member_styles, member_types:C.member_types, target_confidence:C.target_confidence, dims3d:C.dims3d, dim_overlays:C.dim_overlays, dim_style:C.dim_style, prop_labels:C.prop_labels, joints:C.joints, connections:C.connections, detail_placements:C.detail_placements, views:C.views,
|
|
1882
1918
|
plans:C.plans.map(p=>({sheet:p.sheet,members:p.members,default_tos:p.default_tos,details:p.details,dims:p.dims,frame:p.frame||null,grid:p.grid||null}))}));}catch(e){setSaved('err');console.error('local autosave failed',e);}}
|
|
1883
1919
|
// --- server-side draft save: PUT the FULL contract C — this is the copy Approve bakes.
|
|
1884
1920
|
// localStorage (persist) stays the instant per-browser draft cache; this is the durable one.
|
|
@@ -1968,6 +2004,37 @@ function confirmOverwrite(){
|
|
|
1968
2004
|
};
|
|
1969
2005
|
}
|
|
1970
2006
|
|
|
2007
|
+
/**
|
|
2008
|
+
* A styled destructive confirm — same tokens as confirmOverwrite() above, per the no-native-confirm rule.
|
|
2009
|
+
* Resolves true only if the user takes the destructive action; Esc / backdrop / Cancel all resolve false.
|
|
2010
|
+
*
|
|
2011
|
+
* Built with createElement rather than an HTML string: every caller passes MODEL data (a detail number, a
|
|
2012
|
+
* row's own label, a count), and a contract string must never reach a markup position.
|
|
2013
|
+
*/
|
|
2014
|
+
function confirmDanger({title,body,confirmLabel}){
|
|
2015
|
+
return new Promise(resolve=>{
|
|
2016
|
+
const el=(tag,css,text)=>{const n=document.createElement(tag);if(css)n.style.cssText=css;if(text!=null)n.textContent=text;return n;};
|
|
2017
|
+
const back=el('div','position:fixed;inset:0;z-index:60;display:flex;align-items:center;justify-content:center');
|
|
2018
|
+
back.className='modal';
|
|
2019
|
+
const bd=el('div');bd.className='mbackdrop';
|
|
2020
|
+
// Same pinned-head/footer, scrolling-body construction as detailModalShell — a long confirm body
|
|
2021
|
+
// would otherwise push the destructive button out of the viewport where it cannot be reached.
|
|
2022
|
+
const panel=el('div','width:min(520px,92vw);display:flex;flex-direction:column;max-height:86vh');panel.className='mpanel';
|
|
2023
|
+
const head=el('div','padding:14px 16px;border-bottom:1px solid var(--line);font-weight:600;flex:none',title);head.className='mhead';
|
|
2024
|
+
const foot=el('div','padding:12px 16px;display:flex;gap:8px;justify-content:flex-end;border-top:1px solid var(--line);flex:none');
|
|
2025
|
+
const cancel=el('button',null,'Cancel'), go=el('button',null,confirmLabel);go.className='danger';
|
|
2026
|
+
foot.append(cancel,go);
|
|
2027
|
+
panel.append(head,el('div','padding:14px 16px;line-height:1.5;white-space:pre-line;flex:1 1 auto;overflow-y:auto;min-height:0',body),foot);
|
|
2028
|
+
back.append(bd,panel);
|
|
2029
|
+
document.body.appendChild(back);
|
|
2030
|
+
const done=v=>{document.removeEventListener('keydown',onKey,true);back.remove();resolve(v);};
|
|
2031
|
+
const onKey=e=>{if(e.key==='Escape'){e.stopPropagation();done(false);}};
|
|
2032
|
+
document.addEventListener('keydown',onKey,true); // capture: the editor's global Esc handlers must not win over an open modal
|
|
2033
|
+
bd.onclick=()=>done(false);cancel.onclick=()=>done(false);go.onclick=()=>done(true);
|
|
2034
|
+
go.focus();
|
|
2035
|
+
});
|
|
2036
|
+
}
|
|
2037
|
+
|
|
1971
2038
|
// `force` REPLACES the precondition rather than skipping it — `If-Match: *` ("must exist") instead of the
|
|
1972
2039
|
// exact tag, so a deliberate overwrite still cannot create a store out of nothing. Only the explicit
|
|
1973
2040
|
// "Overwrite and save" confirm passes it. (This said "skips the precondition" until P1c made a write
|
|
@@ -2082,6 +2149,7 @@ function applyDraftFields(d){const by={};(d.plans||[]).forEach(p=>by[p.sheet]=p)
|
|
|
2082
2149
|
if(d.member_styles)C.member_styles=sanitizeMemberStyles(d.member_styles); // F5: restore per-type line styles from the local draft (sanitised — the localStorage draft is unvalidated, unlike the server contract)
|
|
2083
2150
|
if(Array.isArray(d.member_types))C.member_types=sanitizeMemberTypes(d.member_types);
|
|
2084
2151
|
if(d.target_confidence!=null)C.target_confidence=d.target_confidence;
|
|
2152
|
+
if(Array.isArray(d.connections))C.connections=sanitizeConnections(d.connections); // the connection library carries each detail's RECIPE, so a captured "5-S504 = this shear plate" must survive a reload that happens before the server draft lands. Sanitised because the localStorage draft is UNVALIDATED input (unlike the server contract) — same treatment as member_styles/dims3d.
|
|
2085
2153
|
C.plans.forEach(p=>{const s=by[p.sheet];if(s){if(Array.isArray(s.members))p.members=s.members;if(s.default_tos!=null)p.default_tos=s.default_tos;if(Array.isArray(s.details))p.details=s.details;if(Array.isArray(s.dims))p.dims=s.dims;if('frame' in s)p.frame=s.frame||null;if('grid' in s)p.grid=s.grid||null;p.autofilled=true;}});
|
|
2086
2154
|
if(Array.isArray(d.dims3d))C.dims3d=SteelCore?SteelCore.sanitizeDims3d(d.dims3d):d.dims3d; // restore model-global 3D dims from the local draft — re-sanitise axisDir (a stale draft could carry junk that would wedge the next save)
|
|
2087
2155
|
if(Array.isArray(d.detail_placements))C.detail_placements=d.detail_placements; // restore placed details
|
|
@@ -2231,6 +2299,29 @@ function sanitizeMemberStyles(ms){if(!ms||typeof ms!=='object'||Array.isArray(ms
|
|
|
2231
2299
|
const w=WOK[s.weight]?s.weight:'med',d=DOK[s.dash]?s.dash:'solid';
|
|
2232
2300
|
if(w!=='med'||d!=='solid')out[key]={weight:w,dash:d};}
|
|
2233
2301
|
return out;}
|
|
2302
|
+
// Sanitize a connection library restored from the localStorage DRAFT (unvalidated input, unlike the
|
|
2303
|
+
// server contract — same treatment as sanitizeMemberStyles / sanitizeDims3d). A row without a usable id is
|
|
2304
|
+
// dropped: every ends[].conn / joints[].conn reference resolves by id, so an id-less row is unreachable
|
|
2305
|
+
// anyway and keeping it would only let a later save write a contract the schema rejects (id is required).
|
|
2306
|
+
// The recipe/notes/image keys carry each detail's meaning, so they are preserved but shape-checked —
|
|
2307
|
+
// detail-recipes.ts already refuses a malformed recipe, and this keeps junk from reaching it at all.
|
|
2308
|
+
function sanitizeConnections(rows){if(!Array.isArray(rows))return [];
|
|
2309
|
+
const txt=(v,n)=>typeof v==='string'?v.slice(0,n):undefined;
|
|
2310
|
+
const obj=v=>(v&&typeof v==='object'&&!Array.isArray(v))?v:undefined;
|
|
2311
|
+
const out=[];
|
|
2312
|
+
for(const r of rows){if(!r||typeof r!=='object'||Array.isArray(r))continue;
|
|
2313
|
+
const id=txt(r.id,120);if(!id||!id.trim())continue;
|
|
2314
|
+
const row={...r,id};
|
|
2315
|
+
const rec=obj(r.recipe);
|
|
2316
|
+
if(rec){const kind=txt(rec.kind,64);
|
|
2317
|
+
row.recipe={...(kind?{kind}:{}),...(obj(rec.params)?{params:obj(rec.params)}:{}),
|
|
2318
|
+
...(Array.isArray(rec.schedule)?{schedule:rec.schedule.filter(s=>s&&typeof s==='object'&&!Array.isArray(s)).slice(0,200)}:{})};
|
|
2319
|
+
}else if('recipe' in row)delete row.recipe;
|
|
2320
|
+
if(Array.isArray(r.notes))row.notes=r.notes.filter(n=>n&&typeof n==='object'&&typeof n.text==='string')
|
|
2321
|
+
.slice(0,200).map(n=>({text:n.text.slice(0,2000),...(typeof n.source==='string'?{source:n.source.slice(0,32)}:{})}));
|
|
2322
|
+
else if('notes' in row)delete row.notes;
|
|
2323
|
+
out.push(row);}
|
|
2324
|
+
return out;}
|
|
2234
2325
|
function len(a,b){return Math.hypot(a[0]-b[0],a[1]-b[1]);}
|
|
2235
2326
|
// ── Column profile sections ─────────────────────────────────────────────────────────────────────
|
|
2236
2327
|
// A column is drawn on the plan as its profile-SECTION footprint (I/box/channel/angle/tube), not a
|
|
@@ -3609,12 +3700,38 @@ function panel(){
|
|
|
3609
3700
|
:(o.conn?'<span class=edec style="text-align:left;color:#fca5a5">references a missing row — re-pick</span>':'');
|
|
3610
3701
|
return `<div class=elab>Connection</div><input id=${id} class=combo data-src=connrows readonly placeholder="— none — (pick from the library)" value="${esc(row?connLabel(row):'')}" autocomplete=off>${cap}`;};
|
|
3611
3702
|
const fb=(o,html)=>`<div class="${o.conn?'connset':''}">${html}</div>`; // dim the note/detail fallback when a library row is referenced
|
|
3703
|
+
// What this end's detail will BUILD. Silent until there is a callout or a library reference to talk
|
|
3704
|
+
// about, so an un-annotated end gains no clutter. A refusal is never a dead end: it says what is missing
|
|
3705
|
+
// and offers the action that fixes it, because "Apply is greyed out and I don't know why" is the failure
|
|
3706
|
+
// this whole surface exists to avoid.
|
|
3707
|
+
const dStat=(id,o,which)=>{
|
|
3708
|
+
if(!o.detail&&!o.conn)return '';
|
|
3709
|
+
const r=resolveDetail(m,which), cap=captureEligible(m,which);
|
|
3710
|
+
const capBtn=cap?`<button id=${id}_cap class=ghost data-tip="Remember what this connection means, so every end with the same callout can be built from it">Remember as ${esc(o.detail)}</button>`:'';
|
|
3711
|
+
if(r.ok){
|
|
3712
|
+
// `built` also requires the joint to CITE this row: an identical-looking connection that came from a
|
|
3713
|
+
// different detail is not this detail's work, and saying "Built" for it would misreport provenance.
|
|
3714
|
+
const j=jointAtEnd(m.id,which), built=!!j&&j.kind===r.kind&&j.conn===r.rowId&&!recipeParamsDiffer(j.params,r.params);
|
|
3715
|
+
const row=connRowById(r.rowId), rec=row&&row.recipe;
|
|
3716
|
+
const why=(r.matched&&rec&&Array.isArray(rec.schedule))?(' · '+esc(schedRowLabel(rec.schedule[r.matched.index]))):'';
|
|
3717
|
+
const nn=(r.notes||[]).length;
|
|
3718
|
+
return `<div class=drow><div class=dmsg>${built?'Built':'Builds'} a <b>${esc(kindLabel(r.kind))}</b>${why}</div>`
|
|
3719
|
+
+`<button id=${id}_ap class=ghostw data-tip="${built?'Build it again from the detail, replacing what is here':'Build this connection from '+esc(o.detail||'the detail')}">${built?'Rebuild it':'Build it'}</button>${capBtn}</div>`
|
|
3720
|
+
+(nn?`<ul class=dnotes id=${id}_nl>${(r.notes||[]).map(n=>`<li>${esc(n.text)}</li>`).join('')}</ul>`:'');
|
|
3721
|
+
}
|
|
3722
|
+
if(r.reason==='no-detail')return ''; // nothing to say yet — the field itself is the prompt
|
|
3723
|
+
// The fixing action, per reason. 'fix' opens the chooser (a disagreement only the user can settle);
|
|
3724
|
+
// capture covers "nothing says what this builds" and "this size isn't in the schedule".
|
|
3725
|
+
const pick=(r.reason==='conflict'||r.reason==='ambiguous');
|
|
3726
|
+
const fixBtn=pick?`<button id=${id}_fx class=ghostw data-tip="Choose which connection this end really uses">Pick one</button>`:'';
|
|
3727
|
+
return `<div class=drow><div class="dmsg warn">${esc(r.message)}</div>${fixBtn}${capBtn}</div>`;
|
|
3728
|
+
};
|
|
3612
3729
|
const dotS='<span class=epdot style="background:#facc15"></span>',dotE='<span class=epdot style="background:#f472b6"></span>'; // start=yellow, end=magenta — matches the canvas end markers
|
|
3613
3730
|
const elev = col
|
|
3614
|
-
? `<div class="sect f">Elevation</div>${ftFld('bos',dotS+'Bottom (BOS)',m.col.bos)}${tosFld('tosC',dotE+'Top (TOS)',m.col)}${cFld('cnC',m.col)}${fb(m.col,nin('ntC',m.col.note)+dFld('dtC',m.col))}`
|
|
3615
|
-
: `<div class="sect f">${dotS}Start</div>${tosFld('tosA','TOS',m.ends[0])}${cFld('cnA',m.ends[0])}${fb(m.ends[0],nin('ntA',m.ends[0].note)+dFld('dtA',m.ends[0]))}
|
|
3731
|
+
? `<div class="sect f">Elevation</div>${ftFld('bos',dotS+'Bottom (BOS)',m.col.bos)}${tosFld('tosC',dotE+'Top (TOS)',m.col)}${cFld('cnC',m.col)}${fb(m.col,nin('ntC',m.col.note)+dFld('dtC',m.col))}${dStat('dtC',m.col,'col')}`
|
|
3732
|
+
: `<div class="sect f">${dotS}Start</div>${tosFld('tosA','TOS',m.ends[0])}${cFld('cnA',m.ends[0])}${fb(m.ends[0],nin('ntA',m.ends[0].note)+dFld('dtA',m.ends[0]))}${dStat('dtA',m.ends[0],0)}
|
|
3616
3733
|
${isBrace(m)?'':`<div class=divrow><hr><button class=ghost id=matchEnds>Match → both ends</button><hr></div>`}
|
|
3617
|
-
<div class=sect>${dotE}End</div>${tosFld('tosB','TOS',m.ends[1])}${cFld('cnB',m.ends[1])}${fb(m.ends[1],nin('ntB',m.ends[1].note)+dFld('dtB',m.ends[1]))}`;
|
|
3734
|
+
<div class=sect>${dotE}End</div>${tosFld('tosB','TOS',m.ends[1])}${cFld('cnB',m.ends[1])}${fb(m.ends[1],nin('ntB',m.ends[1].note)+dFld('dtB',m.ends[1]))}${dStat('dtB',m.ends[1],1)}`;
|
|
3618
3735
|
const bpj=col?(C.joints||[]).find(j=>j&&j.kind==='base-plate'&&j.main===m.id):null; // this column's base-plate joint, if detailed
|
|
3619
3736
|
const pFld=(key,label,ph,unit)=>{const raw=bpj&&bpj.params&&bpj.params[key]!=null?bpj.params[key]:null;const val=raw==null?'':(unit==='mm'?esc(fmtFtIn(Number(raw)/25.4)):esc(String(raw)));return `<div class=elab>${label}</div><input id=bp_${key} inputmode=decimal placeholder="${esc(ph)}" value="${val}" autocomplete=off>${unit&&unit!=='mm'?`<span class=edec>${unit}</span>`:''}`;}; // mm params shown/entered in ft-in
|
|
3620
3737
|
const bpSect=bpj?`<div class=divrow><hr><span class=sect style="margin:0">Base plate</span><hr></div>
|
|
@@ -3779,12 +3896,34 @@ function panel(){
|
|
|
3779
3896
|
const wireDet=(id,o)=>{const i=document.getElementById(id);if(i)i.onchange=e=>edit(()=>{o.detail=e.target.value.trim();});
|
|
3780
3897
|
const pk=document.getElementById(id+'_pk');if(pk)pk.onclick=()=>{if(picking&&pickKind==='detail'&&pickEnd===o){picking=false;pickEnd=null;}else{picking=true;pickKind='detail';pickEnd=o;}render();};
|
|
3781
3898
|
const op=document.getElementById(id+'_open');if(op)op.onclick=()=>openPreview(o.detail);};
|
|
3899
|
+
// The detail→connection actions under the field. `which` identifies the end so the resolver can reach
|
|
3900
|
+
// m.col vs m.ends[i]; the buttons only exist when dStat rendered them, so each lookup is guarded.
|
|
3901
|
+
const wireDetailBuild=(id,o,which)=>{
|
|
3902
|
+
const ap=document.getElementById(id+'_ap');
|
|
3903
|
+
if(ap)ap.onclick=()=>{
|
|
3904
|
+
const r=resolveDetail(m,which);
|
|
3905
|
+
if(!r.ok){toast(r.message);render();return;} // the model can move under an open panel — re-resolve, never build a stale answer
|
|
3906
|
+
// Same guard the bulk sweep applies: joints are matched model-wide by main+at while v1 member ids are
|
|
3907
|
+
// plan-local, so on a model with a repeated id this would clobber the other sheet's joint — which the
|
|
3908
|
+
// bulk action already refuses to touch. One button must not be laxer than the other.
|
|
3909
|
+
if(duplicateMemberIds().has(m.id)){toast('More than one member is called '+m.id+', so this connection could land on the wrong one — rename one of them first.');return;}
|
|
3910
|
+
const blk=detailApplyBlocker(m,which,r,false);
|
|
3911
|
+
if(blk){toast('Not built — '+blk.text+'. Remove it first, or tune this one by hand.');return;}
|
|
3912
|
+
let jid=null;edit(()=>{jid=buildJointFromDetail(m,which,r);});
|
|
3913
|
+
pendingConnSel=jid; // its parts only exist after the 3D rebuild → select the whole connection there
|
|
3914
|
+
toast('Built a '+kindLabel(r.kind)+' on '+m.id+' '+whichLabel(which)+' from '+(o.detail||'its connection'));
|
|
3915
|
+
};
|
|
3916
|
+
const cap=document.getElementById(id+'_cap');
|
|
3917
|
+
if(cap)cap.onclick=()=>openCaptureModal(m,which);
|
|
3918
|
+
const fx=document.getElementById(id+'_fx');
|
|
3919
|
+
if(fx)fx.onclick=()=>openDetailPick(m,which);
|
|
3920
|
+
};
|
|
3782
3921
|
const wireConn=(id,o)=>{const i=document.getElementById(id);if(!i)return;i.onchange=e=>edit(()=>{const v=(e.target.value||'').trim();o.conn=(!v||v==='— none —')?'':v.split(' · ')[0];});};
|
|
3783
3922
|
if(col){
|
|
3784
3923
|
document.getElementById('bos').onchange=e=>edit(()=>{ModelCmd.setBos(m.col,parseLen(e.target.value));});
|
|
3785
3924
|
wireTos('tosC',m.col);
|
|
3786
3925
|
document.getElementById('ntC').onchange=e=>edit(()=>{m.col.note=e.target.value;});
|
|
3787
|
-
wireDet('dtC',m.col);wireConn('cnC',m.col);
|
|
3926
|
+
wireDet('dtC',m.col);wireConn('cnC',m.col);wireDetailBuild('dtC',m.col,'col');
|
|
3788
3927
|
if(bpj){const MAXCOUNT=20, MAXDIM=100000; // bolt grid is capped (scene parts = rows×cols, so a mistyped 1e5 can't explode the renderer); dims sanity-bounded
|
|
3789
3928
|
const wireBp=(key,isInt)=>{const i=document.getElementById('bp_'+key);if(!i)return;i.onchange=e=>{
|
|
3790
3929
|
const raw=e.target.value.trim();
|
|
@@ -3799,10 +3938,10 @@ function panel(){
|
|
|
3799
3938
|
}else{
|
|
3800
3939
|
wireTos('tosA',m.ends[0]);
|
|
3801
3940
|
document.getElementById('ntA').onchange=e=>edit(()=>{m.ends[0].note=e.target.value;});
|
|
3802
|
-
wireDet('dtA',m.ends[0]);wireConn('cnA',m.ends[0]);
|
|
3941
|
+
wireDet('dtA',m.ends[0]);wireConn('cnA',m.ends[0]);wireDetailBuild('dtA',m.ends[0],0);
|
|
3803
3942
|
wireTos('tosB',m.ends[1]);
|
|
3804
3943
|
document.getElementById('ntB').onchange=e=>edit(()=>{m.ends[1].note=e.target.value;});
|
|
3805
|
-
wireDet('dtB',m.ends[1]);wireConn('cnB',m.ends[1]);
|
|
3944
|
+
wireDet('dtB',m.ends[1]);wireConn('cnB',m.ends[1]);wireDetailBuild('dtB',m.ends[1],1);
|
|
3806
3945
|
// Not rendered for a brace — matching ends would FLATTEN the slope its arrowheads encode. Null-guarded
|
|
3807
3946
|
// (the element is absent) plus a defensive isBrace check. (Codex round-4)
|
|
3808
3947
|
{const me=document.getElementById('matchEnds');
|
|
@@ -7036,6 +7175,11 @@ function applyDetailRename(old,nw){nw=(nw||'').trim();if(!nw||nw===old)return fa
|
|
|
7036
7175
|
if(pl.details)for(const d of pl.details)if(d.text===old)d.text=nw;
|
|
7037
7176
|
for(const m of pl.members){if(m.ends)for(const en of m.ends)if(en.detail===old)en.detail=nw;if(m.col&&m.col.detail===old)m.col.detail=nw;}}
|
|
7038
7177
|
if(C.custom_details[old]!=null){C.custom_details[nw]=C.custom_details[old];delete C.custom_details[old];}
|
|
7178
|
+
// The connection library is keyed to the callout TEXT, so a rename that skipped it would leave every row
|
|
7179
|
+
// pointing at a name nothing uses any more — each end would silently stop resolving ("nothing says what
|
|
7180
|
+
// this builds") with no visible cause. Harmless when `detail` was only a display string; not any more,
|
|
7181
|
+
// now that the row carries what the detail BUILDS.
|
|
7182
|
+
for(const r of (C.connections||[]))if(r&&r.detail===old)r.detail=nw;
|
|
7039
7183
|
scheduleSave();return true;}
|
|
7040
7184
|
function detTexts(){const seen=new Set(),out=[];
|
|
7041
7185
|
for(const d of (P.details||[])) if(!seen.has(d.text)){seen.add(d.text);out.push(d.text);}
|
|
@@ -7153,23 +7297,102 @@ function toggleShearPlates(){
|
|
|
7153
7297
|
}
|
|
7154
7298
|
}
|
|
7155
7299
|
{const _s=document.getElementById('spBtn');if(_s)_s.onclick=toggleShearPlates;}
|
|
7300
|
+
// --- Build from details: turn every resolvable detail callout into real connection geometry, model-wide.
|
|
7301
|
+
// The skips are the important half of the result, so they get a modal rather than a toast that scrolls
|
|
7302
|
+
// past — with an explicit second action for the ones that were protected rather than broken. ---
|
|
7303
|
+
const DSKIP_LABEL={'no-row':'Nothing says what the callout means','row-has-no-recipe':'Nothing says what the detail builds',
|
|
7304
|
+
'kind-mismatch':'The detail builds the wrong kind for that end','conflict':'The callout and the connection reference disagree',
|
|
7305
|
+
'ambiguous':'The callout matches more than one connection','no-schedule-match':'That size is not in the detail’s schedule',
|
|
7306
|
+
'verified':'Someone confirmed it','custom':'An imported connection is there','tuned':'Tuned by hand','no-detail':'No detail on that end',
|
|
7307
|
+
'duplicate-id':'More than one member has that name, so the connection could land on the wrong one'};
|
|
7308
|
+
const DSKIP_PROTECTED={verified:1,custom:1,tuned:1}; // skipped to protect existing work — the only ones an overwrite could take
|
|
7309
|
+
function describeSkip(s){return (s.m&&s.m.id?s.m.id:'?')+' '+whichLabel(s.which);}
|
|
7310
|
+
function runApplyAllDetails(force){
|
|
7311
|
+
const res=applyAllDetails({force:force});
|
|
7312
|
+
if(!res.applied&&!res.already&&!res.skipped.length){toast('No detail callouts are bound to member ends yet — bind one with the ⌖ button on a member’s Connection detail.');return;}
|
|
7313
|
+
if(res.applied){pendingConnSel=res.lastId;render();}
|
|
7314
|
+
const groups={};for(const s of res.skipped)(groups[s.reason]=groups[s.reason]||[]).push(s);
|
|
7315
|
+
const order=Object.keys(groups).sort((a,b)=>groups[b].length-groups[a].length);
|
|
7316
|
+
const protectedN=order.filter(k=>DSKIP_PROTECTED[k]).reduce((n,k)=>n+groups[k].length,0);
|
|
7317
|
+
const S=detailModalShell(res.applied?('Built '+res.applied+' connection'+(res.applied===1?'':'s')):'Nothing new to build');
|
|
7318
|
+
const {el,body,foot,close}=S;
|
|
7319
|
+
const head=[];
|
|
7320
|
+
if(res.applied)head.push('Built '+res.applied+' from their detail callouts.');
|
|
7321
|
+
if(res.already)head.push(res.already+' '+(res.already===1?'was':'were')+' already exactly right.');
|
|
7322
|
+
if(!res.applied&&!res.already)head.push('None of the bound callouts could be built yet.');
|
|
7323
|
+
body.append(el('div','font-size:12px;line-height:1.5;color:var(--mut);margin-bottom:'+(order.length?'10px':'0'),head.join(' ')));
|
|
7324
|
+
if(order.length){
|
|
7325
|
+
const lab=el('div',null,'Left alone — '+res.skipped.length);lab.className='elab';body.append(lab);
|
|
7326
|
+
const list=el('div','max-height:220px;overflow:auto;scrollbar-width:thin;scrollbar-color:#475569 transparent;border:1px solid var(--line);border-radius:6px;padding:6px 8px');
|
|
7327
|
+
list.className='dnotes';
|
|
7328
|
+
for(const k of order){
|
|
7329
|
+
const g=groups[k];
|
|
7330
|
+
const line=el('div','margin:0 0 6px');
|
|
7331
|
+
line.append(el('div','font-size:12px;color:var(--text)',(DSKIP_LABEL[k]||k)+' — '+g.length));
|
|
7332
|
+
line.append(el('div','font-size:11px;color:var(--mut);line-height:1.45',
|
|
7333
|
+
g.slice(0,8).map(describeSkip).join(', ')+(g.length>8?(' and '+(g.length-8)+' more'):'')));
|
|
7334
|
+
list.append(line);}
|
|
7335
|
+
body.append(list);}
|
|
7336
|
+
const done=el('button',null,'Done');done.onclick=close;
|
|
7337
|
+
if(protectedN&&!force){
|
|
7338
|
+
const over=el('button',null,'Replace the '+protectedN+' protected one'+(protectedN===1?'':'s'));
|
|
7339
|
+
over.className='danger';
|
|
7340
|
+
over.onclick=async()=>{close();
|
|
7341
|
+
if(await confirmDanger({title:'Replace work that was protected?',
|
|
7342
|
+
body:protectedN+' end'+(protectedN===1?' was':'s were')+' left alone because someone confirmed '+(protectedN===1?'it':'them')+', tuned '+(protectedN===1?'it':'them')+' by hand, or imported the geometry.\n\nReplacing rebuilds '+(protectedN===1?'it':'them')+' from the detail, and imported geometry cannot be recovered by rebuilding. This can be undone with Ctrl+Z.',
|
|
7343
|
+
confirmLabel:'Replace them'}))runApplyAllDetails(true);};
|
|
7344
|
+
foot.append(over);}
|
|
7345
|
+
foot.append(done);done.focus();}
|
|
7346
|
+
{const _d=document.getElementById('dApplyBtn');if(_d)_d.onclick=()=>runApplyAllDetails(false);}
|
|
7156
7347
|
function renderConnTable(){const tb=document.getElementById('connBody');if(!tb)return;
|
|
7157
7348
|
document.getElementById('connCompHead').textContent=(PLAT_LABEL[connPlat]||connPlat)+' id';
|
|
7158
7349
|
const rows=C.connections||[];
|
|
7159
7350
|
if(!rows.length){tb.innerHTML='<tr><td colspan=5 style="text-align:center;padding:32px;color:var(--mut);font-size:12px">No connections defined — click + New row to add the first.</td></tr>';updConnBtn();return;}
|
|
7351
|
+
const dupKeys=new Set(dupDetailKeys()); // detail numbers that two or more rows share, once for the whole table
|
|
7160
7352
|
const srcChip=s=>s==='drawing'?'<span class="chip assumed">drawing</span>':s==='company-rules'?'<span class=chip>company-rules</span>':'<span class=chip style="border-color:#1d4ed8;color:#93c5fd">user</span>';
|
|
7161
7353
|
tb.innerHTML=rows.map(r=>`<tr data-id="${esc(r.id)}">`
|
|
7162
7354
|
+`<td><input class="combo ftab-inp" data-src=conntypes data-f=type value="${esc(r.type||'')}" placeholder="moment" autocomplete=off></td>`
|
|
7163
|
-
+`<td><input class="combo ftab-inp" data-src=details data-f=detail value="${esc(r.detail||'')}" placeholder="e.g. 50S504" autocomplete=off
|
|
7355
|
+
+`<td><input class="combo ftab-inp" data-src=details data-f=detail value="${esc(r.detail||'')}" placeholder="e.g. 50S504" autocomplete=off>`
|
|
7356
|
+
// What this detail BUILDS, under its number — the row is now a definition, not only a mapping, and a
|
|
7357
|
+
// row nobody has defined must say so rather than look identical to one that is ready to use.
|
|
7358
|
+
// Two authoring faults only this table can see, so this is where they get said. A COLLIDING detail
|
|
7359
|
+
// number makes every end carrying that callout un-buildable (the resolver refuses to guess between the
|
|
7360
|
+
// rows) while both rows look perfectly healthy here; a SHADOWED schedule row is one the author wrote
|
|
7361
|
+
// that can never win. Both were computed and documented as warnings but wired to nothing until now.
|
|
7362
|
+
+`<div class=cbuilds>${r.recipe&&r.recipe.kind
|
|
7363
|
+
? `Builds a <b>${esc(recipeSummary(r.recipe))}</b>${(r.notes||[]).length?` · ${(r.notes||[]).length} note${(r.notes||[]).length>1?'s':''}`:''}`
|
|
7364
|
+
: `<span class=cundef>Nothing says what this builds</span>`}`
|
|
7365
|
+
+(dupKeys.has(normDetailKey(r.detail))?`<span class=cwarn data-tip="Another row uses the same detail number, so no member end can be built from either — give them distinct numbers.">shares this number with another row</span>`:'')
|
|
7366
|
+
+((r.recipe&&shadowedSchedRows(r.recipe.schedule).length)?`<span class=cwarn data-tip="A size row here is already covered by an earlier, broader row, so it can never apply.">${shadowedSchedRows(r.recipe.schedule).length} size row${shadowedSchedRows(r.recipe.schedule).length>1?'s':''} can never apply</span>`:'')
|
|
7367
|
+
+`</div></td>`
|
|
7164
7368
|
+`<td><input class=ftab-inp data-f=target value="${esc((r.targets&&r.targets[connPlat])||'')}" placeholder="e.g. 146" autocomplete=off></td>`
|
|
7165
7369
|
+`<td class=csrc>${srcChip(r.source||'user')}</td>`
|
|
7166
7370
|
+`<td><button class="danger cdel" data-tip="Remove this row">✕</button></td></tr>`).join('');
|
|
7167
7371
|
tb.querySelectorAll('tr[data-id]').forEach(tr=>{const id=tr.dataset.id;const row=connRowById(id);if(!row)return;
|
|
7168
7372
|
tr.querySelector('[data-f=type]').onchange=e=>edit(()=>{row.type=e.target.value.trim();});
|
|
7169
|
-
|
|
7373
|
+
// Re-render after a DETAIL edit: this is the field the duplicate-number warning keys on, and the row it
|
|
7374
|
+
// collides with is a different row, so the table cannot update itself in place. Without this the warning
|
|
7375
|
+
// only appeared the next time the library was opened — i.e. never, at the moment you create the clash.
|
|
7376
|
+
tr.querySelector('[data-f=detail]').onchange=e=>{edit(()=>{row.detail=e.target.value.trim();});renderConnTable();};
|
|
7170
7377
|
tr.querySelector('[data-f=target]').onchange=e=>edit(()=>{if(!row.targets)row.targets={};const v=e.target.value.trim();if(v)row.targets[connPlat]=v;else delete row.targets[connPlat];});
|
|
7171
|
-
|
|
7172
|
-
|
|
7378
|
+
// Deleting a row now costs more than a mapping: it also destroys the detail's RECIPE, schedule and
|
|
7379
|
+
// notes. So warn when anything is actually using it, and clear joints[].conn as well as ends[].conn —
|
|
7380
|
+
// that reference already existed in the schema and was never cleared here, so it dangled silently.
|
|
7381
|
+
// The joints themselves are KEPT: the geometry is real work, only its provenance link goes.
|
|
7382
|
+
tr.querySelector('.cdel').onclick=async()=>{
|
|
7383
|
+
const ends=connEndUsage(id), joints=(C.joints||[]).filter(j=>j&&j.conn===id).length, hasRecipe=!!(row.recipe&&row.recipe.kind);
|
|
7384
|
+
if(hasRecipe||ends||joints){
|
|
7385
|
+
const label=row.detail?('Detail '+row.detail):('Connection '+id);
|
|
7386
|
+
const lines=[label+' still has work pointing at it:'];
|
|
7387
|
+
if(hasRecipe)lines.push('• what it builds ('+row.recipe.kind+(Array.isArray(row.recipe.schedule)&&row.recipe.schedule.length?', plus a '+row.recipe.schedule.length+'-row schedule':'')+')'+((row.notes||[]).length?' and '+row.notes.length+' note'+(row.notes.length>1?'s':''):''));
|
|
7388
|
+
if(ends)lines.push('• '+ends+' member end'+(ends>1?'s':'')+' referencing it');
|
|
7389
|
+
if(joints)lines.push('• '+joints+' placed connection'+(joints>1?'s':'')+' citing it');
|
|
7390
|
+
lines.push('','The connections already built stay in the model — they just stop saying which detail they came from. This can be undone with Ctrl+Z.');
|
|
7391
|
+
if(!await confirmDanger({title:'Delete '+label+'?',body:lines.join('\n'),confirmLabel:'Delete it'}))return;
|
|
7392
|
+
}
|
|
7393
|
+
edit(()=>{C.connections=C.connections.filter(x=>x.id!==id);
|
|
7394
|
+
for(const pl of (C.plans||[]))for(const m of (pl.members||[])){if(m.col&&m.col.conn===id)m.col.conn='';for(const en of (m.ends||[]))if(en&&en.conn===id)en.conn='';}
|
|
7395
|
+
for(const j of (C.joints||[]))if(j&&j.conn===id)delete j.conn;});renderConnTable();};});
|
|
7173
7396
|
updConnBtn();}
|
|
7174
7397
|
document.getElementById('connBtn').onclick=openConnLib;
|
|
7175
7398
|
document.getElementById('connClose').onclick=closeConnLib;
|
|
@@ -7485,6 +7708,412 @@ const COMBO_SRC={
|
|
|
7485
7708
|
// back on select); type/detail follow for the human. Kept here so COMBO_SRC + cFld + wireConn agree.
|
|
7486
7709
|
function connLabel(r){return r.id+' · '+(r.type||'?')+(r.detail?' · '+r.detail:'');}
|
|
7487
7710
|
function connRowById(id){return (C.connections||[]).find(r=>r&&r.id===id)||null;}
|
|
7711
|
+
// How many member ends reference this library row — model-wide (a column base counts as one end). Used to
|
|
7712
|
+
// tell the user what a row deletion would cut loose before it happens.
|
|
7713
|
+
function connEndUsage(id){let n=0;
|
|
7714
|
+
for(const pl of (C.plans||[]))for(const m of (pl.members||[])){if(!m)continue;
|
|
7715
|
+
if(m.col&&m.col.conn===id)n++;
|
|
7716
|
+
for(const en of (m.ends||[]))if(en&&en.conn===id)n++;}
|
|
7717
|
+
return n;}
|
|
7718
|
+
|
|
7719
|
+
// ── detail → connection recipe ──────────────────────────────────────────────────────────────────
|
|
7720
|
+
// >>> BEGIN detail-recipes mirror >>> (the markers are load-bearing: detail-recipes-parity.test.ts
|
|
7721
|
+
// slices exactly this block out of the page and runs it against server/detail-recipes.ts over a shared
|
|
7722
|
+
// fixture table, so the two cannot drift. Move a marker and that test fails by name.)
|
|
7723
|
+
// MIRRORS server/detail-recipes.ts (this file is an import-less standalone doc, exactly as it already
|
|
7724
|
+
// mirrors scoreContract / rfiList / redundantDups). The TS module is the TESTED SOURCE OF TRUTH — keep
|
|
7725
|
+
// the two in sync; detail-recipes.test.ts is where the rules are pinned.
|
|
7726
|
+
//
|
|
7727
|
+
// A drawing detail ("5-S504") is a TYPICAL arrangement + a SCHEDULE that varies the numbers by member
|
|
7728
|
+
// size + the NOTES that come with it. All of that lives on the connections[] row, so binding a callout to
|
|
7729
|
+
// an end can now BUILD the connection instead of only recording intent.
|
|
7730
|
+
//
|
|
7731
|
+
// Everything here REFUSES rather than guesses: an ambiguous callout, a stale conn disagreeing with the
|
|
7732
|
+
// visible callout, or a size the schedule does not cover returns a reason and the candidates to choose
|
|
7733
|
+
// between. That is what makes "apply to every end" safe to offer.
|
|
7734
|
+
|
|
7735
|
+
// A matching aid, NEVER an identity: -/ are the same separator, but . _ and zero-padding are left alone
|
|
7736
|
+
// (squashing those merges A.01-S501 with A-1-S501, which can be two different details).
|
|
7737
|
+
function normDetailKey(t){return String(t==null?'':t).trim().toUpperCase().replace(/\s+/g,' ').replace(/\s*[-/]\s*/g,'/');}
|
|
7738
|
+
function connRowsForDetail(text){const k=normDetailKey(text);if(!k)return [];return (C.connections||[]).filter(r=>r&&normDetailKey(r.detail)===k);}
|
|
7739
|
+
function dupDetailKeys(){const seen={},out=[];for(const r of (C.connections||[])){const k=normDetailKey(r&&r.detail);if(k)seen[k]=(seen[k]||0)+1;}
|
|
7740
|
+
for(const k in seen)if(seen[k]>1)out.push(k);return out;}
|
|
7741
|
+
// Specificity rank, most specific first. A row carrying several matchers ranks by its MOST specific one —
|
|
7742
|
+
// without that the rank is undefined and the winner depends on evaluation accident.
|
|
7743
|
+
function schedRank(mt){const m=mt||{};return m.profile?1:m.profilePrefix?2:m.depth?3:m.role?4:5;}
|
|
7744
|
+
function _secDepthIn(profile){const row=(window.__AISC_SECTIONS||{})[canonProfile(profile).replace(/\s+/g,'')];return (row&&isFinite(row[0]))?row[0]:null;}
|
|
7745
|
+
function schedMatches(mt,m){const q=mt||{};
|
|
7746
|
+
if(q.profile&&canonProfile(m&&m.profile)!==canonProfile(q.profile))return false;
|
|
7747
|
+
if(q.profilePrefix&&canonProfile(m&&m.profile).indexOf(canonProfile(q.profilePrefix))!==0)return false;
|
|
7748
|
+
if(q.role&&((m&&m.role==='column')?'column':'beam')!==q.role)return false;
|
|
7749
|
+
if(q.depth){const inch=_secDepthIn(m&&m.profile);
|
|
7750
|
+
if(inch==null)return false; // an untabulated designation FAILS a depth matcher rather than being assigned one — that is why profilePrefix exists beside it
|
|
7751
|
+
const d=q.depth.unit==='mm'?inch*25.4:inch;
|
|
7752
|
+
if(q.depth.min!=null&&d<q.depth.min)return false;
|
|
7753
|
+
if(q.depth.max!=null&&d>q.depth.max)return false;}
|
|
7754
|
+
return true;}
|
|
7755
|
+
function pickSchedRow(sched,m){if(!Array.isArray(sched)||!sched.length)return null;let best=null;
|
|
7756
|
+
sched.forEach((row,index)=>{if(!row||!schedMatches(row.match,m))return;const rank=schedRank(row.match);
|
|
7757
|
+
if(!best||rank<best.rank)best={row,index,rank};}); // strictly < → the FIRST row at a rank wins (document order breaks a tie, deterministically)
|
|
7758
|
+
return best;}
|
|
7759
|
+
function shadowedSchedRows(sched){if(!Array.isArray(sched))return [];const out=[],seen={};let sawCatchAll=false;
|
|
7760
|
+
sched.forEach((row,i)=>{if(!row)return;
|
|
7761
|
+
const mt=row.match||{},sig=JSON.stringify([canonProfile(mt.profile),canonProfile(mt.profilePrefix),mt.depth||null,mt.role||null]);
|
|
7762
|
+
if(seen[sig]){out.push(i);return;}
|
|
7763
|
+
if(sawCatchAll){out.push(i);return;} // nothing after a catch-all is reachable — it matches every member
|
|
7764
|
+
seen[sig]=1;if(schedRank(mt)===5)sawCatchAll=true;});
|
|
7765
|
+
return out;}
|
|
7766
|
+
function mergeRecipeParams(typical,row){return Object.assign({},typical||{},row||{});}
|
|
7767
|
+
// Conservative on purpose: a key on one side only counts as DIFFERENT, because the absent side rides an
|
|
7768
|
+
// engine default that may or may not equal the explicit value. A false "differs" costs one named skip; a
|
|
7769
|
+
// false "same" silently overwrites someone's tuning.
|
|
7770
|
+
function recipeParamsDiffer(a,b){const x=a||{},y=b||{},ks={};for(const k in x)ks[k]=1;for(const k in y)ks[k]=1;
|
|
7771
|
+
for(const k in ks){if(!(k in x)||!(k in y))return true;if(!Object.is(x[k],y[k]))return true;}
|
|
7772
|
+
return false;}
|
|
7773
|
+
function jointAtFor(which){return which==='col'?'base':'end'+which;}
|
|
7774
|
+
const RECIPE_KIND_TARGET={'base-plate':'col','shear-plate':'end'};
|
|
7775
|
+
function endObjFor(m,which){if(!m)return {};return which==='col'?(m.col||{}):((m.ends||[])[which]||{});}
|
|
7776
|
+
// Resolve one member end to {ok:true,kind,params,notes,rowId,matched} or a NAMED refusal carrying the
|
|
7777
|
+
// candidates the user can pick between — a refusal must never be a dead end.
|
|
7778
|
+
function resolveDetail(m,which){
|
|
7779
|
+
const rows=(C.connections||[]).filter(r=>r&&typeof r.id==='string');
|
|
7780
|
+
const end=endObjFor(m,which);
|
|
7781
|
+
const byId=end.conn?rows.find(r=>r.id===end.conn):null;
|
|
7782
|
+
const byText=connRowsForDetail(end.detail);
|
|
7783
|
+
let row=null;
|
|
7784
|
+
if(byId){
|
|
7785
|
+
// The editor writes conn and detail through INDEPENDENT fields, so an end really can carry a stale row
|
|
7786
|
+
// reference beside a newer callout. Building the referenced row while the drawing shows another detail
|
|
7787
|
+
// is the "wrong connection rather than no connection" failure — refuse and name both.
|
|
7788
|
+
if(byText.length&&!byText.some(r=>r.id===byId.id))
|
|
7789
|
+
return {ok:false,reason:'conflict',message:'This end points at connection “'+byId.id+'” but its callout reads “'+(end.detail||'')+'”. Pick which one is right.',candidates:[byId.id].concat(byText.map(r=>r.id))};
|
|
7790
|
+
row=byId;
|
|
7791
|
+
}else if(byText.length>1){
|
|
7792
|
+
return {ok:false,reason:'ambiguous',message:'“'+(end.detail||'')+'” matches '+byText.length+' connections. Pick which one it means.',candidates:byText.map(r=>r.id)};
|
|
7793
|
+
}else if(byText.length===1)row=byText[0];
|
|
7794
|
+
if(!row){
|
|
7795
|
+
if(end.conn)return {ok:false,reason:'no-row',message:'This end points at a connection that no longer exists.'};
|
|
7796
|
+
return normDetailKey(end.detail)
|
|
7797
|
+
? {ok:false,reason:'no-row',message:'Nothing says what “'+end.detail+'” builds yet.'}
|
|
7798
|
+
: {ok:false,reason:'no-detail',message:'No connection detail on this end yet.'};
|
|
7799
|
+
}
|
|
7800
|
+
const rec=row.recipe,kind=(rec&&typeof rec.kind==='string')?rec.kind.trim():'';
|
|
7801
|
+
if(!kind)return {ok:false,reason:'row-has-no-recipe',message:'Nothing says what “'+(row.detail||row.id)+'” builds yet.',candidates:[row.id]};
|
|
7802
|
+
const want=RECIPE_KIND_TARGET[kind];
|
|
7803
|
+
// A brace carries role 'beam', so a shear-plate recipe LOOKS applicable — but expandJoints refuses it
|
|
7804
|
+
// (beam.isBrace → skipped), and auto-detail and the Favourites bake already exclude braces. Without this
|
|
7805
|
+
// the panel would say "built a shear plate" for geometry the engine then silently drops. The rule is
|
|
7806
|
+
// memberType, not role — matched to steel-confidence's isBraceMember so the mirror and module agree.
|
|
7807
|
+
if(want&&typeof m.memberType==='string'&&m.memberType.trim().toLowerCase()==='brace')
|
|
7808
|
+
return {ok:false,reason:'brace-unsupported',message:'A brace can’t carry a '+String(kind).replace(/-/g,' ')+' — building it would produce nothing.',candidates:[row.id]}; // spelled out inline, NOT via kindLabel(): this block is sliced out and run standalone by the parity test, so it must not reach for a helper defined elsewhere on the page
|
|
7809
|
+
if(want&&((want==='col')!==(which==='col')))
|
|
7810
|
+
return {ok:false,reason:'kind-mismatch',message:'“'+(row.detail||row.id)+'” builds a '+kind+', which belongs on a '+(want==='col'?'column base, not a beam end':'beam end, not a column base')+'.',candidates:[row.id]};
|
|
7811
|
+
const hasSched=Array.isArray(rec.schedule)&&rec.schedule.length>0;
|
|
7812
|
+
const picked=hasSched?pickSchedRow(rec.schedule,m):null;
|
|
7813
|
+
// A schedule exists BECAUSE the numbers vary by size, so falling back to the typical for a size nobody
|
|
7814
|
+
// listed would be fabricating a value. Name it instead.
|
|
7815
|
+
if(hasSched&&!picked)
|
|
7816
|
+
return {ok:false,reason:'no-schedule-match',message:'“'+(row.detail||row.id)+'” has a size schedule that doesn’t cover '+((m&&m.profile)||'this member')+'.',candidates:[row.id]};
|
|
7817
|
+
return {ok:true,kind:kind,params:mergeRecipeParams(rec.params,picked&&picked.row.params),
|
|
7818
|
+
// Narrowed to {text, source?} exactly like the module's cleanNotes — returning the caller's own objects
|
|
7819
|
+
// would hand every other key on a contract-supplied note straight through to whatever renders it.
|
|
7820
|
+
notes:(Array.isArray(row.notes)?row.notes:[]).filter(n=>n&&typeof n.text==='string')
|
|
7821
|
+
.map(n=>typeof n.source==='string'?{text:n.text,source:n.source}:{text:n.text}),
|
|
7822
|
+
rowId:row.id,matched:picked?{index:picked.index,rank:picked.rank}:null};}
|
|
7823
|
+
// <<< END detail-recipes mirror <<<
|
|
7824
|
+
|
|
7825
|
+
// ── building a connection FROM a detail ─────────────────────────────────────────────────────────
|
|
7826
|
+
// The apply engine, kept free of DOM so the single-end button, the bulk action and any future caller
|
|
7827
|
+
// all go through one set of rules. Joint shape matches every other authoring path (auto-detail, the
|
|
7828
|
+
// Favourites apply at onInsertPlace, the IFC import): {id,kind,main,at,params,source} + conn.
|
|
7829
|
+
|
|
7830
|
+
// Unique vs ANY existing joint id, the same way bpJointId/spJointId are — NOT the single-shot
|
|
7831
|
+
// Date.now()+random() the favourite/import paths use. Those mint one id per user click; this one runs in a
|
|
7832
|
+
// synchronous sweep where Date.now() is constant for every end, leaving a 10k random space: a 200-end
|
|
7833
|
+
// model has an ~86% chance of at least one collision, and two joints sharing an id collide their part ids,
|
|
7834
|
+
// select the wrong connection, and make the params inspector edit whichever find() reaches first.
|
|
7835
|
+
function detailJointId(){const ids=new Set((C.joints||[]).map(j=>j&&j.id));
|
|
7836
|
+
let n=0,id='cx'+Date.now().toString(36)+Math.floor(Math.random()*1e4).toString(36);
|
|
7837
|
+
while(ids.has(id))id='cx'+Date.now().toString(36)+Math.floor(Math.random()*1e4).toString(36)+'-'+(++n);
|
|
7838
|
+
return id;}
|
|
7839
|
+
// A 'custom' (imported IFC) joint bound to this member. Custom joints carry `main` but never an `at` — the
|
|
7840
|
+
// favourite and import bakes both omit it — so jointAtEnd can never see one, which left the "an imported
|
|
7841
|
+
// connection is here" refusal permanently dead AND let a build drop a second, overlapping connection on
|
|
7842
|
+
// top of imported geometry. Matched by member alone, deliberately: without an `at` we cannot tell WHERE on
|
|
7843
|
+
// the member it sits, and refusing a whole member is the honest side of that ignorance.
|
|
7844
|
+
function customJointOn(memberId){return (C.joints||[]).find(j=>j&&j.kind==='custom'&&j.main===memberId)||null;}
|
|
7845
|
+
// Member ids that occur on more than one sheet. v1 ids are per-plan, so this really happens (two sheets
|
|
7846
|
+
// each reading a "B1"), and anything that matches joints by `main` alone cannot tell them apart.
|
|
7847
|
+
function duplicateMemberIds(){const seen={},dup=new Set();
|
|
7848
|
+
for(const pl of (C.plans||[]))for(const m of (pl.members||[])){if(!m||!m.id)continue;
|
|
7849
|
+
if(seen[m.id])dup.add(m.id);else seen[m.id]=1;}
|
|
7850
|
+
return dup;}
|
|
7851
|
+
// The joint already sitting at this end, if any — one connection per end, same rule the favourite/import
|
|
7852
|
+
// paths use (two overlapping joints would also make "edit on member" target the older one).
|
|
7853
|
+
function jointAtEnd(memberId,which){const at=jointAtFor(which);
|
|
7854
|
+
return (C.joints||[]).find(j=>j&&j.main===memberId&&(j.at===at||(which==='col'&&j.kind==='base-plate'&&!j.at)))||null;}
|
|
7855
|
+
// Every (member, end) in the MODEL that carries a callout or a library reference — the population the
|
|
7856
|
+
// bulk action walks. Model-wide, like joints and the selection.
|
|
7857
|
+
function detailEndTargets(){const out=[];
|
|
7858
|
+
for(const m of allMembers()){if(!m)continue;
|
|
7859
|
+
if(m.role==='column'){if(m.col&&(m.col.detail||m.col.conn))out.push({m,which:'col'});continue;}
|
|
7860
|
+
if(isBrace(m))continue; // a brace carries neither a shear plate nor a base plate — the engine skips the joint, so we must not claim to have applied one
|
|
7861
|
+
for(const w of [0,1]){const e=(m.ends||[])[w];if(e&&(e.detail||e.conn))out.push({m,which:w});}}
|
|
7862
|
+
return out;}
|
|
7863
|
+
/**
|
|
7864
|
+
* Why applying to this end would be REFUSED even though its detail resolves — the protection for work
|
|
7865
|
+
* that already exists. Returns null when it is safe to build.
|
|
7866
|
+
*
|
|
7867
|
+
* Bulk replacement across sheets is the most destructive thing in this feature, so it defaults to
|
|
7868
|
+
* skip-and-name for anything a human or an import put there. `force` is the explicit reviewed overwrite.
|
|
7869
|
+
*/
|
|
7870
|
+
function detailApplyBlocker(m,which,res,force){
|
|
7871
|
+
const end=endObjFor(m,which),j=jointAtEnd(m.id,which);
|
|
7872
|
+
if(!force){
|
|
7873
|
+
if(end.connVerified===true)return {reason:'verified',text:'someone confirmed this end'};
|
|
7874
|
+
if(j&&j.verified===true)return {reason:'verified',text:'someone confirmed this connection'};
|
|
7875
|
+
if((j&&j.kind==='custom')||customJointOn(m.id))return {reason:'custom',text:'an imported connection is on this member — it cannot be rebuilt if replaced'};
|
|
7876
|
+
if(j&&j.source==='user'&&recipeParamsDiffer(j.params,res.params))return {reason:'tuned',text:'this one was tuned by hand'};
|
|
7877
|
+
}
|
|
7878
|
+
return null;}
|
|
7879
|
+
/**
|
|
7880
|
+
* Build the connection this end's detail describes. Caller owns the edit() wrapper so a bulk run is ONE
|
|
7881
|
+
* undo step; pass the resolution in so the caller can report without resolving twice.
|
|
7882
|
+
* Returns the new joint id.
|
|
7883
|
+
*/
|
|
7884
|
+
function buildJointFromDetail(m,which,res){
|
|
7885
|
+
const at=jointAtFor(which),id=detailJointId();
|
|
7886
|
+
const joint={id,kind:res.kind,main:m.id,at,params:Object.assign({},res.params),source:'user',conn:res.rowId};
|
|
7887
|
+
// A fin plate wants its support recorded the same way auto-detail records it (geometry-inferred, and
|
|
7888
|
+
// optional — the engine places the plate off the beam end + axis either way).
|
|
7889
|
+
if(res.kind==='shear-plate'&&which!=='col'){const sup=spInferSupport(m,which);joint.secondaries=sup?[sup.id]:[];}
|
|
7890
|
+
if(!Array.isArray(C.joints))C.joints=[];
|
|
7891
|
+
C.joints=C.joints.filter(j=>!(j&&j.main===m.id&&(j.at===at||(which==='col'&&j.kind==='base-plate'&&!j.at))));
|
|
7892
|
+
C.joints.push(joint);
|
|
7893
|
+
// Point the end at the row it was built from, on BOTH sides: the end gains the library reference the
|
|
7894
|
+
// confidence report scores, and the joint cites the same row for its type/detail identity.
|
|
7895
|
+
const end=endObjFor(m,which);if(end)end.conn=res.rowId;
|
|
7896
|
+
return id;}
|
|
7897
|
+
/**
|
|
7898
|
+
* Resolve + build every end whose detail resolves. One edit() → one undo step for the whole sweep.
|
|
7899
|
+
* Returns {applied, already, skipped:[{m,which,reason,text}]} — the caller reports it; nothing is silent.
|
|
7900
|
+
*/
|
|
7901
|
+
function applyAllDetails(opts){const force=!!(opts&&opts.force),only=opts&&opts.onlyRowId;
|
|
7902
|
+
const targets=detailEndTargets(),skipped=[];let applied=0,already=0,lastId=null;
|
|
7903
|
+
// v1 member ids are PLAN-LOCAL, and joints are matched model-wide by main+at — so two sheets each
|
|
7904
|
+
// holding a "B1" would have the second build silently replace the first one's joint. Every other
|
|
7905
|
+
// authoring path has the same exposure (it is the tracked reader id-uniqueness gap), but this action
|
|
7906
|
+
// sweeps every sheet in one click, which is what turns a latent edge into an easy one. Refuse those
|
|
7907
|
+
// ends by name rather than quietly losing a connection.
|
|
7908
|
+
const dupIds=duplicateMemberIds();
|
|
7909
|
+
const work=[];
|
|
7910
|
+
for(const t of targets){
|
|
7911
|
+
if(dupIds.has(t.m.id)){skipped.push({m:t.m,which:t.which,reason:'duplicate-id',text:'more than one member is called '+t.m.id});continue;}
|
|
7912
|
+
const res=resolveDetail(t.m,t.which);
|
|
7913
|
+
if(!res.ok){skipped.push({m:t.m,which:t.which,reason:res.reason,text:res.message});continue;}
|
|
7914
|
+
if(only&&res.rowId!==only)continue;
|
|
7915
|
+
const blk=detailApplyBlocker(t.m,t.which,res,force);
|
|
7916
|
+
if(blk){skipped.push({m:t.m,which:t.which,reason:blk.reason,text:blk.text});continue;}
|
|
7917
|
+
// Already exactly what the detail says → not work, and not a failure either. Counted separately so
|
|
7918
|
+
// "applied 0" never reads as "nothing happened" when the model is simply already correct.
|
|
7919
|
+
const j=jointAtEnd(t.m.id,t.which);
|
|
7920
|
+
if(j&&j.kind===res.kind&&!recipeParamsDiffer(j.params,res.params)&&j.conn===res.rowId&&endObjFor(t.m,t.which).conn===res.rowId){already++;continue;}
|
|
7921
|
+
work.push({t,res});}
|
|
7922
|
+
if(work.length)edit(()=>{for(const w of work){lastId=buildJointFromDetail(w.t.m,w.t.which,w.res);applied++;}});
|
|
7923
|
+
return {applied,already,skipped,lastId};}
|
|
7924
|
+
|
|
7925
|
+
// ── the two detail modals ───────────────────────────────────────────────────────────────────────
|
|
7926
|
+
// Both are built with createElement rather than an HTML string: every value shown here is MODEL data
|
|
7927
|
+
// (a detail number, a profile, a row's own label), and a contract string must never reach a markup
|
|
7928
|
+
// position. Same tokens as the other modals — .modal/.mbackdrop/.mpanel/.mhead/.elab/.hint/.danger.
|
|
7929
|
+
|
|
7930
|
+
/** Shell shared by the two: backdrop + panel + head + a footer, Esc/backdrop closing. */
|
|
7931
|
+
function detailModalShell(title){
|
|
7932
|
+
const el=(t,css,txt)=>{const n=document.createElement(t);if(css)n.style.cssText=css;if(txt!=null)n.textContent=txt;return n;};
|
|
7933
|
+
const back=el('div','position:fixed;inset:0;z-index:60;display:flex;align-items:center;justify-content:center');
|
|
7934
|
+
back.className='modal';
|
|
7935
|
+
const bd=el('div');bd.className='mbackdrop';
|
|
7936
|
+
// .mpanel is max-height:86vh with overflow:visible, so taller content spills OUTSIDE its own box — the
|
|
7937
|
+
// footer then renders below the fold and the primary button cannot be clicked at all. Measured in the
|
|
7938
|
+
// browser: a 4-option capture dialog put "Remember it" at y=1147 in a 950px viewport. So the panel is a
|
|
7939
|
+
// flex column with a pinned head/footer and only the BODY scrolls. The global `*` rule themes that
|
|
7940
|
+
// scrollbar, so no native white bar appears.
|
|
7941
|
+
const panel=el('div','width:min(520px,92vw);display:flex;flex-direction:column;max-height:86vh');panel.className='mpanel';
|
|
7942
|
+
const head=el('div','padding:14px 16px;border-bottom:1px solid var(--line);font-weight:600;flex:none',title);head.className='mhead';
|
|
7943
|
+
const body=el('div','padding:14px 16px;flex:1 1 auto;overflow-y:auto;min-height:0');
|
|
7944
|
+
const foot=el('div','padding:12px 16px;display:flex;gap:8px;justify-content:flex-end;border-top:1px solid var(--line);flex:none');
|
|
7945
|
+
panel.append(head,body,foot);back.append(bd,panel);document.body.appendChild(back);
|
|
7946
|
+
const close=()=>{document.removeEventListener('keydown',onKey,true);back.remove();};
|
|
7947
|
+
const onKey=e=>{if(e.key==='Escape'){e.stopPropagation();close();}};
|
|
7948
|
+
document.addEventListener('keydown',onKey,true); // capture, so the editor's global Esc handlers do not win over an open modal
|
|
7949
|
+
bd.onclick=close;
|
|
7950
|
+
return {el,back,body,foot,close};}
|
|
7951
|
+
|
|
7952
|
+
/**
|
|
7953
|
+
* "Remember this as 5-S504" — teach the library what a detail means, from an end already built.
|
|
7954
|
+
*
|
|
7955
|
+
* The SCOPE is the whole point of the dialog. Recording what the user did is what builds a schedule
|
|
7956
|
+
* without ever parsing a schedule table, but done silently it turns one tuned end into a project-wide
|
|
7957
|
+
* rule. So each option shows how many ends it would govern, and the default is the narrowest.
|
|
7958
|
+
*/
|
|
7959
|
+
function openCaptureModal(m,which){
|
|
7960
|
+
const e=endObjFor(m,which),j=jointAtEnd(m.id,which);
|
|
7961
|
+
if(!e||!j){toast('Build a connection on this end first, then you can remember what it means');return;}
|
|
7962
|
+
const text=String(e.detail||'').trim();
|
|
7963
|
+
const opts=captureScopeOptions(m,which,text);
|
|
7964
|
+
const existing=connRowsForDetail(text)[0]||(e.conn?connRowById(e.conn):null);
|
|
7965
|
+
const S=detailModalShell('Remember detail '+text);
|
|
7966
|
+
const {el,body,foot,close}=S;
|
|
7967
|
+
body.append(el('div','font-size:12px;line-height:1.5;color:var(--mut);margin-bottom:10px',
|
|
7968
|
+
'This '+whichLabel(which)+' of '+m.id+' has a '+kindLabel(j.kind)+'. Save it as what “'+text+'” means, and any end with the same callout can be built from it.'));
|
|
7969
|
+
const typeLab=el('div',null,'Connection type');typeLab.className='elab';body.append(typeLab);
|
|
7970
|
+
const type=el('input');type.placeholder='shear · moment · pinned — the drawing’s word';type.autocomplete='off';
|
|
7971
|
+
type.value=(existing&&existing.type)||'';
|
|
7972
|
+
body.append(type);
|
|
7973
|
+
const typeHint=el('div','margin-top:4px','Without this the confidence report can never rate these ends highly — it is one word off the drawing.');
|
|
7974
|
+
typeHint.className='hint';body.append(typeHint);
|
|
7975
|
+
const scopeLab=el('div',null,'Use these numbers for');scopeLab.className='elab';body.append(scopeLab);
|
|
7976
|
+
const group=el('div','display:flex;flex-direction:column;gap:2px');
|
|
7977
|
+
opts.forEach((o,i)=>{
|
|
7978
|
+
const row=el('label','display:flex;align-items:baseline;gap:8px;padding:5px 6px;border-radius:6px;cursor:pointer');
|
|
7979
|
+
const rb=el('input');rb.type='radio';rb.name='dcapscope';rb.value=o.scope;rb.checked=i===0;rb.style.cssText='flex:none;margin:0';
|
|
7980
|
+
const txt=el('div','flex:1;min-width:0');
|
|
7981
|
+
txt.append(el('div','font-size:12px;color:var(--text)',o.label));
|
|
7982
|
+
txt.append(el('div','font-size:11px;color:var(--mut);line-height:1.4',o.hint+' — '+o.n+' end'+(o.n===1?'':'s')));
|
|
7983
|
+
row.append(rb,txt);group.append(row);});
|
|
7984
|
+
body.append(group);
|
|
7985
|
+
const cancel=el('button',null,'Cancel'),save=el('button',null,'Remember it');
|
|
7986
|
+
cancel.className='ghost';cancel.onclick=close;
|
|
7987
|
+
save.onclick=()=>{
|
|
7988
|
+
const picked=opts.find(o=>o.scope===(group.querySelector('input[name=dcapscope]:checked')||{}).value)||opts[0];
|
|
7989
|
+
close();
|
|
7990
|
+
const out=captureDetailRecipe(m,which,picked,type.value.trim());
|
|
7991
|
+
if(out&&out.error==='ambiguous'){
|
|
7992
|
+
// Two rows share this callout — settle which one this end means first, then capture onto it.
|
|
7993
|
+
toast('“'+text+'” matches more than one connection — choose which one it means, then remember it');
|
|
7994
|
+
openDetailPick(m,which);return;
|
|
7995
|
+
}
|
|
7996
|
+
if(!out||!out.rowId){toast('Could not save that — the end needs a detail callout and a built connection');return;}
|
|
7997
|
+
toast((picked.scope==='end'
|
|
7998
|
+
? ('“'+text+'” now points at this connection — nothing else changed')
|
|
7999
|
+
: ('“'+text+'” now means a '+kindLabel(j.kind)+' for “'+picked.label+'” — build the other ends from the ⋯ menu')) // NOT lowercased: the label carries a profile designation (W18), and "all w18" reads as a typo
|
|
8000
|
+
+(out.droppedSchedule?' · its old size schedule was dropped — it sized a different connection':''));
|
|
8001
|
+
render();};
|
|
8002
|
+
foot.append(cancel,save);save.focus();}
|
|
8003
|
+
|
|
8004
|
+
/**
|
|
8005
|
+
* The way OUT of a conflict / ambiguity. The resolver refuses to pick between two rows because guessing
|
|
8006
|
+
* would bake a connection the drawing does not show — but a refusal with no next step is just a wall, so
|
|
8007
|
+
* this is that step. Choosing writes end.conn, which settles the end permanently.
|
|
8008
|
+
*/
|
|
8009
|
+
function openDetailPick(m,which){
|
|
8010
|
+
const r=resolveDetail(m,which);
|
|
8011
|
+
if(r.ok||!r.candidates||!r.candidates.length){render();return;}
|
|
8012
|
+
const rows=r.candidates.map(id=>connRowById(id)).filter(Boolean);
|
|
8013
|
+
if(!rows.length){toast('Those connections no longer exist');render();return;}
|
|
8014
|
+
const S=detailModalShell('Which connection does this end use?');
|
|
8015
|
+
const {el,body,foot,close}=S;
|
|
8016
|
+
body.append(el('div','font-size:12px;line-height:1.5;color:var(--mut);margin-bottom:10px',r.message));
|
|
8017
|
+
const group=el('div','display:flex;flex-direction:column;gap:2px');
|
|
8018
|
+
rows.forEach((row,i)=>{
|
|
8019
|
+
const lab=el('label','display:flex;align-items:baseline;gap:8px;padding:5px 6px;border-radius:6px;cursor:pointer');
|
|
8020
|
+
const rb=el('input');rb.type='radio';rb.name='dpick';rb.value=row.id;rb.checked=i===0;rb.style.cssText='flex:none;margin:0';
|
|
8021
|
+
const txt=el('div','flex:1;min-width:0');
|
|
8022
|
+
txt.append(el('div','font-size:12px;color:var(--text)',(row.detail||row.id)+(row.type?(' · '+row.type):'')));
|
|
8023
|
+
txt.append(el('div','font-size:11px;color:var(--mut);line-height:1.4',
|
|
8024
|
+
row.recipe&&row.recipe.kind?('builds a '+recipeSummary(row.recipe)):'nothing says what this one builds yet'));
|
|
8025
|
+
lab.append(rb,txt);group.append(lab);});
|
|
8026
|
+
body.append(group);
|
|
8027
|
+
const cancel=el('button',null,'Cancel'),use=el('button',null,'Use this one');
|
|
8028
|
+
cancel.className='ghost';cancel.onclick=close;
|
|
8029
|
+
use.onclick=()=>{const id=(group.querySelector('input[name=dpick]:checked')||{}).value;close();
|
|
8030
|
+
if(!id)return;
|
|
8031
|
+
const end=endObjFor(m,which);edit(()=>{end.conn=id;});
|
|
8032
|
+
toast('This '+whichLabel(which)+' now uses '+((connRowById(id)||{}).detail||id));};
|
|
8033
|
+
foot.append(cancel,use);use.focus();}
|
|
8034
|
+
|
|
8035
|
+
// ── plain-English labels for the detail UI ──────────────────────────────────────────────────────
|
|
8036
|
+
// Everything a detailer reads. No jargon, no ids where a name will do.
|
|
8037
|
+
function kindLabel(k){return k==='base-plate'?'base plate':k==='shear-plate'?'shear plate':String(k||'connection').replace(/-/g,' ');}
|
|
8038
|
+
function whichLabel(w){return w==='col'?'base':w===1?'end':'start';}
|
|
8039
|
+
// Describe WHICH members a schedule row covers, in the words a schedule uses.
|
|
8040
|
+
function schedRowLabel(row){const q=(row&&row.match)||{};
|
|
8041
|
+
if(q.profile)return q.profile;
|
|
8042
|
+
if(q.profilePrefix)return q.profilePrefix+' sizes';
|
|
8043
|
+
if(q.depth){const u=q.depth.unit==='mm'?'mm':'"';const lo=q.depth.min,hi=q.depth.max;
|
|
8044
|
+
return (lo!=null&&hi!=null)?(lo+'–'+hi+u+' deep'):(lo!=null?('over '+lo+u+' deep'):('up to '+hi+u+' deep'));}
|
|
8045
|
+
if(q.role)return q.role==='column'?'columns':'beams';
|
|
8046
|
+
return 'every size';}
|
|
8047
|
+
function recipeSummary(rec){if(!rec||!rec.kind)return '';
|
|
8048
|
+
const n=Array.isArray(rec.schedule)?rec.schedule.length:0;
|
|
8049
|
+
return kindLabel(rec.kind)+(n?(' · '+n+' size'+(n>1?'s':'')):'');}
|
|
8050
|
+
// A capture is offered only when there is something real to remember: a built connection AND a callout
|
|
8051
|
+
// to remember it under.
|
|
8052
|
+
function captureEligible(m,which){const e=endObjFor(m,which);
|
|
8053
|
+
return !!(e&&normDetailKey(e.detail)&&jointAtEnd(m.id,which));}
|
|
8054
|
+
/**
|
|
8055
|
+
* How many ends each capture SCOPE would govern — the blast radius, shown before anything is written.
|
|
8056
|
+
* A recipe silently becoming a project-wide rule is the main risk in this feature, so the count is part
|
|
8057
|
+
* of the choice rather than a detail discovered later.
|
|
8058
|
+
*/
|
|
8059
|
+
function captureScopeOptions(m,which,detailText){
|
|
8060
|
+
const key=normDetailKey(detailText),prof=canonProfile(m&&m.profile);
|
|
8061
|
+
const series=prof.match(/^([A-Z]+\d+)/); // the leading size family, e.g. W18X35 → W18. Absent for a designation with no digits — that scope is simply not offered.
|
|
8062
|
+
const pool=detailEndTargets().filter(t=>normDetailKey(endObjFor(t.m,t.which).detail)===key);
|
|
8063
|
+
const count=f=>pool.filter(f).length;
|
|
8064
|
+
const opts=[{scope:'end',label:'This end only',hint:'No rule — just these numbers, here',n:1}];
|
|
8065
|
+
if(prof)opts.push({scope:'profile',label:'All '+prof,hint:'A schedule row for this exact size',n:count(t=>canonProfile(t.m.profile)===prof),match:{profile:prof}});
|
|
8066
|
+
if(series&&series[1]!==prof)opts.push({scope:'series',label:'All '+series[1],hint:'A schedule row for this size family',n:count(t=>canonProfile(t.m.profile).indexOf(series[1])===0),match:{profilePrefix:series[1]}});
|
|
8067
|
+
opts.push({scope:'typical',label:'Every size',hint:'The typical — used wherever no size row matches',n:pool.length});
|
|
8068
|
+
return opts;}
|
|
8069
|
+
/**
|
|
8070
|
+
* Write what this end's connection means onto the library row for its callout, creating the row if the
|
|
8071
|
+
* callout names nothing yet. `scope` decides whether it becomes the typical, a schedule row, or nothing
|
|
8072
|
+
* at all (end-only, which just leaves the joint as it is).
|
|
8073
|
+
*/
|
|
8074
|
+
function captureDetailRecipe(m,which,opt,type){
|
|
8075
|
+
const e=endObjFor(m,which),j=jointAtEnd(m.id,which);
|
|
8076
|
+
if(!e||!j)return null;
|
|
8077
|
+
const text=String(e.detail||'').trim(),key=normDetailKey(text);
|
|
8078
|
+
if(!key)return null;
|
|
8079
|
+
const params=Object.assign({},j.params||{});
|
|
8080
|
+
// AMBIGUITY IS REFUSED HERE TOO. resolveDetail refuses to choose between two rows that normalise to the
|
|
8081
|
+
// same callout; capture has to hold the same line. Taking the first hit would write this recipe onto
|
|
8082
|
+
// whichever row happened to be first and corrupt a typical that other ends still resolve against —
|
|
8083
|
+
// silently, since those ends would go on refusing as ambiguous.
|
|
8084
|
+
const hits=connRowsForDetail(text);
|
|
8085
|
+
const bound=e.conn?connRowById(e.conn):null;
|
|
8086
|
+
const boundHere=!!(bound&&normDetailKey(bound.detail)===key); // a stale reference must not be the thing we teach
|
|
8087
|
+
if(hits.length>1&&!boundHere)return {error:'ambiguous'};
|
|
8088
|
+
let rowId=null,droppedSchedule=false;
|
|
8089
|
+
edit(()=>{
|
|
8090
|
+
if(!Array.isArray(C.connections))C.connections=[];
|
|
8091
|
+
let row=boundHere?bound:(hits[0]||null);
|
|
8092
|
+
if(!row){row={id:'cx'+Date.now().toString(36)+Math.floor(Math.random()*1e4).toString(36),type:type||'',detail:text,targets:{},source:'user'};C.connections.push(row);}
|
|
8093
|
+
else if(type&&!row.type)row.type=type; // never overwrite a type the user already set
|
|
8094
|
+
rowId=row.id;
|
|
8095
|
+
// A row that USED to mean a different kind cannot keep its schedule: those rows size a base plate, and
|
|
8096
|
+
// re-teaching the detail as a shear plate would leave them sizing something that no longer exists, then
|
|
8097
|
+
// silently merge base-plate numbers into a fin plate. Drop the schedule and tell the user.
|
|
8098
|
+
const prevKind=row.recipe&&row.recipe.kind;
|
|
8099
|
+
const kindChanged=!!(prevKind&&prevKind!==j.kind);
|
|
8100
|
+
if(kindChanged&&Array.isArray(row.recipe.schedule)&&row.recipe.schedule.length)droppedSchedule=true;
|
|
8101
|
+
const rec=(row.recipe&&!kindChanged)?row.recipe:{};
|
|
8102
|
+
rec.kind=j.kind; // ALWAYS the kind actually being captured, never a leftover from what it used to mean
|
|
8103
|
+
row.recipe=rec;
|
|
8104
|
+
if(opt.scope==='typical'){rec.params=params;}
|
|
8105
|
+
else if(opt.scope!=='end'){
|
|
8106
|
+
const sched=Array.isArray(rec.schedule)?rec.schedule.slice():[];
|
|
8107
|
+
const sig=JSON.stringify(opt.match);
|
|
8108
|
+
const at=sched.findIndex(r=>r&&JSON.stringify(r.match||{})===sig);
|
|
8109
|
+
if(at>=0)sched[at]={match:opt.match,params:params};else sched.push({match:opt.match,params:params});
|
|
8110
|
+
// Keep the catch-all last so it cannot shadow a size row. The resolver ranks by specificity anyway,
|
|
8111
|
+
// so this is for the reader, not for correctness.
|
|
8112
|
+
sched.sort((a,b)=>schedRank(a&&a.match)-schedRank(b&&b.match));
|
|
8113
|
+
rec.schedule=sched;}
|
|
8114
|
+
e.conn=rowId;j.conn=rowId; // the end and the joint both cite the row, so the confidence report sees the reference
|
|
8115
|
+
});
|
|
8116
|
+
return {rowId:rowId,droppedSchedule:droppedSchedule};}
|
|
7488
8117
|
const comboPop=document.createElement('div');comboPop.id='comboPop';document.body.appendChild(comboPop);
|
|
7489
8118
|
let comboInput=null,comboIdx=-1;
|
|
7490
8119
|
function showCombo(inp){const src=COMBO_SRC[inp.dataset.src];if(!src)return;comboInput=inp;
|