pict-section-form 1.0.101 → 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.
- package/example_applications/postcard_example/providers/PictProvider-Dynamic-Sections.js +38 -2
- package/example_applications/postcard_example/views/PictView-Postcard-DynamicInputs.js +36 -2
- package/package.json +2 -2
- package/source/providers/Pict-Provider-DynamicTemplates.js +6 -0
- package/source/templates/Pict-Template-Metatemplate-InputWithHashAddress.js +1 -1
- package/source/templates/Pict-Template-Metatemplate-InputWithView.js +224 -0
- package/source/templates/Pict-Template-Metatemplate-InputWithViewAndDescriptorAddress.js +225 -0
- package/source/templates/Pict-Template-Metatemplate-InputWithViewAndHashAddress.js +244 -0
- package/types/source/providers/Pict-Provider-DynamicTemplates.d.ts.map +1 -1
- package/types/source/providers/Pict-Provider-Informary.d.ts +2 -2
- package/types/source/providers/Pict-Provider-Informary.d.ts.map +1 -1
- package/types/source/templates/Pict-Template-Metatemplate-InputWithView.d.ts +35 -0
- package/types/source/templates/Pict-Template-Metatemplate-InputWithView.d.ts.map +1 -0
- package/types/source/templates/Pict-Template-Metatemplate-InputWithViewAndDescriptorAddress.d.ts +36 -0
- package/types/source/templates/Pict-Template-Metatemplate-InputWithViewAndDescriptorAddress.d.ts.map +1 -0
- package/types/source/templates/Pict-Template-Metatemplate-InputWithViewAndHashAddress.d.ts +35 -0
- package/types/source/templates/Pict-Template-Metatemplate-InputWithViewAndHashAddress.d.ts.map +1 -0
|
@@ -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(
|
|
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.
|
|
3
|
+
"version": "1.0.102",
|
|
4
4
|
"description": "Pict dynamic form sections",
|
|
5
5
|
"main": "source/Pict-Section-Form.js",
|
|
6
6
|
"directories": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"browser-env": "^3.3.0",
|
|
32
32
|
"eslint": "^9.26.0",
|
|
33
33
|
"jquery": "^3.7.1",
|
|
34
|
-
"pict": "^1.0.
|
|
34
|
+
"pict": "^1.0.277",
|
|
35
35
|
"pict-application": "^1.0.27",
|
|
36
36
|
"pict-service-commandlineutility": "^1.0.15",
|
|
37
37
|
"quackage": "^1.0.42",
|
|
@@ -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);
|
|
@@ -149,7 +149,7 @@ class PictTemplateMetatemplateInputTemplate extends libPictTemplate
|
|
|
149
149
|
let tmpDataType;
|
|
150
150
|
let tmpInputType;
|
|
151
151
|
|
|
152
|
-
// This is just a simple 2 part hash (the
|
|
152
|
+
// This is just a simple 2 part hash (the Address and the DataType)
|
|
153
153
|
let tmpHashTemplateSeparator = tmpHash.split(':');
|
|
154
154
|
if (tmpHashTemplateSeparator.length < 2)
|
|
155
155
|
{
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
const libPictTemplate = require('pict-template');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This is a template that will generate a dynamic input using a provided dynamic view (by hash)
|
|
5
|
+
*/
|
|
6
|
+
class PictTemplateInputWithViewTemplate extends libPictTemplate
|
|
7
|
+
{
|
|
8
|
+
/**
|
|
9
|
+
* @param {Object} pFable - The Fable Framework instance
|
|
10
|
+
* @param {Object} pOptions - The options for the service
|
|
11
|
+
* @param {String} pServiceHash - The hash of the service
|
|
12
|
+
*/
|
|
13
|
+
constructor(pFable, pOptions, pServiceHash)
|
|
14
|
+
{
|
|
15
|
+
super(pFable, pOptions, pServiceHash);
|
|
16
|
+
|
|
17
|
+
/** @type {import('pict')} */
|
|
18
|
+
this.pict;
|
|
19
|
+
/** @type {import('pict') & { ManifestFactory: import('../services/ManifestFactory.js') }} */
|
|
20
|
+
this.fable;
|
|
21
|
+
/** @type {any} */
|
|
22
|
+
this.log;
|
|
23
|
+
|
|
24
|
+
this.addPattern('{~InputWithView:', '~}');
|
|
25
|
+
this.addPattern('{~IWV:', '~}');
|
|
26
|
+
|
|
27
|
+
this.currentInputIndex = 0;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Renders an arbitrary PICT input by hash, with a custom data type, input type and label. The Record reference is ignored in this template.
|
|
32
|
+
*
|
|
33
|
+
* @param {string} pTemplateHash - The template hash.
|
|
34
|
+
* @param {object} pRecord - The record object.
|
|
35
|
+
* @param {array} pContextArray - The context array.
|
|
36
|
+
* @param {any} [pScope] - A sticky scope that can be used to carry state and simplify template
|
|
37
|
+
* @returns {string} - The rendered template.
|
|
38
|
+
*/
|
|
39
|
+
render(pTemplateHash, pRecord, pContextArray, pScope)
|
|
40
|
+
{
|
|
41
|
+
let tmpHash = pTemplateHash.trim();
|
|
42
|
+
let tmpMetatemplateGenerator = this.pict.providers.MetatemplateGenerator;
|
|
43
|
+
|
|
44
|
+
if (this.pict.LogNoisiness > 0)
|
|
45
|
+
{
|
|
46
|
+
this.log.trace(`PICT Metacontroller Template [InputWithView]::[${tmpHash}]`);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
let tmpViewHash;
|
|
50
|
+
let tmpInputName;
|
|
51
|
+
let tmpInputAddress;
|
|
52
|
+
let tmpDataType;
|
|
53
|
+
let tmpInputType;
|
|
54
|
+
|
|
55
|
+
let tmpHashTemplateSeparator = tmpHash.split(':');
|
|
56
|
+
if (tmpHashTemplateSeparator.length < 3)
|
|
57
|
+
{
|
|
58
|
+
this.log.warn(`InputWithView template requires at least three parameters (ViewHash, Address and DataType) [${tmpHash}]`);
|
|
59
|
+
return '';
|
|
60
|
+
}
|
|
61
|
+
tmpViewHash = tmpHashTemplateSeparator[0];
|
|
62
|
+
tmpInputName = tmpHashTemplateSeparator[1];
|
|
63
|
+
tmpInputAddress = tmpHashTemplateSeparator[2];
|
|
64
|
+
tmpDataType = tmpHashTemplateSeparator[3];
|
|
65
|
+
if (tmpHashTemplateSeparator.length > 4)
|
|
66
|
+
{
|
|
67
|
+
tmpInputType = tmpHashTemplateSeparator[4];
|
|
68
|
+
}
|
|
69
|
+
// Construct a fake input object
|
|
70
|
+
let tmpInput = {
|
|
71
|
+
Address: tmpInputAddress,
|
|
72
|
+
DataAddress: tmpInputAddress,
|
|
73
|
+
Name: tmpInputName,
|
|
74
|
+
Hash: this.fable.ManifestFactory.sanitizeObjectKey(tmpInputAddress),
|
|
75
|
+
DataType: tmpDataType,
|
|
76
|
+
PictForm: {
|
|
77
|
+
InformaryDataAddress: tmpInputAddress,
|
|
78
|
+
GroupIndex: 0,
|
|
79
|
+
Row: 0
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
this.currentInputIndex++;
|
|
84
|
+
|
|
85
|
+
if (tmpInputType)
|
|
86
|
+
{
|
|
87
|
+
tmpInput.PictForm.InputType = tmpInputType;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const tmpInputView = this.pict.views[tmpViewHash];
|
|
91
|
+
|
|
92
|
+
if (!tmpInputView || !tmpInputView.sectionManifest || typeof tmpInputView.getRow !== 'function')
|
|
93
|
+
{
|
|
94
|
+
this.log.warn(`InputWithView template requires a valid dynamic View hash [${tmpHash}]`);
|
|
95
|
+
return '';
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Check to see if the input is already in the manifest
|
|
99
|
+
let tmpRow = tmpInputView.getRow(0, 0);
|
|
100
|
+
|
|
101
|
+
for (let i = 0; i < tmpRow.Inputs.length; i++)
|
|
102
|
+
{
|
|
103
|
+
if (tmpRow.Inputs[i].Hash === tmpInput.Hash)
|
|
104
|
+
{
|
|
105
|
+
let tmpInput = tmpRow.Inputs[i];
|
|
106
|
+
return this.pict.parseTemplate(tmpMetatemplateGenerator.getInputMetatemplateTemplateReference(tmpInputView, tmpInput.DataType, tmpInput.PictForm.InputType, `getInput("0","0","${tmpInput.PictForm.InputIndex}")`), tmpInput, null, [tmpInputView], tmpInputView);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// It isn't already in the manifest, so add it.
|
|
111
|
+
tmpInput.PictForm.InputIndex = tmpRow.Inputs.length;
|
|
112
|
+
tmpInputView.sectionManifest.addDescriptor(tmpInput.Address, tmpInput);
|
|
113
|
+
tmpRow.Inputs.push(tmpInput);
|
|
114
|
+
|
|
115
|
+
this.pict.providers.MetatemplateMacros.buildInputMacros(tmpInputView, tmpInput);
|
|
116
|
+
|
|
117
|
+
// Now generate the metatemplate
|
|
118
|
+
let tmpTemplate = tmpMetatemplateGenerator.getInputMetatemplateTemplateReference(tmpInputView, tmpInput.DataType, tmpInput.PictForm.InputType, `getInput("0","0","${tmpInput.PictForm.InputIndex}")`);
|
|
119
|
+
|
|
120
|
+
// Now parse it and return it.
|
|
121
|
+
return this.pict.parseTemplate(tmpTemplate, tmpInput, null, [tmpInputView], tmpInputView);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Renders an arbitrary PICT input by hash, with a custom data type, input type and label. The Record reference is ignored in this template.
|
|
126
|
+
*
|
|
127
|
+
* @param {string} pTemplateHash - The schema hash of the control.
|
|
128
|
+
* @param {object} pRecord - The record object.
|
|
129
|
+
* @param {function | null} fCallback - The callback function.
|
|
130
|
+
* @param {array} pContextArray - The context array.
|
|
131
|
+
* @param {any} [pScope] - A sticky scope that can be used to carry state and simplify template
|
|
132
|
+
*
|
|
133
|
+
* @return {void}
|
|
134
|
+
*/
|
|
135
|
+
renderAsync(pTemplateHash, pRecord, fCallback, pContextArray, pScope)
|
|
136
|
+
{
|
|
137
|
+
let tmpHash = pTemplateHash.trim();
|
|
138
|
+
let tmpMetatemplateGenerator = this.pict.providers.MetatemplateGenerator;
|
|
139
|
+
|
|
140
|
+
if (this.pict.LogNoisiness > 0)
|
|
141
|
+
{
|
|
142
|
+
this.log.trace(`PICT Metacontroller Template [InputWithView]::[${tmpHash}]`);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
let tmpViewHash;
|
|
146
|
+
let tmpInputName;
|
|
147
|
+
let tmpInputAddress;
|
|
148
|
+
let tmpDataType;
|
|
149
|
+
let tmpInputType;
|
|
150
|
+
|
|
151
|
+
// This is just a simple 2 part hash (the entity and the ID)
|
|
152
|
+
let tmpHashTemplateSeparator = tmpHash.split(':');
|
|
153
|
+
if (tmpHashTemplateSeparator.length < 3)
|
|
154
|
+
{
|
|
155
|
+
this.log.warn(`InputWithView template requires at least three parameters (ViewHash, Address and DataType) [${tmpHash}]`);
|
|
156
|
+
return fCallback(null, '');
|
|
157
|
+
}
|
|
158
|
+
tmpViewHash = tmpHashTemplateSeparator[0];
|
|
159
|
+
tmpInputName = tmpHashTemplateSeparator[1];
|
|
160
|
+
tmpInputAddress = tmpHashTemplateSeparator[2];
|
|
161
|
+
tmpDataType = tmpHashTemplateSeparator[3];
|
|
162
|
+
if (tmpHashTemplateSeparator.length > 4)
|
|
163
|
+
{
|
|
164
|
+
tmpInputType = tmpHashTemplateSeparator[4];
|
|
165
|
+
}
|
|
166
|
+
// Construct a fake input object
|
|
167
|
+
let tmpInput = {
|
|
168
|
+
Address: tmpInputAddress,
|
|
169
|
+
DataAddress: tmpInputAddress,
|
|
170
|
+
Name: tmpInputName,
|
|
171
|
+
Hash: this.fable.ManifestFactory.sanitizeObjectKey(tmpInputAddress),
|
|
172
|
+
DataType: tmpDataType,
|
|
173
|
+
PictForm: {
|
|
174
|
+
InformaryDataAddress: tmpInputAddress,
|
|
175
|
+
GroupIndex: 0,
|
|
176
|
+
Row: 0
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
this.currentInputIndex++;
|
|
181
|
+
|
|
182
|
+
if (tmpInputType)
|
|
183
|
+
{
|
|
184
|
+
tmpInput.PictForm.InputType = tmpInputType;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const tmpInputView = this.pict.views[tmpViewHash];
|
|
188
|
+
|
|
189
|
+
if (!tmpInputView || !tmpInputView.sectionManifest || typeof tmpInputView.getRow !== 'function')
|
|
190
|
+
{
|
|
191
|
+
this.log.warn(`InputWithView template requires a valid dynamic View hash [${tmpHash}]`);
|
|
192
|
+
return fCallback(null, '');
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// Check to see if the input is already in the manifest
|
|
196
|
+
let tmpRow = tmpInputView.getRow(0, 0);
|
|
197
|
+
|
|
198
|
+
for (let i = 0; i < tmpRow.Inputs.length; i++)
|
|
199
|
+
{
|
|
200
|
+
if (tmpRow.Inputs[i].Hash === tmpInput.Hash)
|
|
201
|
+
{
|
|
202
|
+
let tmpInput = tmpRow.Inputs[i];
|
|
203
|
+
let tmpTemplate = tmpMetatemplateGenerator.getInputMetatemplateTemplateReference(tmpInputView, tmpInput.DataType, tmpInput.PictForm.InputType, `getInput("0","0","${tmpInput.PictForm.InputIndex}")`);
|
|
204
|
+
this.pict.parseTemplate(tmpTemplate, tmpInput, fCallback, [tmpInputView], tmpInputView);
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// It isn't already in the manifest, so add it.
|
|
210
|
+
tmpInput.PictForm.InputIndex = tmpRow.Inputs.length;
|
|
211
|
+
tmpInputView.sectionManifest.addDescriptor(tmpInput.Address, tmpInput);
|
|
212
|
+
tmpRow.Inputs.push(tmpInput);
|
|
213
|
+
|
|
214
|
+
this.pict.providers.MetatemplateMacros.buildInputMacros(tmpInputView, tmpInput);
|
|
215
|
+
|
|
216
|
+
// Now generate the metatemplate
|
|
217
|
+
let tmpTemplate = tmpMetatemplateGenerator.getInputMetatemplateTemplateReference(tmpInputView, tmpInput.DataType, tmpInput.PictForm.InputType, `getInput("0","0","${tmpInput.PictForm.InputIndex}")`);
|
|
218
|
+
|
|
219
|
+
this.pict.parseTemplate(tmpTemplate, tmpInput, fCallback, [tmpInputView], tmpInputView);
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
module.exports = PictTemplateInputWithViewTemplate;
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
const libPictTemplate = require('pict-template');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This is a template that will generate a dynamic input using a provided dynamic view (by hash)
|
|
5
|
+
*/
|
|
6
|
+
class PictTemplateInputWithViewAndDescriptorAddressTemplate extends libPictTemplate
|
|
7
|
+
{
|
|
8
|
+
/**
|
|
9
|
+
* @param {Object} pFable - The Fable Framework instance
|
|
10
|
+
* @param {Object} pOptions - The options for the service
|
|
11
|
+
* @param {String} pServiceHash - The hash of the service
|
|
12
|
+
*/
|
|
13
|
+
constructor(pFable, pOptions, pServiceHash)
|
|
14
|
+
{
|
|
15
|
+
super(pFable, pOptions, pServiceHash);
|
|
16
|
+
|
|
17
|
+
/** @type {import('pict')} */
|
|
18
|
+
this.pict;
|
|
19
|
+
/** @type {import('pict') & { ManifestFactory: import('../services/ManifestFactory.js') }} */
|
|
20
|
+
this.fable;
|
|
21
|
+
/** @type {any} */
|
|
22
|
+
this.log;
|
|
23
|
+
|
|
24
|
+
this.addPattern('{~InputWithViewAndDescriptorAddress:', '~}');
|
|
25
|
+
this.addPattern('{~IWVDA:', '~}');
|
|
26
|
+
|
|
27
|
+
this.currentInputIndex = 0;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Renders an arbitrary PICT input by hash, with a custom data type, input type and label. The Record reference is ignored in this template.
|
|
32
|
+
*
|
|
33
|
+
* @param {string} pTemplateHash - The template hash.
|
|
34
|
+
* @param {object} pRecord - The record object.
|
|
35
|
+
* @param {array} pContextArray - The context array.
|
|
36
|
+
* @param {any} [pScope] - A sticky scope that can be used to carry state and simplify template
|
|
37
|
+
* @returns {string} - The rendered template.
|
|
38
|
+
*/
|
|
39
|
+
render(pTemplateHash, pRecord, pContextArray, pScope)
|
|
40
|
+
{
|
|
41
|
+
let tmpHash = pTemplateHash.trim();
|
|
42
|
+
let tmpMetatemplateGenerator = this.pict.providers.MetatemplateGenerator;
|
|
43
|
+
|
|
44
|
+
if (this.pict.LogNoisiness > 0)
|
|
45
|
+
{
|
|
46
|
+
this.log.trace(`PICT Metacontroller Template [InputWithViewAndDescriptorAddress]::[${tmpHash}]`);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
let tmpViewHash;
|
|
50
|
+
let tmpDescriptorAddress;
|
|
51
|
+
|
|
52
|
+
// This is just a simple 2 part hash (the view hash and the descriptor address)
|
|
53
|
+
let tmpHashTemplateSeparator = tmpHash.split(':');
|
|
54
|
+
if (tmpHashTemplateSeparator.length < 2)
|
|
55
|
+
{
|
|
56
|
+
this.log.warn(`InputWithViewAndDescriptorAddress template requires two parameters (ViewHash and DescriptorAddress) [${tmpHash}]`);
|
|
57
|
+
return '';
|
|
58
|
+
}
|
|
59
|
+
tmpViewHash = tmpHashTemplateSeparator[0];
|
|
60
|
+
tmpDescriptorAddress = tmpHashTemplateSeparator[1];
|
|
61
|
+
|
|
62
|
+
const tmpInput = this.resolveStateFromAddress(tmpDescriptorAddress, pRecord, pContextArray, null, pScope);
|
|
63
|
+
|
|
64
|
+
if (!tmpInput || typeof tmpInput !== 'object' || Array.isArray(tmpInput) || !tmpInput.Address)
|
|
65
|
+
{
|
|
66
|
+
this.log.warn(`InputWithViewAndDescriptorAddress template requires a valid input object at address [${tmpDescriptorAddress}]`);
|
|
67
|
+
return '';
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
this._shoreUpDescriptor(tmpInput);
|
|
71
|
+
|
|
72
|
+
this.currentInputIndex++;
|
|
73
|
+
|
|
74
|
+
const tmpInputView = this.pict.views[tmpViewHash];
|
|
75
|
+
|
|
76
|
+
if (!tmpInputView || !tmpInputView.sectionManifest || typeof tmpInputView.getRow !== 'function')
|
|
77
|
+
{
|
|
78
|
+
this.log.warn(`InputWithViewAndDescriptorAddress template requires a valid dynamic View hash [${tmpHash}]`);
|
|
79
|
+
return '';
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Check to see if the input is already in the manifest
|
|
83
|
+
let tmpRow = tmpInputView.getRow(0, 0);
|
|
84
|
+
|
|
85
|
+
for (let i = 0; i < tmpRow.Inputs.length; i++)
|
|
86
|
+
{
|
|
87
|
+
if (tmpRow.Inputs[i].Hash === tmpInput.Hash)
|
|
88
|
+
{
|
|
89
|
+
let tmpInput = tmpRow.Inputs[i];
|
|
90
|
+
return this.pict.parseTemplate(tmpMetatemplateGenerator.getInputMetatemplateTemplateReference(tmpInputView, tmpInput.DataType, tmpInput.PictForm.InputType, `getInput("0","0","${tmpInput.PictForm.InputIndex}")`), tmpInput, null, [tmpInputView], tmpInputView);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// It isn't already in the manifest, so add it.
|
|
95
|
+
tmpInput.PictForm.InputIndex = tmpRow.Inputs.length;
|
|
96
|
+
tmpInputView.sectionManifest.addDescriptor(tmpInput.Address, tmpInput);
|
|
97
|
+
tmpRow.Inputs.push(tmpInput);
|
|
98
|
+
|
|
99
|
+
this.pict.providers.MetatemplateMacros.buildInputMacros(tmpInputView, tmpInput);
|
|
100
|
+
|
|
101
|
+
// Now generate the metatemplate
|
|
102
|
+
let tmpTemplate = tmpMetatemplateGenerator.getInputMetatemplateTemplateReference(tmpInputView, tmpInput.DataType, tmpInput.PictForm.InputType, `getInput("0","0","${tmpInput.PictForm.InputIndex}")`);
|
|
103
|
+
|
|
104
|
+
// Now parse it and return it.
|
|
105
|
+
return this.pict.parseTemplate(tmpTemplate, tmpInput, null, [tmpInputView], tmpInputView);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Renders an arbitrary PICT input by hash, with a custom data type, input type and label. The Record reference is ignored in this template.
|
|
110
|
+
*
|
|
111
|
+
* @param {string} pTemplateHash - The schema hash of the control.
|
|
112
|
+
* @param {object} pRecord - The record object.
|
|
113
|
+
* @param {function | null} fCallback - The callback function.
|
|
114
|
+
* @param {array} pContextArray - The context array.
|
|
115
|
+
* @param {any} [pScope] - A sticky scope that can be used to carry state and simplify template
|
|
116
|
+
*
|
|
117
|
+
* @return {void}
|
|
118
|
+
*/
|
|
119
|
+
renderAsync(pTemplateHash, pRecord, fCallback, pContextArray, pScope)
|
|
120
|
+
{
|
|
121
|
+
let tmpHash = pTemplateHash.trim();
|
|
122
|
+
let tmpMetatemplateGenerator = this.pict.providers.MetatemplateGenerator;
|
|
123
|
+
|
|
124
|
+
if (this.pict.LogNoisiness > 0)
|
|
125
|
+
{
|
|
126
|
+
this.log.trace(`PICT Metacontroller Template [InputWithViewAndDescriptorAddress]::[${tmpHash}]`);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
let tmpViewHash;
|
|
130
|
+
let tmpDescriptorAddress;
|
|
131
|
+
|
|
132
|
+
// This is just a simple 2 part hash (the view hash and the descriptor address)
|
|
133
|
+
let tmpHashTemplateSeparator = tmpHash.split(':');
|
|
134
|
+
if (tmpHashTemplateSeparator.length < 2)
|
|
135
|
+
{
|
|
136
|
+
this.log.warn(`InputWithViewAndDescriptorAddress template requires two parameters (ViewHash and DescriptorAddress) [${tmpHash}]`);
|
|
137
|
+
return fCallback(null, '');
|
|
138
|
+
}
|
|
139
|
+
tmpViewHash = tmpHashTemplateSeparator[0];
|
|
140
|
+
tmpDescriptorAddress = tmpHashTemplateSeparator[1];
|
|
141
|
+
|
|
142
|
+
const tmpInput = this.resolveStateFromAddress(tmpDescriptorAddress, pRecord, pContextArray, null, pScope);
|
|
143
|
+
|
|
144
|
+
this._shoreUpDescriptor(tmpInput);
|
|
145
|
+
|
|
146
|
+
this.currentInputIndex++;
|
|
147
|
+
|
|
148
|
+
const tmpInputView = this.pict.views[tmpViewHash];
|
|
149
|
+
|
|
150
|
+
if (!tmpInputView || !tmpInputView.sectionManifest || typeof tmpInputView.getRow !== 'function')
|
|
151
|
+
{
|
|
152
|
+
this.log.warn(`InputWithViewAndDescriptorAddress template requires a valid dynamic View hash [${tmpHash}]`);
|
|
153
|
+
return fCallback(null, '');
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Check to see if the input is already in the manifest
|
|
157
|
+
let tmpRow = tmpInputView.getRow(0, 0);
|
|
158
|
+
|
|
159
|
+
for (let i = 0; i < tmpRow.Inputs.length; i++)
|
|
160
|
+
{
|
|
161
|
+
if (tmpRow.Inputs[i].Hash === tmpInput.Hash)
|
|
162
|
+
{
|
|
163
|
+
let tmpInput = tmpRow.Inputs[i];
|
|
164
|
+
let tmpTemplate = tmpMetatemplateGenerator.getInputMetatemplateTemplateReference(tmpInputView, tmpInput.DataType, tmpInput.PictForm.InputType, `getInput("0","0","${tmpInput.PictForm.InputIndex}")`);
|
|
165
|
+
this.pict.parseTemplate(tmpTemplate, tmpInput, fCallback, [tmpInputView], tmpInputView);
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// It isn't already in the manifest, so add it.
|
|
171
|
+
tmpInput.PictForm.InputIndex = tmpRow.Inputs.length;
|
|
172
|
+
tmpInputView.sectionManifest.addDescriptor(tmpInput.Address, tmpInput);
|
|
173
|
+
tmpRow.Inputs.push(tmpInput);
|
|
174
|
+
|
|
175
|
+
this.pict.providers.MetatemplateMacros.buildInputMacros(tmpInputView, tmpInput);
|
|
176
|
+
|
|
177
|
+
// Now generate the metatemplate
|
|
178
|
+
let tmpTemplate = tmpMetatemplateGenerator.getInputMetatemplateTemplateReference(tmpInputView, tmpInput.DataType, tmpInput.PictForm.InputType, `getInput("0","0","${tmpInput.PictForm.InputIndex}")`);
|
|
179
|
+
|
|
180
|
+
this.pict.parseTemplate(tmpTemplate, tmpInput, fCallback, [tmpInputView], tmpInputView);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
_shoreUpDescriptor(pDescriptor)
|
|
185
|
+
{
|
|
186
|
+
if (!pDescriptor || typeof pDescriptor !== 'object' || Array.isArray(pDescriptor))
|
|
187
|
+
{
|
|
188
|
+
throw new Error('Invalid descriptor object provided to shoreUpDescriptor');
|
|
189
|
+
}
|
|
190
|
+
if (!pDescriptor.DataAddress)
|
|
191
|
+
{
|
|
192
|
+
pDescriptor.DataAddress = pDescriptor.Address;
|
|
193
|
+
}
|
|
194
|
+
if (!pDescriptor.Hash)
|
|
195
|
+
{
|
|
196
|
+
pDescriptor.Hash = pDescriptor.Address;
|
|
197
|
+
}
|
|
198
|
+
if (!pDescriptor.Name)
|
|
199
|
+
{
|
|
200
|
+
pDescriptor.Name = pDescriptor.Hash;
|
|
201
|
+
}
|
|
202
|
+
if (!pDescriptor.DataType)
|
|
203
|
+
{
|
|
204
|
+
pDescriptor.DataType = 'String';
|
|
205
|
+
}
|
|
206
|
+
if (!pDescriptor.PictForm)
|
|
207
|
+
{
|
|
208
|
+
pDescriptor.PictForm = { };
|
|
209
|
+
}
|
|
210
|
+
if (!pDescriptor.PictForm.InformaryDataAddress)
|
|
211
|
+
{
|
|
212
|
+
pDescriptor.PictForm.InformaryDataAddress = pDescriptor.DataAddress;
|
|
213
|
+
}
|
|
214
|
+
if (pDescriptor.PictForm.GroupIndex == null)
|
|
215
|
+
{
|
|
216
|
+
pDescriptor.PictForm.GroupIndex = 0;
|
|
217
|
+
}
|
|
218
|
+
if (pDescriptor.PictForm.Row == null)
|
|
219
|
+
{
|
|
220
|
+
pDescriptor.PictForm.Row = 0;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
module.exports = PictTemplateInputWithViewAndDescriptorAddressTemplate;
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
const libPictTemplate = require('pict-template');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This is a template that will generate a dynamic input using a provided dynamic view (by hash) and a hash address.
|
|
5
|
+
*/
|
|
6
|
+
class PictTemplateInputWithViewAndHashAddressTemplate extends libPictTemplate
|
|
7
|
+
{
|
|
8
|
+
/**
|
|
9
|
+
* @param {Object} pFable - The Fable Framework instance
|
|
10
|
+
* @param {Object} pOptions - The options for the service
|
|
11
|
+
* @param {String} pServiceHash - The hash of the service
|
|
12
|
+
*/
|
|
13
|
+
constructor(pFable, pOptions, pServiceHash)
|
|
14
|
+
{
|
|
15
|
+
super(pFable, pOptions, pServiceHash);
|
|
16
|
+
|
|
17
|
+
/** @type {import('pict')} */
|
|
18
|
+
this.pict;
|
|
19
|
+
/** @type {import('pict') & { ManifestFactory: import('../services/ManifestFactory.js') }} */
|
|
20
|
+
this.fable;
|
|
21
|
+
/** @type {any} */
|
|
22
|
+
this.log;
|
|
23
|
+
|
|
24
|
+
this.addPattern('{~InputWithViewAndHashAddress:', '~}');
|
|
25
|
+
this.addPattern('{~IWVHA:', '~}');
|
|
26
|
+
|
|
27
|
+
this.currentInputIndex = 0;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Renders an arbitrary PICT input by hash, with a custom data type, input type and label. The Record reference is ignored in this template.
|
|
32
|
+
*
|
|
33
|
+
* @param {string} pTemplateHash - The template hash.
|
|
34
|
+
* @param {object} pRecord - The record object.
|
|
35
|
+
* @param {array} pContextArray - The context array.
|
|
36
|
+
* @param {any} [pScope] - A sticky scope that can be used to carry state and simplify template
|
|
37
|
+
* @returns {string} - The rendered template.
|
|
38
|
+
*/
|
|
39
|
+
render(pTemplateHash, pRecord, pContextArray, pScope)
|
|
40
|
+
{
|
|
41
|
+
let tmpHash = pTemplateHash.trim();
|
|
42
|
+
let tmpMetatemplateGenerator = this.pict.providers.MetatemplateGenerator;
|
|
43
|
+
|
|
44
|
+
if (this.pict.LogNoisiness > 0)
|
|
45
|
+
{
|
|
46
|
+
this.log.trace(`PICT Metacontroller Template [InputWithViewAndHashAddress]::[${tmpHash}]`);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
let tmpViewHash;
|
|
50
|
+
let tmpInputName;
|
|
51
|
+
let tmpInputAddress;
|
|
52
|
+
let tmpDataType;
|
|
53
|
+
let tmpInputType;
|
|
54
|
+
|
|
55
|
+
let tmpHashTemplateSeparator = tmpHash.split(':');
|
|
56
|
+
if (tmpHashTemplateSeparator.length < 3)
|
|
57
|
+
{
|
|
58
|
+
this.log.warn(`InputWithViewAndHashAddress template requires at least three parameters (ViewHash, Address and DataType) [${tmpHash}]`);
|
|
59
|
+
return '';
|
|
60
|
+
}
|
|
61
|
+
tmpViewHash = tmpHashTemplateSeparator[0];
|
|
62
|
+
tmpInputName = tmpHashTemplateSeparator[1];
|
|
63
|
+
// This template expects this address to be a location to get the hash from...
|
|
64
|
+
//FIXME: should pScope here be the eventual view so the scope is consistent?
|
|
65
|
+
tmpInputAddress = this.resolveStateFromAddress(tmpHashTemplateSeparator[2], pRecord, pContextArray, null, pScope);
|
|
66
|
+
if ((typeof(tmpInputAddress) !== 'string') || tmpInputAddress.length < 1)
|
|
67
|
+
{
|
|
68
|
+
this.log.warn(`InputWithViewAndHashAddress template requires a valid Address for an Address in the third parameter [${tmpHash}]`);
|
|
69
|
+
return '';
|
|
70
|
+
}
|
|
71
|
+
tmpDataType = tmpHashTemplateSeparator[3];
|
|
72
|
+
if (tmpHashTemplateSeparator.length > 4)
|
|
73
|
+
{
|
|
74
|
+
tmpInputType = tmpHashTemplateSeparator[4];
|
|
75
|
+
}
|
|
76
|
+
// Construct a fake input object
|
|
77
|
+
const tmpInput =
|
|
78
|
+
{
|
|
79
|
+
Address: tmpInputAddress,
|
|
80
|
+
DataAddress: tmpInputAddress,
|
|
81
|
+
Name: tmpInputName,
|
|
82
|
+
Hash: this.fable.ManifestFactory.sanitizeObjectKey(tmpInputAddress),
|
|
83
|
+
DataType: tmpDataType,
|
|
84
|
+
PictForm:
|
|
85
|
+
{
|
|
86
|
+
InformaryDataAddress: tmpInputAddress,
|
|
87
|
+
GroupIndex: 0,
|
|
88
|
+
Row: 0
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
this.currentInputIndex++;
|
|
93
|
+
|
|
94
|
+
if (tmpInputType)
|
|
95
|
+
{
|
|
96
|
+
tmpInput.PictForm.InputType = tmpInputType;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const tmpInputView = this.pict.views[tmpViewHash]; //tmpMetatemplateGenerator.dynamicInputView;
|
|
100
|
+
|
|
101
|
+
if (!tmpInputView || !tmpInputView.sectionManifest || typeof tmpInputView.getRow !== 'function')
|
|
102
|
+
{
|
|
103
|
+
this.log.warn(`InputWithViewAndHashAddress template requires a valid dynamic View hash as the first parameter [${tmpHash}]`);
|
|
104
|
+
return '';
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Check to see if the input is already in the manifest
|
|
108
|
+
let tmpRow = tmpInputView.getRow(0, 0);
|
|
109
|
+
|
|
110
|
+
for (let i = 0; i < tmpRow.Inputs.length; i++)
|
|
111
|
+
{
|
|
112
|
+
if (tmpRow.Inputs[i].Hash === tmpInput.Hash)
|
|
113
|
+
{
|
|
114
|
+
const tmpInput = tmpRow.Inputs[i];
|
|
115
|
+
return this.pict.parseTemplate(tmpMetatemplateGenerator.getInputMetatemplateTemplateReference(tmpInputView,
|
|
116
|
+
tmpInput.DataType, tmpInput.PictForm.InputType, `getInput("0","0","${tmpInput.PictForm.InputIndex}")`), tmpInput, null, [tmpInputView], tmpInputView);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// It isn't already in the manifest, so add it.
|
|
121
|
+
tmpInput.PictForm.InputIndex = tmpRow.Inputs.length;
|
|
122
|
+
tmpInputView.sectionManifest.addDescriptor(tmpInput.Address, tmpInput);
|
|
123
|
+
tmpRow.Inputs.push(tmpInput);
|
|
124
|
+
|
|
125
|
+
this.pict.providers.MetatemplateMacros.buildInputMacros(tmpInputView, tmpInput);
|
|
126
|
+
|
|
127
|
+
// Now generate the metatemplate
|
|
128
|
+
const tmpTemplate = tmpMetatemplateGenerator.getInputMetatemplateTemplateReference(tmpInputView,
|
|
129
|
+
tmpInput.DataType, tmpInput.PictForm.InputType, `getInput("0","0","${tmpInput.PictForm.InputIndex}")`);
|
|
130
|
+
|
|
131
|
+
// Now parse it and return it.
|
|
132
|
+
return this.pict.parseTemplate(tmpTemplate, tmpInput, null, [tmpInputView], tmpInputView);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Renders an arbitrary PICT input by hash, with a custom data type, input type and label. The Record reference is ignored in this template.
|
|
137
|
+
*
|
|
138
|
+
* @param {string} pTemplateHash - The schema hash of the control.
|
|
139
|
+
* @param {object} pRecord - The record object.
|
|
140
|
+
* @param {function | null} fCallback - The callback function.
|
|
141
|
+
* @param {array} pContextArray - The context array.
|
|
142
|
+
* @param {any} [pScope] - A sticky scope that can be used to carry state and simplify template
|
|
143
|
+
*
|
|
144
|
+
* @return {void}
|
|
145
|
+
*/
|
|
146
|
+
renderAsync(pTemplateHash, pRecord, fCallback, pContextArray, pScope)
|
|
147
|
+
{
|
|
148
|
+
let tmpHash = pTemplateHash.trim();
|
|
149
|
+
let tmpMetatemplateGenerator = this.pict.providers.MetatemplateGenerator;
|
|
150
|
+
|
|
151
|
+
if (this.pict.LogNoisiness > 0)
|
|
152
|
+
{
|
|
153
|
+
this.log.trace(`PICT Metacontroller Template [InputWithViewAndHashAddress]::[${tmpHash}]`);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
let tmpViewHash;
|
|
157
|
+
let tmpInputName;
|
|
158
|
+
let tmpInputAddress;
|
|
159
|
+
let tmpDataType;
|
|
160
|
+
let tmpInputType;
|
|
161
|
+
|
|
162
|
+
// This is just a simple 2 part hash (the entity and the ID)
|
|
163
|
+
let tmpHashTemplateSeparator = tmpHash.split(':');
|
|
164
|
+
if (tmpHashTemplateSeparator.length < 3)
|
|
165
|
+
{
|
|
166
|
+
this.log.warn(`InputWithViewAndHashAddress template requires at least three parameters (ViewHash, Address and DataType) [${tmpHash}]`);
|
|
167
|
+
return fCallback(null, '');
|
|
168
|
+
}
|
|
169
|
+
tmpViewHash = tmpHashTemplateSeparator[0];
|
|
170
|
+
tmpInputName = tmpHashTemplateSeparator[1];
|
|
171
|
+
// This template expects this address to be a location to get the hash from...
|
|
172
|
+
//FIXME: should pScope here be the eventual view so the scope is consistent?
|
|
173
|
+
tmpInputAddress = this.resolveStateFromAddress(tmpHashTemplateSeparator[2], pRecord, pContextArray, null, pScope);
|
|
174
|
+
if ((typeof(tmpInputAddress) !== 'string') || tmpInputAddress.length < 1)
|
|
175
|
+
{
|
|
176
|
+
this.log.warn(`InputWithViewAndHashAddress template requires a valid Address for an Address in the third parameter [${tmpHash}]`);
|
|
177
|
+
return fCallback(null, '');
|
|
178
|
+
}
|
|
179
|
+
tmpDataType = tmpHashTemplateSeparator[3];
|
|
180
|
+
if (tmpHashTemplateSeparator.length > 4)
|
|
181
|
+
{
|
|
182
|
+
tmpInputType = tmpHashTemplateSeparator[4];
|
|
183
|
+
}
|
|
184
|
+
// Construct a fake input object
|
|
185
|
+
let tmpInput = {
|
|
186
|
+
Address: tmpInputAddress,
|
|
187
|
+
DataAddress: tmpInputAddress,
|
|
188
|
+
Name: tmpInputName,
|
|
189
|
+
Hash: this.fable.ManifestFactory.sanitizeObjectKey(tmpInputAddress),
|
|
190
|
+
DataType: tmpDataType,
|
|
191
|
+
PictForm: {
|
|
192
|
+
InformaryDataAddress: tmpInputAddress,
|
|
193
|
+
GroupIndex: 0,
|
|
194
|
+
Row: 0
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
this.currentInputIndex++;
|
|
199
|
+
|
|
200
|
+
if (tmpInputType)
|
|
201
|
+
{
|
|
202
|
+
tmpInput.PictForm.InputType = tmpInputType;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const tmpInputView = this.pict.views[tmpViewHash]; //tmpMetatemplateGenerator.dynamicInputView;
|
|
206
|
+
|
|
207
|
+
if (!tmpInputView || !tmpInputView.sectionManifest || typeof tmpInputView.getRow !== 'function')
|
|
208
|
+
{
|
|
209
|
+
this.log.warn(`InputWithViewAndHashAddress template requires a valid View hash as the first parameter [${tmpHash}]`);
|
|
210
|
+
return fCallback(null, '');
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// Check to see if the input is already in the manifest
|
|
214
|
+
let tmpRow = tmpInputView.getRow(0, 0);
|
|
215
|
+
|
|
216
|
+
for (let i = 0; i < tmpRow.Inputs.length; i++)
|
|
217
|
+
{
|
|
218
|
+
if (tmpRow.Inputs[i].Hash === tmpInput.Hash)
|
|
219
|
+
{
|
|
220
|
+
let tmpInput = tmpRow.Inputs[i];
|
|
221
|
+
let tmpTemplate = tmpMetatemplateGenerator.getInputMetatemplateTemplateReference(tmpInputView,
|
|
222
|
+
tmpInput.DataType, tmpInput.PictForm.InputType, `getInput("0","0","${tmpInput.PictForm.InputIndex}")`);
|
|
223
|
+
this.pict.parseTemplate(tmpTemplate, tmpInput, fCallback, [tmpInputView], tmpInputView);
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// It isn't already in the manifest, so add it.
|
|
229
|
+
tmpInput.PictForm.InputIndex = tmpRow.Inputs.length;
|
|
230
|
+
tmpInputView.sectionManifest.addDescriptor(tmpInput.Address, tmpInput);
|
|
231
|
+
tmpRow.Inputs.push(tmpInput);
|
|
232
|
+
|
|
233
|
+
this.pict.providers.MetatemplateMacros.buildInputMacros(tmpInputView, tmpInput);
|
|
234
|
+
|
|
235
|
+
// Now generate the metatemplate
|
|
236
|
+
const tmpTemplate = tmpMetatemplateGenerator.getInputMetatemplateTemplateReference(tmpInputView,
|
|
237
|
+
tmpInput.DataType, tmpInput.PictForm.InputType, `getInput("0","0","${tmpInput.PictForm.InputIndex}")`);
|
|
238
|
+
|
|
239
|
+
this.pict.parseTemplate(tmpTemplate, tmpInput, fCallback, [tmpInputView], tmpInputView);
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
module.exports = PictTemplateInputWithViewAndHashAddressTemplate;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Pict-Provider-DynamicTemplates.d.ts","sourceRoot":"","sources":["../../../source/providers/Pict-Provider-DynamicTemplates.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"Pict-Provider-DynamicTemplates.d.ts","sourceRoot":"","sources":["../../../source/providers/Pict-Provider-DynamicTemplates.js"],"names":[],"mappings":";AAiCA;;;GAGG;AACH;IAEC;;;;;OAKG;IACH,2DAoCC;IA9BA,kBAAkB;IAClB,SADW,GAAG,CACF;IACZ,6BAA6B;IAC7B,MADW,OAAO,MAAM,CAAC,CAChB;IA6BV;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,2CA4DC;CACD;;;;;AA/ID,kCAAkC;AAClC,6CADW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAS3B"}
|
|
@@ -15,9 +15,9 @@ declare class PictDynamicFormsInformary extends libPictProvider {
|
|
|
15
15
|
options: any;
|
|
16
16
|
/** @type {import('pict') & { newManyfest: (options: any) => import('manyfest') }} */
|
|
17
17
|
pict: import("pict") & {
|
|
18
|
-
newManyfest: (options: any) =>
|
|
18
|
+
newManyfest: (options: any) => import("manyfest");
|
|
19
19
|
};
|
|
20
|
-
genericManifest:
|
|
20
|
+
genericManifest: import("manyfest");
|
|
21
21
|
/**
|
|
22
22
|
* Retrieves all form elements for a given form hash.
|
|
23
23
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Pict-Provider-Informary.d.ts","sourceRoot":"","sources":["../../../source/providers/Pict-Provider-Informary.js"],"names":[],"mappings":";AAcA;;;GAGG;AACH;IAEC;;;;;OAKG;IACH,oBAJW,MAAM,YACN,MAAM,gBACN,MAAM,EAgBhB;IARA,kBAAkB;IAClB,SADW,GAAG,CACF;IACZ,qFAAqF;IACrF,MADW,OAAO,MAAM,CAAC,GAAG;QAAE,WAAW,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,
|
|
1
|
+
{"version":3,"file":"Pict-Provider-Informary.d.ts","sourceRoot":"","sources":["../../../source/providers/Pict-Provider-Informary.js"],"names":[],"mappings":";AAcA;;;GAGG;AACH;IAEC;;;;;OAKG;IACH,oBAJW,MAAM,YACN,MAAM,gBACN,MAAM,EAgBhB;IARA,kBAAkB;IAClB,SADW,GAAG,CACF;IACZ,qFAAqF;IACrF,MADW,OAAO,MAAM,CAAC,GAAG;QAAE,WAAW,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,OAAO,UAAU,CAAC,CAAA;KAAE,CACxE;IAIT,oCAAwE;IAGzE;;;;;OAKG;IACH,2BAHW,MAAM,GACJ,WAAW,EAAE,CAOzB;IAED;;;;;;;;;;OAUG;IACH,oCANW,MAAM,cACN,MAAM,cACN,MAAM,GAAC,IAAI,UACX,MAAM,GAAC,MAAM,GACX,MAAM,CAalB;IAED;;;;;;;OAOG;IACH,wCALW,MAAM,UACN,MAAM,GAAC,MAAM,cACb,MAAM,GACJ,MAAM,CAKlB;IAED;;;;;;;;OAQG;IACH,iCANW,MAAM,aACN,MAAM,aACN,MAAM,WACN,MAAM,iBACN,MAAM,GAAC,MAAM,QAgBvB;IAED;;;;;;;;;;OAUG;IACH,8CARW,MAAM,kBACN,WAAW,uDAGX,GAAG,uBACH,GAAG,GACD,OAAO,CA0CnB;IAED;;;;;;OAMG;IACH,iCAJW,MAAM,aACN,MAAM,aACN,MAAM,QAahB;IAED;;;;;;;;OAQG;IACH,4CANW,MAAM,gBACN,WAAW,yCAGT,OAAO,CA2CnB;IAED;;;;OAIG;IACH,uCAHW,MAAM,gBA2BhB;IAED;;;;;OAKG;IACH,8CAJW,MAAM,aACN,MAAM,gBA2BhB;IAED;;;;;OAKG;IACH,sCAHW,MAAM,UACN,MAAM,QAKhB;IAED;;;;;;OAMG;IACH,6CAJW,MAAM,UACN,MAAM,aACN,MAAM,QAKhB;CACD;;;;;AApUD,kCAAkC;AAClC,6CADW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAS3B"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export = PictTemplateInputWithViewTemplate;
|
|
2
|
+
/**
|
|
3
|
+
* This is a template that will generate a dynamic input using a provided dynamic view (by hash)
|
|
4
|
+
*/
|
|
5
|
+
declare class PictTemplateInputWithViewTemplate extends libPictTemplate {
|
|
6
|
+
/**
|
|
7
|
+
* @param {Object} pFable - The Fable Framework instance
|
|
8
|
+
* @param {Object} pOptions - The options for the service
|
|
9
|
+
* @param {String} pServiceHash - The hash of the service
|
|
10
|
+
*/
|
|
11
|
+
constructor(pFable: any, pOptions: any, pServiceHash: string);
|
|
12
|
+
/** @type {import('pict')} */
|
|
13
|
+
pict: import("pict");
|
|
14
|
+
/** @type {import('pict') & { ManifestFactory: import('../services/ManifestFactory.js') }} */
|
|
15
|
+
fable: import("pict") & {
|
|
16
|
+
ManifestFactory: import("../services/ManifestFactory.js");
|
|
17
|
+
};
|
|
18
|
+
/** @type {any} */
|
|
19
|
+
log: any;
|
|
20
|
+
currentInputIndex: number;
|
|
21
|
+
/**
|
|
22
|
+
* Renders an arbitrary PICT input by hash, with a custom data type, input type and label. The Record reference is ignored in this template.
|
|
23
|
+
*
|
|
24
|
+
* @param {string} pTemplateHash - The schema hash of the control.
|
|
25
|
+
* @param {object} pRecord - The record object.
|
|
26
|
+
* @param {function | null} fCallback - The callback function.
|
|
27
|
+
* @param {array} pContextArray - The context array.
|
|
28
|
+
* @param {any} [pScope] - A sticky scope that can be used to carry state and simplify template
|
|
29
|
+
*
|
|
30
|
+
* @return {void}
|
|
31
|
+
*/
|
|
32
|
+
renderAsync(pTemplateHash: string, pRecord: object, fCallback: Function | null, pContextArray: any[], pScope?: any): void;
|
|
33
|
+
}
|
|
34
|
+
import libPictTemplate = require("pict-template");
|
|
35
|
+
//# sourceMappingURL=Pict-Template-Metatemplate-InputWithView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Pict-Template-Metatemplate-InputWithView.d.ts","sourceRoot":"","sources":["../../../source/templates/Pict-Template-Metatemplate-InputWithView.js"],"names":[],"mappings":";AAEA;;GAEG;AACH;IAEC;;;;OAIG;IACH,8DAeC;IAXA,6BAA6B;IAC7B,MADW,OAAO,MAAM,CAAC,CAChB;IACT,6FAA6F;IAC7F,OADW,OAAO,MAAM,CAAC,GAAG;QAAE,eAAe,EAAE,OAAO,gCAAgC,CAAC,CAAA;KAAE,CAC/E;IACV,kBAAkB;IAClB,KADW,GAAG,CACN;IAKR,0BAA0B;IAiG3B;;;;;;;;;;OAUG;IACH,2BARW,MAAM,WACN,MAAM,aACN,WAAW,IAAI,iCAEf,GAAG,GAEF,IAAI,CAwFf;CACD"}
|
package/types/source/templates/Pict-Template-Metatemplate-InputWithViewAndDescriptorAddress.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export = PictTemplateInputWithViewAndDescriptorAddressTemplate;
|
|
2
|
+
/**
|
|
3
|
+
* This is a template that will generate a dynamic input using a provided dynamic view (by hash)
|
|
4
|
+
*/
|
|
5
|
+
declare class PictTemplateInputWithViewAndDescriptorAddressTemplate extends libPictTemplate {
|
|
6
|
+
/**
|
|
7
|
+
* @param {Object} pFable - The Fable Framework instance
|
|
8
|
+
* @param {Object} pOptions - The options for the service
|
|
9
|
+
* @param {String} pServiceHash - The hash of the service
|
|
10
|
+
*/
|
|
11
|
+
constructor(pFable: any, pOptions: any, pServiceHash: string);
|
|
12
|
+
/** @type {import('pict')} */
|
|
13
|
+
pict: import("pict");
|
|
14
|
+
/** @type {import('pict') & { ManifestFactory: import('../services/ManifestFactory.js') }} */
|
|
15
|
+
fable: import("pict") & {
|
|
16
|
+
ManifestFactory: import("../services/ManifestFactory.js");
|
|
17
|
+
};
|
|
18
|
+
/** @type {any} */
|
|
19
|
+
log: any;
|
|
20
|
+
currentInputIndex: number;
|
|
21
|
+
/**
|
|
22
|
+
* Renders an arbitrary PICT input by hash, with a custom data type, input type and label. The Record reference is ignored in this template.
|
|
23
|
+
*
|
|
24
|
+
* @param {string} pTemplateHash - The schema hash of the control.
|
|
25
|
+
* @param {object} pRecord - The record object.
|
|
26
|
+
* @param {function | null} fCallback - The callback function.
|
|
27
|
+
* @param {array} pContextArray - The context array.
|
|
28
|
+
* @param {any} [pScope] - A sticky scope that can be used to carry state and simplify template
|
|
29
|
+
*
|
|
30
|
+
* @return {void}
|
|
31
|
+
*/
|
|
32
|
+
renderAsync(pTemplateHash: string, pRecord: object, fCallback: Function | null, pContextArray: any[], pScope?: any): void;
|
|
33
|
+
_shoreUpDescriptor(pDescriptor: any): void;
|
|
34
|
+
}
|
|
35
|
+
import libPictTemplate = require("pict-template");
|
|
36
|
+
//# sourceMappingURL=Pict-Template-Metatemplate-InputWithViewAndDescriptorAddress.d.ts.map
|
package/types/source/templates/Pict-Template-Metatemplate-InputWithViewAndDescriptorAddress.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Pict-Template-Metatemplate-InputWithViewAndDescriptorAddress.d.ts","sourceRoot":"","sources":["../../../source/templates/Pict-Template-Metatemplate-InputWithViewAndDescriptorAddress.js"],"names":[],"mappings":";AAEA;;GAEG;AACH;IAEC;;;;OAIG;IACH,8DAeC;IAXA,6BAA6B;IAC7B,MADW,OAAO,MAAM,CAAC,CAChB;IACT,6FAA6F;IAC7F,OADW,OAAO,MAAM,CAAC,GAAG;QAAE,eAAe,EAAE,OAAO,gCAAgC,CAAC,CAAA;KAAE,CAC/E;IACV,kBAAkB;IAClB,KADW,GAAG,CACN;IAKR,0BAA0B;IAiF3B;;;;;;;;;;OAUG;IACH,2BARW,MAAM,WACN,MAAM,aACN,WAAW,IAAI,iCAEf,GAAG,GAEF,IAAI,CAiEf;IAED,2CAsCC;CACD"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export = PictTemplateInputWithViewAndHashAddressTemplate;
|
|
2
|
+
/**
|
|
3
|
+
* This is a template that will generate a dynamic input using a provided dynamic view (by hash) and a hash address.
|
|
4
|
+
*/
|
|
5
|
+
declare class PictTemplateInputWithViewAndHashAddressTemplate extends libPictTemplate {
|
|
6
|
+
/**
|
|
7
|
+
* @param {Object} pFable - The Fable Framework instance
|
|
8
|
+
* @param {Object} pOptions - The options for the service
|
|
9
|
+
* @param {String} pServiceHash - The hash of the service
|
|
10
|
+
*/
|
|
11
|
+
constructor(pFable: any, pOptions: any, pServiceHash: string);
|
|
12
|
+
/** @type {import('pict')} */
|
|
13
|
+
pict: import("pict");
|
|
14
|
+
/** @type {import('pict') & { ManifestFactory: import('../services/ManifestFactory.js') }} */
|
|
15
|
+
fable: import("pict") & {
|
|
16
|
+
ManifestFactory: import("../services/ManifestFactory.js");
|
|
17
|
+
};
|
|
18
|
+
/** @type {any} */
|
|
19
|
+
log: any;
|
|
20
|
+
currentInputIndex: number;
|
|
21
|
+
/**
|
|
22
|
+
* Renders an arbitrary PICT input by hash, with a custom data type, input type and label. The Record reference is ignored in this template.
|
|
23
|
+
*
|
|
24
|
+
* @param {string} pTemplateHash - The schema hash of the control.
|
|
25
|
+
* @param {object} pRecord - The record object.
|
|
26
|
+
* @param {function | null} fCallback - The callback function.
|
|
27
|
+
* @param {array} pContextArray - The context array.
|
|
28
|
+
* @param {any} [pScope] - A sticky scope that can be used to carry state and simplify template
|
|
29
|
+
*
|
|
30
|
+
* @return {void}
|
|
31
|
+
*/
|
|
32
|
+
renderAsync(pTemplateHash: string, pRecord: object, fCallback: Function | null, pContextArray: any[], pScope?: any): void;
|
|
33
|
+
}
|
|
34
|
+
import libPictTemplate = require("pict-template");
|
|
35
|
+
//# sourceMappingURL=Pict-Template-Metatemplate-InputWithViewAndHashAddress.d.ts.map
|
package/types/source/templates/Pict-Template-Metatemplate-InputWithViewAndHashAddress.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Pict-Template-Metatemplate-InputWithViewAndHashAddress.d.ts","sourceRoot":"","sources":["../../../source/templates/Pict-Template-Metatemplate-InputWithViewAndHashAddress.js"],"names":[],"mappings":";AAEA;;GAEG;AACH;IAEC;;;;OAIG;IACH,8DAeC;IAXA,6BAA6B;IAC7B,MADW,OAAO,MAAM,CAAC,CAChB;IACT,6FAA6F;IAC7F,OADW,OAAO,MAAM,CAAC,GAAG;QAAE,eAAe,EAAE,OAAO,gCAAgC,CAAC,CAAA;KAAE,CAC/E;IACV,kBAAkB;IAClB,KADW,GAAG,CACN;IAKR,0BAA0B;IA4G3B;;;;;;;;;;OAUG;IACH,2BARW,MAAM,WACN,MAAM,aACN,WAAW,IAAI,iCAEf,GAAG,GAEF,IAAI,CAiGf;CACD"}
|