pict-section-form 1.0.138 → 1.0.140
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/docs/input_providers/009-chart.md +209 -0
- package/example_applications/complex_table/Complex-Tabular-Application.js +265 -120
- package/example_applications/complex_table/html/index.html +1 -0
- package/example_applications/complex_table/package.json +8 -2
- package/package.json +2 -2
- package/source/providers/Pict-Provider-DynamicSolver.js +17 -1
- package/source/providers/dynamictemplates/Pict-DynamicTemplates-DefaultFormTemplates.js +12 -0
- package/source/providers/inputs/Pict-Provider-Input-Chart.js +726 -0
- package/source/providers/layouts/Pict-Layout-Record.js +50 -1
- package/source/views/Pict-View-Form-Metacontroller.js +1 -1
- package/types/source/providers/Pict-Provider-DynamicSolver.d.ts +1 -0
- package/types/source/providers/Pict-Provider-DynamicSolver.d.ts.map +1 -1
- package/types/source/providers/inputs/Pict-Provider-Input-Chart.d.ts +103 -0
- package/types/source/providers/inputs/Pict-Provider-Input-Chart.d.ts.map +1 -0
- package/types/source/providers/layouts/Pict-Layout-Record.d.ts.map +1 -1
- package/types/source/views/support/Pict-View-PSF-SupportBase.d.ts.map +1 -1
|
@@ -0,0 +1,726 @@
|
|
|
1
|
+
const libPictSectionInputExtension = require('../Pict-Provider-InputExtension.js');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* CustomInputHandler class.
|
|
5
|
+
*
|
|
6
|
+
* @class
|
|
7
|
+
* @extends libPictSectionInputExtension
|
|
8
|
+
* @memberof providers.inputs
|
|
9
|
+
*/
|
|
10
|
+
class CustomInputHandler extends libPictSectionInputExtension
|
|
11
|
+
{
|
|
12
|
+
constructor(pFable, pOptions, pServiceHash)
|
|
13
|
+
{
|
|
14
|
+
super(pFable, pOptions, pServiceHash);
|
|
15
|
+
|
|
16
|
+
/** @type {import('pict')} */
|
|
17
|
+
this.pict;
|
|
18
|
+
/** @type {import('pict')} */
|
|
19
|
+
this.fable;
|
|
20
|
+
/** @type {any} */
|
|
21
|
+
this.log;
|
|
22
|
+
|
|
23
|
+
// Manage the the configuration parsing configurations -- these can be overridden in the object or even per-input
|
|
24
|
+
if (!this.options.DefaultCoreParsingConfiguration || !Array.isArray(this.options.DefaultCoreParsingConfiguration))
|
|
25
|
+
{
|
|
26
|
+
this.options.DefaultCoreParsingConfiguration = (
|
|
27
|
+
{
|
|
28
|
+
AddressInObject: '',
|
|
29
|
+
ObjectType: 'object',
|
|
30
|
+
MergeMethod: 'Object',
|
|
31
|
+
Steps: [
|
|
32
|
+
{
|
|
33
|
+
InputProperty: false,
|
|
34
|
+
Method: `Initialize`,
|
|
35
|
+
Merge: false
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
InputProperty: 'PictForm.ChartConfigCorePrototypeRaw',
|
|
39
|
+
Method: `Raw`,
|
|
40
|
+
Merge: true
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
InputProperty: 'PictForm.ChartConfigCorePrototypeAddress',
|
|
44
|
+
Method: `Address`,
|
|
45
|
+
Merge: true
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
InputProperty: `PictForm.ChartConfigCorePrototype`,
|
|
49
|
+
Method: 'SingleSolver',
|
|
50
|
+
Merge: true
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
this.defaultCoreParsingConfiguration = JSON.parse(JSON.stringify(this.options.DefaultCoreParsingConfiguration));
|
|
56
|
+
|
|
57
|
+
if (typeof (this.options.DefaultLabelParsingConfiguration) !== 'object' || !Array.isArray(this.options.DefaultLabelParsingConfiguration.Steps))
|
|
58
|
+
{
|
|
59
|
+
this.options.DefaultLabelParsingConfiguration = (
|
|
60
|
+
{
|
|
61
|
+
AddressInObject: 'data.labels',
|
|
62
|
+
ObjectType: 'array',
|
|
63
|
+
MergeMethod: 'Array',
|
|
64
|
+
Steps: [
|
|
65
|
+
{
|
|
66
|
+
InputProperty: false,
|
|
67
|
+
Method: `Initialize`,
|
|
68
|
+
Merge: false
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
InputProperty: 'PictForm.ChartLabelsRaw',
|
|
72
|
+
Method: `Raw`,
|
|
73
|
+
Merge: false
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
InputProperty: 'PictForm.ChartLabelsAddress',
|
|
77
|
+
Method: `Address`,
|
|
78
|
+
Merge: false
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
InputProperty: `PictForm.ChartLabelsSolver`,
|
|
82
|
+
Method: 'SingleSolver',
|
|
83
|
+
Merge: false
|
|
84
|
+
}
|
|
85
|
+
]
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
this.defaultLabelParsingConfiguration = JSON.parse(JSON.stringify(this.options.DefaultLabelParsingConfiguration));
|
|
89
|
+
|
|
90
|
+
if (typeof (this.options.DefaultDataParsingConfiguration) !== 'object' || !Array.isArray(this.options.DefaultDataParsingConfiguration.Steps))
|
|
91
|
+
{
|
|
92
|
+
this.options.DefaultDataParsingConfiguration = (
|
|
93
|
+
{
|
|
94
|
+
AddressInObject: 'data.datasets',
|
|
95
|
+
ObjectType: 'array',
|
|
96
|
+
MergeMethod: 'Array',
|
|
97
|
+
Steps: [
|
|
98
|
+
{
|
|
99
|
+
InputProperty: false,
|
|
100
|
+
Method: `Initialize`,
|
|
101
|
+
Merge: false
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
InputProperty: 'PictForm.ChartDatasetsRaw',
|
|
105
|
+
Method: `Raw`,
|
|
106
|
+
Merge: false
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
InputProperty: 'PictForm.ChartDatasetsAddress',
|
|
110
|
+
Method: `Address`,
|
|
111
|
+
Merge: false
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
InputProperty: 'PictForm.ChartDatasetsSolvers',
|
|
115
|
+
Method: `ArrayOfSolvers`,
|
|
116
|
+
Merge: true
|
|
117
|
+
}
|
|
118
|
+
]
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
this.defaultDataParsingConfiguration = JSON.parse(JSON.stringify(this.options.DefaultDataParsingConfiguration));
|
|
122
|
+
|
|
123
|
+
this.currentChartObjects = {};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
*
|
|
128
|
+
* @param {Object} pInput - The PictForm input object
|
|
129
|
+
* @param {*} pChartConfiguration - The current configuration object for the form
|
|
130
|
+
* @param {*} pParsingConfiguration - The parsing configuration to apply
|
|
131
|
+
* @param {*} pInputParsingConfigurationScope - The input-specific parsing configuration string address for additional configuration
|
|
132
|
+
* @returns
|
|
133
|
+
*/
|
|
134
|
+
applyInputParsingConfiguration(pInput, pChartConfiguration, pParsingConfiguration, pInputParsingConfigurationScope)
|
|
135
|
+
{
|
|
136
|
+
// TODO: There is a ton of DRY to be had in this function when we break it out to the base class
|
|
137
|
+
let tmpInput = pInput;
|
|
138
|
+
let tmpInputParsingConfigurationScope = pInputParsingConfigurationScope;
|
|
139
|
+
|
|
140
|
+
let tmpChartConfiguration = pChartConfiguration;
|
|
141
|
+
let tmpParsingConfiguration = pParsingConfiguration;
|
|
142
|
+
|
|
143
|
+
if (typeof (pInput) !== 'object')
|
|
144
|
+
{
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
if (typeof (pInputParsingConfigurationScope) !== 'string' || (pInputParsingConfigurationScope.length < 1))
|
|
148
|
+
{
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
if (typeof (tmpParsingConfiguration) !== 'object')
|
|
152
|
+
{
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (typeof (tmpChartConfiguration) !== 'object')
|
|
157
|
+
{
|
|
158
|
+
tmpChartConfiguration = {};
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// 1. Check if there is any custom configurtion for how to parse the config for this input (dynamic dynamic)
|
|
162
|
+
let tmpInputCustomConfiguration = this.pict.manifest.getValueByHash(tmpInput, tmpInputParsingConfigurationScope);
|
|
163
|
+
if (typeof (tmpInputCustomConfiguration) === 'object')
|
|
164
|
+
{
|
|
165
|
+
// Merge the custom configuration into the base configuration
|
|
166
|
+
tmpParsingConfiguration = Object.assign(tmpParsingConfiguration, tmpInputCustomConfiguration);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// Get existing data
|
|
170
|
+
let tmpExistingData;
|
|
171
|
+
if (!tmpParsingConfiguration.AddressInObject || (tmpParsingConfiguration.AddressInObject == ''))
|
|
172
|
+
{
|
|
173
|
+
tmpExistingData = tmpChartConfiguration;
|
|
174
|
+
}
|
|
175
|
+
else
|
|
176
|
+
{
|
|
177
|
+
tmpExistingData = this.pict.manifest.getValueByHash(tmpChartConfiguration, tmpParsingConfiguration.AddressInObject);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// 2. Enumerate through each step and apply them consistently
|
|
181
|
+
for (let i = 0; i < tmpParsingConfiguration.Steps.length; i++)
|
|
182
|
+
{
|
|
183
|
+
let tmpCurrentStep = tmpParsingConfiguration.Steps[i];
|
|
184
|
+
|
|
185
|
+
switch (tmpCurrentStep.Method)
|
|
186
|
+
{
|
|
187
|
+
case 'Initialize':
|
|
188
|
+
// Do nothing, already initialized
|
|
189
|
+
if (tmpParsingConfiguration.AddressInObject && (typeof (tmpParsingConfiguration.AddressInObject) === 'string') && (tmpParsingConfiguration.AddressInObject.length > 0))
|
|
190
|
+
{
|
|
191
|
+
let tmpCurrentStepData = this.pict.manifest.getValueByHash(tmpChartConfiguration, tmpParsingConfiguration.AddressInObject);
|
|
192
|
+
// see if the address exists and if it's the type we expect
|
|
193
|
+
if (tmpParsingConfiguration.ObjectType === 'array')
|
|
194
|
+
{
|
|
195
|
+
if (!tmpCurrentStepData || !Array.isArray(tmpCurrentStepData))
|
|
196
|
+
{
|
|
197
|
+
this.pict.manifest.setValueByHash(tmpChartConfiguration, tmpParsingConfiguration.AddressInObject, []);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
else if (tmpParsingConfiguration.ObjectType === 'object')
|
|
201
|
+
{
|
|
202
|
+
if (!tmpCurrentStepData || (typeof (tmpCurrentStepData) !== 'object'))
|
|
203
|
+
{
|
|
204
|
+
this.pict.manifest.setValueByHash(tmpChartConfiguration, tmpParsingConfiguration.AddressInObject, {});
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
else
|
|
208
|
+
{
|
|
209
|
+
this.pict.log.warn(`Unsupported ObjectType ${tmpParsingConfiguration.ObjectType} parsing chart Initialize configuration for input ${tmpInput.Macro.RawHTMLID}`);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
break;
|
|
213
|
+
case 'Raw':
|
|
214
|
+
// Check if the Raw is in there
|
|
215
|
+
let tmpRawDataExists = this.pict.manifest.checkAddressExists(tmpInput, tmpCurrentStep.InputProperty);
|
|
216
|
+
if (!tmpRawDataExists)
|
|
217
|
+
{
|
|
218
|
+
break;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// Get the raw data from the input
|
|
222
|
+
let tmpRawData = this.pict.manifest.getValueByHash(tmpInput, tmpCurrentStep.InputProperty);
|
|
223
|
+
let tmpRawDataType = typeof(tmpRawData);
|
|
224
|
+
|
|
225
|
+
// We only support objects as configuration
|
|
226
|
+
if (tmpRawDataType !== 'object')
|
|
227
|
+
{
|
|
228
|
+
break;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
if (tmpParsingConfiguration.ObjectType === 'array')
|
|
232
|
+
{
|
|
233
|
+
if (Array.isArray(tmpRawData))
|
|
234
|
+
{
|
|
235
|
+
if (tmpCurrentStep.Merge)
|
|
236
|
+
{
|
|
237
|
+
// Get existing data
|
|
238
|
+
if (!Array.isArray(tmpExistingData))
|
|
239
|
+
{
|
|
240
|
+
tmpExistingData = [];
|
|
241
|
+
}
|
|
242
|
+
// Merge in the arrays
|
|
243
|
+
let tmpMergedData = tmpExistingData.concat(tmpRawData);
|
|
244
|
+
this.pict.manifest.setValueByHash(tmpChartConfiguration, tmpParsingConfiguration.AddressInObject, tmpMergedData);
|
|
245
|
+
}
|
|
246
|
+
else
|
|
247
|
+
{
|
|
248
|
+
// Just set the value
|
|
249
|
+
this.pict.manifest.setValueByHash(tmpChartConfiguration, tmpParsingConfiguration.AddressInObject, tmpRawData);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
else if (tmpParsingConfiguration.ObjectType === 'object')
|
|
254
|
+
{
|
|
255
|
+
if (tmpCurrentStep.Merge)
|
|
256
|
+
{
|
|
257
|
+
if (!tmpParsingConfiguration.AddressInObject || (tmpParsingConfiguration.AddressInObject == ''))
|
|
258
|
+
{
|
|
259
|
+
// This is the "root" object, so we need to merge or set directly
|
|
260
|
+
if (tmpCurrentStep.Merge)
|
|
261
|
+
{
|
|
262
|
+
tmpChartConfiguration = Object.assign(tmpChartConfiguration, tmpRawData);
|
|
263
|
+
}
|
|
264
|
+
else
|
|
265
|
+
{
|
|
266
|
+
tmpChartConfiguration = tmpRawData;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
else
|
|
270
|
+
{
|
|
271
|
+
if ((typeof(tmpExistingData) != 'object') || (tmpExistingData == null))
|
|
272
|
+
{
|
|
273
|
+
tmpExistingData = {};
|
|
274
|
+
}
|
|
275
|
+
if (tmpCurrentStep.Merge)
|
|
276
|
+
{
|
|
277
|
+
// Merge the objects
|
|
278
|
+
let tmpMergedData = Object.assign(tmpExistingData, tmpRawData);
|
|
279
|
+
this.pict.manifest.setValueByHash(tmpChartConfiguration, tmpParsingConfiguration.AddressInObject, tmpMergedData);
|
|
280
|
+
}
|
|
281
|
+
else
|
|
282
|
+
{
|
|
283
|
+
// Just set the value
|
|
284
|
+
this.pict.manifest.setValueByHash(tmpChartConfiguration, tmpParsingConfiguration.AddressInObject, tmpRawData);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
else
|
|
289
|
+
{
|
|
290
|
+
// Just set the value?
|
|
291
|
+
this.pict.manifest.setValueByHash(tmpChartConfiguration, tmpParsingConfiguration.AddressInObject, tmpRawData);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
break;
|
|
295
|
+
case 'Address':
|
|
296
|
+
let tmpAddress = this.pict.manifest.getValueByHash(tmpInput, tmpCurrentStep.InputProperty);
|
|
297
|
+
// Input is the Record in the resolution chain
|
|
298
|
+
if (!tmpAddress)
|
|
299
|
+
{
|
|
300
|
+
break;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
let tmpPotentialConfigurationObject = this.pict.resolveStateFromAddress(tmpAddress, pInput);
|
|
304
|
+
|
|
305
|
+
if (typeof (tmpPotentialConfigurationObject) !== 'object')
|
|
306
|
+
{
|
|
307
|
+
break;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
if (tmpParsingConfiguration.ObjectType === 'array')
|
|
311
|
+
{
|
|
312
|
+
if (Array.isArray(tmpRawData))
|
|
313
|
+
{
|
|
314
|
+
if (tmpCurrentStep.Merge)
|
|
315
|
+
{
|
|
316
|
+
// Get existing data
|
|
317
|
+
if (!Array.isArray(tmpExistingData))
|
|
318
|
+
{
|
|
319
|
+
tmpExistingData = [];
|
|
320
|
+
}
|
|
321
|
+
// Merge in the arrays
|
|
322
|
+
let tmpMergedData = tmpExistingData.concat(tmpRawData);
|
|
323
|
+
this.pict.manifest.setValueByHash(tmpChartConfiguration, tmpParsingConfiguration.AddressInObject, tmpMergedData);
|
|
324
|
+
}
|
|
325
|
+
else
|
|
326
|
+
{
|
|
327
|
+
// Just set the value
|
|
328
|
+
this.pict.manifest.setValueByHash(tmpChartConfiguration, tmpParsingConfiguration.AddressInObject, tmpRawData);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
else if (tmpParsingConfiguration.ObjectType === 'object')
|
|
333
|
+
{
|
|
334
|
+
if (tmpCurrentStep.Merge)
|
|
335
|
+
{
|
|
336
|
+
if (!tmpParsingConfiguration.AddressInObject || (tmpParsingConfiguration.AddressInObject == ''))
|
|
337
|
+
{
|
|
338
|
+
// This is the "root" object, so we need to merge or set directly
|
|
339
|
+
if (tmpCurrentStep.Merge)
|
|
340
|
+
{
|
|
341
|
+
tmpChartConfiguration = Object.assign(tmpChartConfiguration, tmpRawData);
|
|
342
|
+
}
|
|
343
|
+
else
|
|
344
|
+
{
|
|
345
|
+
tmpChartConfiguration = tmpRawData;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
else
|
|
349
|
+
{
|
|
350
|
+
if ((typeof(tmpExistingData) != 'object') || (tmpExistingData == null))
|
|
351
|
+
{
|
|
352
|
+
tmpExistingData = {};
|
|
353
|
+
}
|
|
354
|
+
if (tmpCurrentStep.Merge)
|
|
355
|
+
{
|
|
356
|
+
// Merge the objects
|
|
357
|
+
let tmpMergedData = Object.assign(tmpExistingData, tmpRawData);
|
|
358
|
+
this.pict.manifest.setValueByHash(tmpChartConfiguration, tmpParsingConfiguration.AddressInObject, tmpMergedData);
|
|
359
|
+
}
|
|
360
|
+
else
|
|
361
|
+
{
|
|
362
|
+
// Just set the value
|
|
363
|
+
this.pict.manifest.setValueByHash(tmpChartConfiguration, tmpParsingConfiguration.AddressInObject, tmpRawData);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
else
|
|
368
|
+
{
|
|
369
|
+
// Just set the value?
|
|
370
|
+
this.pict.manifest.setValueByHash(tmpChartConfiguration, tmpParsingConfiguration.AddressInObject, tmpRawData);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
break;
|
|
374
|
+
case 'SingleSolver':
|
|
375
|
+
let tmpSolverExpression = this.pict.manifest.getValueByHash(tmpInput, tmpCurrentStep.InputProperty);
|
|
376
|
+
// Check that the expression is a string
|
|
377
|
+
if (typeof (tmpSolverExpression) !== 'string')
|
|
378
|
+
{
|
|
379
|
+
break;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
let tmpSolvedConfiguration = this.pict.providers.DynamicSolver.runSolver(tmpSolverExpression);
|
|
383
|
+
|
|
384
|
+
if (tmpParsingConfiguration.ObjectType === 'array')
|
|
385
|
+
{
|
|
386
|
+
if (Array.isArray(tmpSolvedConfiguration))
|
|
387
|
+
{
|
|
388
|
+
if (tmpCurrentStep.Merge)
|
|
389
|
+
{
|
|
390
|
+
// Get existing data
|
|
391
|
+
if (!Array.isArray(tmpExistingData))
|
|
392
|
+
{
|
|
393
|
+
tmpExistingData = [];
|
|
394
|
+
}
|
|
395
|
+
// Merge in the arrays
|
|
396
|
+
let tmpMergedData = tmpExistingData.concat(tmpSolvedConfiguration);
|
|
397
|
+
this.pict.manifest.setValueByHash(tmpChartConfiguration, tmpParsingConfiguration.AddressInObject, tmpMergedData);
|
|
398
|
+
}
|
|
399
|
+
else
|
|
400
|
+
{
|
|
401
|
+
// Just set the value
|
|
402
|
+
this.pict.manifest.setValueByHash(tmpChartConfiguration, tmpParsingConfiguration.AddressInObject, tmpSolvedConfiguration);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
else if (tmpParsingConfiguration.ObjectType === 'object')
|
|
407
|
+
{
|
|
408
|
+
if (tmpCurrentStep.Merge)
|
|
409
|
+
{
|
|
410
|
+
if (!tmpParsingConfiguration.AddressInObject || (tmpParsingConfiguration.AddressInObject == ''))
|
|
411
|
+
{
|
|
412
|
+
// This is the "root" object, so we need to merge or set directly
|
|
413
|
+
if (tmpCurrentStep.Merge)
|
|
414
|
+
{
|
|
415
|
+
tmpChartConfiguration = Object.assign(tmpChartConfiguration, tmpSolvedConfiguration);
|
|
416
|
+
}
|
|
417
|
+
else
|
|
418
|
+
{
|
|
419
|
+
tmpChartConfiguration = tmpSolvedConfiguration;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
else
|
|
423
|
+
{
|
|
424
|
+
if ((typeof(tmpExistingData) != 'object') || (tmpExistingData == null))
|
|
425
|
+
{
|
|
426
|
+
tmpExistingData = {};
|
|
427
|
+
}
|
|
428
|
+
if (tmpCurrentStep.Merge)
|
|
429
|
+
{
|
|
430
|
+
// Merge the objects
|
|
431
|
+
let tmpMergedData = Object.assign(tmpExistingData, tmpSolvedConfiguration);
|
|
432
|
+
this.pict.manifest.setValueByHash(tmpChartConfiguration, tmpParsingConfiguration.AddressInObject, tmpMergedData);
|
|
433
|
+
}
|
|
434
|
+
else
|
|
435
|
+
{
|
|
436
|
+
// Just set the value
|
|
437
|
+
this.pict.manifest.setValueByHash(tmpChartConfiguration, tmpParsingConfiguration.AddressInObject, tmpRawData);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
else
|
|
442
|
+
{
|
|
443
|
+
// Just set the value?
|
|
444
|
+
this.pict.manifest.setValueByHash(tmpChartConfiguration, tmpParsingConfiguration.AddressInObject, tmpRawData);
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
break;
|
|
448
|
+
|
|
449
|
+
case 'ArrayOfSolvers':
|
|
450
|
+
let tmpSolverExpressionList = this.pict.manifest.getValueByHash(tmpInput, tmpCurrentStep.InputProperty);
|
|
451
|
+
|
|
452
|
+
// Check that the expression is a string
|
|
453
|
+
if (!Array.isArray(tmpSolverExpressionList))
|
|
454
|
+
{
|
|
455
|
+
break;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
for (let i = 0; i < tmpSolverExpressionList.length; i++)
|
|
459
|
+
{
|
|
460
|
+
let tmpCurrentSolverExpression = tmpSolverExpressionList[i];
|
|
461
|
+
if (typeof(tmpCurrentSolverExpression) !== 'object')
|
|
462
|
+
{
|
|
463
|
+
continue;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
let tmpSolverLabel = tmpCurrentSolverExpression.Label;
|
|
467
|
+
let tmpSolverExpression = tmpCurrentSolverExpression.DataSolver;
|
|
468
|
+
let tmpSolvedDataSet = this.pict.providers.DynamicSolver.runSolver(tmpSolverExpression);
|
|
469
|
+
|
|
470
|
+
let tmpDataObject = (
|
|
471
|
+
{
|
|
472
|
+
label: tmpSolverLabel,
|
|
473
|
+
data: (Array.isArray(tmpSolvedDataSet)) ? tmpSolvedDataSet : []
|
|
474
|
+
});
|
|
475
|
+
|
|
476
|
+
if (tmpParsingConfiguration.ObjectType === 'array')
|
|
477
|
+
{
|
|
478
|
+
if (Array.isArray(tmpSolvedDataSet))
|
|
479
|
+
{
|
|
480
|
+
if (tmpCurrentStep.Merge)
|
|
481
|
+
{
|
|
482
|
+
// Get existing data
|
|
483
|
+
if (!Array.isArray(tmpExistingData))
|
|
484
|
+
{
|
|
485
|
+
tmpExistingData = [];
|
|
486
|
+
}
|
|
487
|
+
tmpExistingData.push(tmpDataObject);
|
|
488
|
+
this.pict.manifest.setValueByHash(tmpChartConfiguration, tmpParsingConfiguration.AddressInObject, tmpExistingData);
|
|
489
|
+
}
|
|
490
|
+
else
|
|
491
|
+
{
|
|
492
|
+
this.pict.manifest.setValueByHash(tmpChartConfiguration, tmpParsingConfiguration.AddressInObject, [tmpDataObject]);
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
else if (tmpParsingConfiguration.ObjectType === 'object')
|
|
497
|
+
{
|
|
498
|
+
if (tmpCurrentStep.Merge)
|
|
499
|
+
{
|
|
500
|
+
if (!tmpParsingConfiguration.AddressInObject || (tmpParsingConfiguration.AddressInObject == ''))
|
|
501
|
+
{
|
|
502
|
+
// This is the "root" object, so we need to merge or set directly
|
|
503
|
+
if (tmpCurrentStep.Merge)
|
|
504
|
+
{
|
|
505
|
+
tmpChartConfiguration = Object.assign(tmpChartConfiguration, tmpSolvedDataSet);
|
|
506
|
+
}
|
|
507
|
+
else
|
|
508
|
+
{
|
|
509
|
+
tmpChartConfiguration = tmpSolvedDataSet;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
else
|
|
513
|
+
{
|
|
514
|
+
if ((typeof(tmpExistingData) != 'object') || (tmpExistingData == null))
|
|
515
|
+
{
|
|
516
|
+
tmpExistingData = {};
|
|
517
|
+
}
|
|
518
|
+
if (tmpCurrentStep.Merge)
|
|
519
|
+
{
|
|
520
|
+
// Merge the objects
|
|
521
|
+
let tmpMergedData = Object.assign(tmpExistingData, tmpSolvedDataSet);
|
|
522
|
+
this.pict.manifest.setValueByHash(tmpChartConfiguration, tmpParsingConfiguration.AddressInObject, tmpMergedData);
|
|
523
|
+
}
|
|
524
|
+
else
|
|
525
|
+
{
|
|
526
|
+
// Just set the value
|
|
527
|
+
this.pict.manifest.setValueByHash(tmpChartConfiguration, tmpParsingConfiguration.AddressInObject, tmpRawData);
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
else
|
|
532
|
+
{
|
|
533
|
+
// Just set the value?
|
|
534
|
+
this.pict.manifest.setValueByHash(tmpChartConfiguration, tmpParsingConfiguration.AddressInObject, tmpRawData);
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
break;
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
getInputChartConfiguration(pView, pInput, pValue)
|
|
544
|
+
{
|
|
545
|
+
let tmpView = pView;
|
|
546
|
+
let tmpInput = pInput;
|
|
547
|
+
let tmpValue = pValue;
|
|
548
|
+
|
|
549
|
+
if (!('PictForm' in tmpInput))
|
|
550
|
+
{
|
|
551
|
+
return false;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
let tmpPictform = pInput.PictForm;
|
|
555
|
+
|
|
556
|
+
let tmpChartConfiguration = (typeof (tmpPictform.ChartJSOptionsCorePrototype) === 'object') ? tmpPictform.ChartJSOptionsCorePrototype : {};
|
|
557
|
+
|
|
558
|
+
this.applyInputParsingConfiguration(pInput, tmpChartConfiguration, this.defaultCoreParsingConfiguration, 'PictForm.ChartConfigCoreParsingConfigurationOverride');
|
|
559
|
+
if (!('type' in tmpChartConfiguration))
|
|
560
|
+
{
|
|
561
|
+
tmpChartConfiguration.type = (typeof (tmpPictform.ChartType) === 'string') ? tmpPictform.ChartType : 'bar';
|
|
562
|
+
}
|
|
563
|
+
this.applyInputParsingConfiguration(pInput, tmpChartConfiguration, this.defaultLabelParsingConfiguration, 'PictForm.ChartLabelsParsingConfigurationOverride');
|
|
564
|
+
this.applyInputParsingConfiguration(pInput, tmpChartConfiguration, this.defaultDataParsingConfiguration, 'PictForm.ChartDataParsingConfigurationOverride');
|
|
565
|
+
|
|
566
|
+
return tmpChartConfiguration;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
initializeChartVisualization(pView, pGroup, pRow, pInput, pValue, pHTMLSelector)
|
|
570
|
+
{
|
|
571
|
+
// Stuff the config into a hidden element for reference
|
|
572
|
+
let tmpConfigStorageLocation = `#CONFIG-FOR-${pInput.Macro.RawHTMLID}`;
|
|
573
|
+
let tmpChartConfiguration = this.getInputChartConfiguration(pView, pInput, pValue);
|
|
574
|
+
this.pict.ContentAssignment.assignContent(tmpConfigStorageLocation, JSON.stringify(tmpChartConfiguration));
|
|
575
|
+
|
|
576
|
+
let tmpChartCanvasElementSelector = `#CANVAS-FOR-${pInput.Macro.RawHTMLID}`;
|
|
577
|
+
let tmpChartCanvasElement = this.pict.ContentAssignment.getElement(tmpChartCanvasElementSelector);
|
|
578
|
+
if ((!Array.isArray(tmpChartCanvasElement)) || (tmpChartCanvasElement.length < 1))
|
|
579
|
+
{
|
|
580
|
+
this.log.warn(`Chart canvas element not found for input ${tmpChartCanvasElementSelector}`);
|
|
581
|
+
return false;
|
|
582
|
+
}
|
|
583
|
+
tmpChartCanvasElement = tmpChartCanvasElement[0]
|
|
584
|
+
|
|
585
|
+
// Check if there is a window.Chart which is the Chart.js library
|
|
586
|
+
if (typeof (window.Chart) !== 'function')
|
|
587
|
+
{
|
|
588
|
+
this.log.warn(`Chart.js library not loaded for input ${tmpChartCanvasElementSelector}`);
|
|
589
|
+
}
|
|
590
|
+
else
|
|
591
|
+
{
|
|
592
|
+
this.currentChartObjects[`Object-For-${pInput.Macro.RawHTMLID}`] = new window.Chart(tmpChartCanvasElement, tmpChartConfiguration);
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
/**
|
|
597
|
+
* Initializes the input element for the Pict provider select input.
|
|
598
|
+
*
|
|
599
|
+
* @param {Object} pView - The view object.
|
|
600
|
+
* @param {Object} pGroup - The group object.
|
|
601
|
+
* @param {Object} pRow - The row object.
|
|
602
|
+
* @param {Object} pInput - The input object.
|
|
603
|
+
* @param {any} pValue - The input value.
|
|
604
|
+
* @param {string} pHTMLSelector - The HTML selector.
|
|
605
|
+
* @param {string} pTransactionGUID - The transaction GUID for the event dispatch.
|
|
606
|
+
* @returns {boolean} - Returns true if the input element is successfully initialized, false otherwise.
|
|
607
|
+
*/
|
|
608
|
+
onInputInitialize(pView, pGroup, pRow, pInput, pValue, pHTMLSelector, pTransactionGUID)
|
|
609
|
+
{
|
|
610
|
+
this.initializeChartVisualization(pView, pGroup, pRow, pInput, pValue, pHTMLSelector);
|
|
611
|
+
return super.onInputInitialize(pView, pGroup, pRow, pInput, pValue, pHTMLSelector, pTransactionGUID);
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
/**
|
|
615
|
+
* Initializes a tabular input element.
|
|
616
|
+
*
|
|
617
|
+
* @param {Object} pView - The view object.
|
|
618
|
+
* @param {Object} pGroup - The group object.
|
|
619
|
+
* @param {Object} pInput - The input object.
|
|
620
|
+
* @param {any} pValue - The input value.
|
|
621
|
+
* @param {string} pHTMLSelector - The HTML selector.
|
|
622
|
+
* @param {number} pRowIndex - The index of the row.
|
|
623
|
+
* @param {string} pTransactionGUID - The transaction GUID for the event dispatch.
|
|
624
|
+
* @returns {any} - The result of the initialization.
|
|
625
|
+
*/
|
|
626
|
+
onInputInitializeTabular(pView, pGroup, pInput, pValue, pHTMLSelector, pRowIndex, pTransactionGUID)
|
|
627
|
+
{
|
|
628
|
+
return super.onInputInitializeTabular(pView, pGroup, pInput, pValue, pHTMLSelector, pRowIndex, pTransactionGUID);
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
/**
|
|
632
|
+
* Handles the change event for the data in the select input.
|
|
633
|
+
*
|
|
634
|
+
* @param {Object} pView - The view object.
|
|
635
|
+
* @param {Object} pInput - The input object.
|
|
636
|
+
* @param {any} pValue - The new value of the input.
|
|
637
|
+
* @param {string} pHTMLSelector - The HTML selector of the input.
|
|
638
|
+
* @param {string} pTransactionGUID - The transaction GUID for the event dispatch.
|
|
639
|
+
* @returns {any} - The result of the super.onDataChange method.
|
|
640
|
+
*/
|
|
641
|
+
onDataChange(pView, pInput, pValue, pHTMLSelector, pTransactionGUID)
|
|
642
|
+
{
|
|
643
|
+
return super.onDataChange(pView, pInput, pValue, pHTMLSelector, pTransactionGUID);
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
/**
|
|
647
|
+
* Handles the change event for tabular data.
|
|
648
|
+
*
|
|
649
|
+
* @param {Object} pView - The view object.
|
|
650
|
+
* @param {Object} pInput - The input object.
|
|
651
|
+
* @param {any} pValue - The new value.
|
|
652
|
+
* @param {string} pHTMLSelector - The HTML selector.
|
|
653
|
+
* @param {number} pRowIndex - The index of the row.
|
|
654
|
+
* @param {string} pTransactionGUID - The transaction GUID for the event dispatch.
|
|
655
|
+
* @returns {any} - The result of the super method.
|
|
656
|
+
*/
|
|
657
|
+
onDataChangeTabular(pView, pInput, pValue, pHTMLSelector, pRowIndex, pTransactionGUID)
|
|
658
|
+
{
|
|
659
|
+
return super.onDataChangeTabular(pView, pInput, pValue, pHTMLSelector, pRowIndex, pTransactionGUID);
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
/**
|
|
663
|
+
* Marshals data to the form for the given input.
|
|
664
|
+
*
|
|
665
|
+
* @param {Object} pView - The view object.
|
|
666
|
+
* @param {Object} pGroup - The group object.
|
|
667
|
+
* @param {Object} pRow - The row object.
|
|
668
|
+
* @param {Object} pInput - The input object.
|
|
669
|
+
* @param {any} pValue - The value to be marshaled.
|
|
670
|
+
* @param {string} pHTMLSelector - The HTML selector.
|
|
671
|
+
* @param {string} pTransactionGUID - The transaction GUID for the event dispatch.
|
|
672
|
+
* @returns {boolean} - Returns true if the value is successfully marshaled to the form, otherwise false.
|
|
673
|
+
*/
|
|
674
|
+
onDataMarshalToForm(pView, pGroup, pRow, pInput, pValue, pHTMLSelector, pTransactionGUID)
|
|
675
|
+
{
|
|
676
|
+
return super.onDataMarshalToForm(pView, pGroup, pRow, pInput, pValue, pHTMLSelector, pTransactionGUID);
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
/**
|
|
680
|
+
* Marshals data to a form in tabular format.
|
|
681
|
+
*
|
|
682
|
+
* @param {Object} pView - The view object.
|
|
683
|
+
* @param {Object} pGroup - The group object.
|
|
684
|
+
* @param {Object} pInput - The input object.
|
|
685
|
+
* @param {any} pValue - The value parameter.
|
|
686
|
+
* @param {string} pHTMLSelector - The HTML selector parameter.
|
|
687
|
+
* @param {number} pRowIndex - The row index parameter.
|
|
688
|
+
* @param {string} pTransactionGUID - The transaction GUID for the event dispatch.
|
|
689
|
+
* @returns {any} - The result of the data marshaling.
|
|
690
|
+
*/
|
|
691
|
+
onDataMarshalToFormTabular(pView, pGroup, pInput, pValue, pHTMLSelector, pRowIndex, pTransactionGUID)
|
|
692
|
+
{
|
|
693
|
+
return super.onDataMarshalToFormTabular(pView, pGroup, pInput, pValue, pHTMLSelector, pRowIndex, pTransactionGUID);
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
/**
|
|
697
|
+
* Handles the data request event for a select input in the PictProviderInputSelect class.
|
|
698
|
+
*
|
|
699
|
+
* @param {Object} pView - The view object.
|
|
700
|
+
* @param {Object} pInput - The input object.
|
|
701
|
+
* @param {any} pValue - The value object.
|
|
702
|
+
* @param {string} pHTMLSelector - The HTML selector object.
|
|
703
|
+
* @returns {any} - The result of the onDataRequest method.
|
|
704
|
+
*/
|
|
705
|
+
onDataRequest(pView, pInput, pValue, pHTMLSelector)
|
|
706
|
+
{
|
|
707
|
+
return super.onDataRequest(pView, pInput, pValue, pHTMLSelector);
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
/**
|
|
711
|
+
* Handles the data request event for a tabular input.
|
|
712
|
+
*
|
|
713
|
+
* @param {Object} pView - The view object.
|
|
714
|
+
* @param {Object} pInput - The input object.
|
|
715
|
+
* @param {any} pValue - The value object.
|
|
716
|
+
* @param {string} pHTMLSelector - The HTML selector.
|
|
717
|
+
* @param {number} pRowIndex - The row index.
|
|
718
|
+
* @returns {any} - The result of the data request.
|
|
719
|
+
*/
|
|
720
|
+
onDataRequestTabular(pView, pInput, pValue, pHTMLSelector, pRowIndex)
|
|
721
|
+
{
|
|
722
|
+
return super.onDataRequestTabular(pView, pInput, pValue, pHTMLSelector, pRowIndex);
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
module.exports = CustomInputHandler;
|