pict-section-form 1.0.154 → 1.0.155
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
CHANGED
|
@@ -370,7 +370,14 @@ class PictDynamicSolver extends libPictProvider
|
|
|
370
370
|
|
|
371
371
|
// Now sort the ordinal container keys
|
|
372
372
|
let tmpOrdinalKeys = Object.keys(tmpOrdinalsToSolve);
|
|
373
|
-
tmpOrdinalKeys.sort()
|
|
373
|
+
tmpOrdinalKeys.sort((a, b) =>
|
|
374
|
+
{
|
|
375
|
+
if (isNaN(Number(a)) || isNaN(Number(b)))
|
|
376
|
+
{
|
|
377
|
+
return a.localeCompare(b);
|
|
378
|
+
}
|
|
379
|
+
return Number(a) - Number(b);
|
|
380
|
+
});
|
|
374
381
|
|
|
375
382
|
// Now enumerate the keys and solve each layer of the solution set
|
|
376
383
|
for (let i = 0; i < tmpOrdinalKeys.length; i++)
|
|
@@ -50,6 +50,46 @@ class DoNothingView extends libPictView
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
class OrderedSolverApplication extends DoNothingApplication
|
|
54
|
+
{
|
|
55
|
+
constructor(pFable, pOptions, pServiceHash)
|
|
56
|
+
{
|
|
57
|
+
super(pFable, pOptions, pServiceHash);
|
|
58
|
+
|
|
59
|
+
this.pict.AppData.A = '5';
|
|
60
|
+
this.pict.AppData.B = '3';
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
onAfterSolve()
|
|
64
|
+
{
|
|
65
|
+
super.onAfterSolve();
|
|
66
|
+
this.pict.log.info('OrderedSolverApplication onAfterSolve called.');
|
|
67
|
+
this?._testDone?.();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
onAfterInitialize()
|
|
71
|
+
{
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
OrderedSolverApplication.default_configuration.pict_configuration.DefaultFormManifest =
|
|
76
|
+
{
|
|
77
|
+
Scope: 'OrderedSolverApplicationForm',
|
|
78
|
+
Descriptors: {},
|
|
79
|
+
Sections:
|
|
80
|
+
[
|
|
81
|
+
{
|
|
82
|
+
Name: 'Ordered Solver Section',
|
|
83
|
+
Hash: 'OrderedSolverSection',
|
|
84
|
+
Solvers:
|
|
85
|
+
[
|
|
86
|
+
{ Ordinal: 5, Expression: 'C = A + B' },
|
|
87
|
+
{ Ordinal: 40, Expression: 'D = C - B' },
|
|
88
|
+
],
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
};
|
|
92
|
+
|
|
53
93
|
suite
|
|
54
94
|
(
|
|
55
95
|
'PictSectionForm Basic',
|
|
@@ -137,6 +177,66 @@ suite
|
|
|
137
177
|
|
|
138
178
|
_Pict.PictApplication.testDone = fDone;
|
|
139
179
|
|
|
180
|
+
_Pict.PictApplication.initializeAsync(
|
|
181
|
+
function (pError)
|
|
182
|
+
{
|
|
183
|
+
if (pError)
|
|
184
|
+
{
|
|
185
|
+
console.log('Error initializing the pict application: '+pError)
|
|
186
|
+
}
|
|
187
|
+
_Pict.log.info('Loading the Application and associated views.');
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
);
|
|
191
|
+
test(
|
|
192
|
+
'Solve Ordinals',
|
|
193
|
+
(fDone) =>
|
|
194
|
+
{
|
|
195
|
+
//NOTE: code is a clone of Pict.safeLoadPictApplication
|
|
196
|
+
let _Pict;
|
|
197
|
+
const tmpApplicationClass = OrderedSolverApplication;
|
|
198
|
+
if (tmpApplicationClass && ('default_configuration' in tmpApplicationClass) && ('pict_configuration' in tmpApplicationClass.default_configuration))
|
|
199
|
+
{
|
|
200
|
+
_Pict = new libPict(tmpApplicationClass.default_configuration.pict_configuration);
|
|
201
|
+
}
|
|
202
|
+
else
|
|
203
|
+
{
|
|
204
|
+
_Pict = new libPict();
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
//_Pict.LogNoisiness = 0;
|
|
208
|
+
|
|
209
|
+
let tmpApplicationHash = 'DefaultApplication';
|
|
210
|
+
let tmpDefaultConfiguration = {};
|
|
211
|
+
|
|
212
|
+
if ('default_configuration' in tmpApplicationClass)
|
|
213
|
+
{
|
|
214
|
+
tmpDefaultConfiguration = tmpApplicationClass.default_configuration;
|
|
215
|
+
|
|
216
|
+
if ('Hash' in tmpApplicationClass.default_configuration)
|
|
217
|
+
{
|
|
218
|
+
tmpDefaultConfiguration = tmpApplicationClass.default_configuration;
|
|
219
|
+
tmpApplicationHash = tmpApplicationClass.default_configuration.Hash;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
_Pict.log.info(`Loading the pict application [${tmpApplicationHash}] and associated views.`);
|
|
223
|
+
|
|
224
|
+
_Pict.addApplication(tmpApplicationHash, tmpDefaultConfiguration, tmpApplicationClass);
|
|
225
|
+
|
|
226
|
+
_Pict.PictApplication.testDone = () =>
|
|
227
|
+
{
|
|
228
|
+
try
|
|
229
|
+
{
|
|
230
|
+
Expect(_Pict.AppData.C).to.equal('8', 'C should equal 8 (A + B)');
|
|
231
|
+
Expect(_Pict.AppData.D).to.equal('5', 'D should equal 5 (C - B)');
|
|
232
|
+
}
|
|
233
|
+
catch (pError)
|
|
234
|
+
{
|
|
235
|
+
return fDone(pError);
|
|
236
|
+
}
|
|
237
|
+
fDone();
|
|
238
|
+
};
|
|
239
|
+
|
|
140
240
|
_Pict.PictApplication.initializeAsync(
|
|
141
241
|
function (pError)
|
|
142
242
|
{
|