pict-section-form 1.0.159 → 1.0.160
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/source/application/Pict-Application-Form.js +1 -0
- package/source/providers/Pict-Provider-DynamicSolver.js +131 -9
- package/source/providers/inputs/Pict-Provider-Input-Chart.js +2 -2
- package/source/views/Pict-View-Form-Metacontroller.js +2 -2
- package/test/PictSectionForm-Basic_tests.js +3 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pict-section-form",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.160",
|
|
4
4
|
"description": "Pict dynamic form sections",
|
|
5
5
|
"main": "source/Pict-Section-Form.js",
|
|
6
6
|
"directories": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"browser-env": "^3.3.0",
|
|
35
35
|
"eslint": "^9.39.1",
|
|
36
36
|
"jquery": "^3.7.1",
|
|
37
|
-
"pict": "^1.0.
|
|
37
|
+
"pict": "^1.0.341",
|
|
38
38
|
"pict-application": "^1.0.29",
|
|
39
39
|
"pict-service-commandlineutility": "^1.0.16",
|
|
40
40
|
"quackage": "^1.0.45",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"pict-provider": "^1.0.6",
|
|
49
49
|
"pict-section-tuigrid": "^1.0.27",
|
|
50
50
|
"pict-template": "^1.0.13",
|
|
51
|
-
"pict-view": "^1.0.
|
|
51
|
+
"pict-view": "^1.0.64"
|
|
52
52
|
},
|
|
53
53
|
"mocha": {
|
|
54
54
|
"diff": true,
|
|
@@ -78,7 +78,117 @@ class PictDynamicSolver extends libPictProvider
|
|
|
78
78
|
this.pict.addProviderSingleton('Pict-Input-Chart', libInputChart.default_configuration, libInputChart);
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
logSolveOutcome(pSolveOutcome)
|
|
82
|
+
{
|
|
83
|
+
let tmpSolveOutcome = pSolveOutcome;
|
|
84
|
+
if (typeof(tmpSolveOutcome) !== 'object' || tmpSolveOutcome === null)
|
|
85
|
+
{
|
|
86
|
+
tmpSolveOutcome = this.lastSolveOutcome;
|
|
87
|
+
}
|
|
88
|
+
if (typeof(tmpSolveOutcome) !== 'object' || tmpSolveOutcome === null)
|
|
89
|
+
{
|
|
90
|
+
this.log.error(`DynamicSolver [${this.UUID}]::[${this.Hash}] No solve outcome available to log.`);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
let tmpSolversRun = tmpSolveOutcome.SolverResultsMap.ExecutedSolvers.length;
|
|
95
|
+
|
|
96
|
+
this.log.info(`DynamicSolver completed solving ${tmpSolversRun} solvers in ${tmpSolveOutcome.EndTimeStamp - tmpSolveOutcome.StartTimeStamp} ms.`);
|
|
97
|
+
|
|
98
|
+
for (let i = 0; i < tmpSolveOutcome.SolverResultsMap.ExecutedSolvers.length; i++)
|
|
99
|
+
{
|
|
100
|
+
let tmpSolver = tmpSolveOutcome.SolverResultsMap.ExecutedSolvers[i];
|
|
101
|
+
this.log.info(` Solver [${tmpSolver.Hash}] Ordinal ${tmpSolver.Ordinal} executed in ${tmpSolver.EndTimeStamp - tmpSolver.StartTimeStamp}ms solving for [${tmpSolver?.ResultsObject?.PostfixedAssignmentAddress}] expression [${tmpSolver.Expression}]`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Prepares the solver results map by ensuring it has the necessary structure.
|
|
107
|
+
*
|
|
108
|
+
* @param {Object} pSolverResultsMap - The solver results map to prepare.
|
|
109
|
+
* @returns {Object} - The prepared solver results map.
|
|
110
|
+
*/
|
|
111
|
+
prepareSolverResultsMap(pSolverResultsMap)
|
|
112
|
+
{
|
|
113
|
+
let tmpSolverResultsMap = pSolverResultsMap;
|
|
114
|
+
if (typeof(tmpSolverResultsMap) !== 'object' || tmpSolverResultsMap === null)
|
|
115
|
+
{
|
|
116
|
+
tmpSolverResultsMap = {};
|
|
117
|
+
}
|
|
118
|
+
if (!('ExecutedSolvers' in tmpSolverResultsMap))
|
|
119
|
+
{
|
|
120
|
+
tmpSolverResultsMap.ExecutedSolvers = [];
|
|
121
|
+
}
|
|
122
|
+
if (!('SolverResolutionMap' in tmpSolverResultsMap))
|
|
123
|
+
{
|
|
124
|
+
tmpSolverResultsMap.SolverResolutionMap = {};
|
|
125
|
+
}
|
|
126
|
+
return tmpSolverResultsMap;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Backfills solver dependencies into the solve outcome.
|
|
131
|
+
*
|
|
132
|
+
* @param {Object} pSolveOutcome - The solve outcome object.
|
|
133
|
+
* @returns {Object} - The updated solve outcome with backfilled dependencies.
|
|
134
|
+
*/
|
|
135
|
+
backfillSolverDependencies(pSolveOutcome)
|
|
136
|
+
{
|
|
137
|
+
let tmpSolveOutcome = pSolveOutcome;
|
|
138
|
+
|
|
139
|
+
if (typeof(tmpSolveOutcome) !== 'object' || tmpSolveOutcome === null)
|
|
140
|
+
{
|
|
141
|
+
tmpSolveOutcome = this.lastSolveOutcome;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (typeof(tmpSolveOutcome) !== 'object' || tmpSolveOutcome === null)
|
|
145
|
+
{
|
|
146
|
+
this.log.error(`DynamicSolver [${this.UUID}]::[${this.Hash}] No solve outcome available to backfill solver dependencies.`);
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
for (let i = 0; i < tmpSolveOutcome.SolverResultsMap.ExecutedSolvers.length; i++)
|
|
151
|
+
{
|
|
152
|
+
let tmpSolver = tmpSolveOutcome.SolverResultsMap.ExecutedSolvers[i];
|
|
153
|
+
if (('ResultsObject' in tmpSolver) && (typeof(tmpSolver.ResultsObject) === 'object') && (tmpSolver.ResultsObject !== null))
|
|
154
|
+
{
|
|
155
|
+
// Now fill any dependencies from the results object
|
|
156
|
+
// If the Postfixed Assignment Address is "Result" it hasn't been set and we will ignore it.
|
|
157
|
+
if (tmpSolver.ResultsObject.PostfixedAssignmentAddress && (tmpSolver.ResultsObject.PostfixedAssignmentAddress != 'Result'))
|
|
158
|
+
{
|
|
159
|
+
if (typeof(tmpSolveOutcome.SolverResultsMap.SolverResolutionMap[tmpSolver.ResultsObject.PostfixedAssignmentAddress]) !== 'object')
|
|
160
|
+
{
|
|
161
|
+
tmpSolveOutcome.SolverResultsMap.SolverResolutionMap[tmpSolver.ResultsObject.PostfixedAssignmentAddress] = {};
|
|
162
|
+
}
|
|
163
|
+
// Go through the postfixed list and pull out any symbols being assigned
|
|
164
|
+
for (let j = 0; j < tmpSolver.ResultsObject.PostfixTokenObjects.length; j++)
|
|
165
|
+
{
|
|
166
|
+
let tmpTokenObject = tmpSolver.ResultsObject.PostfixTokenObjects[j];
|
|
167
|
+
if (tmpTokenObject.Type == 'Token.Symbol')
|
|
168
|
+
{
|
|
169
|
+
if (!(tmpTokenObject.Token in tmpSolveOutcome.SolverResultsMap.SolverResolutionMap[tmpSolver.ResultsObject.PostfixedAssignmentAddress]))
|
|
170
|
+
{
|
|
171
|
+
tmpSolveOutcome.SolverResultsMap.SolverResolutionMap[tmpSolver.ResultsObject.PostfixedAssignmentAddress][tmpTokenObject.Token] = 0;
|
|
172
|
+
}
|
|
173
|
+
tmpSolveOutcome.SolverResultsMap.SolverResolutionMap[tmpSolver.ResultsObject.PostfixedAssignmentAddress][tmpTokenObject.Token] = tmpSolveOutcome.SolverResultsMap.SolverResolutionMap[tmpSolver.ResultsObject.PostfixedAssignmentAddress][tmpTokenObject.Token] + 1;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return tmpSolveOutcome;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Runs a manual solver expression against the dynamic view marshal destination or the application data.
|
|
186
|
+
*
|
|
187
|
+
* @param {string} pSolverExpression - The solver expression to run.
|
|
188
|
+
* @param {boolean} [pSilent=false] - Whether to suppress debug logging output.
|
|
189
|
+
* @returns {any} - The result of the solver expression.
|
|
190
|
+
*/
|
|
191
|
+
runSolver(pSolverExpression, pSilent = false)
|
|
82
192
|
{
|
|
83
193
|
let tmpViewMarshalDestinationObject = this.pict.resolveStateFromAddress(this.pict.views.PictFormMetacontroller.viewMarshalDestination);
|
|
84
194
|
|
|
@@ -95,7 +205,10 @@ class PictDynamicSolver extends libPictProvider
|
|
|
95
205
|
delete tmpResultsObject.fable;
|
|
96
206
|
}
|
|
97
207
|
|
|
98
|
-
|
|
208
|
+
if (!pSilent)
|
|
209
|
+
{
|
|
210
|
+
this.pict.log.trace(`Manual solve executed for expression: ${pSolverExpression}`, tmpResultsObject);
|
|
211
|
+
}
|
|
99
212
|
|
|
100
213
|
return tmpSolutionValue;
|
|
101
214
|
}
|
|
@@ -147,11 +260,13 @@ class PictDynamicSolver extends libPictProvider
|
|
|
147
260
|
*
|
|
148
261
|
* @param {array} pGroupSolverArray - An array of Solvers from the groups to solve.
|
|
149
262
|
* @param {number} pOrdinal - The ordinal value to filter to. Optional.
|
|
263
|
+
* @param {Object} pSolverResultsMap - The solver results map.
|
|
150
264
|
*/
|
|
151
|
-
executeGroupSolvers(pGroupSolverArray, pOrdinal)
|
|
265
|
+
executeGroupSolvers(pGroupSolverArray, pOrdinal, pSolverResultsMap)
|
|
152
266
|
{
|
|
153
267
|
// This is purely for readability of the code below ... uglify optimizes it out.
|
|
154
268
|
let tmpFiltered = (typeof(pOrdinal) === 'undefined') ? false : true;
|
|
269
|
+
let tmpSolverReultsMap = this.prepareSolverResultsMap(pSolverResultsMap);
|
|
155
270
|
|
|
156
271
|
// Solve the group RecordSet solvers first
|
|
157
272
|
for (let j = 0; j < pGroupSolverArray.length; j++)
|
|
@@ -201,6 +316,7 @@ class PictDynamicSolver extends libPictProvider
|
|
|
201
316
|
}
|
|
202
317
|
}
|
|
203
318
|
}
|
|
319
|
+
tmpSolverReultsMap.ExecutedSolvers.push(tmpSolver);
|
|
204
320
|
tmpSolver.EndTimeStamp = Date.now();
|
|
205
321
|
}
|
|
206
322
|
}
|
|
@@ -210,10 +326,12 @@ class PictDynamicSolver extends libPictProvider
|
|
|
210
326
|
*
|
|
211
327
|
* @param {Array} pViewSectionSolverArray - The array of view section solvers.
|
|
212
328
|
* @param {number} pOrdinal - The ordinal value.
|
|
329
|
+
* @param {Object} pSolverResultsMap - The solver results map.
|
|
213
330
|
*/
|
|
214
|
-
executeSectionSolvers(pViewSectionSolverArray, pOrdinal)
|
|
331
|
+
executeSectionSolvers(pViewSectionSolverArray, pOrdinal, pSolverResultsMap)
|
|
215
332
|
{
|
|
216
333
|
let tmpFiltered = (typeof(pOrdinal) === 'undefined') ? false : true;
|
|
334
|
+
let tmpSolverReultsMap = this.prepareSolverResultsMap(pSolverResultsMap);
|
|
217
335
|
|
|
218
336
|
for (let i = 0; i < pViewSectionSolverArray.length; i++)
|
|
219
337
|
{
|
|
@@ -234,11 +352,11 @@ class PictDynamicSolver extends libPictProvider
|
|
|
234
352
|
}
|
|
235
353
|
tmpSolver.ResultsObject = {};
|
|
236
354
|
let tmpSolutionValue = tmpView.fable.ExpressionParser.solve(tmpSolver.Expression, tmpView.getMarshalDestinationObject(), tmpSolver.ResultsObject, this.pict.manifest, tmpView.getMarshalDestinationObject());
|
|
237
|
-
//let tmpSolutionValue = tmpView.fable.ExpressionParser.solve(tmpSolver.Expression, tmpView.getMarshalDestinationObject(), tmpSolver.ResultsObject, tmpView.sectionManifest, tmpView.getMarshalDestinationObject());
|
|
238
355
|
if (this.pict.LogNoisiness > 1)
|
|
239
356
|
{
|
|
240
357
|
tmpView.log.trace(`[${tmpSolver.Expression}] result was ${tmpSolutionValue}`);
|
|
241
358
|
}
|
|
359
|
+
tmpSolverReultsMap.ExecutedSolvers.push(tmpSolver);
|
|
242
360
|
tmpSolver.EndTimeStamp = +new Date();
|
|
243
361
|
}
|
|
244
362
|
}
|
|
@@ -248,10 +366,12 @@ class PictDynamicSolver extends libPictProvider
|
|
|
248
366
|
*
|
|
249
367
|
* @param {Array} pViewSolverArray - The array of view solvers to execute.
|
|
250
368
|
* @param {number} pOrdinal - The ordinal value.
|
|
369
|
+
* @param {Object} pSolverResultsMap - The solver results map.
|
|
251
370
|
*/
|
|
252
|
-
executeViewSolvers(pViewSolverArray, pOrdinal)
|
|
371
|
+
executeViewSolvers(pViewSolverArray, pOrdinal, pSolverResultsMap)
|
|
253
372
|
{
|
|
254
373
|
let tmpFiltered = (typeof(pOrdinal) === 'undefined') ? false : true;
|
|
374
|
+
let tmpSolverReultsMap = this.prepareSolverResultsMap(pSolverResultsMap);
|
|
255
375
|
|
|
256
376
|
for (let i = 0; i < pViewSolverArray.length; i++)
|
|
257
377
|
{
|
|
@@ -269,6 +389,7 @@ class PictDynamicSolver extends libPictProvider
|
|
|
269
389
|
}
|
|
270
390
|
// Solve with the normal view solve() pipeline
|
|
271
391
|
tmpView.solve();
|
|
392
|
+
tmpSolverReultsMap.ExecutedSolvers.push(tmpSolver);
|
|
272
393
|
tmpSolver.EndTimeStamp = +new Date();
|
|
273
394
|
}
|
|
274
395
|
}
|
|
@@ -319,6 +440,7 @@ class PictDynamicSolver extends libPictProvider
|
|
|
319
440
|
let tmpViewHashes = Array.isArray(pViewHashes) ? pViewHashes : Object.keys(this.fable.views);
|
|
320
441
|
|
|
321
442
|
let tmpSolveOutcome = {};
|
|
443
|
+
tmpSolveOutcome.SolverResultsMap = {};
|
|
322
444
|
tmpSolveOutcome.StartTimeStamp = +new Date();
|
|
323
445
|
tmpSolveOutcome.ViewHashes = tmpViewHashes;
|
|
324
446
|
|
|
@@ -387,9 +509,9 @@ class PictDynamicSolver extends libPictProvider
|
|
|
387
509
|
this.log.trace(`DynamicSolver [${this.UUID}]::[${this.Hash}] Solving ordinal ${tmpOrdinalKeys[i]}`);
|
|
388
510
|
}
|
|
389
511
|
let tmpOrdinalContainer = tmpOrdinalsToSolve[tmpOrdinalKeys[i]];
|
|
390
|
-
this.executeGroupSolvers(tmpOrdinalContainer.GroupSolvers, Number(tmpOrdinalKeys[i]));
|
|
391
|
-
this.executeSectionSolvers(tmpOrdinalContainer.SectionSolvers, Number(tmpOrdinalKeys[i]));
|
|
392
|
-
this.executeViewSolvers(tmpOrdinalContainer.ViewSolvers, Number(tmpOrdinalKeys[i]));
|
|
512
|
+
this.executeGroupSolvers(tmpOrdinalContainer.GroupSolvers, Number(tmpOrdinalKeys[i]), tmpSolveOutcome.SolverResultsMap);
|
|
513
|
+
this.executeSectionSolvers(tmpOrdinalContainer.SectionSolvers, Number(tmpOrdinalKeys[i]), tmpSolveOutcome.SolverResultsMap);
|
|
514
|
+
this.executeViewSolvers(tmpOrdinalContainer.ViewSolvers, Number(tmpOrdinalKeys[i]), tmpSolveOutcome.SolverResultsMap);
|
|
393
515
|
}
|
|
394
516
|
|
|
395
517
|
// Now regenerate the metalists .. after the solve has happened.
|
|
@@ -380,7 +380,7 @@ class CustomInputHandler extends libPictSectionInputExtension
|
|
|
380
380
|
break;
|
|
381
381
|
}
|
|
382
382
|
|
|
383
|
-
let tmpSolvedConfiguration = this.pict.providers.DynamicSolver.runSolver(tmpSolverExpression);
|
|
383
|
+
let tmpSolvedConfiguration = this.pict.providers.DynamicSolver.runSolver(tmpSolverExpression, true);
|
|
384
384
|
|
|
385
385
|
if (tmpParsingConfiguration.ObjectType === 'array')
|
|
386
386
|
{
|
|
@@ -466,7 +466,7 @@ class CustomInputHandler extends libPictSectionInputExtension
|
|
|
466
466
|
|
|
467
467
|
let tmpSolverLabel = tmpCurrentSolverExpression.Label;
|
|
468
468
|
let tmpSolverExpression = tmpCurrentSolverExpression.DataSolver;
|
|
469
|
-
let tmpSolvedDataSet = this.pict.providers.DynamicSolver.runSolver(tmpSolverExpression);
|
|
469
|
+
let tmpSolvedDataSet = this.pict.providers.DynamicSolver.runSolver(tmpSolverExpression, true);
|
|
470
470
|
|
|
471
471
|
let tmpDataObject = (
|
|
472
472
|
{
|
|
@@ -178,9 +178,9 @@ class PictFormMetacontroller extends libPictViewClass
|
|
|
178
178
|
return super.onSolve();
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
-
runSolver(pExpression)
|
|
181
|
+
runSolver(pExpression, pSilent)
|
|
182
182
|
{
|
|
183
|
-
this.pict.providers.DynamicSolver.runSolver(pExpression);
|
|
183
|
+
this.pict.providers.DynamicSolver.runSolver(pExpression, pSilent);
|
|
184
184
|
}
|
|
185
185
|
|
|
186
186
|
onBeforeFilterViews(pViewFilterState)
|