pict-section-form 1.0.13 → 1.0.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 (36) hide show
  1. package/eslint.config.mjs +10 -0
  2. package/package.json +11 -4
  3. package/source/application/Pict-Application-Form.js +1 -1
  4. package/source/providers/Pict-Provider-DynamicLayout.js +33 -0
  5. package/source/providers/Pict-Provider-DynamicSolver.js +86 -27
  6. package/source/providers/Pict-Provider-DynamicTemplates-DefaultFormTemplates.js +2 -2
  7. package/source/providers/Pict-Provider-DynamicTemplates.js +5 -5
  8. package/source/providers/Pict-Provider-Informary.js +52 -4
  9. package/source/templates/Pict-Template-Metacontroller-ValueSetWithGroup.js +8 -3
  10. package/source/views/Pict-View-DynamicForm.js +1 -19
  11. package/source/views/Pict-View-Form-Metacontroller.js +27 -1
  12. package/test/PictSectionForm-Basic_tests.js +88 -1
  13. package/tsconfig.json +14 -0
  14. package/types/Pict-Section-Form.d.ts +35 -0
  15. package/types/Pict-Section-Form.d.ts.map +1 -0
  16. package/types/application/Pict-Application-Form.d.ts +18 -0
  17. package/types/application/Pict-Application-Form.d.ts.map +1 -0
  18. package/types/providers/Pict-Provider-DynamicLayout.d.ts +24 -0
  19. package/types/providers/Pict-Provider-DynamicLayout.d.ts.map +1 -0
  20. package/types/providers/Pict-Provider-DynamicSolver.d.ts +97 -0
  21. package/types/providers/Pict-Provider-DynamicSolver.d.ts.map +1 -0
  22. package/types/providers/Pict-Provider-DynamicTemplates-DefaultFormTemplates.d.ts +6 -0
  23. package/types/providers/Pict-Provider-DynamicTemplates-DefaultFormTemplates.d.ts.map +1 -0
  24. package/types/providers/Pict-Provider-DynamicTemplates.d.ts +16 -0
  25. package/types/providers/Pict-Provider-DynamicTemplates.d.ts.map +1 -0
  26. package/types/providers/Pict-Provider-Informary.d.ts +69 -0
  27. package/types/providers/Pict-Provider-Informary.d.ts.map +1 -0
  28. package/types/providers/Pict-Provider-MetatemplateGenerator.d.ts +14 -0
  29. package/types/providers/Pict-Provider-MetatemplateGenerator.d.ts.map +1 -0
  30. package/types/templates/Pict-Template-Metacontroller-ValueSetWithGroup.d.ts +17 -0
  31. package/types/templates/Pict-Template-Metacontroller-ValueSetWithGroup.d.ts.map +1 -0
  32. package/types/views/Pict-View-DynamicForm.d.ts +45 -0
  33. package/types/views/Pict-View-DynamicForm.d.ts.map +1 -0
  34. package/types/views/Pict-View-Form-Metacontroller.d.ts +94 -0
  35. package/types/views/Pict-View-Form-Metacontroller.d.ts.map +1 -0
  36. package/source/templates/Pict-Template-Base.js +0 -87
@@ -0,0 +1,10 @@
1
+ import globals from "globals";
2
+ import pluginJs from "@eslint/js";
3
+
4
+
5
+ export default [
6
+ { files: ["source/**"], languageOptions: { sourceType: "commonjs" } },
7
+ { languageOptions: { globals: { ...globals.browser, ...globals.mocha, } } },
8
+ pluginJs.configs.recommended,
9
+ { rules: { "no-prototype-builtins": "off", "no-unused-vars": "warn", "no-case-declarations": "warn" } },
10
+ ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pict-section-form",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "description": "Pict dynamic form sections",
5
5
  "main": "source/Pict-Section-Form.js",
6
6
  "directories": {
@@ -19,20 +19,27 @@
19
19
  "tests": "npx mocha -u tdd --exit -R spec --grep",
20
20
  "coverage": "npx nyc --reporter=lcov --reporter=text-lcov npx mocha -- -u tdd -R spec",
21
21
  "build": "npx quack build",
22
- "test": "npx mocha -u tdd -R spec"
22
+ "test": "npx mocha -u tdd -R spec",
23
+ "lint": "eslint source/**",
24
+ "types": "npx -p typescript tsc -p . --outDir types"
23
25
  },
26
+ "types": "types/Pict-Section-Form.d.ts",
24
27
  "author": "steven velozo <steven@velozo.com>",
25
28
  "license": "MIT",
26
29
  "devDependencies": {
30
+ "@eslint/js": "^9.4.0",
27
31
  "browser-env": "^3.3.0",
32
+ "eslint": "^9.4.0",
28
33
  "jquery": "^3.7.1",
29
- "pict": "^1.0.199",
34
+ "pict": "^1.0.200",
30
35
  "pict-application": "^1.0.18",
31
- "quackage": "^1.0.30"
36
+ "quackage": "^1.0.30",
37
+ "typescript": "^5.4.5"
32
38
  },
33
39
  "dependencies": {
34
40
  "fable-serviceproviderbase": "^3.0.13",
35
41
  "pict-provider": "^1.0.2",
42
+ "pict-template": "^1.0.1",
36
43
  "pict-view": "^1.0.47"
37
44
  },
38
45
  "mocha": {
@@ -39,4 +39,4 @@ module.exports.default_configuration = (
39
39
  {
40
40
  "Product": "PictDefaultFormsApp"
41
41
  }
42
- });
42
+ });
@@ -0,0 +1,33 @@
1
+ const libPictProvider = require('pict-provider');
2
+
3
+ const _DefaultProviderConfiguration = (
4
+ {
5
+ "ProviderIdentifier": "Pict-DynamicForms-Layout",
6
+
7
+ "AutoInitialize": true,
8
+ "AutoInitializeOrdinal": 0,
9
+
10
+ "AutoSolveWithApp": false
11
+ });
12
+
13
+ /**
14
+ * The PictDynamicLayout class is a provider that generates dynamic layouts based on configuration.
15
+ */
16
+ class PictDynamicLayout extends libPictProvider
17
+ {
18
+ /**
19
+ * Creates an instance of the PictDynamicLayout class.
20
+ *
21
+ * @param {object} pFable - The fable object.
22
+ * @param {object} pOptions - The options object.
23
+ * @param {object} pServiceHash - The service hash object.
24
+ */
25
+ constructor(pFable, pOptions, pServiceHash)
26
+ {
27
+ let tmpOptions = Object.assign({}, JSON.parse(JSON.stringify(_DefaultProviderConfiguration)), pOptions);
28
+ super(pFable, tmpOptions, pServiceHash);
29
+ }
30
+ }
31
+
32
+ module.exports = PictDynamicLayout;
33
+ module.exports.default_configuration = _DefaultProviderConfiguration;
@@ -2,7 +2,7 @@ const libPictProvider = require('pict-provider');
2
2
 
3
3
  const _DefaultProviderConfiguration = (
4
4
  {
5
- "ProviderIdentifier": "Pict-DynamicForm-Solve",
5
+ "ProviderIdentifier": "Pict-DynamicForms-Solver",
6
6
 
7
7
  "AutoInitialize": true,
8
8
  "AutoInitializeOrdinal": 0,
@@ -10,8 +10,18 @@ const _DefaultProviderConfiguration = (
10
10
  "AutoSolveWithApp": false
11
11
  });
12
12
 
13
- class PictSectionFormTemplateProvider extends libPictProvider
13
+ /**
14
+ * The PictDynamicSolver class is a provider that solves configuration-generated dynamic views.
15
+ */
16
+ class PictDynamicSolver extends libPictProvider
14
17
  {
18
+ /**
19
+ * Creates an instance of the PictDynamicSolver class.
20
+ *
21
+ * @param {object} pFable - The fable object.
22
+ * @param {object} pOptions - The options object.
23
+ * @param {object} pServiceHash - The service hash object.
24
+ */
15
25
  constructor(pFable, pOptions, pServiceHash)
16
26
  {
17
27
  let tmpOptions = Object.assign({}, JSON.parse(JSON.stringify(_DefaultProviderConfiguration)), pOptions);
@@ -33,7 +43,6 @@ class PictSectionFormTemplateProvider extends libPictProvider
33
43
  let tmpSolver = pSolver;
34
44
  if (tmpSolver === undefined)
35
45
  {
36
- console.log('wut');
37
46
  return;
38
47
  }
39
48
  if (typeof(tmpSolver) === 'string')
@@ -42,7 +51,7 @@ class PictSectionFormTemplateProvider extends libPictProvider
42
51
  }
43
52
  if (!('Expression' in tmpSolver))
44
53
  {
45
- pView.log.error(`Dynamic View [${pView.UUID}]::[${pView.Hash}] group ${tmpGroup.Hash} solver ${k} is missing the Expression property.`);
54
+ this.pict.log.error(`Dynamic View solver ${pOrdinal} is missing the Expression property.`, { Solver: pSolver });
46
55
  return;
47
56
  }
48
57
  if (!(`Ordinal` in tmpSolver))
@@ -60,7 +69,8 @@ class PictSectionFormTemplateProvider extends libPictProvider
60
69
  }
61
70
 
62
71
  /**
63
- * Runs each recordset solver formulae for a dynamic view group at a given ordinal.
72
+ * Runs each RecordSet solver formulae for a dynamic view group at a given ordinal.
73
+ *
64
74
  * Or for all ordinals if no ordinal is passed.
65
75
  *
66
76
  * @param {array} pGroupSolverArray - An array of Solvers from the groups to solve.
@@ -82,7 +92,13 @@ class PictSectionFormTemplateProvider extends libPictProvider
82
92
  continue;
83
93
  }
84
94
 
85
- tmpView.log.trace(`Dynamic View [${tmpView.UUID}]::[${tmpView.Hash}] solving RecordSet ordinal ${tmpSolver.Ordinal} [${tmpSolver.Expression}]`);
95
+ tmpSolver.StartTimeStamp = +new Date();
96
+ tmpSolver.Hash = `${pGroupSolverArray[j].ViewHash}-GroupSolver-${j}`;
97
+
98
+ if (this.pict.LogNoisiness > 1)
99
+ {
100
+ tmpView.log.trace(`Dynamic View [${tmpView.UUID}]::[${tmpView.Hash}] solving RecordSet ordinal ${tmpSolver.Ordinal} [${tmpSolver.Expression}]`);
101
+ }
86
102
 
87
103
  let tmpRecordSet = tmpView.getTabularRecordSet(j);
88
104
 
@@ -92,26 +108,33 @@ class PictSectionFormTemplateProvider extends libPictProvider
92
108
  for (let l = 0; l < tmpRecordSetKeys.length; l++)
93
109
  {
94
110
  let tmpRecord = tmpRecordSet[tmpRecordSetKeys[l]];
95
- let tmpResultsObject = {};
96
- let tmpSolutionValue = tmpView.fable.ExpressionParser.solve(tmpSolver.Expression, tmpRecord, tmpResultsObject, tmpGroup.supportingManifest, tmpRecord);
97
- tmpView.log.trace(`Group ${tmpGroup.Hash} [${tmpSolver.Expression}] record ${l} result was ${tmpSolutionValue}`);
111
+ tmpSolver.ResultsObject = {};
112
+ let tmpSolutionValue = tmpView.fable.ExpressionParser.solve(tmpSolver.Expression, tmpRecord, tmpSolver.ResultsObject, tmpGroup.supportingManifest, tmpRecord);
113
+ if (this.pict.LogNoisiness > 1)
114
+ {
115
+ tmpView.log.trace(`Group ${tmpGroup.Hash} [${tmpSolver.Expression}] record ${l} result was ${tmpSolutionValue}`);
116
+ }
98
117
  }
99
118
  }
100
- if (typeof(tmpRecordSet) == 'array')
119
+ if (Array.isArray(tmpRecordSet))
101
120
  {
102
121
  for (let l = 0; l < tmpRecordSet.length; l++)
103
122
  {
104
123
  let tmpRecord = tmpRecordSet[l];
105
- let tmpResultsObject = {};
106
- let tmpSolutionValue = tmpView.fable.ExpressionParser.solve(tmpSolver.Expression, tmpRecord, tmpResultsObject, tmpGroup.supportingManifest, tmpRecord);
107
- tmpView.log.trace(`Group ${tmpGroup.Hash} [${tmpSolver.Expression}] record ${l} result was ${tmpSolutionValue}`);
124
+ tmpSolver.ResultsObject = {};
125
+ let tmpSolutionValue = tmpView.fable.ExpressionParser.solve(tmpSolver.Expression, tmpRecord, tmpSolver.ResultsObject, tmpGroup.supportingManifest, tmpRecord);
126
+ if (this.pict.LogNoisiness > 1)
127
+ {
128
+ tmpView.log.trace(`Group ${tmpGroup.Hash} [${tmpSolver.Expression}] record ${l} result was ${tmpSolutionValue}`);
129
+ }
108
130
  }
109
131
  }
132
+ tmpSolver.EndTimeStamp = +new Date();
110
133
  }
111
134
  }
112
135
 
113
136
  /**
114
- * Executes the section solvers.
137
+ * Executes the section solvers at a given ordinal (or all if no ordinal is passed).
115
138
  *
116
139
  * @param {Array} pViewSectionSolverArray - The array of view section solvers.
117
140
  * @param {number} pOrdinal - The ordinal value.
@@ -129,16 +152,26 @@ class PictSectionFormTemplateProvider extends libPictProvider
129
152
  continue;
130
153
  }
131
154
 
155
+ tmpSolver.StartTimeStamp = +new Date();
156
+ tmpSolver.Hash = `${pViewSectionSolverArray[i].ViewHash}-SectionSolver-${i}`;
157
+
132
158
  // TODO: Precompile the solvers (it's super easy)
133
- tmpView.log.trace(`Dynamic View [${tmpView.UUID}]::[${tmpView.Hash}] solving equation ${i} ordinal ${tmpSolver.Ordinal} [${tmpView.options.Solvers[i]}]`);
134
- let tmpResultsObject = {};
135
- let tmpSolutionValue = tmpView.fable.ExpressionParser.solve(tmpSolver.Expression, tmpView.getMarshalDestinationObject(), tmpResultsObject, tmpView.sectionManifest, tmpView.getMarshalDestinationObject());
136
- tmpView.log.trace(`[${tmpSolver.Expression}] result was ${tmpSolutionValue}`);
159
+ if (this.pict.LogNoisiness > 1)
160
+ {
161
+ tmpView.log.trace(`Dynamic View [${tmpView.UUID}]::[${tmpView.Hash}] solving equation ${i} ordinal ${tmpSolver.Ordinal} [${tmpView.options.Solvers[i]}]`);
162
+ }
163
+ tmpSolver.ResultsObject = {};
164
+ let tmpSolutionValue = tmpView.fable.ExpressionParser.solve(tmpSolver.Expression, tmpView.getMarshalDestinationObject(), tmpSolver.ResultsObject, tmpView.sectionManifest, tmpView.getMarshalDestinationObject());
165
+ if (this.pict.LogNoisiness > 1)
166
+ {
167
+ tmpView.log.trace(`[${tmpSolver.Expression}] result was ${tmpSolutionValue}`);
168
+ }
169
+ tmpSolver.EndTimeStamp = +new Date();
137
170
  }
138
171
  }
139
172
 
140
173
  /**
141
- * Executes the view solvers for the given array of views.
174
+ * Executes the view solvers for the given array of view hashes.
142
175
  *
143
176
  * @param {Array} pViewSolverArray - The array of view solvers to execute.
144
177
  * @param {number} pOrdinal - The ordinal value.
@@ -154,13 +187,28 @@ class PictSectionFormTemplateProvider extends libPictProvider
154
187
  {
155
188
  continue;
156
189
  }
157
- // Solve a normal view
158
- tmpView.log.trace(`Dynamic View [${tmpView.UUID}]::[${tmpView.Hash}] running solve() on view [${pViewSolverArray[i].ViewHash}`);
190
+ tmpSolver.Hash = `${pViewSolverArray[i].ViewHash}-ViewSolve-${i}`;
191
+ tmpSolver.StartTimeStamp = +new Date();
192
+ if (this.pict.LogNoisiness > 1)
193
+ {
194
+ tmpView.log.trace(`Dynamic View [${tmpView.UUID}]::[${tmpView.Hash}] running solve() on view [${pViewSolverArray[i].ViewHash}`);
195
+ }
196
+ // Solve with the normal view solve() pipeline
159
197
  let tmpView = this.pict.views[pViewSolverArray[i].ViewHash];
160
198
  tmpView.solve();
199
+ tmpSolver.EndTimeStamp = +new Date();
161
200
  }
162
201
  }
163
202
 
203
+ /**
204
+ * Checks if the given ordinal exists in the provided ordinal set.
205
+ *
206
+ * If not, it adds the ordinal to the set.
207
+ *
208
+ * @param {number} pOrdinal - The ordinal to check.
209
+ * @param {Object} pOrdinalSet - The ordinal set to check against.
210
+ * @returns {Object} - The ordinal object from the ordinal set.
211
+ */
164
212
  checkAutoSolveOrdinal (pOrdinal, pOrdinalSet)
165
213
  {
166
214
  if (!(pOrdinal.toString() in pOrdinalSet))
@@ -179,7 +227,7 @@ class PictSectionFormTemplateProvider extends libPictProvider
179
227
  * order across two dimensions:
180
228
  *
181
229
  * 1. The order of the views in the view hash array.
182
- * 2. Precedence order
230
+ * 2. Precedence order (based on Ordinal)
183
231
  *
184
232
  * The way it manages the precedence order solving is by enumerating the
185
233
  * view hash array multiple times until it exhausts the solution set.
@@ -197,8 +245,12 @@ class PictSectionFormTemplateProvider extends libPictProvider
197
245
  this.log.trace(`Dynamic View Provider [${this.UUID}]::[${this.Hash}] solving views.`);
198
246
  let tmpViewHashes = Array.isArray(pViewHashes) ? pViewHashes : Object.keys(this.fable.views);
199
247
 
200
- let tmpOrdinalsToSolve = {};
248
+ let tmpSolveOutcome = {};
249
+ tmpSolveOutcome.StartTimeStamp = +new Date();
250
+ tmpSolveOutcome.ViewHashes = tmpViewHashes;
201
251
 
252
+ let tmpOrdinalsToSolve = {};
253
+ tmpSolveOutcome.SolveOrdinals = tmpOrdinalsToSolve;
202
254
  for (let i = 0; i < tmpViewHashes.length; i++)
203
255
  {
204
256
  let tmpView = this.fable.views[tmpViewHashes[i]];
@@ -250,15 +302,22 @@ class PictSectionFormTemplateProvider extends libPictProvider
250
302
  // Now enumerate the keys and solve each layer of the solution set
251
303
  for (let i = 0; i < tmpOrdinalKeys.length; i++)
252
304
  {
305
+ if (this.pict.LogNoisiness > 1)
306
+ {
307
+ this.log.trace(`DynamicSolver [${this.UUID}]::[${this.Hash}] Solving ordinal ${tmpOrdinalKeys[i]}`);
308
+ }
253
309
  let tmpOrdinalContainer = tmpOrdinalsToSolve[tmpOrdinalKeys[i]];
254
310
  this.executeGroupSolvers(tmpOrdinalContainer.GroupSolvers, tmpOrdinalKeys[i]);
255
311
  this.executeSectionSolvers(tmpOrdinalContainer.SectionSolvers, tmpOrdinalKeys[i]);
256
312
  this.executeViewSolvers(tmpOrdinalContainer.ViewSolvers, tmpOrdinalKeys[i]);
257
313
  }
258
-
259
- console.log(tmpOrdinalsToSolve);
314
+
315
+ tmpSolveOutcome.EndTimeStamp = +new Date();
316
+
317
+ // It's up to the developer to decide if they want to use this information somewhere.
318
+ this.lastSolveOutcome = tmpSolveOutcome;
260
319
  }
261
320
  }
262
321
 
263
- module.exports = PictSectionFormTemplateProvider;
264
- module.exports.default_configuration = _DefaultProviderConfiguration;
322
+ module.exports = PictDynamicSolver;
323
+ module.exports.default_configuration = _DefaultProviderConfiguration;
@@ -17,7 +17,7 @@ module.exports = (
17
17
  ;,//;, ,;/
18
18
  o:::::::;;///
19
19
  >::::::::;;\\\
20
- ''\\\\\'" ';\
20
+ ''\\\\'" ';\
21
21
 
22
22
  Glug glug glug Oo... -->
23
23
  <div id="Pict-{~D:Context[0].UUID~}-FormContainer" class="pict-form">`
@@ -341,4 +341,4 @@ Glug glug glug Oo... -->
341
341
  */
342
342
 
343
343
  ]
344
- });
344
+ });
@@ -4,7 +4,7 @@ const _DefaultFormTemplates = require('./Pict-Provider-DynamicTemplates-DefaultF
4
4
 
5
5
  const _DefaultProviderConfiguration = (
6
6
  {
7
- "ProviderIdentifier": "Pict-Section-Form-Provider-Templates-Basic",
7
+ "ProviderIdentifier": "Pict-DynamicForms-MetaTemplates-Basic",
8
8
 
9
9
  "AutoInitialize": true,
10
10
  "AutoInitializeOrdinal": 0,
@@ -12,7 +12,7 @@ const _DefaultProviderConfiguration = (
12
12
  "AutoSolveWithApp": false
13
13
  });
14
14
 
15
- class PictSectionFormTemplateProvider extends libPictProvider
15
+ class PictDynamicFormsTemplates extends libPictProvider
16
16
  {
17
17
  constructor(pFable, pOptions, pServiceHash)
18
18
  {
@@ -29,12 +29,12 @@ class PictSectionFormTemplateProvider extends libPictProvider
29
29
  this.formsTemplateSetPrefix = '';
30
30
  this.formsTemplateSet = {};
31
31
 
32
- if (!('TemplatePrefix' in this.options.MetaTemplateSet) && (this.options.ProviderIdentifier == 'Pict-Section-Form-Provider-Templates-Basic'))
32
+ if (!('TemplatePrefix' in this.options.MetaTemplateSet) && (this.options.ProviderIdentifier == 'Pict-DynamicForms-MetaTemplates-Basic'))
33
33
  {
34
34
  // The default template prefix is 'Pict-Forms-Basic'
35
35
  this.formsTemplateSetPrefix = _DefaultFormTemplates.TemplatePrefix;
36
36
  }
37
- else if (!('TemplatePrefix' in this.options.MetaTemplateSet) && (this.options.ProviderIdentifier != 'Pict-Section-Form-Provider-Templates-Basic'))
37
+ else if (!('TemplatePrefix' in this.options.MetaTemplateSet) && (this.options.ProviderIdentifier != 'Pict-DynamicForms-MetaTemplates-Basic'))
38
38
  {
39
39
  this.log.error(`No TemplatePrefix defined in the provider options.MetaTemplateSet.TemplatePrefix -- Provider [${this.UUID}]::[${this.Hash}]. Templates will not be loaded.`);
40
40
  }
@@ -86,5 +86,5 @@ class PictSectionFormTemplateProvider extends libPictProvider
86
86
  }
87
87
  }
88
88
 
89
- module.exports = PictSectionFormTemplateProvider;
89
+ module.exports = PictDynamicFormsTemplates;
90
90
  module.exports.default_configuration = _DefaultProviderConfiguration;
@@ -3,7 +3,7 @@ const libPictProvider = require('pict-provider');
3
3
  // TODO: Pull this back to pict as a core service once we are happy with the shape.
4
4
  const _DefaultProviderConfiguration = (
5
5
  {
6
- "ProviderIdentifier": "Pict-Section-Form-Provider-Informary",
6
+ "ProviderIdentifier": "Pict-DynamicForms-Informary",
7
7
 
8
8
  "AutoInitialize": false,
9
9
  "AutoInitializeOrdinal": 0,
@@ -11,8 +11,18 @@ const _DefaultProviderConfiguration = (
11
11
  "AutoSolveWithApp": false
12
12
  });
13
13
 
14
- class PictServiceInformary extends libPictProvider
14
+ /**
15
+ * Represents a provider for dynamic forms in the PICT system.
16
+ * Extends the `libPictProvider` class.
17
+ */
18
+ class PictDynamicFormsInformary extends libPictProvider
15
19
  {
20
+ /**
21
+ * Creates an instance of the `PictDynamicFormsInformary` class.
22
+ * @param {object} pFable - The fable object.
23
+ * @param {object} pOptions - The options object.
24
+ * @param {object} pServiceHash - The service hash object.
25
+ */
16
26
  constructor(pFable, pOptions, pServiceHash)
17
27
  {
18
28
  let tmpOptions = Object.assign({}, JSON.parse(JSON.stringify(_DefaultProviderConfiguration)), pOptions);
@@ -22,6 +32,12 @@ class PictServiceInformary extends libPictProvider
22
32
  this.genericManifest = this.pict.newManyfest({Scope:'GenericInformary'});
23
33
  }
24
34
 
35
+ /**
36
+ * Retrieves all form elements for a given form hash.
37
+ *
38
+ * @param {string} pFormHash - The hash of the form.
39
+ * @returns {HTMLElement[]} - An array of HTML elements representing the form elements.
40
+ */
25
41
  getFormElements(pFormHash)
26
42
  {
27
43
  let tmpSelector = `[data-i-form="${pFormHash}"]`;
@@ -29,6 +45,17 @@ class PictServiceInformary extends libPictProvider
29
45
  return this.pict.ContentAssignment.getElement(tmpSelector);
30
46
  }
31
47
 
48
+ /**
49
+ * Get a full content browser address based on the form, datum and optionally the container and index.
50
+ *
51
+ * This can be used in getDomElementByAddress or jquery selectors to return the element.
52
+ *
53
+ * @param {string} pFormHash - The form hash.
54
+ * @param {string} pDatumHash - The datum hash.
55
+ * @param {string|null} pContainer - The container (optional).
56
+ * @param {number} pIndex - The index.
57
+ * @returns {string} The content browser address.
58
+ */
32
59
  getContentBrowserAddress(pFormHash, pDatumHash, pContainer, pIndex)
33
60
  {
34
61
  // TODO: Need some guards, yo
@@ -42,12 +69,26 @@ class PictServiceInformary extends libPictProvider
42
69
  }
43
70
  }
44
71
 
72
+ /**
73
+ * Returns the composed container address string for a given container, index, and datum hash.
74
+ *
75
+ * @param {string} pContainer - The container name.
76
+ * @param {number} pIndex - The index of the container.
77
+ * @param {string} pDatumHash - The datum hash.
78
+ * @returns {string} The composed container address.
79
+ */
45
80
  getComposedContainerAddress(pContainer, pIndex, pDatumHash)
46
81
  {
47
82
  return `${pContainer}[${pIndex}].${pDatumHash}`;
48
83
  }
49
84
 
50
- // TODO: DRY or bust. Later.
85
+ /**
86
+ * Marshals form data to the provided application state data object using the given form hash and manifest.
87
+ *
88
+ * @param {object} pAppStateData - The application state data object to marshal the form data to.
89
+ * @param {string} pFormHash - The form hash representing the form elements.
90
+ * @param {object} pManifest - The manifest object used to map form data to the application state data.
91
+ */
51
92
  marshalFormToData(pAppStateData, pFormHash, pManifest)
52
93
  {
53
94
  let tmpManifest = typeof(pManifest) === 'object' ? pManifest : this.genericManifest;
@@ -85,6 +126,13 @@ class PictServiceInformary extends libPictProvider
85
126
  }
86
127
  }
87
128
 
129
+ /**
130
+ * Marshals data from some application state object to a specific subset of browser form elements.
131
+ *
132
+ * @param {object} pAppStateData - The application state data to marshal into the form. Usually AppData but can be other objects.
133
+ * @param {string} pFormHash - The hash of the form to marshal data into. This is the data-i-form attribute.
134
+ * @param {object} pManifest - The manifest object. If not provided, the generic manifest is used.
135
+ */
88
136
  marshalDataToForm(pAppStateData, pFormHash, pManifest)
89
137
  {
90
138
  let tmpManifest = typeof(pManifest) === 'object' ? pManifest : this.genericManifest;
@@ -130,5 +178,5 @@ class PictServiceInformary extends libPictProvider
130
178
  }
131
179
  }
132
180
 
133
- module.exports = PictServiceInformary;
181
+ module.exports = PictDynamicFormsInformary;
134
182
  module.exports.default_configuration = _DefaultProviderConfiguration;
@@ -1,5 +1,10 @@
1
- const libPictTemplate = require('./Pict-Template-Base.js');
1
+ const libPictTemplate = require('pict-template');
2
2
 
3
+ /**
4
+ * This is a template that will take a value set and render a template for each value in the set.
5
+ *
6
+ * It passes along additional context (the metacontroller group) for dynamic programming tables.
7
+ */
3
8
  class PictTemplateMetacontrollerValueSet extends libPictTemplate
4
9
  {
5
10
  /**
@@ -123,7 +128,7 @@ class PictTemplateMetacontrollerValueSet extends libPictTemplate
123
128
  {
124
129
  for (let i = 0; i < tmpData.length; i++)
125
130
  {
126
- tmpDataValueSet.push({ Value: tmpData[i], Key: i, Group: tmpGroupIndex });
131
+ tmpDataValueSet.push({ Value: tmpData[i], Key: i, });
127
132
  }
128
133
  }
129
134
  else if (typeof (tmpData) === 'object')
@@ -131,7 +136,7 @@ class PictTemplateMetacontrollerValueSet extends libPictTemplate
131
136
  let tmpValueKeys = Object.keys(tmpData);
132
137
  for (let i = 0; i < tmpValueKeys.length; i++)
133
138
  {
134
- tmpDataValueSet.push({ Value: tmpData[tmpValueKeys[i]], Key: tmpValueKeys[i], Group: tmpGroupIndex });
139
+ tmpDataValueSet.push({ Value: tmpData[tmpValueKeys[i]], Key: tmpValueKeys[i] });
135
140
  }
136
141
  }
137
142
  else
@@ -13,12 +13,10 @@ class PictViewDynamicForm extends libPictViewClass
13
13
  if (!tmpOptions.Manifests)
14
14
  {
15
15
  throw new Error('PictSectionForm instantiation attempt without a Manifests in pOptions.Manifest -- cannot instantiate.');
16
- return;
17
16
  }
18
17
  if (!('Section' in tmpOptions.Manifests))
19
18
  {
20
19
  throw new Error('PictSectionForm instantiation attempt without a Section manifest in pOptions.Manifests -- cannot instantiate.');
21
- return;
22
20
  }
23
21
 
24
22
  // Set the default destination address to be based on the section hash if it hasn't been overridden by the manifest section definition
@@ -85,12 +83,6 @@ class PictViewDynamicForm extends libPictViewClass
85
83
  let tmpDynamicSolver = this.pict.addProvider('DynamicSolver', libDynamicSolver.default_configuration, libDynamicSolver);
86
84
  tmpDynamicSolver.initialize();
87
85
  }
88
- // This is for if we decide to abstract metatemplates into a separate provider for code simplification
89
- // if (!this.pict.providers.PictFormSectionMetatemplateGenerator)
90
- // {
91
- // let tmpMetatemplateGenerator = this.pict.addProvider('PictFormSectionMetatemplateGenerator', libFormsMetatemplateGenerator.default_configuration, libFormsMetatemplateGenerator);
92
- // tmpMetatemplateGenerator.initialize();
93
- // }
94
86
 
95
87
  // Load any view section-specific templates
96
88
  this.formsTemplateSetPrefix = `PFT-${this.Hash}-${this.UUID}`;
@@ -127,16 +119,6 @@ class PictViewDynamicForm extends libPictViewClass
127
119
  this.initializeFormGroups();
128
120
  }
129
121
 
130
- addSolver(pSolveFunctionString)
131
- {
132
- return (
133
- {
134
- "Type": "SingleSolve",
135
- "Priority": 0,
136
- "SolveFunction": pSolveFunctionString
137
- });
138
- }
139
-
140
122
  renderToPrimary()
141
123
  {
142
124
  // Render to the primary view that the
@@ -981,4 +963,4 @@ class PictViewDynamicForm extends libPictViewClass
981
963
  }
982
964
  }
983
965
 
984
- module.exports = PictViewDynamicForm;
966
+ module.exports = PictViewDynamicForm;
@@ -86,6 +86,16 @@ class PictFormMetacontroller extends libPictViewClass
86
86
  return super.onSolve();
87
87
  }
88
88
 
89
+
90
+ /**
91
+ * Filters the views based on the provided filter and sort functions.
92
+ *
93
+ * By default, filters views based on the provided filter function and sorts them based on the provided sort function.
94
+ *
95
+ * @param {Function} fFilterFunction - The filter function used to determine if a view should be included.
96
+ * @param {Function} fSortFunction - The sort function used to sort the filtered views.
97
+ * @returns {Array} - The filtered and sorted views.
98
+ */
89
99
  filterViews(fFilterFunction, fSortFunction)
90
100
  {
91
101
  let tmpViewList = Object.keys(this.fable.views);
@@ -113,6 +123,14 @@ class PictFormMetacontroller extends libPictViewClass
113
123
  return tmpFilteredViewList;
114
124
  }
115
125
 
126
+ /**
127
+ * Renders a specific dynamic form section based on the provided form section hash.
128
+ *
129
+ * For this to work, we need the container for the section to be available on the form.
130
+ *
131
+ * @param {string} pFormSectionHash - The hash of the form section to render.
132
+ * @returns {void}
133
+ */
116
134
  renderSpecificFormSection(pFormSectionHash)
117
135
  {
118
136
  let fViewFilter = (pView) => { return pView.Hash == pFormSectionHash; };
@@ -120,6 +138,14 @@ class PictFormMetacontroller extends libPictViewClass
120
138
  this.render();
121
139
  }
122
140
 
141
+ /**
142
+ * Renders the form sections based on the provided filter and sort functions.
143
+ *
144
+ * If no filter and sort functions are provided, render all form sections.
145
+ *
146
+ * @param {Function} fFilterFunction - The filter function used to filter the views.
147
+ * @param {Function} fSortFunction - The sort function used to sort the views.
148
+ */
123
149
  renderFormSections(fFilterFunction, fSortFunction)
124
150
  {
125
151
  let tmpViewList = this.filterViews(fFilterFunction, fSortFunction);
@@ -223,7 +249,7 @@ class PictFormMetacontroller extends libPictViewClass
223
249
  }
224
250
  catch(pError)
225
251
  {
226
- this.log.error('getSectionDefinition() failed to parse the section object.');
252
+ this.log.error(`getSectionDefinition() failed to parse the section object with error: ${pError.message || pError}`);
227
253
  return false;
228
254
  }
229
255
  }