T5.5 - CR-006: section toggles, and X4 resolved rather than deferred
X4 first, because the brief asks for it explicitly.
IMPLEMENTATION.md sequences CR-006 after B7 on the grounds that the toggles must
suppress sections inside the creator, which is an iframe child until T7.1. The
wave file puts it in wave 5 anyway, and its last done-when is written to
accommodate exactly that: "toggle state propagates into the creator, OR the PR
documents exactly where it does not and why".
It propagates. Both ways, by two separate paths, because they fail differently:
ON THE CREATOR'S OWN BOOT the flags ride on the SOP, which the creator already
reads - ProjectData.pullProject hydrates it from the server. Nothing crosses
the frame boundary at all, so this path is unaffected by B7 either way. It
covers a reload, a fresh tab, the standalone creator page, and a colleague
opening the project on another machine.
WHILE THE FRAME IS OPEN the wizard hands the change straight across
(pushSectionsToCreator -> cw.applySopSections), the same shape T5.3 used for
the dashboard filter. Without it, flipping a toggle would appear to do nothing
until a reload.
T7.1 removes the second path, not the first. That is the whole of the X4
exposure and it is one function, commented as such. Building CR-006 after B7
would not have made the SOP-borne path any different; it would only have saved
writing the hand-off.
What it does
Ten sections, one shared list (html/wp-sections.js) read by the wizard, the
creator's form and the creator's rendered document. Three surfaces meant three
chances to drift, which is how "Assets is off, except in the export" happens.
Off means NOT RENDERED - form, detail view and PDF export. It never means
deleted. renderPackage() was rebuilt from one long string into a list of
(section, html) blocks so a suppressed section leaves no empty heading and the
survivors renumber 1.0, 2.0, 3.0 instead of leaving a hole. The print window
reuses that same HTML, so the export needed no separate change.
Absent means ON. A SOP saved before today mentions no sections, and reading
that as "all off" would blank every project in the estate the moment this
shipped. WPSections.normalize is the one place that decision lives.
html/wp-sections.js new - the shared list, defaults, normalize
html/work-package-suite.html step 12, a 12th rail button
html/work-package-suite-app.js the toggles, state.sections, the hand-off
html/work-package-suite-styles.css the toggle rows
html/wp-creation-index.html stable ids on the five unnamed cards
html/wp-creation-app.js WP_SECTION_NODES, applySopSections,
renderPackage rebuilt as blocks
tests/sections_check.py new - 53 checks
Done when
[x] all 10 sections are toggleable - each one driven off and back on
[x] a section toggled off is absent from the form, the detail view and the
PDF export - checked by content marker, not by heading, so "the section
is gone" and "the section was empty" cannot be confused
[x] toggling off then on restores prior data with no loss - and the sharper
version: a package EDITED while Assets is off still carries its assets
through collectPackage(), which is what Save uses
[x] new SOPs default to all sections on
[x] toggle state propagates into the creator - both paths, separately
Two things worth arguing with
General Information is toggleable, because CR-006 enumerates it. Turning it
off leaves nothing to identify a package by. The row says so in its own note
rather than being quietly excluded from the list.
Location has no card of its own - it is a field inside General Information's
grid, and its toggle governs that one row. CR-004 gives it structured
building/floor/sector fields in wave 6, at which point one line of
WP_SECTION_NODES changes. Written down because "the toggle does nothing" and
"the toggle governs one row" look identical from outside.
Approvals & Sign-offs is NOT toggleable and is not one of the ten. A package
nobody signed is not a shorter package.
Verified one at a time
sections_check 53/53 new
stepper_check 70/70 (STEP_COUNT 11 -> 12)
locations_check 58/58 (its "step 11 is last" check now asserts the thing that
is actually invariant - the wizard's navigation follows)
browser_check 71/71
a11y 22/22
url_state 23/23
autosave 34/34
aggregates 16/16
pipeline 43/43
launcher 58/58
f_items F1-F5 FIXED, F6 REPRODUCES (T7.2)
No colour literal added: still 0 across all page sheets and inline blocks. Each
toggle says its state three ways - the checkbox, the words "In use" / "Not used",
and the rule down its left edge (C1).
Question for the PR, per CLAUDE.md: the toggles are SOP-wide, so a project
cannot use Kitting on install packages and not on BIM ones. BL-000b already
records the field-level version of this question; the per-WP-type version is the
same shape and is not recorded anywhere yet.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -120,6 +120,9 @@ function applySOP(){
|
||||
if(!pkgAssets.length){ pkgAssets=[{tag:'',desc:'',link:''}]; buildAssets(); }
|
||||
if(!pkgWorkSteps.length){ pkgWorkSteps=['']; buildWorkSteps(); }
|
||||
updateNumber(); updateReleaseBanner();
|
||||
// CR-006. Last, after every builder has rendered its card — applying it earlier
|
||||
// would be undone by whichever builder touched the same card afterwards.
|
||||
applySopSections(SOP && SOP.sections);
|
||||
}
|
||||
// Per-package kind. A project whose SOP has bimEnabled produces both install (IWP)
|
||||
// and BIM (EWP) packages; the kind selector tailors which fields, WP types, and
|
||||
@@ -1178,22 +1181,40 @@ function savePackage(view){
|
||||
document.getElementById('loadingOverlay').classList.add('active');
|
||||
setTimeout(()=>{ document.getElementById('loadingOverlay').classList.remove('active'); if(view) renderPackage(pkg); }, 400);
|
||||
}
|
||||
// The package as a document — this is both the detail view and, via
|
||||
// printPackage(), the PDF export: the print window reuses #pkg-doc's HTML, so a
|
||||
// section suppressed here is suppressed in both. That is why CR-006 needed one
|
||||
// change rather than two.
|
||||
//
|
||||
// Built as a LIST of (section id, html) blocks rather than one long string, so a
|
||||
// section this project has turned off is dropped and what survives is numbered
|
||||
// 1.0, 2.0, 3.0 — not 1.0, 3.0, 4.0 with a hole where Assets used to be.
|
||||
let _lastRenderedPkg = null;
|
||||
|
||||
function renderPackage(pkg){
|
||||
_lastRenderedPkg = pkg;
|
||||
const r = pkg.constraints ? {open:pkg.constraints.filter(c=>c.status==='open').length,total:pkg.constraints.length} : {open:0,total:0};
|
||||
const readyTxt = pkg.status==='Issue' ? 'ON HOLD' : (r.open===0?'RELEASE-READY':(r.open+' OPEN CONSTRAINTS'));
|
||||
const kindLbl = pkg.kind==='ewp' ? 'BIM (EWP)' : 'IWP';
|
||||
let h=`<h1>${esc(pkg.number||'(no number)')} — Work Package</h1>
|
||||
let head=`<h1>${esc(pkg.number||'(no number)')} — Work Package</h1>
|
||||
<div class="doc-subtitle">${esc(pkg.project)} · ${kindLbl} · TYPE: ${esc(pkg.type).toUpperCase()} · STATUS: ${esc(pkg.status).toUpperCase()} · ${readyTxt}</div>`;
|
||||
const costDesc = (COST_CODES.find(c=>c.split('|')[0]===pkg.cost)||'').split('|')[1];
|
||||
// Project system links travel with the WP; fall back to the live SOP for older packages.
|
||||
const plinks = (pkg.projectLinks&&pkg.projectLinks.length) ? pkg.projectLinks : ((SOP&&SOP.projectLinks)||[]);
|
||||
h+=`<h2>1.0 General Information</h2><table><tbody>
|
||||
|
||||
// Each entry is [section id, title, body]. `null` bodies are skipped, which is
|
||||
// how a section that simply has no content behaves — different from a section
|
||||
// this project does not use, which never reaches the list at all.
|
||||
const blocks = [];
|
||||
const add = (id, title, body) => { if(body != null && sectionOn(id)) blocks.push([title, body]); };
|
||||
|
||||
add('general', 'General Information', `<table><tbody>
|
||||
<tr><th style="width:200px">WP Number</th><td>${cell(pkg.number)}</td></tr>
|
||||
<tr><th>Subject</th><td>${cell(pkg.subject)}</td></tr>
|
||||
<tr><th>Type</th><td>${cell(pkg.type)}</td></tr>
|
||||
${pkg.disciplines&&pkg.disciplines.length?`<tr><th>Discipline(s)</th><td>${esc(pkg.disciplines.join(', '))}${pkg.split?' <span style="color:var(--accent);font-size:10px">[MASTER — split into instances]</span>':''}${pkg.instanceOf?` <span style="color:var(--accent);font-size:10px">[instance of ${esc(pkg.parentNumber||'')}]</span>`:''}</td></tr>`:''}
|
||||
<tr><th>System / Facility Code / UPN</th><td>${cell(pkg.system)}</td></tr>
|
||||
<tr><th>Location</th><td>${cell(pkg.location)}</td></tr>
|
||||
${sectionOn('location')?`<tr><th>Location</th><td>${cell(pkg.location)}</td></tr>`:''}
|
||||
<tr><th>Cost Code</th><td>${pkg.cost?esc(pkg.cost)+(costDesc?' — '+esc(costDesc):''):ns()}</td></tr>
|
||||
<tr><th>Acumatica Task</th><td>${cell(pkg.wbs)}</td></tr>
|
||||
<tr><th>Assignees</th><td>${cell(pkg.assignees)}</td></tr>
|
||||
@@ -1204,9 +1225,20 @@ function renderPackage(pkg){
|
||||
${plinks.length?`<tr><th>Project Systems</th><td>${plinks.map(l=>esc(l.label)+': '+linkify(l.url)).join('<br>')}</td></tr>`:''}
|
||||
${pkg.bimlink?`<tr><th>Enabled by (BIM)</th><td>${/^https?:\/\//i.test(pkg.bimlink)?linkify(pkg.bimlink):cell(pkg.bimlink)}</td></tr>`:''}
|
||||
${(pkg.lod||pkg.iff||pkg.modelArea||pkg.clash||pkg.scanLink)?`<tr><th>BIM / Model</th><td>${[pkg.modelArea?'Area: '+esc(pkg.modelArea):'', pkg.clash?'Coordination: '+esc(pkg.clash):'', pkg.iff?'IFF #: '+esc(pkg.iff):'', pkg.scanLink?'Scan: '+linkify(pkg.scanLink):'', pkg.lod?'LOD: '+esc(pkg.lod)+' (legacy)':''].filter(Boolean).join('<br>')}</td></tr>`:''}
|
||||
</tbody></table>`;
|
||||
if(pkg.assets&&pkg.assets.length){ h+=`<h2>2.0 Assets (controls.dev)</h2><table><thead><tr><th style="width:180px">Asset Tag / ID</th><th>Description</th><th>controls.dev Link</th></tr></thead><tbody>`;
|
||||
pkg.assets.forEach(a=>h+=`<tr><td>${cell(a.tag)}</td><td>${cell(a.desc)}</td><td>${a.link?linkify(a.link):ns()}</td></tr>`); h+=`</tbody></table>`; }
|
||||
</tbody></table>`);
|
||||
|
||||
// Location has no block of its own yet — it is a row inside General
|
||||
// Information, suppressed above. CR-004 gives it structured fields in wave 6
|
||||
// and this is where its own block will go. Recorded rather than left implicit,
|
||||
// because "the toggle does nothing" and "the toggle governs one row" look the
|
||||
// same from outside.
|
||||
|
||||
if(pkg.assets&&pkg.assets.length){
|
||||
let t=`<table><thead><tr><th style="width:180px">Asset Tag / ID</th><th>Description</th><th>controls.dev Link</th></tr></thead><tbody>`;
|
||||
pkg.assets.forEach(a=>t+=`<tr><td>${cell(a.tag)}</td><td>${cell(a.desc)}</td><td>${a.link?linkify(a.link):ns()}</td></tr>`);
|
||||
add('assets', 'Assets (controls.dev)', t+`</tbody></table>`);
|
||||
}
|
||||
|
||||
let scopeHtml;
|
||||
if(pkg.scope && Object.keys(pkg.scope).length){ // per-discipline scope sections
|
||||
scopeHtml = Object.keys(pkg.scope).map(d=>{
|
||||
@@ -1219,7 +1251,7 @@ function renderPackage(pkg){
|
||||
const stepsArr = pkg.workSteps && pkg.workSteps.length ? pkg.workSteps : (pkg.work?String(pkg.work).split('\n').filter(Boolean):[]);
|
||||
scopeHtml = stepsArr.length ? '<ol style="margin:0;padding-left:18px">'+stepsArr.map(s=>`<li>${esc(s)}</li>`).join('')+'</ol>' : ns();
|
||||
}
|
||||
h+=`<h2>3.0 Scope & Work</h2><table><tbody>
|
||||
add('scope', 'Scope & Work', `<table><tbody>
|
||||
<tr><th style="width:200px">Description of Work</th><td>${scopeHtml}</td></tr>
|
||||
<tr><th>Labor Est. Hrs.</th><td>${cell(pkg.hours)}</td></tr>
|
||||
<tr><th>Predecessor packages</th><td>${
|
||||
@@ -1229,42 +1261,60 @@ function renderPackage(pkg){
|
||||
}</td></tr>
|
||||
<tr><th>Sequence phase</th><td>${pkg.seq?esc(pkg.seq):ns()}</td></tr>
|
||||
${pkg.gateOverride?`<tr><th>Released early</th><td><strong>Predecessor gate overridden.</strong><br>${esc(pkg.gateOverride.reason||'')}<br><span style="color:var(--text-dim)">${esc(pkg.gateOverride.by||'')} · ${esc(pkg.gateOverride.at?wpFormatDateTime(pkg.gateOverride.at):'')}</span></td></tr>`:''}
|
||||
</tbody></table>`;
|
||||
</tbody></table>`);
|
||||
|
||||
if(pkg.materials&&pkg.materials.length){ const showDisc=pkg.materials.some(m=>m.discipline);
|
||||
h+=`<h2>4.0 Material List</h2><table><thead><tr><th style="width:80px">Qty</th><th style="width:80px">Unit</th><th>Description</th>${showDisc?'<th style="width:120px">Discipline</th>':''}</tr></thead><tbody>`;
|
||||
pkg.materials.forEach(m=>h+=`<tr><td>${cell(m.qty)}</td><td>${cell(m.unit)}</td><td>${cell(m.desc)}</td>${showDisc?`<td>${cell(m.discipline)}</td>`:''}</tr>`); h+=`</tbody></table>`; }
|
||||
if(pkg.attachments&&pkg.attachments.length){ h+=`<h2>5.0 Drawings & Attachments</h2><table><thead><tr><th>Document</th><th style="width:60px">Rev</th><th>Link / Note</th></tr></thead><tbody>`;
|
||||
pkg.attachments.forEach(a=>h+=`<tr><td>${cell(a.doc)}</td><td>${cell(a.rev)}</td><td>${a.link?linkify(a.link):ns()}</td></tr>`); h+=`</tbody></table>`; }
|
||||
h+=`<h2>6.0 Kitting & MIMO</h2><table><tbody>
|
||||
let t=`<table><thead><tr><th style="width:80px">Qty</th><th style="width:80px">Unit</th><th>Description</th>${showDisc?'<th style="width:120px">Discipline</th>':''}</tr></thead><tbody>`;
|
||||
pkg.materials.forEach(m=>t+=`<tr><td>${cell(m.qty)}</td><td>${cell(m.unit)}</td><td>${cell(m.desc)}</td>${showDisc?`<td>${cell(m.discipline)}</td>`:''}</tr>`);
|
||||
add('materials', 'Material List', t+`</tbody></table>`); }
|
||||
|
||||
if(pkg.attachments&&pkg.attachments.length){
|
||||
let t=`<table><thead><tr><th>Document</th><th style="width:60px">Rev</th><th>Link / Note</th></tr></thead><tbody>`;
|
||||
pkg.attachments.forEach(a=>t+=`<tr><td>${cell(a.doc)}</td><td>${cell(a.rev)}</td><td>${a.link?linkify(a.link):ns()}</td></tr>`);
|
||||
add('drawings', 'Drawings & Attachments', t+`</tbody></table>`); }
|
||||
|
||||
add('kitting', 'Kitting & MIMO', `<table><tbody>
|
||||
<tr><th style="width:200px">Kitting Status</th><td>${cell(pkg.kitStatus)}</td></tr>
|
||||
<tr><th>Warehouse Owner</th><td>${cell(pkg.kitOwner)}</td></tr>
|
||||
<tr><th>Kitting Need Date</th><td>${cell(pkg.kitDate)}</td></tr>
|
||||
<tr><th>MIMO Sch. Time / Location</th><td>${cell(pkg.mimoTime)} ${pkg.mimoLoc?'· '+esc(pkg.mimoLoc):''}</td></tr>
|
||||
</tbody></table>`;
|
||||
h+=`<h2>7.0 Constraints — Release Readiness</h2><table><thead><tr><th>Constraint</th><th style="width:90px">Status</th><th>Comment</th></tr></thead><tbody>`;
|
||||
</tbody></table>`);
|
||||
|
||||
let ct=`<table><thead><tr><th>Constraint</th><th style="width:90px">Status</th><th>Comment</th></tr></thead><tbody>`;
|
||||
(pkg.constraints||[]).forEach(c=>{ const lbl=c.status==='cleared'?'Cleared':c.status==='na'?'N/A':'Open'; const col=c.status==='cleared'?'var(--accent-green)':c.status==='na'?'var(--text-dim)':'var(--red)';
|
||||
h+=`<tr><td>${esc(c.name)}</td><td style="color:${col};font-weight:700">${lbl}</td><td>${cell(c.comment)}</td></tr>`; });
|
||||
h+=`</tbody></table>`;
|
||||
h+=`<h2>8.0 Quality & Hold Points</h2><table><tbody>
|
||||
ct+=`<tr><td>${esc(c.name)}</td><td style="color:${col};font-weight:700">${lbl}</td><td>${cell(c.comment)}</td></tr>`; });
|
||||
add('constraints', 'Constraints — Release Readiness', ct+`</tbody></table>`);
|
||||
|
||||
add('qaqc', 'Quality & Hold Points', `<table><tbody>
|
||||
<tr><th style="width:200px">QC</th><td>${cell(pkg.qc)}${pkg.overrides&&pkg.overrides.wp_qc?` <span style="color:var(--accent-amber)">(overridden: ${esc(pkg.overrides.wp_qc)})</span>`:(pkg.qcFromSOP?' <span style="color:var(--accent);font-size:10px">[from SOP]</span>':'')}</td></tr>
|
||||
<tr><th>Photo Documentation</th><td>${cell(pkg.photo)}${pkg.overrides&&pkg.overrides.wp_photo?` <span style="color:var(--accent-amber)">(overridden: ${esc(pkg.overrides.wp_photo)})</span>`:(pkg.photoFromSOP?' <span style="color:var(--accent);font-size:10px">[from SOP]</span>':'')}</td></tr>
|
||||
<tr><th>Witness / Hold Points</th><td>${cell(pkg.hold)}</td></tr>
|
||||
</tbody></table>`;
|
||||
</tbody></table>`);
|
||||
|
||||
if(pkg.holds&&pkg.holds.length){
|
||||
h+=`<h2>8.5 Hold Log</h2><table><thead><tr><th style="width:150px">Logged</th><th style="width:200px">Constraint</th><th>Details</th><th style="width:120px">Support</th></tr></thead><tbody>`;
|
||||
let t=`<table><thead><tr><th style="width:150px">Logged</th><th style="width:200px">Constraint</th><th>Details</th><th style="width:120px">Support</th></tr></thead><tbody>`;
|
||||
pkg.holds.forEach(hd=>{ const when=hd.ts?wpFormatDateTime(hd.ts):''; const sup=[hd.doc?linkify(hd.doc):'', hd.photo?'<span style="color:var(--accent-green)">photo attached</span>':''].filter(Boolean).join('<br>')||ns();
|
||||
h+=`<tr><td>${esc(when)}</td><td>${cell(hd.constraint)}</td><td>${cell(hd.details)}</td><td>${sup}</td></tr>`; });
|
||||
h+=`</tbody></table>`;
|
||||
t+=`<tr><td>${esc(when)}</td><td>${cell(hd.constraint)}</td><td>${cell(hd.details)}</td><td>${sup}</td></tr>`; });
|
||||
// The hold LOG belongs to QA/QC — it is the record of the hold points that
|
||||
// section defines, so it goes with it rather than surviving on its own.
|
||||
add('qaqc', 'Hold Log', t+`</tbody></table>`);
|
||||
}
|
||||
h+=`<h2>9.0 Approvals & Sign-offs</h2><table><thead><tr><th>Role</th><th>Name</th><th style="width:120px">Date</th><th style="width:80px">Signed</th></tr></thead><tbody>`;
|
||||
(pkg.signoffs||[]).forEach(s=>h+=`<tr><td>${esc(s.role)}</td><td>${cell(s.name)}</td><td>${cell(s.date)}</td><td>${s.signed?'✓':'—'}</td></tr>`);
|
||||
h+=`</tbody></table>`;
|
||||
if(pkg.actualHrs||pkg.installedQty||pkg.redlines||pkg.lessons){ h+=`<h2>10.0 Closeout</h2><table><tbody>
|
||||
|
||||
// Approvals are not one of CR-006's ten sections and are not toggleable: a
|
||||
// package nobody signed is not a shorter package, it is an unapproved one.
|
||||
let st=`<table><thead><tr><th>Role</th><th>Name</th><th style="width:120px">Date</th><th style="width:80px">Signed</th></tr></thead><tbody>`;
|
||||
(pkg.signoffs||[]).forEach(s=>st+=`<tr><td>${esc(s.role)}</td><td>${cell(s.name)}</td><td>${cell(s.date)}</td><td>${s.signed?'✓':'—'}</td></tr>`);
|
||||
blocks.push(['Approvals & Sign-offs', st+`</tbody></table>`]);
|
||||
|
||||
if(pkg.actualHrs||pkg.installedQty||pkg.redlines||pkg.lessons){
|
||||
add('closeout', 'Closeout', `<table><tbody>
|
||||
<tr><th style="width:200px">Actual Hrs.</th><td>${cell(pkg.actualHrs)}</td></tr>
|
||||
<tr><th>Installed Quantity</th><td>${cell(pkg.installedQty)}</td></tr>
|
||||
<tr><th>Redlines / As-Built</th><td>${cell(pkg.redlines)}</td></tr>
|
||||
<tr><th>Lessons Learned</th><td>${cell(pkg.lessons)}</td></tr>
|
||||
</tbody></table>`; }
|
||||
</tbody></table>`); }
|
||||
|
||||
let h = head + blocks.map(([title, body], i) => `<h2>${i+1}.0 ${esc(title)}</h2>${body}`).join('');
|
||||
h+=`<p style="margin-top:18px;color:var(--text-dim);font-size:11px">Pushed to: ${cell(pkg.track)}</p>`;
|
||||
document.getElementById('pkg-doc').innerHTML=h; showOutput();
|
||||
}
|
||||
@@ -1325,7 +1375,9 @@ function buildSectionNav(){
|
||||
const nav=document.getElementById('section-nav'); if(!nav) return;
|
||||
const chips=[];
|
||||
document.querySelectorAll('.main > .card').forEach((card,i)=>{
|
||||
if(card.id==='saved-card' || card.style.display==='none') return;
|
||||
// `hidden` is how CR-006 suppresses a section; the chip strip is a table of
|
||||
// contents for the form, so it has to lose the same entries.
|
||||
if(card.id==='saved-card' || card.style.display==='none' || card.hidden) return;
|
||||
const h=card.querySelector('.section-title, .sub-heading'); if(!h) return;
|
||||
const clone=h.cloneNode(true); clone.querySelectorAll('.help-tip').forEach(x=>x.remove());
|
||||
const label=clone.textContent.trim().replace(/\s+/g,' '); if(!label) return;
|
||||
@@ -1368,6 +1420,69 @@ function updateStickyStatus(){
|
||||
else { el.className='sticky-status ss-notready'; el.textContent=`⚠ ${r.open} of ${r.total} constraint${r.open===1?'':'s'} open`+(r.blocking.length?` · ${r.blocking.length} predecessor${r.blocking.length===1?'':'s'}`:''); }
|
||||
}
|
||||
|
||||
// ── SECTION TOGGLES (CR-006 / T5.5) ──────────────────────────────────────────
|
||||
// Which sections this project uses. The list is wp-sections.js, shared with the
|
||||
// SOP wizard; this file owns the mapping from a section id to the DOM it governs
|
||||
// and to the blocks renderPackage() emits.
|
||||
//
|
||||
// NOTHING HERE WRITES TO A PACKAGE. A section that is off is not rendered — in
|
||||
// the form, in the package view or in the export. Everything captured while it
|
||||
// was on stays on the package, and turning it back on shows it again. That is
|
||||
// the whole of CR-006's contract, and the reason CR-002 and CR-016 are toggles.
|
||||
|
||||
// Location is a field inside General Information's grid today rather than a card
|
||||
// of its own; CR-004 gives it structured fields in wave 6 and only this line
|
||||
// changes then.
|
||||
const WP_SECTION_NODES = {
|
||||
general: ['#general-card'],
|
||||
location: ['#location-card'],
|
||||
scope: ['#scope-card'],
|
||||
assets: ['#asset-card'],
|
||||
materials: ['#material-card'],
|
||||
kitting: ['#mimo-card'],
|
||||
drawings: ['#drawings-card'],
|
||||
constraints: ['#constraint-card'],
|
||||
qaqc: ['#quality-card'],
|
||||
closeout: ['#closeout-card'],
|
||||
};
|
||||
|
||||
let wpSections = (typeof WPSections !== 'undefined') ? WPSections.defaults() : {};
|
||||
|
||||
function sectionOn(id){
|
||||
if(typeof WPSections === 'undefined') return true;
|
||||
return WPSections.isOn(wpSections, id);
|
||||
}
|
||||
|
||||
/* Apply a section map to the form. Called from applySOP() on boot — which covers
|
||||
a reload, a fresh tab and the standalone page — and from the SOP wizard next
|
||||
door while the frame is already open (X4). Exposed on window deliberately: the
|
||||
wizard is a different document and can only reach a global. */
|
||||
function applySopSections(sections){
|
||||
if(typeof WPSections === 'undefined') return wpSections;
|
||||
wpSections = WPSections.normalize(sections);
|
||||
Object.keys(WP_SECTION_NODES).forEach(id => {
|
||||
const on = wpSections[id];
|
||||
WP_SECTION_NODES[id].forEach(sel => {
|
||||
document.querySelectorAll(sel).forEach(el => {
|
||||
// `hidden` rather than display:none — several of these cards are shown
|
||||
// and hidden by other code (showOutput, showDashboard, the BIM flag) with
|
||||
// inline display, and two mechanisms fighting over one property is how a
|
||||
// section comes back on its own.
|
||||
el.hidden = !on;
|
||||
el.dataset.sectionOff = on ? '' : '1';
|
||||
});
|
||||
});
|
||||
});
|
||||
// The section chips are a table of contents for the form, so they have to lose
|
||||
// the same entries.
|
||||
if(typeof buildSectionNav === 'function') buildSectionNav();
|
||||
// A package already on screen is re-rendered, or the view keeps showing a
|
||||
// section the form no longer has.
|
||||
if(currentView === 'Package View' && _lastRenderedPkg) renderPackage(_lastRenderedPkg);
|
||||
return wpSections;
|
||||
}
|
||||
window.applySopSections = applySopSections;
|
||||
|
||||
// ── SAVED PACKAGES ───────────────────────────────────────────────────────────
|
||||
const STORE_KEY='wp_iwp_v1';
|
||||
// Per-project namespaced key so each project keeps its own packages in the browser.
|
||||
|
||||
Reference in New Issue
Block a user