The team concluded these two are noise on a field work package: cost codes are
effectively constant on a job and the Acumatica task mapping is a PM concern.
The cost visibility they actually want is by building and floor, which is CR-004
and CR-018.
Hidden, not removed. CLAUDE.md: "Removed fields are hidden, not deleted (CR-002,
CR-016). Retain the data and the model." So this is a second, narrower toggle
list beside T5.5's sections - two fields inside General Information rather than
two more sections, because a section is a block of the document and these are
two rows in one.
no migration the values live in the work package's JSON data blob,
which nothing here writes to. The probe greps every
migration for a drop_column touching either.
no model change server/models.py is untouched by this task
no code change to the toggles are SOP data. Another project turns them
re-enable back on from step 12 and both fields return, values
included
A field is on only if its own toggle is on AND the section holding it is. Asked
as one question (WPSections.fieldOn) so no caller has to remember to ask both -
a field showing inside a hidden section is not a state worth reasoning about,
and the probe checks that case explicitly.
html/wp-sections.js FIELDS, fieldOn, normalizeFields
html/work-package-suite-app.js field rows nested under their section
html/work-package-suite-styles.css .field-toggle
html/wp-creation-index.html ids on the two .field wrappers
html/wp-creation-app.js WP_FIELD_NODES; both document rows conditional
tests/sections_check.py +22 checks (53 -> 75)
Done when
[x] neither field appears in the form, detail view or PDF export when off
[x] existing records still hold their values - a package EDITED while both are
off comes back through collectPackage() with both intact
[x] the fields can be re-enabled for another SOP without a code change
[x] no schema migration drops data - checked against every migration in the
tree, not just the ones this wave added
The whole .field wrapper is hidden, not the input: a bare label over nothing is
worse than either state.
Raised, not fixed
BL-019 A cost code that has left COST_CODES is silently blanked on edit.
wp_cost is a <select>, and setting .value to something with no matching
<option> does nothing at all - so opening such a package clears the
field and the next save writes the blank back. The same bug was fixed
once already for gov_wosize (work-package-suite-app.js:490-495) by
adding the stored value as an option; cost code never got it.
Found the honest way: a probe here used an invented cost code to prove
hiding a field does not delete its value, and the value came back
empty. That looked exactly like the toggle eating data. It was not, and
the probe now uses a real code and says why in a comment - a probe that
fails for a reason other than the one it names is worse than no probe.
Verified one at a time
sections_check 75/75 (53 + 22 for CR-002)
browser_check 71/71
stepper_check 70/70
a11y 22/22
url_state 23/23
autosave 34/34
locations_check 58/58
Question for the PR, per CLAUDE.md: BL-000b asks whether General Information
wants per-field toggles generally. This is not that - it is the two fields
CR-002 names, and the list is deliberately closed. If a third field wants one,
that is the general question and it needs the product answer BL-000b is holding.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
158 lines
6.7 KiB
JavaScript
158 lines
6.7 KiB
JavaScript
/* Work package section toggles — CR-006 / T5.5.
|
||
---------------------------------------------------------------------------
|
||
The structural fix behind most of the removal requests in the plan. Rather
|
||
than deleting fields globally, each project turns on only the sections it
|
||
uses: it is what lets Micron drop Kitting and Assets while another project
|
||
keeps them, and it is why CR-002 and CR-016 are toggles rather than deletions.
|
||
|
||
THE ONE RULE: toggling a section OFF never deletes anything. It stops the
|
||
section rendering — in the creation form, in the detail view and in the PDF
|
||
export — and that is all. Whatever was captured stays on the package, and
|
||
toggling back on shows it again, intact. Everything in this file is about
|
||
what is DISPLAYED; nothing here writes to a package.
|
||
|
||
This list lives in its own file because three surfaces read it and they must
|
||
not drift: the SOP wizard renders the toggles, the creator applies them to
|
||
its form and its printed output, and a work package's detail view honours
|
||
them. A fourth copy is how "Assets is off" and "Assets is off, except in the
|
||
export" happen.
|
||
|
||
IDS ARE PERMANENT. They are written into every SOP that has ever been saved,
|
||
so renaming one silently turns that section back on for every existing
|
||
project. Change `label` freely; never change `id`.
|
||
*/
|
||
(function (window) {
|
||
'use strict';
|
||
|
||
var LIST = [
|
||
{ id: 'general', label: 'General Information',
|
||
note: 'Holds the WP number, subject and type. Turning this off leaves nothing to identify a package by — it is listed for completeness, not as a suggestion.' },
|
||
{ id: 'location', label: 'Location',
|
||
note: 'Where the work happens. CR-004 gives this its own structured fields; today it is the location field inside General Information.' },
|
||
{ id: 'scope', label: 'Scope of Work',
|
||
note: 'The ordered steps the crew performs, and the labour estimate.' },
|
||
{ id: 'assets', label: 'Assets',
|
||
note: 'Asset tags and controls.dev links. Off for Micron EUV — the content duplicates the database Clinton’s team maintains (CR-016).' },
|
||
{ id: 'materials', label: 'Materials',
|
||
note: 'The bill of materials that feeds kitting.' },
|
||
{ id: 'kitting', label: 'Kitting',
|
||
note: 'Kitting status, warehouse owner and MIMO. Off for Micron EUV, which is not kitting today (CR-009).' },
|
||
{ id: 'drawings', label: 'Drawings and Attachments',
|
||
note: 'Drawing references and attachment links.' },
|
||
{ id: 'constraints', label: 'Constraints',
|
||
note: 'Release-readiness items. A package cannot be issued while one is open.' },
|
||
{ id: 'qaqc', label: 'QA/QC',
|
||
note: 'Quality requirements, photo standard and hold points.' },
|
||
{ id: 'closeout', label: 'Closeout',
|
||
note: 'Actual hours, installed quantity, redlines and lessons learned. Actual Hours stays here — its removal was proposed and rejected (CR-017).' },
|
||
];
|
||
|
||
var IDS = LIST.map(function (s) { return s.id; });
|
||
|
||
/* Individual fields that can be switched off inside a section — CR-002.
|
||
|
||
A second, narrower list rather than more sections, because a section is a
|
||
block of the document and these are two rows inside one. BL-000b asks
|
||
whether General Information wants per-field toggles generally; this is not
|
||
that. It is the two fields CR-002 names, expressed as toggles because
|
||
CLAUDE.md says removals are expressed through toggles and the data is
|
||
retained — the columns and the model stay exactly as they are.
|
||
|
||
Same rule as sections: an id is permanent, absent means ON. */
|
||
var FIELDS = [
|
||
{ id: 'costCode', section: 'general', label: 'Acumatica cost code',
|
||
note: 'Effectively constant on a job, so it is noise on a field work package (CR-002). The value stays on every package that has one.' },
|
||
{ id: 'acumaticaTask', section: 'general', label: 'Acumatica task',
|
||
note: 'A PM concern rather than a field one (CR-002). The cost visibility the team actually wants is by building and floor — CR-004 and CR-018.' },
|
||
];
|
||
|
||
var FIELD_IDS = FIELDS.map(function (f) { return f.id; });
|
||
|
||
function fieldDefaults() {
|
||
var out = {};
|
||
FIELD_IDS.forEach(function (id) { out[id] = true; });
|
||
return out;
|
||
}
|
||
|
||
function normalizeFields(stored) {
|
||
var out = fieldDefaults();
|
||
if (stored && typeof stored === 'object') {
|
||
FIELD_IDS.forEach(function (id) {
|
||
if (Object.prototype.hasOwnProperty.call(stored, id)) out[id] = stored[id] !== false;
|
||
});
|
||
}
|
||
return out;
|
||
}
|
||
|
||
function fieldsFor(sectionId) {
|
||
return FIELDS.filter(function (f) { return f.section === sectionId; });
|
||
}
|
||
|
||
function defaults() {
|
||
// A new SOP has everything on. A project opts OUT of what it does not use;
|
||
// it does not have to discover and opt in to what it does.
|
||
var out = {};
|
||
IDS.forEach(function (id) { out[id] = true; });
|
||
return out;
|
||
}
|
||
|
||
/* Fill in anything a stored SOP does not mention.
|
||
|
||
This is what makes adding an eleventh section safe: every SOP saved before
|
||
it existed says nothing about it, and "says nothing" has to mean ON. The
|
||
alternative — absent meaning off — would switch a brand-new section off for
|
||
every project in the estate the moment it shipped. */
|
||
function normalize(stored) {
|
||
var out = defaults();
|
||
if (stored && typeof stored === 'object') {
|
||
IDS.forEach(function (id) {
|
||
if (Object.prototype.hasOwnProperty.call(stored, id)) out[id] = stored[id] !== false;
|
||
});
|
||
}
|
||
return out;
|
||
}
|
||
|
||
function isOn(stored, id) {
|
||
if (IDS.indexOf(id) < 0) return true; // not a section we govern
|
||
return normalize(stored)[id];
|
||
}
|
||
|
||
function offList(stored) {
|
||
var s = normalize(stored);
|
||
return LIST.filter(function (x) { return !s[x.id]; }).map(function (x) { return x.label; });
|
||
}
|
||
|
||
/* A field is on only if its own toggle is on AND the section holding it is.
|
||
Asked as one question so no caller has to remember to ask both — a field
|
||
showing inside a hidden section is not a state anyone wants to reason
|
||
about. */
|
||
function fieldOn(sections, fields, id) {
|
||
var f = FIELDS.filter(function (x) { return x.id === id; })[0];
|
||
if (!f) return true;
|
||
if (!isOn(sections, f.section)) return false;
|
||
return normalizeFields(fields)[id];
|
||
}
|
||
|
||
function offFieldList(fields) {
|
||
var s = normalizeFields(fields);
|
||
return FIELDS.filter(function (x) { return !s[x.id]; }).map(function (x) { return x.label; });
|
||
}
|
||
|
||
window.WPSections = {
|
||
LIST: LIST,
|
||
IDS: IDS,
|
||
defaults: defaults,
|
||
normalize: normalize,
|
||
isOn: isOn,
|
||
offList: offList,
|
||
|
||
FIELDS: FIELDS,
|
||
FIELD_IDS: FIELD_IDS,
|
||
fieldDefaults: fieldDefaults,
|
||
normalizeFields: normalizeFields,
|
||
fieldsFor: fieldsFor,
|
||
fieldOn: fieldOn,
|
||
offFieldList: offFieldList,
|
||
};
|
||
})(window);
|