pict-section-form 1.3.13 → 1.3.15

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.
Files changed (48) hide show
  1. package/docs/Injection_Conformance.md +137 -0
  2. package/docs/_sidebar.md +1 -0
  3. package/docs/input_providers/012-tab-group-selector.md +3 -1
  4. package/docs/input_providers/013-tab-section-selector.md +3 -1
  5. package/package.json +6 -5
  6. package/source/providers/Pict-Provider-DynamicFormSolverBehaviors.js +73 -5
  7. package/source/providers/Pict-Provider-DynamicSolver.js +20 -2
  8. package/source/providers/inputs/Pict-Provider-Input-TabGroupSelector.js +42 -3
  9. package/source/providers/inputs/Pict-Provider-Input-TabSectionSelector.js +42 -3
  10. package/source/views/Pict-View-Form-Metacontroller.js +685 -90
  11. package/test/Pict-Provider-DynamicFormSolverBehaviors-OrdinalScope_tests.js +105 -0
  12. package/test/Pict-Provider-Input-TabGroupSelector-TabHashValidation_tests.js +178 -0
  13. package/test/Pict-Provider-Input-TabSectionSelector-TabHashValidation_tests.js +193 -0
  14. package/test/Pict-View-Form-Metacontroller-DistinctManifest_tests.js +410 -0
  15. package/test/PictSectionForm-Injection-Conformance_tests.js +751 -0
  16. package/test/browser/Injection-Conformance-Differential-Scenario.js +346 -0
  17. package/test/browser/Injection-Conformance-EdgeCase-Scenario.js +168 -0
  18. package/test/browser/Injection-Conformance-Harness-Driver.js +538 -0
  19. package/test/browser/Injection-Conformance-Harness-Runner.js +487 -0
  20. package/test/browser/Injection-Conformance-Reconstitution-Scenario.js +191 -0
  21. package/test/browser/Injection-Conformance-Standalone-Scenario.js +114 -0
  22. package/test/fixtures/injection/Injection-Fixture-Cases.js +203 -0
  23. package/test/fixtures/injection/Injection-Fixture-Manifest.json +366 -0
  24. package/types/source/providers/Pict-Provider-DynamicFormSolverBehaviors.d.ts +110 -1
  25. package/types/source/providers/Pict-Provider-DynamicFormSolverBehaviors.d.ts.map +1 -1
  26. package/types/source/providers/Pict-Provider-DynamicSolver.d.ts.map +1 -1
  27. package/types/source/providers/Pict-Provider-DynamicTabularData.d.ts +17 -1
  28. package/types/source/providers/Pict-Provider-DynamicTabularData.d.ts.map +1 -1
  29. package/types/source/providers/Pict-Provider-InputExtension.d.ts +31 -0
  30. package/types/source/providers/Pict-Provider-InputExtension.d.ts.map +1 -1
  31. package/types/source/providers/inputs/Pict-Provider-Input-Chart-CSS.d.ts +16 -0
  32. package/types/source/providers/inputs/Pict-Provider-Input-Chart-CSS.d.ts.map +1 -0
  33. package/types/source/providers/inputs/Pict-Provider-Input-Chart.d.ts +47 -0
  34. package/types/source/providers/inputs/Pict-Provider-Input-Chart.d.ts.map +1 -1
  35. package/types/source/providers/inputs/Pict-Provider-Input-Diagram.d.ts +86 -0
  36. package/types/source/providers/inputs/Pict-Provider-Input-Diagram.d.ts.map +1 -1
  37. package/types/source/providers/inputs/Pict-Provider-Input-ObjectEditor.d.ts +128 -0
  38. package/types/source/providers/inputs/Pict-Provider-Input-ObjectEditor.d.ts.map +1 -0
  39. package/types/source/providers/inputs/Pict-Provider-Input-PreciseNumber.d.ts.map +1 -1
  40. package/types/source/providers/inputs/Pict-Provider-Input-TabGroupSelector.d.ts +10 -1
  41. package/types/source/providers/inputs/Pict-Provider-Input-TabGroupSelector.d.ts.map +1 -1
  42. package/types/source/providers/inputs/Pict-Provider-Input-TabSectionSelector.d.ts +10 -1
  43. package/types/source/providers/inputs/Pict-Provider-Input-TabSectionSelector.d.ts.map +1 -1
  44. package/types/source/providers/layouts/Pict-Layout-Tabular.d.ts +76 -4
  45. package/types/source/providers/layouts/Pict-Layout-Tabular.d.ts.map +1 -1
  46. package/types/source/views/Pict-View-DynamicForm.d.ts.map +1 -1
  47. package/types/source/views/Pict-View-Form-Metacontroller.d.ts +63 -2
  48. package/types/source/views/Pict-View-Form-Metacontroller.d.ts.map +1 -1
@@ -0,0 +1,137 @@
1
+ # Injection Conformance
2
+
3
+ A manifest can be injected into a running form more than once. `PictFormMetacontroller.createDistinctManifest()`
4
+ salts each copy -- section, group and input hashes get the salt appended, data addresses get nested under it --
5
+ so that every copy owns its own data. Every reference the manifest makes to itself has to be translated with
6
+ it, and every reference it makes to something outside itself has to be left alone.
7
+
8
+ The injection conformance fixture is how that stays true. It is one manifest that uses every construct the
9
+ injector has to translate, injected twice into a host form that deliberately holds same-named data at the
10
+ unsalted root, so a copy that reads or writes the wrong place is visible immediately.
11
+
12
+ ## The two tiers
13
+
14
+ | | Data tier | Browser tier |
15
+ |---|---|---|
16
+ | File | `test/PictSectionForm-Injection-Conformance_tests.js` | `test/browser/` |
17
+ | Runs with | `npm test` (always) | `npm run test:injection` |
18
+ | Needs | nothing beyond the test dependencies | a chrome-family browser (`CHROME_BIN` overrides) |
19
+ | Asserts | fixture coverage, that a salted copy names nothing of its own by its unsalted name, and a data round trip through the view API: data in, solve, read back, write through the view, re-render | what needs a painted page: charts, tab switching, solver-driven visibility, templated rendering, trigger groups driven by real change events, the unsalted root after all of it, and that a form rebuilt from its saved data matches the one that was filled in |
20
+
21
+ `browser-env` gives the data tier a DOM object model but does not paint: views render, macros and selectors
22
+ are built, but no input elements land in the document. That is why the always-on tier round trips through the
23
+ view data API (`setDataByInput`, `marshalToView`, `render`) and the browser tier owns everything that needs
24
+ real elements and real events.
25
+
26
+ The browser tier runs three scenarios. The edge case scenario injects the fixture twice with two salts that
27
+ share a prefix (`alpha`, `alphabeta`) and asserts what each copy should hold. The differential scenario needs
28
+ no expected values and works for any manifest: it loads the same manifest as a pair of copies, then each copy
29
+ alone, and compares -- a copy that reads or writes outside its own subtree computes differently next to a
30
+ sibling than it does alone. The reconstitution scenario answers a different question: it fills the copies in,
31
+ publishes the data a host would save, then boots a second page from nothing but that saved data and injects
32
+ the same copies again, the way reopening a saved form does. The two runs have to agree on every copy's data,
33
+ on what is hidden, on chart contents and on what each input displays; a disagreement means a saved form reads
34
+ back differently from the one that was filled in.
35
+
36
+ Both scenarios take either one `Manifest` for every salt, or a `Manifests` array carrying a different manifest
37
+ per salt -- so a form holding several different injected manifests is exercised the same way as one holding
38
+ two copies of a single manifest. Manifests that share input names (as sibling manifests generated from one
39
+ template usually do) are the interesting case, because that is where a copy can reach into its neighbour.
40
+
41
+ Both are also libraries: `require()` the runner and call `runDifferential` / `runReconstitution` with any
42
+ manifest, which is how a host application runs its own manifests through the same checks without those
43
+ manifests having to live here.
44
+
45
+ ## Adding a case
46
+
47
+ 1. Add the input to `test/fixtures/injection/Injection-Fixture-Manifest.json`, in the `Inputs` or `Composed`
48
+ section, configured the way the input type is meant to be used.
49
+ 2. Add a case to `INPUT_CASES` in `test/fixtures/injection/Injection-Fixture-Cases.js`:
50
+
51
+ ```js
52
+ { Registry: 'InputType:TextArea', Hash: 'NoteText', Tier: 'data', Marshals: true, Accepts: true, Value: 'a crate note' },
53
+ ```
54
+
55
+ * `Registry` is `InputType:<name>` for a type the metatemplates dispatch on, or `Provider:<name>` for an
56
+ input provider an input opts into through `PictForm.Providers`.
57
+ * `Tier` is `data` when the round trip can be asserted without a browser, `browser` when it needs a painted
58
+ page, and `expression` when the input cannot round trip at all in a test (it gathers from a server, or
59
+ needs a third party editing surface) -- then only its salted configuration is asserted. A case that is
60
+ not on the data tier carries a `Note` saying why.
61
+ * `Marshals` is whether data reaches the control, `Accepts` whether a write through the control reaches the
62
+ data, and `Value` is what the round trip writes.
63
+ 3. If the input type genuinely needs no case, add it to `EXCLUDED_REGISTRY_ENTRIES` with the reason. An input
64
+ type that is only reached through another one (`Select` through `InputType:Option`) belongs here.
65
+
66
+ Keep the fixture's vocabulary neutral: it is a crate of fruit, not anything from a product that uses the
67
+ library.
68
+
69
+ ## What a coverage failure means
70
+
71
+ The coverage suite measures the fixture against the library's own registries rather than against a list
72
+ someone has to remember to update.
73
+
74
+ **"every input type and input provider in the library has a fixture case"** -- the metatemplates
75
+ (`source/providers/dynamictemplates/`) dispatch on an `InputType` that no case names, or a provider file
76
+ appeared in `source/providers/inputs/`. Add a case, or an explained exclusion.
77
+
78
+ **"every construct the injector translates appears in the fixture manifest"** -- `createDistinctManifest`
79
+ translates a `PictForm` property the fixture never uses. The list comes from `InjectionTranslation`, exported
80
+ by `source/views/Pict-View-Form-Metacontroller.js`, which is the same list the translation itself runs off; if
81
+ you taught the injector about a new property, the fixture has to exercise it.
82
+
83
+ **"every solver directive is used by the fixture manifest"** -- the fixture has no solver using a directive
84
+ the injector knows how to scope (`SERIES`, `MAP`, `MULTIROWMAP`, `MONTECARLO`). A directive that cannot be
85
+ asserted in a fixture (`MONTECARLO` samples at random) is declared in `EXCLUDED_SOLVER_DIRECTIVES` with the
86
+ reason and is asserted at the expression level instead.
87
+
88
+ **"every reference shape ... appears in the fixture manifest"** -- `REFERENCE_SHAPES` lists the ways a solver
89
+ can name something of its own: an exact symbol, a state address, `X.length`, `X[0]`, `X[].Column`, a nested
90
+ property, a marshal-destination-prefixed string, a hash passed as a string parameter, a string literal that
91
+ merely looks like a hash, and a reference to something outside the manifest. Each has to appear in a fixture
92
+ solver.
93
+
94
+ **"no section, group or input of an injected copy holds an untranslated reference"** -- this is the check that
95
+ catches a construct nobody thought about. It walks the salted copy, reads solver expressions with the
96
+ expression parser (so an iteration variable a directive declares, a string literal that is not an address
97
+ parameter, and the columns a record set solver reads are not mistaken for references) and scans every other
98
+ string for a name the manifest owns. When it fails, either translate the construct in `createDistinctManifest`,
99
+ or -- if the property is prose or presentation and cannot name anything -- add it to `LABEL_PROPERTIES` in the
100
+ cases file.
101
+
102
+ ## Known open behavior
103
+
104
+ These are properties of injection itself rather than of the translation. They are declared in `KNOWN_OPEN` in
105
+ the cases file and both tiers print them rather than failing on them:
106
+
107
+ * **Undeclared solver targets.** A solver can assign to a name no descriptor declares, and the expression
108
+ parser assigns an expression that has no assignment of its own to `Result`. Neither is nested into the copy,
109
+ so copies share them.
110
+
111
+ ## Trigger groups
112
+
113
+ A trigger group hash is salted with the rest of the copy, so a change in one copy runs only that copy's
114
+ trigger groups. Every carrier is salted together -- a group configuration (`AutofillTriggerGroup`,
115
+ `TemplatedEntityLookup`, `TabularTriggerGroup`) and a bare hash (`TriggerGroupHash`,
116
+ `EntityBundleTriggerGroup`) -- because both sides of a trigger read the hash from their own configuration, so
117
+ salting one side and not the other leaves the group silently dead.
118
+
119
+ A manifest that means to hear the form it is injected into lists those hashes in `SharedTriggerGroups` at its
120
+ root, and they are left unsalted:
121
+
122
+ ```json
123
+ { "Scope": "Crate", "SharedTriggerGroups": [ "HostCrateChange" ], "Sections": [] }
124
+ ```
125
+
126
+ A host with input providers of its own carries its trigger group hashes in properties this library knows
127
+ nothing about. It adds them to the carrier lists on the metacontroller, before anything is injected:
128
+
129
+ ```javascript
130
+ pict.views.PictFormMetacontroller.injectionTriggerGroupProperties.push('MyGroupConfiguration');
131
+ pict.views.PictFormMetacontroller.injectionTriggerGroupHashProperties.push('MyTriggerGroupHash');
132
+ ```
133
+
134
+ Not declared in `KNOWN_OPEN`, because neither tier exercises it: the library has no way to remove an injected
135
+ copy. Injection appends the copy's sections, descriptors and (translated, de-duplicated) `ValidationSolvers`
136
+ to the form's manifest; a host that tears a copy down again has to take its validation solvers out of
137
+ `manifestDescription.ValidationSolvers` too, or they keep running against the removed copy's data.
package/docs/_sidebar.md CHANGED
@@ -17,6 +17,7 @@
17
17
  - [Comprehensions](Comprehensions.md)
18
18
  - [Comprehensions - Advanced](Comprehensions_Advanced.md)
19
19
  - [Providers](Providers.md)
20
+ - [Injection Conformance](Injection_Conformance.md)
20
21
 
21
22
  - Playground
22
23
 
@@ -84,7 +84,7 @@ Fallback default tab when value is empty:
84
84
  1. Generates tab button HTML
85
85
  2. Assigns to container element
86
86
  3. Applies CSS snippets for show/hide behavior
87
- 4. Sets default tab based on value or DefaultTabGroupHash
87
+ 4. Sets the default tab: the stored value (unless `DefaultFromData` is false), else `DefaultTabGroupHash`, else the first tab. Hashes not in `TabGroupSet` are skipped.
88
88
 
89
89
  ### setCSSSnippets
90
90
 
@@ -98,6 +98,8 @@ Core method that:
98
98
  3. Updates tab button styling
99
99
  4. Updates input value
100
100
 
101
+ Returns `true` once the tab is shown, and `false` without changing anything if the view, input or `TabGroupSet` is missing or the hash is not in `TabGroupSet`.
102
+
101
103
  ## Example: Complete Configuration
102
104
 
103
105
  ```json
@@ -84,7 +84,7 @@ Fallback default section when value is empty:
84
84
  1. Resolves section hashes to view hashes via metacontroller
85
85
  2. Generates tab button HTML
86
86
  3. Applies CSS for visibility control
87
- 4. Sets default section based on value or DefaultTabSectionHash
87
+ 4. Sets the default section: the stored value (unless `DefaultFromData` is false), else `DefaultTabSectionHash`, else the first section. Hashes not in `TabSectionSet` are skipped.
88
88
 
89
89
  ### getViewHash
90
90
 
@@ -99,6 +99,8 @@ Core method that:
99
99
  3. Updates tab button styling
100
100
  4. Updates input value
101
101
 
102
+ Returns `true` once the section is shown, and `false` without changing anything if the view, input, `TabSectionSet` or section view is missing or the hash is not in `TabSectionSet`.
103
+
102
104
  ## Example: Multi-Page Form
103
105
 
104
106
  ```json
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pict-section-form",
3
- "version": "1.3.13",
3
+ "version": "1.3.15",
4
4
  "description": "Pict dynamic forms",
5
5
  "main": "source/Pict-Section-Form.js",
6
6
  "directories": {
@@ -20,6 +20,7 @@
20
20
  "coverage": "npx quack coverage",
21
21
  "build": "npx quack build",
22
22
  "test": "npx quack test",
23
+ "test:injection": "node test/browser/Injection-Conformance-Harness-Runner.js",
23
24
  "lint": "eslint source/**",
24
25
  "types": "tsc -p ./tsconfig.build.json",
25
26
  "check": "tsc -p ./tsconfig.json --noEmit",
@@ -38,7 +39,7 @@
38
39
  "browser-env": "^3.3.0",
39
40
  "eslint": "^9.39.2",
40
41
  "jquery": "^4.0.0",
41
- "pict": "^1.0.387",
42
+ "pict": "^1.0.401",
42
43
  "pict-application": "^1.0.34",
43
44
  "pict-docuserve": "^1.4.19",
44
45
  "pict-service-commandlineutility": "^1.0.20",
@@ -51,10 +52,10 @@
51
52
  "fable-serviceproviderbase": "^3.0.19",
52
53
  "marked": "^4.3.0",
53
54
  "pict-provider": "^1.0.13",
54
- "pict-section-excalidraw": "^1.0.3",
55
- "pict-section-markdowneditor": "^1.0.19",
55
+ "pict-section-excalidraw": "^1.0.6",
56
+ "pict-section-markdowneditor": "^1.0.21",
56
57
  "pict-section-objecteditor": "^1.0.3",
57
- "pict-section-tuigrid": "^1.0.31",
58
+ "pict-section-tuigrid": "^1.0.32",
58
59
  "pict-template": "^1.0.15",
59
60
  "pict-view": "^1.0.68"
60
61
  },
@@ -70,6 +70,13 @@ class PictDynamicFormsSolverBehaviors extends libPictProvider
70
70
  + ' td.pict-tabular-column-highlight, th.pict-tabular-column-highlight { background-color: var(--pict-tabular-highlight-color, #FFF3CD) !important; }';
71
71
 
72
72
  this.solverOrdinalMap = {};
73
+ // An injected copy gating an ordinal must not gate the same ordinal in a sibling copy, so a gate set
74
+ // while solving a copy is recorded against that copy. A gate set by the form itself stays global,
75
+ // which is what a form that gates its own ordinals has always relied on.
76
+ /** @type {Record<string, Record<string, boolean>>} */
77
+ this.scopedSolverOrdinalMap = {};
78
+ /** @type {string} */
79
+ this.activeSolverScope = '';
73
80
 
74
81
  this.setCSSSnippets();
75
82
  }
@@ -286,13 +293,64 @@ class PictDynamicFormsSolverBehaviors extends libPictProvider
286
293
  return pArray.sort();
287
294
  }
288
295
 
296
+ /**
297
+ * The copy a view belongs to: the salt createDistinctManifest appended to its section hash, or an empty
298
+ * string for a section the form declares itself.
299
+ *
300
+ * @param {any} pView - A dynamic form view.
301
+ *
302
+ * @return {string} The scope gates set while solving that view are recorded against.
303
+ */
304
+ getViewSolverScope(pView)
305
+ {
306
+ const tmpSection = pView ? pView.sectionDefinition : undefined;
307
+ if (!tmpSection || !tmpSection.OriginalHash || !tmpSection.Hash || (tmpSection.Hash === tmpSection.OriginalHash))
308
+ {
309
+ return '';
310
+ }
311
+ return tmpSection.Hash.substring(tmpSection.OriginalHash.length + 1);
312
+ }
313
+
314
+ /**
315
+ * Records which copy's solvers are running, so a gate one of them sets lands on that copy.
316
+ *
317
+ * @param {string} pScope - A scope from getViewSolverScope.
318
+ *
319
+ * @return {string} The scope that was active before, to restore afterwards.
320
+ */
321
+ setActiveSolverScope(pScope)
322
+ {
323
+ const tmpPreviousScope = this.activeSolverScope;
324
+ this.activeSolverScope = pScope || '';
325
+ return tmpPreviousScope;
326
+ }
327
+
328
+ /**
329
+ * @param {number|string} pSolverOrdinal
330
+ * @param {boolean} pEnabled
331
+ */
332
+ writeSolverOrdinalGate(pSolverOrdinal, pEnabled)
333
+ {
334
+ const tmpOrdinalKey = `ORD-${pSolverOrdinal}`;
335
+ if (!this.activeSolverScope)
336
+ {
337
+ this.solverOrdinalMap[tmpOrdinalKey] = pEnabled;
338
+ return;
339
+ }
340
+ if (!this.scopedSolverOrdinalMap[this.activeSolverScope])
341
+ {
342
+ this.scopedSolverOrdinalMap[this.activeSolverScope] = {};
343
+ }
344
+ this.scopedSolverOrdinalMap[this.activeSolverScope][tmpOrdinalKey] = pEnabled;
345
+ }
346
+
289
347
  /**
290
348
  * @param {number|string} pSolverOrdinal
291
349
  * @param {boolean|string|number} pEnabled
292
350
  */
293
351
  setSolverOrdinalEnabled(pSolverOrdinal, pEnabled)
294
352
  {
295
- this.solverOrdinalMap[`ORD-${pSolverOrdinal}`] = pEnabled == true || pEnabled == '1';
353
+ this.writeSolverOrdinalGate(pSolverOrdinal, pEnabled == true || pEnabled == '1');
296
354
  }
297
355
 
298
356
  /**
@@ -300,7 +358,7 @@ class PictDynamicFormsSolverBehaviors extends libPictProvider
300
358
  */
301
359
  enableSolverOrdinal(pSolverOrdinal)
302
360
  {
303
- this.solverOrdinalMap[`ORD-${pSolverOrdinal}`] = true;
361
+ this.writeSolverOrdinalGate(pSolverOrdinal, true);
304
362
  }
305
363
 
306
364
  /**
@@ -308,18 +366,28 @@ class PictDynamicFormsSolverBehaviors extends libPictProvider
308
366
  */
309
367
  disableSolverOrdinal(pSolverOrdinal)
310
368
  {
311
- this.solverOrdinalMap[`ORD-${pSolverOrdinal}`] = false;
369
+ this.writeSolverOrdinalGate(pSolverOrdinal, false);
312
370
  }
313
371
 
314
372
  /**
315
373
  * @param {number|string} pSolveOrdinal
374
+ * @param {string} [pScope] - The copy being solved; without one only the form's own gates apply.
316
375
  *
317
376
  * @return {boolean}
318
377
  */
319
- checkSolverOrdinalEnabled(pSolveOrdinal)
378
+ checkSolverOrdinalEnabled(pSolveOrdinal, pScope)
320
379
  {
321
380
  let tmpOrdinalKey = `ORD-${pSolveOrdinal}`;
322
- return (!(tmpOrdinalKey in this.solverOrdinalMap)) || (this.solverOrdinalMap[tmpOrdinalKey] === true);
381
+ if ((tmpOrdinalKey in this.solverOrdinalMap) && (this.solverOrdinalMap[tmpOrdinalKey] !== true))
382
+ {
383
+ return false;
384
+ }
385
+ const tmpScopedGates = pScope ? this.scopedSolverOrdinalMap[pScope] : undefined;
386
+ if (tmpScopedGates && (tmpOrdinalKey in tmpScopedGates) && (tmpScopedGates[tmpOrdinalKey] !== true))
387
+ {
388
+ return false;
389
+ }
390
+ return true;
323
391
  }
324
392
 
325
393
  getSectionSelector(pSectionFormID)
@@ -307,10 +307,13 @@ class PictDynamicSolver extends libPictProvider
307
307
  this.log.trace(`DynamicSolver [${this.UUID}]::[${this.Hash}] [${pReason}] Solving ordinal ${tmpOrdinalKeys[i]}`);
308
308
  }
309
309
  let tmpOrdinalContainer = tmpOrdinalsToSolve[tmpOrdinalKeys[i]];
310
- let tmpExecuteOrdinal = this.pict.providers.DynamicFormSolverBehaviors.checkSolverOrdinalEnabled(tmpOrdinalKeys[i]);
310
+ const tmpAdhocScope = this.pict.providers.DynamicFormSolverBehaviors.getViewSolverScope(pView);
311
+ let tmpExecuteOrdinal = this.pict.providers.DynamicFormSolverBehaviors.checkSolverOrdinalEnabled(tmpOrdinalKeys[i], tmpAdhocScope);
311
312
  if (tmpExecuteOrdinal)
312
313
  {
314
+ const tmpPreviousScope = this.pict.providers.DynamicFormSolverBehaviors.setActiveSolverScope(tmpAdhocScope);
313
315
  this.executeAdhocSolvers(pView, tmpOrdinalContainer.AdhocSolvers, pReason, Number(tmpOrdinalKeys[i]), tmpSolveOutcome.SolverResultsMap);
316
+ this.pict.providers.DynamicFormSolverBehaviors.setActiveSolverScope(tmpPreviousScope);
314
317
  }
315
318
  }
316
319
 
@@ -399,6 +402,12 @@ class PictDynamicSolver extends libPictProvider
399
402
  {
400
403
  continue;
401
404
  }
405
+ const tmpGroupScope = this.pict.providers.DynamicFormSolverBehaviors.getViewSolverScope(tmpView);
406
+ if (tmpGroupScope && !this.pict.providers.DynamicFormSolverBehaviors.checkSolverOrdinalEnabled(tmpSolver.Ordinal, tmpGroupScope))
407
+ {
408
+ continue;
409
+ }
410
+ this.pict.providers.DynamicFormSolverBehaviors.setActiveSolverScope(tmpGroupScope);
402
411
 
403
412
  if (pPreventSolverCycles && tmpSolver.Expression.match(this._RunSolversRegex))
404
413
  {
@@ -449,6 +458,7 @@ class PictDynamicSolver extends libPictProvider
449
458
  tmpSolverReultsMap.ExecutedSolvers.push(tmpSolver);
450
459
  tmpSolver.EndTimeStamp = Date.now();
451
460
  }
461
+ this.pict.providers.DynamicFormSolverBehaviors.setActiveSolverScope('');
452
462
  }
453
463
 
454
464
  /**
@@ -472,6 +482,13 @@ class PictDynamicSolver extends libPictProvider
472
482
  {
473
483
  continue;
474
484
  }
485
+ // A gate an injected copy set applies to that copy's solvers, not to a sibling's at the same ordinal.
486
+ const tmpSectionScope = this.pict.providers.DynamicFormSolverBehaviors.getViewSolverScope(tmpView);
487
+ if (tmpSectionScope && !this.pict.providers.DynamicFormSolverBehaviors.checkSolverOrdinalEnabled(tmpSolver.Ordinal, tmpSectionScope))
488
+ {
489
+ continue;
490
+ }
491
+ this.pict.providers.DynamicFormSolverBehaviors.setActiveSolverScope(tmpSectionScope);
475
492
 
476
493
  if (pPreventSolverCycles && tmpSolver.Expression.match(this._RunSolversRegex))
477
494
  {
@@ -499,6 +516,7 @@ class PictDynamicSolver extends libPictProvider
499
516
  tmpSolverReultsMap.ExecutedSolvers.push(tmpSolver);
500
517
  tmpSolver.EndTimeStamp = +new Date();
501
518
  }
519
+ this.pict.providers.DynamicFormSolverBehaviors.setActiveSolverScope('');
502
520
  }
503
521
 
504
522
  /**
@@ -569,7 +587,7 @@ class PictDynamicSolver extends libPictProvider
569
587
  {
570
588
  this.pict.log.trace(`Running validation solver ordinal ${tmpSolver.Ordinal} [${tmpSolver.Expression}]`);
571
589
  }
572
- this.pict.ExpressionParser.solve(tmpSolver.Expression, tmpMarshalDestination, pSolverResultsMap, this.pict.manifest, this.pict.AppData);
590
+ this.pict.ExpressionParser.solve(tmpSolver.Expression, tmpMarshalDestination, pSolverResultsMap, this.pict.manifest, tmpMarshalDestination);
573
591
  }
574
592
  }
575
593
 
@@ -70,12 +70,26 @@ class CustomInputHandler extends libPictSectionInputExtension
70
70
  return `#GROUP-${pView.formID}-${pGroupHash}`;
71
71
  }
72
72
 
73
+ /**
74
+ * Is this tab group hash actually one of the input's tabs?
75
+ *
76
+ * @param {Object} pInput - The input object.
77
+ * @param {string} pTabGroupHash - The tab group hash to test.
78
+ *
79
+ * @return {boolean}
80
+ */
81
+ isTabInSet(pInput, pTabGroupHash)
82
+ {
83
+ let tmpTabSet = pInput?.PictForm?.TabGroupSet;
84
+ return !!pTabGroupHash && Array.isArray(tmpTabSet) && (tmpTabSet.indexOf(pTabGroupHash) > -1);
85
+ }
86
+
73
87
  /**
74
88
  * @param {string} pViewHash
75
89
  * @param {string} pInputHash
76
90
  * @param {string} pTabHash
77
91
  *
78
- * @return {boolean}
92
+ * @return {boolean} - true once the tab is shown; false (nothing changed) if the view, input or tab hash is not valid.
79
93
  */
80
94
  selectTabByViewHash(pViewHash, pInputHash, pTabHash)
81
95
  {
@@ -101,6 +115,14 @@ class CustomInputHandler extends libPictSectionInputExtension
101
115
  return false;
102
116
  }
103
117
 
118
+ // A hash that is not in the set matches nothing below, so it would hide EVERY group and leave no
119
+ // tab selected. Refuse it without touching anything; false already means "did not switch".
120
+ if (!this.isTabInSet(tmpInput, pTabHash))
121
+ {
122
+ this.pict.log.warn(`TabSelector input provider was asked for tab [${pTabHash}] on view [${pViewHash}] input [${pInputHash}] but it is not in the TabGroupSet; leaving the current tab selected.`);
123
+ return false;
124
+ }
125
+
104
126
  for (let i = 0; i < tmpInput.PictForm.TabGroupSet.length; i++)
105
127
  {
106
128
  let tmpTabGroupHash = tmpInput.PictForm.TabGroupSet[i];
@@ -166,8 +188,25 @@ class CustomInputHandler extends libPictSectionInputExtension
166
188
  // TODO: Fix typescript types so this function has an optional rather than required fourth parameter.
167
189
  this.pict.ContentAssignment.projectContent('replace', this.getTabSelectorInputHTMLID(pInput.Macro.RawHTMLID), tmpTabGroupSetEntries, 'FixTheTypescriptTypes');
168
190
 
169
- // Now set the default tab (or first one)
170
- const tmpDefaultTabGroupHash = (pInput.PictForm?.DefaultFromData !== false && pValue) || pInput.PictForm?.DefaultTabGroupHash || tmpTabSet[0];
191
+ // Now set the default tab (or first one). Take the first candidate that is actually one of this
192
+ // input's tabs, since selectTabByViewHash refuses anything else: a stored value can name a group
193
+ // since renamed or dropped from the manifest, and DefaultTabGroupHash can simply be a typo.
194
+ const tmpTabCandidates = [];
195
+ if (pInput.PictForm?.DefaultFromData !== false)
196
+ {
197
+ tmpTabCandidates.push(pValue);
198
+ }
199
+ tmpTabCandidates.push(pInput.PictForm?.DefaultTabGroupHash);
200
+
201
+ let tmpDefaultTabGroupHash = tmpTabSet[0];
202
+ for (let i = 0; i < tmpTabCandidates.length; i++)
203
+ {
204
+ if (this.isTabInSet(pInput, tmpTabCandidates[i]))
205
+ {
206
+ tmpDefaultTabGroupHash = tmpTabCandidates[i];
207
+ break;
208
+ }
209
+ }
171
210
 
172
211
  this.selectTabByViewHash(pView.Hash, pInput.Hash, tmpDefaultTabGroupHash);
173
212
 
@@ -76,12 +76,26 @@ class CustomInputHandler extends libPictSectionInputExtension
76
76
  return `#Pict-${metaController ? metaController.UUID : this.UUID}-${pTabViewSectionHash}-Wrap`;
77
77
  }
78
78
 
79
+ /**
80
+ * Is this tab section hash actually one of the input's tabs?
81
+ *
82
+ * @param {Object} pInput - The input object.
83
+ * @param {string} pTabSectionHash - The tab section hash to test.
84
+ *
85
+ * @return {boolean}
86
+ */
87
+ isTabInSet(pInput, pTabSectionHash)
88
+ {
89
+ let tmpTabSet = pInput?.PictForm?.TabSectionSet;
90
+ return !!pTabSectionHash && Array.isArray(tmpTabSet) && (tmpTabSet.indexOf(pTabSectionHash) > -1);
91
+ }
92
+
79
93
  /**
80
94
  * @param {string} pViewHash
81
95
  * @param {string} pInputHash
82
96
  * @param {string} pTabViewHash
83
97
  *
84
- * @return {boolean}
98
+ * @return {boolean} - true once the section is shown; false (nothing changed) if the view, input or tab hash is not valid.
85
99
  */
86
100
  selectTabByViewHash(pViewHash, pInputHash, pTabViewHash)
87
101
  {
@@ -106,6 +120,13 @@ class CustomInputHandler extends libPictSectionInputExtension
106
120
  this.pict.log.error(`TabSelector input provider tried to switch to view [${pViewHash}] input [${pInputHash}] tab [${pTabViewHash}] but the input did not have a valid TabSectionSet array in the PictForm object!`)
107
121
  return false;
108
122
  }
123
+ // A hash that is not in the set matches nothing below, so it would hide EVERY section and leave no
124
+ // tab selected. Refuse it without touching anything; false already means "did not switch".
125
+ if (!this.isTabInSet(tmpInput, pTabViewHash))
126
+ {
127
+ this.pict.log.warn(`TabSelector input provider was asked for tab [${pTabViewHash}] on view [${pViewHash}] input [${pInputHash}] but it is not in the TabSectionSet; leaving the current tab selected.`);
128
+ return false;
129
+ }
109
130
  let tmpTabView = this.pict.views[this.getViewHash(pTabViewHash)];
110
131
  if (!tmpTabView)
111
132
  {
@@ -180,8 +201,26 @@ class CustomInputHandler extends libPictSectionInputExtension
180
201
  // TODO: Fix typescript types so this function has an optional rather than required fourth parameter.
181
202
  this.pict.ContentAssignment.projectContent('replace', this.getTabSelectorInputHTMLID(pInput.Macro.RawHTMLID), tmpTabSectionSetEntries, 'FixTheTypescriptTypes');
182
203
 
183
- // Now set the default tab (or first one)
184
- const tmpDefaultTabSectionHash = (pInput.PictForm?.DefaultFromData !== false && pValue) || pInput.PictForm?.DefaultTabSectionHash || tmpTabSet[0];
204
+ // Now set the default tab (or first one). Take the first candidate that is actually one of this
205
+ // input's tabs, since selectTabByViewHash refuses anything else: a stored value can name a section
206
+ // since renamed or dropped from the manifest, and DefaultTabSectionHash can simply be a typo.
207
+ const tmpTabCandidates = [];
208
+ if (pInput.PictForm?.DefaultFromData !== false)
209
+ {
210
+ tmpTabCandidates.push(pValue);
211
+ }
212
+ tmpTabCandidates.push(pInput.PictForm?.DefaultTabSectionHash);
213
+
214
+ let tmpDefaultTabSectionHash = tmpTabSet[0];
215
+ for (let i = 0; i < tmpTabCandidates.length; i++)
216
+ {
217
+ if (this.isTabInSet(pInput, tmpTabCandidates[i]))
218
+ {
219
+ tmpDefaultTabSectionHash = tmpTabCandidates[i];
220
+ break;
221
+ }
222
+ }
223
+
185
224
  this.selectTabByViewHash(pView.Hash, pInput.Hash, tmpDefaultTabSectionHash);
186
225
 
187
226
  return super.onInputInitialize(pView, pGroup, pRow, pInput, pValue, pHTMLTabSelector, pTransactionGUID);