pict-section-form 1.3.14 → 1.3.16

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 (80) hide show
  1. package/docs/Injection_Conformance.md +137 -0
  2. package/docs/Providers.md +12 -7
  3. package/docs/_sidebar.md +3 -0
  4. package/docs/input_providers/016-facet-filter.md +106 -0
  5. package/docs/input_providers/README.md +1 -0
  6. package/example_applications/README.md +6 -0
  7. package/example_applications/facet_filter/.quackage.json +9 -0
  8. package/example_applications/facet_filter/Facet-Filter-Application.js +210 -0
  9. package/example_applications/facet_filter/Facet-Filter-Server.js +233 -0
  10. package/example_applications/facet_filter/Facet-Filter-Smoke-Runner.js +101 -0
  11. package/example_applications/facet_filter/FacetFilterData.json +44 -0
  12. package/example_applications/facet_filter/README-FacetFilter.md +70 -0
  13. package/example_applications/facet_filter/html/Facet-Filter-Smoke.js +128 -0
  14. package/example_applications/facet_filter/html/index.html +74 -0
  15. package/example_applications/facet_filter/package.json +27 -0
  16. package/example_applications/nested_distill_sandbox/Sandbox-Driver-Headlight.js +17 -0
  17. package/example_applications/nested_distill_sandbox/Sandbox-Driver.js +369 -0
  18. package/example_applications/nested_distill_sandbox/Sandbox-Runner.js +372 -0
  19. package/example_applications/nested_distill_sandbox/approaches/A1-tabular-trigger-group.js +67 -0
  20. package/example_applications/nested_distill_sandbox/approaches/A3-crossmap-selectoptionsrefresh.js +61 -0
  21. package/example_applications/nested_distill_sandbox/approaches/A4-graph-solvers-flat-list.js +53 -0
  22. package/example_applications/nested_distill_sandbox/approaches/A5-facet-filter.js +75 -0
  23. package/example_applications/nested_distill_sandbox/approaches/A5b-facet-filter-symmetric.js +15 -0
  24. package/example_applications/nested_distill_sandbox/approaches/A5h-facet-filter-headlight-picker.js +15 -0
  25. package/example_applications/nested_distill_sandbox/approaches/R0-original-jmf-manifest-headlight.js +27 -0
  26. package/example_applications/nested_distill_sandbox/approaches/R1-real-jmf-manifest-headlight.js +136 -0
  27. package/example_applications/nested_distill_sandbox/approaches/_Common.js +344 -0
  28. package/example_applications/nested_distill_sandbox/approaches/_Scenarios.js +262 -0
  29. package/package.json +6 -5
  30. package/source/providers/Pict-Provider-DynamicFormSolverBehaviors.js +73 -5
  31. package/source/providers/Pict-Provider-DynamicSolver.js +22 -2
  32. package/source/providers/Pict-Provider-ListDistilling.js +266 -1
  33. package/source/providers/Pict-Provider-MetaLists.js +16 -2
  34. package/source/providers/inputs/Pict-Provider-Input-FacetFilter.js +232 -0
  35. package/source/providers/inputs/Pict-Provider-Input-Select.js +41 -1
  36. package/source/views/Pict-View-Form-Metacontroller.js +690 -93
  37. package/test/Pict-Provider-DynamicFormSolverBehaviors-OrdinalScope_tests.js +105 -0
  38. package/test/Pict-Provider-ListDistilling-Facet_tests.js +375 -0
  39. package/test/Pict-View-Form-Metacontroller-DistinctManifest_tests.js +410 -0
  40. package/test/PictSectionForm-Injection-Conformance_tests.js +762 -0
  41. package/test/browser/Injection-Conformance-Differential-Scenario.js +346 -0
  42. package/test/browser/Injection-Conformance-EdgeCase-Scenario.js +168 -0
  43. package/test/browser/Injection-Conformance-Harness-Driver.js +538 -0
  44. package/test/browser/Injection-Conformance-Harness-Runner.js +487 -0
  45. package/test/browser/Injection-Conformance-Reconstitution-Scenario.js +191 -0
  46. package/test/browser/Injection-Conformance-Standalone-Scenario.js +114 -0
  47. package/test/fixtures/injection/Injection-Fixture-Cases.js +204 -0
  48. package/test/fixtures/injection/Injection-Fixture-Manifest.json +381 -0
  49. package/types/source/providers/Pict-Provider-DynamicFormSolverBehaviors.d.ts +110 -1
  50. package/types/source/providers/Pict-Provider-DynamicFormSolverBehaviors.d.ts.map +1 -1
  51. package/types/source/providers/Pict-Provider-DynamicSolver.d.ts.map +1 -1
  52. package/types/source/providers/Pict-Provider-DynamicTabularData.d.ts +17 -1
  53. package/types/source/providers/Pict-Provider-DynamicTabularData.d.ts.map +1 -1
  54. package/types/source/providers/Pict-Provider-InputExtension.d.ts +31 -0
  55. package/types/source/providers/Pict-Provider-InputExtension.d.ts.map +1 -1
  56. package/types/source/providers/Pict-Provider-ListDistilling.d.ts +90 -1
  57. package/types/source/providers/Pict-Provider-ListDistilling.d.ts.map +1 -1
  58. package/types/source/providers/Pict-Provider-MetaLists.d.ts.map +1 -1
  59. package/types/source/providers/inputs/Pict-Provider-Input-Chart-CSS.d.ts +16 -0
  60. package/types/source/providers/inputs/Pict-Provider-Input-Chart-CSS.d.ts.map +1 -0
  61. package/types/source/providers/inputs/Pict-Provider-Input-Chart.d.ts +47 -0
  62. package/types/source/providers/inputs/Pict-Provider-Input-Chart.d.ts.map +1 -1
  63. package/types/source/providers/inputs/Pict-Provider-Input-Diagram.d.ts +86 -0
  64. package/types/source/providers/inputs/Pict-Provider-Input-Diagram.d.ts.map +1 -1
  65. package/types/source/providers/inputs/Pict-Provider-Input-FacetFilter.d.ts +103 -0
  66. package/types/source/providers/inputs/Pict-Provider-Input-FacetFilter.d.ts.map +1 -0
  67. package/types/source/providers/inputs/Pict-Provider-Input-ObjectEditor.d.ts +128 -0
  68. package/types/source/providers/inputs/Pict-Provider-Input-ObjectEditor.d.ts.map +1 -0
  69. package/types/source/providers/inputs/Pict-Provider-Input-PreciseNumber.d.ts.map +1 -1
  70. package/types/source/providers/inputs/Pict-Provider-Input-Select.d.ts +12 -0
  71. package/types/source/providers/inputs/Pict-Provider-Input-Select.d.ts.map +1 -1
  72. package/types/source/providers/inputs/Pict-Provider-Input-TabGroupSelector.d.ts +10 -1
  73. package/types/source/providers/inputs/Pict-Provider-Input-TabGroupSelector.d.ts.map +1 -1
  74. package/types/source/providers/inputs/Pict-Provider-Input-TabSectionSelector.d.ts +10 -1
  75. package/types/source/providers/inputs/Pict-Provider-Input-TabSectionSelector.d.ts.map +1 -1
  76. package/types/source/providers/layouts/Pict-Layout-Tabular.d.ts +76 -4
  77. package/types/source/providers/layouts/Pict-Layout-Tabular.d.ts.map +1 -1
  78. package/types/source/views/Pict-View-DynamicForm.d.ts.map +1 -1
  79. package/types/source/views/Pict-View-Form-Metacontroller.d.ts +63 -2
  80. package/types/source/views/Pict-View-Form-Metacontroller.d.ts.map +1 -1
@@ -0,0 +1,105 @@
1
+ /*
2
+ Solver ordinal gates are per copy.
3
+
4
+ `setsolverordinalenabled` / `enablesolverordinal` / `disablesolverordinal` gate solvers by ordinal number,
5
+ and ordinals are small integers that every manifest uses from 1. So a gate an injected copy sets has to
6
+ stay inside that copy, or it silences whatever a sibling copy happens to have at the same ordinal.
7
+
8
+ A gate the form itself sets stays global: a form that gates its own ordinals has always been able to, and
9
+ the sections it declares carry no salt to scope by.
10
+ */
11
+
12
+ const Chai = require('chai');
13
+ const Expect = Chai.expect;
14
+
15
+ const libPict = require('pict');
16
+ const libDynamicFormSolverBehaviors = require('../source/providers/Pict-Provider-DynamicFormSolverBehaviors.js');
17
+
18
+ /**
19
+ * @return {any} the behaviors provider, wired to a pict instance and nothing else
20
+ */
21
+ function buildBehaviors()
22
+ {
23
+ const tmpPict = new libPict({ Product: 'OrdinalScopeTests', LogStreams: [ { streamtype: 'console', level: 'fatal' } ] });
24
+ tmpPict.addProvider('DynamicFormSolverBehaviors', {}, libDynamicFormSolverBehaviors);
25
+ return tmpPict.providers.DynamicFormSolverBehaviors;
26
+ }
27
+
28
+ /**
29
+ * @param {string} pSectionHash - The section hash as the view holds it.
30
+ * @param {string} [pOriginalHash] - What the section was called before it was salted, when it is a copy.
31
+ *
32
+ * @return {any} a view stub carrying just the section definition the scope is read from
33
+ */
34
+ function buildView(pSectionHash, pOriginalHash)
35
+ {
36
+ const tmpSection = { Hash: pSectionHash };
37
+ if (pOriginalHash)
38
+ {
39
+ tmpSection.OriginalHash = pOriginalHash;
40
+ }
41
+ return { sectionDefinition: tmpSection };
42
+ }
43
+
44
+ suite('Dynamic form solver behaviors ordinal scope', () =>
45
+ {
46
+ suite('getViewSolverScope', () =>
47
+ {
48
+ test('a section the form declares itself has no scope', () =>
49
+ {
50
+ const tmpBehaviors = buildBehaviors();
51
+ Expect(tmpBehaviors.getViewSolverScope(buildView('Measure'))).to.equal('');
52
+ Expect(tmpBehaviors.getViewSolverScope(undefined)).to.equal('');
53
+ });
54
+
55
+ test('an injected section is scoped by the salt it carries', () =>
56
+ {
57
+ const tmpBehaviors = buildBehaviors();
58
+ Expect(tmpBehaviors.getViewSolverScope(buildView('Measure_alpha', 'Measure'))).to.equal('alpha');
59
+ Expect(tmpBehaviors.getViewSolverScope(buildView('Measure_alphabeta', 'Measure'))).to.equal('alphabeta');
60
+ });
61
+ });
62
+
63
+ suite('gates', () =>
64
+ {
65
+ test('a gate one copy sets does not silence a sibling copy at the same ordinal', () =>
66
+ {
67
+ const tmpBehaviors = buildBehaviors();
68
+ tmpBehaviors.setActiveSolverScope('alpha');
69
+ tmpBehaviors.disableSolverOrdinal(5);
70
+ tmpBehaviors.setActiveSolverScope('');
71
+
72
+ Expect(tmpBehaviors.checkSolverOrdinalEnabled(5, 'alpha'), 'the copy that set it is gated').to.equal(false);
73
+ Expect(tmpBehaviors.checkSolverOrdinalEnabled(5, 'beta'), 'a sibling copy is not').to.equal(true);
74
+ Expect(tmpBehaviors.checkSolverOrdinalEnabled(5, ''), 'the form itself is not').to.equal(true);
75
+ });
76
+
77
+ test('a gate the form sets applies everywhere, as it always has', () =>
78
+ {
79
+ const tmpBehaviors = buildBehaviors();
80
+ tmpBehaviors.disableSolverOrdinal(7);
81
+
82
+ Expect(tmpBehaviors.checkSolverOrdinalEnabled(7, '')).to.equal(false);
83
+ Expect(tmpBehaviors.checkSolverOrdinalEnabled(7, 'alpha')).to.equal(false);
84
+ });
85
+
86
+ test('an ordinal nothing has gated runs', () =>
87
+ {
88
+ const tmpBehaviors = buildBehaviors();
89
+ Expect(tmpBehaviors.checkSolverOrdinalEnabled(3, 'alpha')).to.equal(true);
90
+ Expect(tmpBehaviors.checkSolverOrdinalEnabled(3)).to.equal(true);
91
+ });
92
+
93
+ test('re-enabling inside a copy only re-enables that copy', () =>
94
+ {
95
+ const tmpBehaviors = buildBehaviors();
96
+ tmpBehaviors.setActiveSolverScope('alpha');
97
+ tmpBehaviors.setSolverOrdinalEnabled(9, false);
98
+ tmpBehaviors.setSolverOrdinalEnabled(9, '1');
99
+ tmpBehaviors.setActiveSolverScope('');
100
+
101
+ Expect(tmpBehaviors.checkSolverOrdinalEnabled(9, 'alpha')).to.equal(true);
102
+ Expect(tmpBehaviors.checkSolverOrdinalEnabled(9, 'beta')).to.equal(true);
103
+ });
104
+ });
105
+ });
@@ -0,0 +1,375 @@
1
+ /*
2
+ Facet ListFilterRules + the Pict-Input-FacetFilter provider: dropdowns in a tabular row that choose from
3
+ one shared join list, each narrowed by the others in the same row, kept consistent when one changes.
4
+ Also covers the global PickList source (ListSourceAddressGlobal) the facet lists are built from.
5
+ */
6
+
7
+ const libBrowserEnv = require('browser-env');
8
+ libBrowserEnv();
9
+
10
+ const Chai = require('chai');
11
+ const Expect = Chai.expect;
12
+
13
+ const libPict = require('pict');
14
+ const libPictSectionForm = require('../source/Pict-Section-Form.js');
15
+
16
+ const _Catalog =
17
+ [
18
+ { IDBook: 1, Genre: 'Mystery', Author: 'Christie', Language: 'EN', InPrintUntil: '2030-12-31T00:00:00.000Z' },
19
+ { IDBook: 2, Genre: 'Mystery', Author: 'Christie', Language: 'EN', InPrintUntil: '2030-12-31T00:00:00.000Z' },
20
+ { IDBook: 3, Genre: 'Mystery', Author: 'Simenon', Language: 'FR', InPrintUntil: '2020-06-30T00:00:00.000Z' },
21
+ { IDBook: 4, Genre: 'Science', Author: 'Sagan', Language: 'EN', InPrintUntil: '2025-01-01T00:00:00.000Z' },
22
+ { IDBook: 5, Genre: 'Poetry', Author: 'Christie', Language: 'EN', InPrintUntil: '2030-12-31T00:00:00.000Z' },
23
+ { IDBook: 6, Genre: 'Poetry', Author: 'Rilke', Language: 'DE', InPrintUntil: '2030-12-31T00:00:00.000Z' },
24
+ { IDBook: 7, Genre: 'History' },
25
+ ];
26
+
27
+ function facetRule(pJoinListValueAddress, pExtra)
28
+ {
29
+ return Object.assign({ FilterType: 'Facet', JoinListAddress: 'AppData.Catalog', JoinListAddressGlobal: true, JoinListValueAddress: pJoinListValueAddress }, pExtra || {});
30
+ }
31
+
32
+ function makeApplication(pRuleExtra, pRows)
33
+ {
34
+ const fColumn = (pKey, pPickList, pJoinListValueAddress) => (
35
+ {
36
+ Hash: `Shelf${pKey}`, Name: pKey, DataAddress: pKey, DataType: 'String', IsTabular: true,
37
+ PictForm:
38
+ {
39
+ Section: 'Library', Group: 'Shelf', InputType: 'Option', SelectOptionsPickList: pPickList,
40
+ ListFilterRules: [ facetRule(pJoinListValueAddress, pRuleExtra) ], Providers: [ 'Pict-Input-FacetFilter' ]
41
+ }
42
+ });
43
+ const tmpManifest =
44
+ {
45
+ Scope: 'FacetTestForm',
46
+ PickLists:
47
+ [
48
+ { Hash: 'Genres', ListAddress: 'Genres', ListSourceAddress: 'AppData.Catalog', ListSourceAddressGlobal: true, IDTemplate: '{~D:Record.Genre~}', TextTemplate: '{~D:Record.Genre~}', Unique: true, Sorted: true },
49
+ { Hash: 'Authors', ListAddress: 'Authors', ListSourceAddress: 'AppData.Catalog', ListSourceAddressGlobal: true, IDTemplate: '{~D:Record.Author~}', TextTemplate: '{~D:Record.Author~}', Unique: true, Sorted: true, SkipEmpty: true },
50
+ { Hash: 'Books', ListAddress: 'Books', ListSourceAddress: 'AppData.Catalog', ListSourceAddressGlobal: true, IDTemplate: '{~D:Record.IDBook~}', TextTemplate: 'Book {~D:Record.IDBook~}' },
51
+ ],
52
+ Descriptors: {},
53
+ Sections: [ { Hash: 'Library', Name: 'Library', Groups: [ { Hash: 'Shelf', Name: 'Shelf', Layout: 'Tabular', RecordSetAddress: 'Shelf', RecordManifest: 'ShelfRow' } ] } ],
54
+ ReferenceManifests:
55
+ {
56
+ ShelfRow:
57
+ {
58
+ Scope: 'ShelfRow',
59
+ Descriptors:
60
+ {
61
+ Genre: fColumn('Genre', 'Genres', 'Genre'),
62
+ Author: fColumn('Author', 'Authors', 'Author'),
63
+ Book: fColumn('Book', 'Books', 'IDBook'),
64
+ }
65
+ }
66
+ }
67
+ };
68
+ class TestApp extends libPictSectionForm.PictFormApplication
69
+ {
70
+ set testDone(fDone) { this._testDone = fDone; }
71
+ onAfterInitialize()
72
+ {
73
+ this._testDone && this._testDone();
74
+ }
75
+ }
76
+ TestApp.default_configuration = JSON.parse(JSON.stringify(libPictSectionForm.PictFormApplication.default_configuration));
77
+ TestApp.default_configuration.pict_configuration =
78
+ {
79
+ Product: 'FacetTest',
80
+ DefaultAppData: { Catalog: _Catalog, Shelf: pRows || [ {}, {} ] },
81
+ DefaultFormManifest: tmpManifest
82
+ };
83
+ return TestApp;
84
+ }
85
+
86
+ function bootstrap(pAppClass, fCheck, fDone)
87
+ {
88
+ const tmpPict = new libPict(pAppClass.default_configuration.pict_configuration);
89
+ tmpPict.LogNoisiness = 0;
90
+ tmpPict.addApplication('FacetTest', pAppClass.default_configuration, pAppClass);
91
+ tmpPict.PictApplication.testDone = () =>
92
+ {
93
+ try
94
+ {
95
+ // Rendering is what stamps each input's GroupIndex / Macro, which the row-scoped paths read.
96
+ document.body.innerHTML = '<div id="Pict-Form-Container"></div>';
97
+ tmpPict.views.PictFormMetacontroller.render();
98
+ const tmpView = tmpPict.views['PictSectionForm-Library'];
99
+ fCheck(tmpPict, tmpView);
100
+ fDone();
101
+ }
102
+ catch (pError)
103
+ {
104
+ fDone(pError);
105
+ }
106
+ };
107
+ tmpPict.PictApplication.initializeAsync(() => { });
108
+ }
109
+
110
+ /** @return {{ Input: any, InputIndex: number }} */
111
+ function column(pView, pKey)
112
+ {
113
+ const tmpAddresses = pView.getGroup(0).supportingManifest.elementAddresses;
114
+ const tmpIndex = tmpAddresses.indexOf(pKey);
115
+ return { Input: pView.getTabularRecordInput(0, tmpIndex), InputIndex: tmpIndex };
116
+ }
117
+
118
+ /** The ids a row's dropdown for pKey would offer. */
119
+ function offered(pPict, pView, pKey, pRowIndex)
120
+ {
121
+ const tmpColumn = column(pView, pKey);
122
+ const tmpList = pPict.providers.DynamicMetaLists.getList(tmpColumn.Input.PictForm.SelectOptionsPickList);
123
+ return pPict.providers.ListDistilling.filterList(pView, tmpColumn.Input, tmpList, pRowIndex).map((pEntry) => pEntry.id);
124
+ }
125
+
126
+ /** A user change: setDataTabularByHash writes the cell and runs the input's change providers, as dataChangedTabular does. */
127
+ function change(pPict, pView, pKey, pRowIndex, pValue)
128
+ {
129
+ pView.setDataTabularByHash(0, column(pView, pKey).Input.Hash, pRowIndex, pValue);
130
+ }
131
+
132
+ suite('ListDistilling Facet rules', () =>
133
+ {
134
+ test('a global PickList source reads application state rather than the form data', (fDone) =>
135
+ {
136
+ bootstrap(makeApplication(), (pPict) =>
137
+ {
138
+ Expect(pPict.providers.DynamicMetaLists.getList('Genres').map((pEntry) => pEntry.id)).to.deep.equal([ 'History', 'Mystery', 'Poetry', 'Science' ]);
139
+ Expect(pPict.providers.DynamicMetaLists.getList('Books').length).to.equal(7);
140
+ }, fDone);
141
+ });
142
+
143
+ test('with nothing chosen every value is offered (records missing a value are skipped)', (fDone) =>
144
+ {
145
+ bootstrap(makeApplication(), (pPict, pView) =>
146
+ {
147
+ Expect(offered(pPict, pView, 'Author', 0)).to.deep.equal([ 'Christie', 'Rilke', 'Sagan', 'Simenon' ]);
148
+ }, fDone);
149
+ });
150
+
151
+ test('a SkipEmpty PickList skips records without the value and does not log them', (fDone) =>
152
+ {
153
+ bootstrap(makeApplication(), (pPict) =>
154
+ {
155
+ const tmpErrors = [];
156
+ const tmpOriginalError = pPict.log.error;
157
+ pPict.log.error = (pMessage) => tmpErrors.push(pMessage);
158
+ pPict.providers.DynamicMetaLists.rebuildListByHash('Authors');
159
+ pPict.providers.DynamicMetaLists.rebuildListByHash('Genres');
160
+ pPict.log.error = tmpOriginalError;
161
+ Expect(pPict.providers.DynamicMetaLists.getList('Authors').length).to.equal(4);
162
+ Expect(tmpErrors.filter((pMessage) => String(pMessage).includes('[Authors]'))).to.deep.equal([]);
163
+ }, fDone);
164
+ });
165
+
166
+ test('a row\'s list is narrowed by the other choices in that row only', (fDone) =>
167
+ {
168
+ bootstrap(makeApplication(), (pPict, pView) =>
169
+ {
170
+ change(pPict, pView, 'Genre', 0, 'Mystery');
171
+ Expect(offered(pPict, pView, 'Author', 0)).to.deep.equal([ 'Christie', 'Simenon' ]);
172
+ Expect(offered(pPict, pView, 'Book', 0)).to.deep.equal([ '1', '2', '3' ]);
173
+ Expect(offered(pPict, pView, 'Author', 1)).to.deep.equal([ 'Christie', 'Rilke', 'Sagan', 'Simenon' ]);
174
+ }, fDone);
175
+ });
176
+
177
+ test('narrowing is joint: one join record must agree with every constraint', (fDone) =>
178
+ {
179
+ bootstrap(makeApplication({ AutoFillSingle: false }), (pPict, pView) =>
180
+ {
181
+ change(pPict, pView, 'Author', 0, 'Christie');
182
+ change(pPict, pView, 'Genre', 0, 'Poetry');
183
+ Expect(offered(pPict, pView, 'Book', 0)).to.deep.equal([ '5' ]);
184
+ }, fDone);
185
+ });
186
+
187
+ test('explicit Facets add constraints that are not columns of the row', (fDone) =>
188
+ {
189
+ bootstrap(makeApplication({ Facets: [ { JoinListValueAddress: 'Language', Value: 'EN' } ] }), (pPict, pView) =>
190
+ {
191
+ Expect(offered(pPict, pView, 'Author', 0)).to.deep.equal([ 'Christie', 'Sagan' ]);
192
+ }, fDone);
193
+ });
194
+
195
+ test('explicit Facets compare with an Operator; a bare date compares against the date part', (fDone) =>
196
+ {
197
+ bootstrap(makeApplication({ Facets: [ { JoinListValueAddress: 'InPrintUntil', Operator: 'GE', Value: '2025-01-01' } ] }), (pPict, pView) =>
198
+ {
199
+ Expect(offered(pPict, pView, 'Book', 0)).to.deep.equal([ '1', '2', '4', '5', '6' ]);
200
+ }, fDone);
201
+ });
202
+
203
+ test('a stored value outside the facets is still offered in its own row (KeepCurrentValue)', (fDone) =>
204
+ {
205
+ bootstrap(makeApplication({ Facets: [ { JoinListValueAddress: 'InPrintUntil', Operator: 'GE', Value: '2026-01-01' } ] }, [ { Book: '3' }, {} ]), (pPict, pView) =>
206
+ {
207
+ Expect(offered(pPict, pView, 'Book', 0)).to.include('3');
208
+ Expect(offered(pPict, pView, 'Book', 1)).to.not.include('3');
209
+ }, fDone);
210
+ });
211
+
212
+ test('KeepCurrentValue:false filters a stored value like any other', (fDone) =>
213
+ {
214
+ bootstrap(makeApplication({ KeepCurrentValue: false, Facets: [ { JoinListValueAddress: 'InPrintUntil', Operator: 'GE', Value: '2026-01-01' } ] }, [ { Book: '3' }, {} ]), (pPict, pView) =>
215
+ {
216
+ Expect(offered(pPict, pView, 'Book', 0)).to.not.include('3');
217
+ }, fDone);
218
+ });
219
+
220
+ test('NarrowBy Preceding narrows a list by the columns before it only', (fDone) =>
221
+ {
222
+ bootstrap(makeApplication({ NarrowBy: 'Preceding' }), (pPict, pView) =>
223
+ {
224
+ change(pPict, pView, 'Book', 0, '4');
225
+ Expect(offered(pPict, pView, 'Genre', 0)).to.deep.equal([ 'History', 'Mystery', 'Poetry', 'Science' ]);
226
+ Expect(offered(pPict, pView, 'Author', 0)).to.deep.equal([ 'Sagan' ]);
227
+ }, fDone);
228
+ });
229
+ });
230
+
231
+ suite('Pict-Input-FacetFilter', () =>
232
+ {
233
+ test('a value with exactly one consistent choice is filled in', (fDone) =>
234
+ {
235
+ bootstrap(makeApplication(), (pPict, pView) =>
236
+ {
237
+ change(pPict, pView, 'Book', 1, '4');
238
+ const tmpRow = pView.getTabularRecordData(0, 1);
239
+ Expect(tmpRow.Genre).to.equal('Science');
240
+ Expect(tmpRow.Author).to.equal('Sagan');
241
+ Expect(pView.getTabularRecordData(0, 0).Genre).to.equal(undefined);
242
+ }, fDone);
243
+ });
244
+
245
+ test('an ambiguous choice is left blank', (fDone) =>
246
+ {
247
+ bootstrap(makeApplication(), (pPict, pView) =>
248
+ {
249
+ change(pPict, pView, 'Author', 0, 'Christie');
250
+ const tmpRow = pView.getTabularRecordData(0, 0);
251
+ Expect(tmpRow.Genre || '').to.equal('');
252
+ Expect(tmpRow.Book || '').to.equal('');
253
+ }, fDone);
254
+ });
255
+
256
+ test('fills cascade until nothing is left to infer', (fDone) =>
257
+ {
258
+ bootstrap(makeApplication(), (pPict, pView) =>
259
+ {
260
+ change(pPict, pView, 'Author', 0, 'Simenon');
261
+ const tmpRow = pView.getTabularRecordData(0, 0);
262
+ Expect(tmpRow.Genre).to.equal('Mystery');
263
+ Expect(tmpRow.Book).to.equal('3');
264
+ }, fDone);
265
+ });
266
+
267
+ test('a change keeps the changed value and clears siblings it contradicts', (fDone) =>
268
+ {
269
+ bootstrap(makeApplication({ NarrowBy: 'Preceding' }), (pPict, pView) =>
270
+ {
271
+ change(pPict, pView, 'Book', 0, '4');
272
+ change(pPict, pView, 'Genre', 0, 'Poetry');
273
+ const tmpRow = pView.getTabularRecordData(0, 0);
274
+ Expect(tmpRow.Genre).to.equal('Poetry');
275
+ Expect(tmpRow.Author || '').to.equal('');
276
+ Expect(tmpRow.Book || '').to.equal('');
277
+ }, fDone);
278
+ });
279
+
280
+ test('a sibling still consistent with the change is kept', (fDone) =>
281
+ {
282
+ bootstrap(makeApplication({ NarrowBy: 'Preceding' }), (pPict, pView) =>
283
+ {
284
+ change(pPict, pView, 'Book', 0, '1');
285
+ change(pPict, pView, 'Genre', 0, 'Poetry');
286
+ const tmpRow = pView.getTabularRecordData(0, 0);
287
+ Expect(tmpRow.Author).to.equal('Christie');
288
+ Expect(tmpRow.Book).to.equal('5');
289
+ }, fDone);
290
+ });
291
+
292
+ test('ClearInvalid:false and AutoFillSingle:false leave siblings alone', (fDone) =>
293
+ {
294
+ bootstrap(makeApplication({ ClearInvalid: false, AutoFillSingle: false }), (pPict, pView) =>
295
+ {
296
+ change(pPict, pView, 'Book', 0, '4');
297
+ Expect(pView.getTabularRecordData(0, 0).Genre || '').to.equal('');
298
+ change(pPict, pView, 'Genre', 0, 'Poetry');
299
+ Expect(pView.getTabularRecordData(0, 0).Book).to.equal('4');
300
+ }, fDone);
301
+ });
302
+
303
+ test('CarryFields copies the identified record into the row on a change, and clears with it', (fDone) =>
304
+ {
305
+ bootstrap(makeApplication({ CarryFields: { Lang: 'Language' } }), (pPict, pView) =>
306
+ {
307
+ change(pPict, pView, 'Book', 0, '3');
308
+ Expect(pView.getTabularRecordData(0, 0).Lang).to.equal('FR');
309
+ change(pPict, pView, 'Book', 0, '');
310
+ Expect(pView.getTabularRecordData(0, 0).Lang).to.equal('');
311
+ }, fDone);
312
+ });
313
+
314
+ test('clearing a value the rest of the row still pins down stays cleared', (fDone) =>
315
+ {
316
+ bootstrap(makeApplication(), (pPict, pView) =>
317
+ {
318
+ change(pPict, pView, 'Book', 0, '4');
319
+ change(pPict, pView, 'Book', 0, '');
320
+ const tmpRow = pView.getTabularRecordData(0, 0);
321
+ Expect(tmpRow.Book).to.equal('');
322
+ Expect(tmpRow.Genre).to.equal('Science');
323
+ }, fDone);
324
+ });
325
+
326
+ test('CarryFields leaves a value it cannot pin to one record blank', (fDone) =>
327
+ {
328
+ bootstrap(makeApplication({ CarryFields: { Lang: 'Language' }, AutoFillSingle: false }), (pPict, pView) =>
329
+ {
330
+ change(pPict, pView, 'Author', 0, 'Christie');
331
+ Expect(pView.getTabularRecordData(0, 0).Lang).to.equal('');
332
+ }, fDone);
333
+ });
334
+
335
+ test('carried values on a saved row are kept when the form opens', (fDone) =>
336
+ {
337
+ bootstrap(makeApplication({ CarryFields: { Lang: 'Language' } }, [ { Genre: 'Mystery', Author: 'Simenon', Book: '3', Lang: 'saved' } ]), (pPict, pView) =>
338
+ {
339
+ Expect(pView.getTabularRecordData(0, 0).Lang).to.equal('saved');
340
+ }, fDone);
341
+ });
342
+
343
+ test('opening a form with saved values does not rewrite them', (fDone) =>
344
+ {
345
+ bootstrap(makeApplication(null, [ { Genre: 'Poetry', Author: 'Sagan', Book: '4' } ]), (pPict, pView) =>
346
+ {
347
+ Expect(pView.getTabularRecordData(0, 0)).to.deep.equal({ Genre: 'Poetry', Author: 'Sagan', Book: '4' });
348
+ }, fDone);
349
+ });
350
+ });
351
+
352
+ suite('Form-level InitialBundle from settings.DefaultFormManifest', () =>
353
+ {
354
+ test('runs before the form bootstraps, so form-level PickLists see its data', (fDone) =>
355
+ {
356
+ const tmpApp = makeApplication();
357
+ const tmpConfiguration = tmpApp.default_configuration.pict_configuration;
358
+ tmpConfiguration.DefaultFormManifest.InitialBundle =
359
+ [
360
+ {
361
+ Type: 'ProjectDataset',
362
+ InputRecordsetAddress: 'AppData.Catalog',
363
+ OutputRecordsetAddress: 'AppData.Projected',
364
+ RecordPrototypeAddress: 'OutputRecordset[]<<~?IDBook,==,{~D:InputRecord.IDBook~}?~>>',
365
+ RecordFieldMapping: { Default: { 'InputRecord.IDBook': 'OutputRecord.IDBook', 'InputRecord.Author': 'OutputRecord.Writer' } }
366
+ }
367
+ ];
368
+ tmpConfiguration.DefaultFormManifest.PickLists.push({ Hash: 'Writers', ListAddress: 'Writers', ListSourceAddress: 'AppData.Projected', ListSourceAddressGlobal: true, IDTemplate: '{~D:Record.Writer~}', TextTemplate: '{~D:Record.Writer~}', Unique: true, Sorted: true });
369
+ bootstrap(tmpApp, (pPict) =>
370
+ {
371
+ Expect(pPict.AppData.Projected.length).to.equal(7);
372
+ Expect(pPict.providers.DynamicMetaLists.getList('Writers').map((pEntry) => pEntry.id)).to.deep.equal([ 'Christie', 'Rilke', 'Sagan', 'Simenon' ]);
373
+ }, fDone);
374
+ });
375
+ });