pict-section-form 1.0.100 → 1.0.102

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 (39) hide show
  1. package/example_applications/postcard_example/providers/PictProvider-Dynamic-Sections.js +38 -2
  2. package/example_applications/postcard_example/views/PictView-Postcard-DynamicInputs.js +36 -2
  3. package/package.json +5 -5
  4. package/source/providers/Pict-Provider-DynamicTemplates.js +6 -0
  5. package/source/templates/Pict-Template-ControlFromDynamicManifest.js +8 -4
  6. package/source/templates/Pict-Template-ControlFromDynamicManifestForHash.js +8 -4
  7. package/source/templates/Pict-Template-DyanmicView-Value.js +7 -5
  8. package/source/templates/Pict-Template-DyanmicView-ValueByHash.js +7 -5
  9. package/source/templates/Pict-Template-Metacontroller-ValueSetWithGroup.js +10 -8
  10. package/source/templates/Pict-Template-Metatemplate-Input.js +8 -6
  11. package/source/templates/Pict-Template-Metatemplate-InputWithHashAddress.js +13 -9
  12. package/source/templates/Pict-Template-Metatemplate-InputWithView.js +224 -0
  13. package/source/templates/Pict-Template-Metatemplate-InputWithViewAndDescriptorAddress.js +225 -0
  14. package/source/templates/Pict-Template-Metatemplate-InputWithViewAndHashAddress.js +244 -0
  15. package/source/templates/Pict-Template-Proxy-PluckJoinUnique.js +3 -2
  16. package/types/source/providers/Pict-Provider-DynamicTemplates.d.ts.map +1 -1
  17. package/types/source/providers/Pict-Provider-Informary.d.ts +2 -2
  18. package/types/source/providers/Pict-Provider-Informary.d.ts.map +1 -1
  19. package/types/source/templates/Pict-Template-ControlFromDynamicManifest.d.ts +2 -1
  20. package/types/source/templates/Pict-Template-ControlFromDynamicManifest.d.ts.map +1 -1
  21. package/types/source/templates/Pict-Template-ControlFromDynamicManifestForHash.d.ts +2 -1
  22. package/types/source/templates/Pict-Template-ControlFromDynamicManifestForHash.d.ts.map +1 -1
  23. package/types/source/templates/Pict-Template-DyanmicView-Value.d.ts +2 -1
  24. package/types/source/templates/Pict-Template-DyanmicView-Value.d.ts.map +1 -1
  25. package/types/source/templates/Pict-Template-DyanmicView-ValueByHash.d.ts +2 -1
  26. package/types/source/templates/Pict-Template-DyanmicView-ValueByHash.d.ts.map +1 -1
  27. package/types/source/templates/Pict-Template-Metacontroller-ValueSetWithGroup.d.ts +2 -1
  28. package/types/source/templates/Pict-Template-Metacontroller-ValueSetWithGroup.d.ts.map +1 -1
  29. package/types/source/templates/Pict-Template-Metatemplate-Input.d.ts +2 -1
  30. package/types/source/templates/Pict-Template-Metatemplate-Input.d.ts.map +1 -1
  31. package/types/source/templates/Pict-Template-Metatemplate-InputWithHashAddress.d.ts +2 -1
  32. package/types/source/templates/Pict-Template-Metatemplate-InputWithHashAddress.d.ts.map +1 -1
  33. package/types/source/templates/Pict-Template-Metatemplate-InputWithView.d.ts +35 -0
  34. package/types/source/templates/Pict-Template-Metatemplate-InputWithView.d.ts.map +1 -0
  35. package/types/source/templates/Pict-Template-Metatemplate-InputWithViewAndDescriptorAddress.d.ts +36 -0
  36. package/types/source/templates/Pict-Template-Metatemplate-InputWithViewAndDescriptorAddress.d.ts.map +1 -0
  37. package/types/source/templates/Pict-Template-Metatemplate-InputWithViewAndHashAddress.d.ts +35 -0
  38. package/types/source/templates/Pict-Template-Metatemplate-InputWithViewAndHashAddress.d.ts.map +1 -0
  39. package/types/source/templates/Pict-Template-Proxy-PluckJoinUnique.d.ts.map +1 -1
@@ -1,6 +1,6 @@
1
1
  const libPictProvider = require('pict-provider');
2
2
 
3
- const _DEFAULT_PROVIDER_CONFIGURATION =
3
+ const _DEFAULT_PROVIDER_CONFIGURATION =
4
4
  {
5
5
  ProviderIdentifier: 'Postcard-DynamicSection-Provider',
6
6
 
@@ -18,6 +18,42 @@ class PostcardDynamicSectionProvider extends libPictProvider
18
18
 
19
19
  onInitializeAsync(fCallback)
20
20
  {
21
+ const tmpDynamicInputViewSection = (
22
+ {
23
+ "Hash": "PostkardDynamicInputs",
24
+ "Name": "Custom Dynamic Inputs",
25
+ "ViewHash": "MyDynamicView",
26
+
27
+ "AutoMarshalDataOnSolve": true,
28
+ "IncludeInMetatemplateSectionGeneration": false,
29
+
30
+ "Manifests": {
31
+ "Section": {
32
+ "Scope": "PostkardDyanmic",
33
+ "Sections": [
34
+ {
35
+ "Hash": "PostkardDynamicInputs",
36
+ "Name": "Dynamic Inputs"
37
+ }
38
+ ],
39
+ "Descriptors": {
40
+ "Postkard.DynamicInputPlaceholder": {
41
+ "Name": "DynamicInputPlaceholder",
42
+ "Hash": "DynamicInputPlaceholder",
43
+ "DataType": "String",
44
+ "Macro": {
45
+ "HTMLSelector": ""
46
+ },
47
+ "PictForm": {
48
+ "Section": "PostkardDynamicInputs"
49
+ }
50
+ }
51
+ }
52
+ }
53
+ }
54
+ });
55
+ const tmpViewConfiguration = Object.assign({}, tmpDynamicInputViewSection);
56
+ this.pict.views.PictFormMetacontroller.addDynamicView(tmpViewConfiguration.ViewHash, tmpViewConfiguration);
21
57
  this.log.info('PostcardDynamicSectionProvider.onInitializeAsync() called --- loading dynamic section views from "server".');
22
58
  // Load the dynamnic section views from the server
23
59
  this.pict.settings.DefaultFormManifest = require('./PictProvider-Dynamic-Sections-MockServerResponse.json');
@@ -28,4 +64,4 @@ class PostcardDynamicSectionProvider extends libPictProvider
28
64
  }
29
65
 
30
66
  module.exports = PostcardDynamicSectionProvider;
31
- module.exports.default_configuration = _DEFAULT_PROVIDER_CONFIGURATION;
67
+ module.exports.default_configuration = _DEFAULT_PROVIDER_CONFIGURATION;
@@ -1,5 +1,4 @@
1
1
  const libPictView = require('pict-view');
2
- const { isTemplateSpan } = require('typescript');
3
2
 
4
3
  const _ViewConfiguration = (
5
4
  {
@@ -26,6 +25,8 @@ and
26
25
 
27
26
  {~MTI:Second funny place for the data's storage, yo...:DynamoData.SomeFunnyPlaceForTheDataAsASignatureInputType:String:PostKardSignature~}
28
27
 
28
+ {~IWVDA:MyDynamicView:AppData.CustomDescriptor~}
29
+
29
30
  <br />
30
31
 
31
32
  <a href="#" onclick="_Pict.views.PostcardDynamicInputs.makeMoreInputs();" class="button">Add More Inputs</a>
@@ -52,14 +53,47 @@ class PostcardMainApplicationView extends libPictView
52
53
  this.inputCounter = 0;
53
54
  }
54
55
 
56
+ onInitialize()
57
+ {
58
+ this.pict.AppData.CustomDescriptor =
59
+ {
60
+ Hash: 'CustomPostkardData',
61
+ Name: 'Custom PostKard Data',
62
+ Address: 'CustomPostkardData',
63
+ DataType: 'String',
64
+ PictForm:
65
+ {
66
+ InputType: 'TexaArea',
67
+ Description: 'This is a custom descriptor for the PostKard application.',
68
+ },
69
+ };
70
+ return super.onInitialize();
71
+ }
72
+
55
73
  makeMoreInputs()
56
74
  {
57
75
  let tmpDefectInput = {
58
76
  SpecificDefectHash: this.fable.getUUID(),
59
77
  InputCounter: this.inputCounter++
60
78
  };
79
+ if (!Array.isArray(this.pict.AppData.CustomDescriptors))
80
+ {
81
+ this.pict.AppData.CustomDescriptors = [];
82
+ }
83
+ const tmpIndex = this.pict.AppData.CustomDescriptors.length;
84
+ this.pict.AppData.CustomDescriptors.push(
85
+ {
86
+ Hash: `CustomPostkardData${tmpIndex}`,
87
+ Name: `Custom PostKard Data ${tmpIndex}`,
88
+ Address: `CustomPostkardData${tmpIndex}`,
89
+ DataType: 'PreciseNumber',
90
+ PictForm:
91
+ {
92
+ Description: 'This is a custom descriptor for the PostKard application.',
93
+ },
94
+ });
61
95
 
62
- this.pict.parseTemplate('<p>Input Numero {~D:Record.InputCounter~}: {~MTIWHA:Nombre:Record.SpecificDefectHash:String~}</p>', tmpDefectInput,
96
+ this.pict.parseTemplate(`<p>Input Numero {~D:Record.InputCounter~}: {~MTIWHA:Nombre:Record.SpecificDefectHash:String~} {~IWVDA:MyDynamicView:AppData.CustomDescriptors[${tmpIndex}]~}</p>`, tmpDefectInput,
63
97
  function (pError, pParsedTemplate)
64
98
  {
65
99
  this.pict.ContentAssignment.appendContent('#DynamicInputContainer', pParsedTemplate);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pict-section-form",
3
- "version": "1.0.100",
3
+ "version": "1.0.102",
4
4
  "description": "Pict dynamic form sections",
5
5
  "main": "source/Pict-Section-Form.js",
6
6
  "directories": {
@@ -31,10 +31,10 @@
31
31
  "browser-env": "^3.3.0",
32
32
  "eslint": "^9.26.0",
33
33
  "jquery": "^3.7.1",
34
- "pict": "^1.0.273",
34
+ "pict": "^1.0.277",
35
35
  "pict-application": "^1.0.27",
36
36
  "pict-service-commandlineutility": "^1.0.15",
37
- "quackage": "^1.0.41",
37
+ "quackage": "^1.0.42",
38
38
  "tui-grid": "^4.21.22",
39
39
  "typescript": "^5.8.3"
40
40
  },
@@ -43,8 +43,8 @@
43
43
  "marked": "^15.0.11",
44
44
  "pict-provider": "^1.0.6",
45
45
  "pict-section-tuigrid": "^1.0.27",
46
- "pict-template": "^1.0.11",
47
- "pict-view": "^1.0.61"
46
+ "pict-template": "^1.0.12",
47
+ "pict-view": "^1.0.62"
48
48
  },
49
49
  "mocha": {
50
50
  "diff": true,
@@ -8,6 +8,9 @@ const templateSetReadOnlyTemplates = require('./dynamictemplates/Pict-DynamicTem
8
8
  const libTemplateValueSetWithGroup = require('../templates/Pict-Template-Metacontroller-ValueSetWithGroup.js');
9
9
  const libTemplateDynamicInput = require('../templates/Pict-Template-Metatemplate-Input.js');
10
10
  const libTemplateDynamicInputWithHashAddress = require('../templates/Pict-Template-Metatemplate-InputWithHashAddress.js');
11
+ const libTemplateDynamicInputWithView = require('../templates/Pict-Template-Metatemplate-InputWithView.js');
12
+ const libTemplateDynamicInputWithViewAndHashAddress = require('../templates/Pict-Template-Metatemplate-InputWithViewAndHashAddress.js');
13
+ const libTemplateDynamicInputWithViewAndDescriptorAddress = require('../templates/Pict-Template-Metatemplate-InputWithViewAndDescriptorAddress.js');
11
14
  const libTemplateControlFromDynamicManifest = require('../templates/Pict-Template-ControlFromDynamicManifest.js');
12
15
  const libTemplateControlFromDynamicManifestForHash = require('../templates/Pict-Template-ControlFromDynamicManifestForHash.js');
13
16
  const libTemplateGetViewSchemaValue = require('../templates/Pict-Template-DyanmicView-Value.js');
@@ -58,6 +61,9 @@ class PictDynamicFormsTemplates extends libPictProvider
58
61
  this.pict.addTemplate(libTemplateValueSetWithGroup);
59
62
  this.pict.addTemplate(libTemplateDynamicInput);
60
63
  this.pict.addTemplate(libTemplateDynamicInputWithHashAddress);
64
+ this.pict.addTemplate(libTemplateDynamicInputWithView);
65
+ this.pict.addTemplate(libTemplateDynamicInputWithViewAndHashAddress);
66
+ this.pict.addTemplate(libTemplateDynamicInputWithViewAndDescriptorAddress);
61
67
  this.pict.addTemplate(libTemplatePluckJoinUnique);
62
68
  this.pict.addTemplate(libTemplateControlFromDynamicManifest);
63
69
  this.pict.addTemplate(libTemplateControlFromDynamicManifestForHash);
@@ -66,11 +66,12 @@ class PictTemplateControlFromDynamicManifest extends libPictTemplate
66
66
  * @param {string} pTemplateHash - The schema hash of the control.
67
67
  * @param {object} pRecord - The record object.
68
68
  * @param {array} pContextArray - The context array.
69
+ * @param {any} [pScope] - A sticky scope that can be used to carry state and simplify template
69
70
  * @returns {string} - The rendered template.
70
71
  */
71
- render(pTemplateHash, pRecord, pContextArray)
72
+ render(pTemplateHash, pRecord, pContextArray, pScope)
72
73
  {
73
- return this.renderAsync(pTemplateHash, pRecord, null, pContextArray);
74
+ return this.renderAsync(pTemplateHash, pRecord, null, pContextArray, pScope);
74
75
  }
75
76
 
76
77
  /**
@@ -80,9 +81,10 @@ class PictTemplateControlFromDynamicManifest extends libPictTemplate
80
81
  * @param {object} pRecord - The record object.
81
82
  * @param {function | null} fCallback - The callback function.
82
83
  * @param {array} pContextArray - The context array.
84
+ * @param {any} [pScope] - A sticky scope that can be used to carry state and simplify template
83
85
  * @returns {string | undefined} - The rendered template or undefined if callback is provided.
84
86
  */
85
- renderAsync(pTemplateHash, pRecord, fCallback, pContextArray)
87
+ renderAsync(pTemplateHash, pRecord, fCallback, pContextArray, pScope)
86
88
  {
87
89
  const tmpMetatemplateGenerator = this.pict.providers.MetatemplateGenerator;
88
90
  const tmpHash = pTemplateHash.trim();
@@ -101,6 +103,8 @@ class PictTemplateControlFromDynamicManifest extends libPictTemplate
101
103
  return '';
102
104
  }
103
105
  const tmpView = this.pict.views[descriptor.PictForm.ViewHash];
106
+ const tmpScope = tmpView || pScope;
107
+ const tmpContextArray = tmpScope ? [ tmpScope ] : (pContextArray || [ this.pict ]);
104
108
 
105
109
  this.pict.providers.MetatemplateMacros.buildInputMacros(tmpView, descriptor);
106
110
 
@@ -109,7 +113,7 @@ class PictTemplateControlFromDynamicManifest extends libPictTemplate
109
113
  `getInput("${descriptor.PictForm.GroupIndex}","${descriptor.PictForm.RowIndex}","${descriptor.PictForm.InputIndex}")`);
110
114
 
111
115
  // Now parse it and return it.
112
- return this.pict.parseTemplate(tmpTemplate, descriptor, fCallback, [tmpView]);
116
+ return this.pict.parseTemplate(tmpTemplate, descriptor, fCallback, tmpContextArray, tmpScope);
113
117
  }
114
118
  }
115
119
 
@@ -31,11 +31,12 @@ class PictTemplateControlFromDynamicManifest extends libPictTemplate
31
31
  * @param {string} pTemplateHash - The schema hash of the control.
32
32
  * @param {object} pRecord - The record object.
33
33
  * @param {array} pContextArray - The context array.
34
+ * @param {any} [pScope] - A sticky scope that can be used to carry state and simplify template
34
35
  * @returns {string} - The rendered template.
35
36
  */
36
- render(pTemplateHash, pRecord, pContextArray)
37
+ render(pTemplateHash, pRecord, pContextArray, pScope)
37
38
  {
38
- return this.renderAsync(pTemplateHash, pRecord, null, pContextArray);
39
+ return this.renderAsync(pTemplateHash, pRecord, null, pContextArray, pScope);
39
40
  }
40
41
 
41
42
  /**
@@ -45,9 +46,10 @@ class PictTemplateControlFromDynamicManifest extends libPictTemplate
45
46
  * @param {object} pRecord - The record object.
46
47
  * @param {function | null} fCallback - The callback function.
47
48
  * @param {array} pContextArray - The context array.
49
+ * @param {any} [pScope] - A sticky scope that can be used to carry state and simplify template
48
50
  * @returns {string | undefined} - The rendered template or undefined if callback is provided.
49
51
  */
50
- renderAsync(pTemplateHash, pRecord, fCallback, pContextArray)
52
+ renderAsync(pTemplateHash, pRecord, fCallback, pContextArray, pScope)
51
53
  {
52
54
  const tmpMetatemplateGenerator = this.pict.providers.MetatemplateGenerator;
53
55
  const tmpHash = pTemplateHash.trim();
@@ -66,6 +68,8 @@ class PictTemplateControlFromDynamicManifest extends libPictTemplate
66
68
  return '';
67
69
  }
68
70
  const tmpView = this.pict.views[descriptor.PictForm.ViewHash];
71
+ const tmpScope = tmpView || pScope;
72
+ const tmpContextArray = tmpScope ? [ tmpScope ] : (pContextArray || [ this.pict ]);
69
73
 
70
74
  this.pict.providers.MetatemplateMacros.buildInputMacros(tmpView, descriptor);
71
75
 
@@ -74,7 +78,7 @@ class PictTemplateControlFromDynamicManifest extends libPictTemplate
74
78
  `getInput("${descriptor.PictForm.GroupIndex}","${descriptor.PictForm.RowIndex}","${descriptor.PictForm.InputIndex}")`);
75
79
 
76
80
  // Now parse it and return it.
77
- return this.pict.parseTemplate(tmpTemplate, descriptor, fCallback, [tmpView]);
81
+ return this.pict.parseTemplate(tmpTemplate, descriptor, fCallback, tmpContextArray, tmpScope);
78
82
  }
79
83
  }
80
84
 
@@ -31,11 +31,12 @@ class PictTemplateGetViewSchemaValue extends libPictTemplate
31
31
  * @param {string} pTemplateHash - The schema hash of the control.
32
32
  * @param {object} pRecord - The record object.
33
33
  * @param {array} pContextArray - The context array.
34
+ * @param {any} [pScope] - A sticky scope that can be used to carry state and simplify template
34
35
  * @returns {string} - The rendered template.
35
36
  */
36
- render(pTemplateHash, pRecord, pContextArray)
37
+ render(pTemplateHash, pRecord, pContextArray, pScope)
37
38
  {
38
- return this.renderAsync(pTemplateHash, pRecord, null, pContextArray);
39
+ return this.renderAsync(pTemplateHash, pRecord, null, pContextArray, pScope);
39
40
  }
40
41
 
41
42
  /**
@@ -45,9 +46,10 @@ class PictTemplateGetViewSchemaValue extends libPictTemplate
45
46
  * @param {object} pRecord - The record object.
46
47
  * @param {function | null} fCallback - The callback function.
47
48
  * @param {array} pContextArray - The context array.
49
+ * @param {any} [pScope] - A sticky scope that can be used to carry state and simplify template
48
50
  * @returns {string | undefined} - The rendered template or undefined if callback is provided.
49
51
  */
50
- renderAsync(pTemplateHash, pRecord, fCallback, pContextArray)
52
+ renderAsync(pTemplateHash, pRecord, fCallback, pContextArray, pScope)
51
53
  {
52
54
  const [ tmpSchemaAddress, tmpTemplateHash ] = pTemplateHash.trim().split('^');
53
55
  /** @type{import('../views/Pict-View-Form-Metacontroller.js')} */
@@ -74,7 +76,7 @@ class PictTemplateGetViewSchemaValue extends libPictTemplate
74
76
  const tmpRecord = { Value: value, ParentRecord: pRecord, View: tmpView, Descriptor: descriptor };
75
77
  if (typeof fCallback !== 'function')
76
78
  {
77
- return this.pict.parseTemplateByHash(tmpTemplateHash, tmpRecord, null, pContextArray);
79
+ return this.pict.parseTemplateByHash(tmpTemplateHash, tmpRecord, null, pContextArray, pScope);
78
80
  }
79
81
  return this.pict.parseTemplateByHash(tmpTemplateHash, tmpRecord,
80
82
  (pError, pValue) =>
@@ -84,7 +86,7 @@ class PictTemplateGetViewSchemaValue extends libPictTemplate
84
86
  return fCallback(pError, '');
85
87
  }
86
88
  return fCallback(null, pValue);
87
- }, pContextArray);
89
+ }, pContextArray, pScope);
88
90
  }
89
91
 
90
92
  if (typeof(fCallback) === 'function')
@@ -31,11 +31,12 @@ class PictTemplateGetViewSchemaValueByHash extends libPictTemplate
31
31
  * @param {string} pTemplateHash - The schema hash of the control.
32
32
  * @param {object} pRecord - The record object.
33
33
  * @param {array} pContextArray - The context array.
34
+ * @param {any} [pScope] - A sticky scope that can be used to carry state and simplify template
34
35
  * @returns {string} - The rendered template.
35
36
  */
36
- render(pTemplateHash, pRecord, pContextArray)
37
+ render(pTemplateHash, pRecord, pContextArray, pScope)
37
38
  {
38
- return this.renderAsync(pTemplateHash, pRecord, null, pContextArray);
39
+ return this.renderAsync(pTemplateHash, pRecord, null, pContextArray, pScope);
39
40
  }
40
41
 
41
42
  /**
@@ -45,9 +46,10 @@ class PictTemplateGetViewSchemaValueByHash extends libPictTemplate
45
46
  * @param {object} pRecord - The record object.
46
47
  * @param {function | null} fCallback - The callback function.
47
48
  * @param {array} pContextArray - The context array.
49
+ * @param {any} [pScope] - A sticky scope that can be used to carry state and simplify template
48
50
  * @returns {string | undefined} - The rendered template or undefined if callback is provided.
49
51
  */
50
- renderAsync(pTemplateHash, pRecord, fCallback, pContextArray)
52
+ renderAsync(pTemplateHash, pRecord, fCallback, pContextArray, pScope)
51
53
  {
52
54
  const [ tmpSchemaHash, tmpTemplateHash ] = pTemplateHash.trim().split('^');
53
55
  /** @type{import('../views/Pict-View-Form-Metacontroller.js')} */
@@ -74,7 +76,7 @@ class PictTemplateGetViewSchemaValueByHash extends libPictTemplate
74
76
  const tmpRecord = { Value: value, ParentRecord: pRecord, View: tmpView, Descriptor: descriptor };
75
77
  if (typeof fCallback !== 'function')
76
78
  {
77
- return this.pict.parseTemplateByHash(tmpTemplateHash, tmpRecord, null, pContextArray);
79
+ return this.pict.parseTemplateByHash(tmpTemplateHash, tmpRecord, null, pContextArray, pScope);
78
80
  }
79
81
  return this.pict.parseTemplateByHash(tmpTemplateHash, tmpRecord,
80
82
  (pError, pValue) =>
@@ -84,7 +86,7 @@ class PictTemplateGetViewSchemaValueByHash extends libPictTemplate
84
86
  return fCallback(pError, '');
85
87
  }
86
88
  return fCallback(null, pValue);
87
- }, pContextArray);
89
+ }, pContextArray, pScope);
88
90
  }
89
91
 
90
92
  if (typeof(fCallback) === 'function')
@@ -33,9 +33,10 @@ class PictTemplateMetacontrollerValueSet extends libPictTemplate
33
33
  * @param {string} pTemplateHash - The template hash.
34
34
  * @param {object} pRecord - The record object.
35
35
  * @param {array} pContextArray - The context array.
36
+ * @param {any} [pScope] - A sticky scope that can be used to carry state and simplify template
36
37
  * @returns {string} - The rendered template.
37
38
  */
38
- render(pTemplateHash, pRecord, pContextArray)
39
+ render(pTemplateHash, pRecord, pContextArray, pScope)
39
40
  {
40
41
  let tmpHash = pTemplateHash.trim();
41
42
  let tmpData = (typeof (pRecord) === 'object') ? pRecord : {};
@@ -64,7 +65,7 @@ class PictTemplateMetacontrollerValueSet extends libPictTemplate
64
65
  tmpGroupIndex = tmpHashTemplateSeparator[1];
65
66
  tmpAddressOfData = tmpHashTemplateSeparator[2];
66
67
 
67
- tmpData = this.resolveStateFromAddress(tmpAddressOfData, tmpData, pContextArray);
68
+ tmpData = this.resolveStateFromAddress(tmpAddressOfData, tmpData, pContextArray, null, pScope);
68
69
 
69
70
  let tmpDataValueSet = [];
70
71
  if (Array.isArray(tmpData))
@@ -91,11 +92,11 @@ class PictTemplateMetacontrollerValueSet extends libPictTemplate
91
92
  if (!tmpData)
92
93
  {
93
94
  // No address was provided, just render the template with what this template has.
94
- return this.pict.parseTemplateSetByHash(tmpTemplateHash, pRecord, null, pContextArray);
95
+ return this.pict.parseTemplateSetByHash(tmpTemplateHash, pRecord, null, pContextArray, pScope);
95
96
  }
96
97
  else
97
98
  {
98
- return this.pict.parseTemplateSetByHash(tmpTemplateHash, tmpData, null, pContextArray);
99
+ return this.pict.parseTemplateSetByHash(tmpTemplateHash, tmpData, null, pContextArray, pScope);
99
100
  }
100
101
  }
101
102
 
@@ -106,10 +107,11 @@ class PictTemplateMetacontrollerValueSet extends libPictTemplate
106
107
  * @param {object} pRecord - The record object to use for rendering the template.
107
108
  * @param {function} fCallback - The callback function to invoke after rendering the template.
108
109
  * @param {array} pContextArray - The context array to use for resolving the data.
110
+ * @param {any} [pScope] - A sticky scope that can be used to carry state and simplify template
109
111
  *
110
112
  * @return {void}
111
113
  */
112
- renderAsync(pTemplateHash, pRecord, fCallback, pContextArray)
114
+ renderAsync(pTemplateHash, pRecord, fCallback, pContextArray, pScope)
113
115
  {
114
116
  let tmpHash = pTemplateHash.trim();
115
117
  let tmpData = (typeof (pRecord) === 'object') ? pRecord : {};
@@ -147,7 +149,7 @@ class PictTemplateMetacontrollerValueSet extends libPictTemplate
147
149
  }
148
150
 
149
151
  // Now resolve the data
150
- tmpData = this.resolveStateFromAddress(tmpAddressOfData, tmpData, pContextArray);
152
+ tmpData = this.resolveStateFromAddress(tmpAddressOfData, tmpData, pContextArray, null, pScope);
151
153
 
152
154
  let tmpDataValueSet = [];
153
155
  if (Array.isArray(tmpData))
@@ -183,7 +185,7 @@ class PictTemplateMetacontrollerValueSet extends libPictTemplate
183
185
  return tmpCallback(pError, '');
184
186
  }
185
187
  return tmpCallback(null, pValue);
186
- }, pContextArray);
188
+ }, pContextArray, pScope);
187
189
  return;
188
190
  }
189
191
  else
@@ -196,7 +198,7 @@ class PictTemplateMetacontrollerValueSet extends libPictTemplate
196
198
  return tmpCallback(pError, '');
197
199
  }
198
200
  return tmpCallback(null, pValue);
199
- }, pContextArray);
201
+ }, pContextArray, pScope);
200
202
  return;
201
203
  }
202
204
  }
@@ -33,9 +33,10 @@ class PictTemplateMetatemplateInputTemplate extends libPictTemplate
33
33
  * @param {string} pTemplateHash - The template hash.
34
34
  * @param {object} pRecord - The record object.
35
35
  * @param {array} pContextArray - The context array.
36
+ * @param {any} [pScope] - A sticky scope that can be used to carry state and simplify template
36
37
  * @returns {string} - The rendered template.
37
38
  */
38
- render(pTemplateHash, pRecord, pContextArray)
39
+ render(pTemplateHash, pRecord, pContextArray, pScope)
39
40
  {
40
41
  let tmpHash = pTemplateHash.trim();
41
42
  let tmpMetatemplateGenerator = this.pict.providers.MetatemplateGenerator;
@@ -93,7 +94,7 @@ class PictTemplateMetatemplateInputTemplate extends libPictTemplate
93
94
  if (tmpRow.Inputs[i].Hash === tmpInput.Hash)
94
95
  {
95
96
  let tmpInput = tmpRow.Inputs[i];
96
- return this.pict.parseTemplate(tmpMetatemplateGenerator.getInputMetatemplateTemplateReference(tmpMetatemplateGenerator.dynamicInputView, tmpInput.DataType, tmpInput.PictForm.InputType, `getInput("0","0","${tmpInput.PictForm.InputIndex}")`), tmpInput, null, [tmpMetatemplateGenerator.dynamicInputView]);
97
+ return this.pict.parseTemplate(tmpMetatemplateGenerator.getInputMetatemplateTemplateReference(tmpMetatemplateGenerator.dynamicInputView, tmpInput.DataType, tmpInput.PictForm.InputType, `getInput("0","0","${tmpInput.PictForm.InputIndex}")`), tmpInput, null, [tmpMetatemplateGenerator.dynamicInputView], tmpMetatemplateGenerator.dynamicInputView);
97
98
  }
98
99
  }
99
100
 
@@ -108,7 +109,7 @@ class PictTemplateMetatemplateInputTemplate extends libPictTemplate
108
109
  let tmpTemplate = tmpMetatemplateGenerator.getInputMetatemplateTemplateReference(tmpMetatemplateGenerator.dynamicInputView, tmpInput.DataType, tmpInput.PictForm.InputType, `getInput("0","0","${tmpInput.PictForm.InputIndex}")`);
109
110
 
110
111
  // Now parse it and return it.
111
- return this.pict.parseTemplate(tmpTemplate, tmpInput, null, [tmpMetatemplateGenerator.dynamicInputView]);
112
+ return this.pict.parseTemplate(tmpTemplate, tmpInput, null, [tmpMetatemplateGenerator.dynamicInputView], tmpMetatemplateGenerator.dynamicInputView);
112
113
  }
113
114
 
114
115
  /**
@@ -118,10 +119,11 @@ class PictTemplateMetatemplateInputTemplate extends libPictTemplate
118
119
  * @param {object} pRecord - The record object.
119
120
  * @param {function | null} fCallback - The callback function.
120
121
  * @param {array} pContextArray - The context array.
122
+ * @param {any} [pScope] - A sticky scope that can be used to carry state and simplify template
121
123
  *
122
124
  * @return {void}
123
125
  */
124
- renderAsync(pTemplateHash, pRecord, fCallback, pContextArray)
126
+ renderAsync(pTemplateHash, pRecord, fCallback, pContextArray, pScope)
125
127
  {
126
128
  let tmpHash = pTemplateHash.trim();
127
129
  let tmpMetatemplateGenerator = this.pict.providers.MetatemplateGenerator;
@@ -180,7 +182,7 @@ class PictTemplateMetatemplateInputTemplate extends libPictTemplate
180
182
  {
181
183
  let tmpInput = tmpRow.Inputs[i];
182
184
  let tmpTemplate = tmpMetatemplateGenerator.getInputMetatemplateTemplateReference(tmpMetatemplateGenerator.dynamicInputView, tmpInput.DataType, tmpInput.PictForm.InputType, `getInput("0","0","${tmpInput.PictForm.InputIndex}")`);
183
- this.pict.parseTemplate(tmpTemplate, tmpInput, fCallback, [tmpMetatemplateGenerator.dynamicInputView]);
185
+ this.pict.parseTemplate(tmpTemplate, tmpInput, fCallback, [tmpMetatemplateGenerator.dynamicInputView], tmpMetatemplateGenerator.dynamicInputView);
184
186
  return;
185
187
  }
186
188
  }
@@ -195,7 +197,7 @@ class PictTemplateMetatemplateInputTemplate extends libPictTemplate
195
197
  // Now generate the metatemplate
196
198
  let tmpTemplate = tmpMetatemplateGenerator.getInputMetatemplateTemplateReference(tmpMetatemplateGenerator.dynamicInputView, tmpInput.DataType, tmpInput.PictForm.InputType, `getInput("0","0","${tmpInput.PictForm.InputIndex}")`);
197
199
 
198
- this.pict.parseTemplate(tmpTemplate, tmpInput, fCallback, [tmpMetatemplateGenerator.dynamicInputView]);
200
+ this.pict.parseTemplate(tmpTemplate, tmpInput, fCallback, [tmpMetatemplateGenerator.dynamicInputView], tmpMetatemplateGenerator.dynamicInputView);
199
201
  return;
200
202
  }
201
203
  }
@@ -33,9 +33,10 @@ class PictTemplateMetatemplateInputTemplate extends libPictTemplate
33
33
  * @param {string} pTemplateHash - The template hash.
34
34
  * @param {object} pRecord - The record object.
35
35
  * @param {array} pContextArray - The context array.
36
+ * @param {any} [pScope] - A sticky scope that can be used to carry state and simplify template
36
37
  * @returns {string} - The rendered template.
37
38
  */
38
- render(pTemplateHash, pRecord, pContextArray)
39
+ render(pTemplateHash, pRecord, pContextArray, pScope)
39
40
  {
40
41
  let tmpHash = pTemplateHash.trim();
41
42
  let tmpMetatemplateGenerator = this.pict.providers.MetatemplateGenerator;
@@ -59,7 +60,8 @@ class PictTemplateMetatemplateInputTemplate extends libPictTemplate
59
60
  }
60
61
  tmpInputName = tmpHashTemplateSeparator[0];
61
62
  // This template expects this address to be a location to get the hash from...
62
- tmpInputAddress = this.resolveStateFromAddress(tmpHashTemplateSeparator[1], pRecord, pContextArray);
63
+ //FIXME: should pScope here be the eventual view so the scope is consistent?
64
+ tmpInputAddress = this.resolveStateFromAddress(tmpHashTemplateSeparator[1], pRecord, pContextArray, null, pScope);
63
65
  if ((typeof(tmpInputAddress) !== 'string') || tmpInputAddress.length < 1)
64
66
  {
65
67
  this.log.warn(`MetaTemplateInput template requires a valid Address for an Address in the second parameter [${tmpHash}]`);
@@ -102,7 +104,7 @@ class PictTemplateMetatemplateInputTemplate extends libPictTemplate
102
104
  {
103
105
  const tmpInput = tmpRow.Inputs[i];
104
106
  return this.pict.parseTemplate(tmpMetatemplateGenerator.getInputMetatemplateTemplateReference(tmpMetatemplateGenerator.dynamicInputView,
105
- tmpInput.DataType, tmpInput.PictForm.InputType, `getInput("0","0","${tmpInput.PictForm.InputIndex}")`), tmpInput, null, [tmpMetatemplateGenerator.dynamicInputView]);
107
+ tmpInput.DataType, tmpInput.PictForm.InputType, `getInput("0","0","${tmpInput.PictForm.InputIndex}")`), tmpInput, null, [tmpMetatemplateGenerator.dynamicInputView], tmpMetatemplateGenerator.dynamicInputView);
106
108
  }
107
109
  }
108
110
 
@@ -118,7 +120,7 @@ class PictTemplateMetatemplateInputTemplate extends libPictTemplate
118
120
  tmpInput.DataType, tmpInput.PictForm.InputType, `getInput("0","0","${tmpInput.PictForm.InputIndex}")`);
119
121
 
120
122
  // Now parse it and return it.
121
- return this.pict.parseTemplate(tmpTemplate, tmpInput, null, [tmpMetatemplateGenerator.dynamicInputView]);
123
+ return this.pict.parseTemplate(tmpTemplate, tmpInput, null, [tmpMetatemplateGenerator.dynamicInputView], tmpMetatemplateGenerator.dynamicInputView);
122
124
  }
123
125
 
124
126
  /**
@@ -128,10 +130,11 @@ class PictTemplateMetatemplateInputTemplate extends libPictTemplate
128
130
  * @param {object} pRecord - The record object.
129
131
  * @param {function | null} fCallback - The callback function.
130
132
  * @param {array} pContextArray - The context array.
133
+ * @param {any} [pScope] - A sticky scope that can be used to carry state and simplify template
131
134
  *
132
135
  * @return {void}
133
136
  */
134
- renderAsync(pTemplateHash, pRecord, fCallback, pContextArray)
137
+ renderAsync(pTemplateHash, pRecord, fCallback, pContextArray, pScope)
135
138
  {
136
139
  let tmpHash = pTemplateHash.trim();
137
140
  let tmpMetatemplateGenerator = this.pict.providers.MetatemplateGenerator;
@@ -146,7 +149,7 @@ class PictTemplateMetatemplateInputTemplate extends libPictTemplate
146
149
  let tmpDataType;
147
150
  let tmpInputType;
148
151
 
149
- // This is just a simple 2 part hash (the entity and the ID)
152
+ // This is just a simple 2 part hash (the Address and the DataType)
150
153
  let tmpHashTemplateSeparator = tmpHash.split(':');
151
154
  if (tmpHashTemplateSeparator.length < 2)
152
155
  {
@@ -155,7 +158,8 @@ class PictTemplateMetatemplateInputTemplate extends libPictTemplate
155
158
  }
156
159
  tmpInputName = tmpHashTemplateSeparator[0];
157
160
  // This template expects this address to be a location to get the hash from...
158
- tmpInputAddress = this.resolveStateFromAddress(tmpHashTemplateSeparator[1], pRecord, pContextArray);
161
+ //FIXME: should pScope here be the eventual view so the scope is consistent?
162
+ tmpInputAddress = this.resolveStateFromAddress(tmpHashTemplateSeparator[1], pRecord, pContextArray, null, pScope);
159
163
  if ((typeof(tmpInputAddress) !== 'string') || tmpInputAddress.length < 1)
160
164
  {
161
165
  this.log.warn(`MetaTemplateInput template requires a valid Address for an Address in the second parameter [${tmpHash}]`);
@@ -197,7 +201,7 @@ class PictTemplateMetatemplateInputTemplate extends libPictTemplate
197
201
  let tmpInput = tmpRow.Inputs[i];
198
202
  let tmpTemplate = tmpMetatemplateGenerator.getInputMetatemplateTemplateReference(tmpMetatemplateGenerator.dynamicInputView,
199
203
  tmpInput.DataType, tmpInput.PictForm.InputType, `getInput("0","0","${tmpInput.PictForm.InputIndex}")`);
200
- this.pict.parseTemplate(tmpTemplate, tmpInput, fCallback, [tmpMetatemplateGenerator.dynamicInputView]);
204
+ this.pict.parseTemplate(tmpTemplate, tmpInput, fCallback, [tmpMetatemplateGenerator.dynamicInputView], tmpMetatemplateGenerator.dynamicInputView);
201
205
  return;
202
206
  }
203
207
  }
@@ -213,7 +217,7 @@ class PictTemplateMetatemplateInputTemplate extends libPictTemplate
213
217
  const tmpTemplate = tmpMetatemplateGenerator.getInputMetatemplateTemplateReference(tmpMetatemplateGenerator.dynamicInputView,
214
218
  tmpInput.DataType, tmpInput.PictForm.InputType, `getInput("0","0","${tmpInput.PictForm.InputIndex}")`);
215
219
 
216
- this.pict.parseTemplate(tmpTemplate, tmpInput, fCallback, [tmpMetatemplateGenerator.dynamicInputView]);
220
+ this.pict.parseTemplate(tmpTemplate, tmpInput, fCallback, [tmpMetatemplateGenerator.dynamicInputView], tmpMetatemplateGenerator.dynamicInputView);
217
221
  return;
218
222
  }
219
223
  }