pict-section-form 1.0.10 → 1.0.13
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/.vscode/settings.json +3 -0
- package/example_applications/Build-Examples.sh +41 -0
- package/example_applications/Clean-Examples.sh +10 -0
- package/example_applications/Open-Examples.sh +8 -0
- package/example_applications/README.md +57 -0
- package/example_applications/complex_table/Complex-Tabular-Application.js +219 -0
- package/example_applications/complex_table/FruitData.json +695 -0
- package/example_applications/complex_table/README-ComplexTable.md +31 -0
- package/example_applications/complex_table/html/index.html +13 -0
- package/example_applications/complex_table/package.json +26 -0
- package/example_applications/gradebook/source/Gradebook-Application.js +2 -1
- package/example_applications/gradebook/source/manifests/Assignment-Manifest.json +36 -1
- package/example_applications/gradebook/source/manifests/Gradebook-Manifest.js +20 -3
- package/example_applications/gradebook/source/manifests/Student-Manifest.json +34 -23
- package/example_applications/gradebook/source/views/BasicContent-View-Templates.json +42 -0
- package/example_applications/postcard_example/Pict-Application-Postcard.js +15 -0
- package/example_applications/postcard_example/providers/PictProvider-BestPostcardTheme.js +19 -46
- package/example_applications/postcard_example/providers/PictProvider-Dynamic-Sections-MockServerResponse.json +8 -4
- package/example_applications/simple_form/html/index.html +1 -1
- package/example_applications/simple_table/FruitData.json +693 -692
- package/example_applications/simple_table/Simple-Tabular-Application.js +6 -18
- package/example_applications/simple_table_from_object/FruitDataInAnObject.json +692 -2
- package/example_applications/simple_table_from_object/MigrateThatFruit.js +2 -2
- package/example_applications/simple_table_from_object/Simple-Tabular-Application-FromObject.js +5 -18
- package/package.json +3 -2
- package/source/Pict-Section-Form.js +6 -10
- package/source/{Pict-Section-Form-Application.js → application/Pict-Application-Form.js} +1 -1
- package/source/providers/Pict-Provider-DynamicSolver.js +264 -0
- package/source/{Pict-Section-Form-Provider-Templates-DefaultFormTemplates.js → providers/Pict-Provider-DynamicTemplates-DefaultFormTemplates.js} +88 -77
- package/source/{Pict-Section-Form-Provider-Templates.js → providers/Pict-Provider-DynamicTemplates.js} +4 -1
- package/source/{Pict-Service-Informary.js → providers/Pict-Provider-Informary.js} +13 -4
- package/source/templates/Pict-Template-Base.js +87 -0
- package/source/{Pict-Template-MetacontrollerValueSetWithGroup.js → templates/Pict-Template-Metacontroller-ValueSetWithGroup.js} +1 -1
- package/source/{Pict-Section-Form-View-DefaultConfiguration.json → views/Pict-View-DynamicForm-DefaultConfiguration.json} +1 -0
- package/source/{Pict-Section-Form-View.js → views/Pict-View-DynamicForm.js} +149 -38
- package/source/{Pict-Form-Metacontroller.js → views/Pict-View-Form-Metacontroller.js} +45 -15
- /package/source/{Pict-Section-Form-MetatemplateGenerator.js → providers/Pict-Provider-MetatemplateGenerator.js} +0 -0
|
@@ -1,39 +1,36 @@
|
|
|
1
1
|
module.exports = (
|
|
2
2
|
{
|
|
3
3
|
"TemplatePrefix": "Pict-Forms-Basic",
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
"Templates":
|
|
5
|
+
[
|
|
6
6
|
/*
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
//
|
|
7
|
+
*
|
|
8
|
+
* [ Metacontroller Templates ]
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
// the form "Header", rendered once before the dynamic views, after which come the section(s), then their group(s)
|
|
12
12
|
{
|
|
13
13
|
"HashPostfix": "-Template-Form-Container-Header",
|
|
14
14
|
"Template": /*HTML*/`
|
|
15
|
-
<!--
|
|
16
|
-
Pict Form Metacontroller container Header
|
|
15
|
+
<!-- Pict Form Metacontroller container Header
|
|
17
16
|
|
|
18
17
|
;,//;, ,;/
|
|
19
18
|
o:::::::;;///
|
|
20
19
|
>::::::::;;\\\
|
|
21
20
|
''\\\\\'" ';\
|
|
22
21
|
|
|
23
|
-
Glug glug glug Oo...
|
|
24
|
-
-->
|
|
22
|
+
Glug glug glug Oo... -->
|
|
25
23
|
<div id="Pict-{~D:Context[0].UUID~}-FormContainer" class="pict-form">`
|
|
26
24
|
},
|
|
27
|
-
|
|
28
|
-
// -Form-Container-Wrap-Prefix
|
|
25
|
+
//
|
|
29
26
|
{
|
|
30
27
|
"HashPostfix": "-Template-Form-Container-Wrap-Prefix",
|
|
31
28
|
"Template": /*HTML*/`
|
|
32
29
|
<!-- Pict Form Metacontroller container [{~D:Context[0].UUID~}] -->
|
|
33
|
-
<div id="Pict-{~D:Context[0].UUID~}-
|
|
30
|
+
<div id="Pict-{~D:Context[0].UUID~}-{~D:Record.options.Hash~}-Wrap" class="pict-form">`
|
|
34
31
|
},
|
|
35
|
-
//
|
|
36
|
-
//
|
|
32
|
+
// the container div into which the actual view renders.
|
|
33
|
+
// if you overwrite this template, make sure this ID is available on a container somewhere or auto rendering won't work
|
|
37
34
|
{
|
|
38
35
|
"HashPostfix": "-Template-Form-Container",
|
|
39
36
|
"Template": /*HTML*/`
|
|
@@ -53,27 +50,24 @@ Glug glug glug Oo...
|
|
|
53
50
|
|
|
54
51
|
|
|
55
52
|
/*
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
//
|
|
53
|
+
*
|
|
54
|
+
* [ Basic Form Templates START ]
|
|
55
|
+
*
|
|
56
|
+
*/
|
|
57
|
+
// the wrapping container for a view which is a collection of form section(s)...
|
|
61
58
|
{
|
|
62
59
|
"HashPostfix": "-Template-Wrap-Prefix",
|
|
63
60
|
"Template": /*HTML*/`
|
|
64
61
|
<!-- Pict Form Wrap Prefix [{~D:Context[0].UUID~}]::[{~D:Context[0].Hash~}] -->
|
|
65
62
|
`
|
|
66
63
|
},
|
|
67
|
-
// -Form-Template-Wrap-Postfix
|
|
68
64
|
{
|
|
69
65
|
"HashPostfix": "-Template-Wrap-Postfix",
|
|
70
66
|
"Template": /*HTML*/`
|
|
71
67
|
<!-- Pict Form Wrap Postfix [{~D:Context[0].UUID~}]::[{~D:Context[0].Hash~}] -->
|
|
72
68
|
`
|
|
73
69
|
},
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
// -Form-Template-Section-Prefix
|
|
70
|
+
// the wrapping container for each specific section in a form... for legends and the like
|
|
77
71
|
{
|
|
78
72
|
"HashPostfix": "-Template-Section-Prefix",
|
|
79
73
|
"Template": /*HTML*/`
|
|
@@ -91,13 +85,10 @@ Glug glug glug Oo...
|
|
|
91
85
|
`
|
|
92
86
|
},
|
|
93
87
|
|
|
94
|
-
|
|
95
88
|
/*
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
*/
|
|
100
|
-
// -Form-Template-Group-Prefix
|
|
89
|
+
* BEGIN Group and Row Templates (default)
|
|
90
|
+
*/
|
|
91
|
+
// a "group" is a cluster of inputs that are further categorized into row(s)
|
|
101
92
|
{
|
|
102
93
|
"HashPostfix": "-Template-Group-Prefix",
|
|
103
94
|
"Template": /*HTML*/`
|
|
@@ -106,7 +97,8 @@ Glug glug glug Oo...
|
|
|
106
97
|
<div>
|
|
107
98
|
`
|
|
108
99
|
},
|
|
109
|
-
//
|
|
100
|
+
// row(s) are useful when our form has multiple inputs on some lines and a single on another...
|
|
101
|
+
// like city, state and zip all in the same "row" of an address form
|
|
110
102
|
{
|
|
111
103
|
"HashPostfix": "-Template-Row-Prefix",
|
|
112
104
|
"Template": /*HTML*/`
|
|
@@ -114,7 +106,6 @@ Glug glug glug Oo...
|
|
|
114
106
|
<div>
|
|
115
107
|
`
|
|
116
108
|
},
|
|
117
|
-
// -Form-Template-Row-Postfix
|
|
118
109
|
{
|
|
119
110
|
"HashPostfix": "-Template-Row-Postfix",
|
|
120
111
|
"Template": /*HTML*/`
|
|
@@ -122,7 +113,6 @@ Glug glug glug Oo...
|
|
|
122
113
|
<!-- Form Template Row Postfix [{~D:Context[0].UUID~}]::[{~D:Context[0].Hash~}] {~D:Record.Hash~}::{~D:Record.Name~} -->
|
|
123
114
|
`
|
|
124
115
|
},
|
|
125
|
-
// -Form-Template-Group-Postfix
|
|
126
116
|
{
|
|
127
117
|
"HashPostfix": "-Template-Group-Postfix",
|
|
128
118
|
"Template": /*HTML*/`
|
|
@@ -130,14 +120,13 @@ Glug glug glug Oo...
|
|
|
130
120
|
<!-- Form Template Group Prefix [{~D:Context[0].UUID~}]::[{~D:Context[0].Hash~}] {~D:Record.Hash~}::{~D:Record.Name~} -->
|
|
131
121
|
`
|
|
132
122
|
},
|
|
133
|
-
|
|
123
|
+
/*
|
|
124
|
+
* END Group and Row Templates (default)
|
|
125
|
+
*/
|
|
134
126
|
|
|
135
127
|
/*
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
*
|
|
139
|
-
*/
|
|
140
|
-
// -Form-Template-Input
|
|
128
|
+
* BEGIN Input Templates (default)
|
|
129
|
+
*/
|
|
141
130
|
{
|
|
142
131
|
"HashPostfix": "-Template-Input",
|
|
143
132
|
"Template": /*HTML*/`
|
|
@@ -145,7 +134,6 @@ Glug glug glug Oo...
|
|
|
145
134
|
<span>{~D:Record.Name~}:</span> <input type="text" {~D:Record.Macro.InputFullProperties~} {~D:Record.Macro.InputChangeHandler~} value="">
|
|
146
135
|
`
|
|
147
136
|
},
|
|
148
|
-
// -Form-Template-Input-DataType-String
|
|
149
137
|
{
|
|
150
138
|
"HashPostfix": "-Template-Input-DataType-String",
|
|
151
139
|
"Template": /*HTML*/`
|
|
@@ -153,7 +141,6 @@ Glug glug glug Oo...
|
|
|
153
141
|
<span>{~D:Record.Name~}:</span> <input type="text" {~D:Record.Macro.InputFullProperties~} {~D:Record.Macro.InputChangeHandler~} value="">
|
|
154
142
|
`
|
|
155
143
|
},
|
|
156
|
-
// -Form-Template-Input-DataType-Number
|
|
157
144
|
{
|
|
158
145
|
"HashPostfix": "-Template-Input-DataType-Number",
|
|
159
146
|
"Template": /*HTML*/`
|
|
@@ -161,7 +148,6 @@ Glug glug glug Oo...
|
|
|
161
148
|
<span>{~D:Record.Name~}:</span> <input type="Number" {~D:Record.Macro.InputFullProperties~} {~D:Record.Macro.InputChangeHandler~} value="">
|
|
162
149
|
`
|
|
163
150
|
},
|
|
164
|
-
// -Form-Template-Input-InputType-TextArea
|
|
165
151
|
{
|
|
166
152
|
"HashPostfix": "-Template-Input-InputType-TextArea",
|
|
167
153
|
"Template": /*HTML*/`
|
|
@@ -169,46 +155,77 @@ Glug glug glug Oo...
|
|
|
169
155
|
<span>{~D:Record.Name~}:</span> <textarea {~D:Record.Macro.InputFullProperties~} {~D:Record.Macro.InputChangeHandler~}></textarea>
|
|
170
156
|
`
|
|
171
157
|
},
|
|
158
|
+
/*
|
|
159
|
+
* END Input Templates (default)
|
|
160
|
+
*/
|
|
161
|
+
/*
|
|
162
|
+
*
|
|
163
|
+
* [ Basic Form Templates END ]
|
|
164
|
+
*
|
|
165
|
+
*/
|
|
166
|
+
|
|
172
167
|
|
|
173
168
|
|
|
174
169
|
/*
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
170
|
+
*
|
|
171
|
+
* [ Tabular Templates START ]
|
|
172
|
+
*
|
|
173
|
+
*/
|
|
179
174
|
{
|
|
180
175
|
"HashPostfix": "-TabularTemplate-Group-Prefix",
|
|
181
176
|
"Template": /*HTML*/`
|
|
182
177
|
<div>
|
|
183
178
|
<table>
|
|
184
179
|
<tbody>
|
|
185
|
-
<!-- Form Template Group Prefix [{~D:Context[0].UUID~}]::[{~D:Context[0].Hash~}] {~D:Record.Hash~}::{~D:Record.Name~} -->
|
|
180
|
+
<!-- Form Tabular Template Group Prefix [{~D:Context[0].UUID~}]::[{~D:Context[0].Hash~}] {~D:Record.Hash~}::{~D:Record.Name~} -->
|
|
181
|
+
`
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
"HashPostfix": "-TabularTemplate-Group-Postfix",
|
|
185
|
+
"Template": /*HTML*/`
|
|
186
|
+
</tbody>
|
|
187
|
+
</table>
|
|
188
|
+
<div><a href="#" onclick="{~D:Record.Macro.TabularCreateRowFunctionCall~}">create</a></div>
|
|
189
|
+
</div>
|
|
190
|
+
<!-- Form Tabular Template Group Prefix [{~D:Context[0].UUID~}]::[{~D:Context[0].Hash~}] {~D:Record.Hash~}::{~D:Record.Name~} -->
|
|
186
191
|
`
|
|
187
192
|
},
|
|
188
193
|
|
|
189
|
-
|
|
190
|
-
|
|
194
|
+
/*
|
|
195
|
+
* BEGIN Tabular Template "Extra" Columns
|
|
196
|
+
* these are meant to be easy ways to add controls to the left or right side of a record column
|
|
197
|
+
*/
|
|
191
198
|
{
|
|
192
199
|
"HashPostfix": "-TabularTemplate-RowHeader-ExtraPrefix",
|
|
193
200
|
"Template": /*HTML*/`<!-- TabularTemplateRowHeader-ExtraPrefix -->`
|
|
194
201
|
},
|
|
195
|
-
|
|
196
|
-
"HashPostfix": "-TabularTemplate-Row-ExtraPrefix",
|
|
197
|
-
"Template": /*HTML*/`<!-- TabularTemplateRow-ExtraPrefix -->`
|
|
198
|
-
},
|
|
202
|
+
// because the row extension template below adds an extra column, we need to make our header have parity
|
|
199
203
|
{
|
|
200
204
|
"HashPostfix": "-TabularTemplate-RowHeader-ExtraPostfix",
|
|
201
205
|
"Template": /*HTML*/`<!-- TabularTemplateRowHeader-ExtraPostfix -->
|
|
202
|
-
<th></th>
|
|
206
|
+
<th style="min-width:100px;"></th>
|
|
203
207
|
`
|
|
204
208
|
},
|
|
209
|
+
{
|
|
210
|
+
"HashPostfix": "-TabularTemplate-Row-ExtraPrefix",
|
|
211
|
+
"Template": /*HTML*/`<!-- TabularTemplateRow-ExtraPrefix -->`
|
|
212
|
+
},
|
|
213
|
+
// by default PICT puts a "delete row" button on the right side of a tabular templateset
|
|
205
214
|
{
|
|
206
215
|
"HashPostfix": "-TabularTemplate-Row-ExtraPostfix",
|
|
207
216
|
"Template": /*HTML*/`<!-- TabularTemplateRow-ExtraPostfix-->
|
|
208
|
-
<td><a href="#" onClick="_Pict.views['{~D:Context[0].Hash~}'].deleteDynamicTableRow({~D:Record.Group~},'{~D:Record.Key~}')">
|
|
217
|
+
<td><a href="#" onClick="_Pict.views['{~D:Context[0].Hash~}'].deleteDynamicTableRow({~D:Record.Group~},'{~D:Record.Key~}')">del</a>
|
|
218
|
+
<a href="#" onClick="_Pict.views['{~D:Context[0].Hash~}'].moveDynamicTableRowUp({~D:Record.Group~},'{~D:Record.Key~}')">up</a>
|
|
219
|
+
<a href="#" onClick="_Pict.views['{~D:Context[0].Hash~}'].moveDynamicTableRowDown({~D:Record.Group~},'{~D:Record.Key~}')">down</a></td>
|
|
209
220
|
`
|
|
210
221
|
},
|
|
222
|
+
/*
|
|
223
|
+
* END Tabular Template "Extra" Columns
|
|
224
|
+
*/
|
|
211
225
|
|
|
226
|
+
/*
|
|
227
|
+
* BEGIN Tabular Template Header Columns
|
|
228
|
+
*/
|
|
212
229
|
{
|
|
213
230
|
"HashPostfix": "-TabularTemplate-RowHeader-Prefix",
|
|
214
231
|
"Template": /*HTML*/`
|
|
@@ -231,12 +248,13 @@ Glug glug glug Oo...
|
|
|
231
248
|
<tbody>
|
|
232
249
|
`
|
|
233
250
|
},
|
|
234
|
-
|
|
251
|
+
/*
|
|
252
|
+
* END Tabular Template Header Columns
|
|
253
|
+
*/
|
|
235
254
|
|
|
236
255
|
/*
|
|
237
|
-
*
|
|
238
|
-
*
|
|
239
|
-
*
|
|
256
|
+
* BEGIN Tabular TemplateSet Templates (row and cell prefix/postfix ... tr/td)
|
|
257
|
+
* (these are repeated for each "row" which is a record, and then wrap each "cell" which is a columnar input)
|
|
240
258
|
*/
|
|
241
259
|
{
|
|
242
260
|
"HashPostfix": "-TabularTemplate-Row-Prefix",
|
|
@@ -262,27 +280,12 @@ Glug glug glug Oo...
|
|
|
262
280
|
{~T:TabularTemplateRow-ExtraPostfix~}</tr>`
|
|
263
281
|
},
|
|
264
282
|
/*
|
|
265
|
-
*
|
|
266
|
-
* END of the above Tabular TemplateSet metatemplate entries
|
|
267
|
-
*
|
|
283
|
+
* END Tabular TemplateSet Templates
|
|
268
284
|
*/
|
|
269
285
|
|
|
270
286
|
|
|
271
|
-
{
|
|
272
|
-
"HashPostfix": "-TabularTemplate-Group-Postfix",
|
|
273
|
-
"Template": /*HTML*/`
|
|
274
|
-
</tbody>
|
|
275
|
-
</table>
|
|
276
|
-
<div><a href="#" onclick="{~D:Record.Macro.TabularCreateRowFunctionCall~}">PICT.create</a></div>
|
|
277
|
-
</div>
|
|
278
|
-
<!-- Form Template Group Prefix [{~D:Context[0].UUID~}]::[{~D:Context[0].Hash~}] {~D:Record.Hash~}::{~D:Record.Name~} -->
|
|
279
|
-
`
|
|
280
|
-
},
|
|
281
|
-
|
|
282
287
|
/*
|
|
283
|
-
*
|
|
284
|
-
* Input Templates (tabular)
|
|
285
|
-
*
|
|
288
|
+
* BEGIN Tabular Input Templates
|
|
286
289
|
*/
|
|
287
290
|
{
|
|
288
291
|
"HashPostfix": "-TabularTemplate-Begin-Input",
|
|
@@ -328,6 +331,14 @@ Glug glug glug Oo...
|
|
|
328
331
|
"Template": /*HTML*/` {~D:Record.Macro.InputChangeHandler~}></textarea>
|
|
329
332
|
`
|
|
330
333
|
}
|
|
334
|
+
/*
|
|
335
|
+
* END Tabular Input Templates
|
|
336
|
+
*/
|
|
337
|
+
/*
|
|
338
|
+
*
|
|
339
|
+
* [ Tabular Templates END ]
|
|
340
|
+
*
|
|
341
|
+
*/
|
|
331
342
|
|
|
332
343
|
]
|
|
333
344
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const libPictProvider = require('pict-provider');
|
|
2
2
|
|
|
3
|
-
const _DefaultFormTemplates = require('./Pict-
|
|
3
|
+
const _DefaultFormTemplates = require('./Pict-Provider-DynamicTemplates-DefaultFormTemplates.js');
|
|
4
|
+
|
|
4
5
|
const _DefaultProviderConfiguration = (
|
|
5
6
|
{
|
|
6
7
|
"ProviderIdentifier": "Pict-Section-Form-Provider-Templates-Basic",
|
|
@@ -80,6 +81,8 @@ class PictSectionFormTemplateProvider extends libPictProvider
|
|
|
80
81
|
{
|
|
81
82
|
this.pict.TemplateProvider.addTemplate(this.formsTemplateSet[tmpTemplateList[i]].Hash, this.formsTemplateSet[tmpTemplateList[i]].Template);
|
|
82
83
|
}
|
|
84
|
+
|
|
85
|
+
this.pict.addTemplate(require(`../templates/Pict-Template-Metacontroller-ValueSetWithGroup.js`));
|
|
83
86
|
}
|
|
84
87
|
}
|
|
85
88
|
|
|
@@ -25,7 +25,7 @@ class PictServiceInformary extends libPictProvider
|
|
|
25
25
|
getFormElements(pFormHash)
|
|
26
26
|
{
|
|
27
27
|
let tmpSelector = `[data-i-form="${pFormHash}"]`;
|
|
28
|
-
this.log.trace(`Getting form elements for form hash selector: ${tmpSelector}`);
|
|
28
|
+
//this.log.trace(`Getting form elements for form hash selector: ${tmpSelector}`);
|
|
29
29
|
return this.pict.ContentAssignment.getElement(tmpSelector);
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -63,7 +63,10 @@ class PictServiceInformary extends libPictProvider
|
|
|
63
63
|
|
|
64
64
|
let tmpBrowserValue = this.pict.ContentAssignment.readContent(this.getContentBrowserAddress(pFormHash, tmpDatumAddress, tmpContainerAddress, tmpIndex));
|
|
65
65
|
|
|
66
|
-
this.
|
|
66
|
+
if (this.pict.LogNoisiness > 3)
|
|
67
|
+
{
|
|
68
|
+
this.log.trace(`Informary marshalling BrowserForm Data ${tmpBrowserValue} from form element [${tmpDatumAddress}] in container [${tmpContainerAddress}] at index [${tmpIndex}] to the datum address [${tmpDatumAddress}].`);
|
|
69
|
+
}
|
|
67
70
|
|
|
68
71
|
if (typeof(tmpBrowserValue) === 'undefined')
|
|
69
72
|
{
|
|
@@ -99,7 +102,10 @@ class PictServiceInformary extends libPictProvider
|
|
|
99
102
|
{
|
|
100
103
|
let tmpAppStateValue = tmpManifest.getValueAtAddress(pAppStateData, tmpDatumAddress);
|
|
101
104
|
|
|
102
|
-
this.
|
|
105
|
+
if (this.pict.LogNoisiness > 3)
|
|
106
|
+
{
|
|
107
|
+
this.log.trace(`Informary marshalling App State data ${tmpAppStateValue} to Browser Form element [${tmpDatumAddress}] in container [${tmpContainerAddress}] at index [${tmpIndex}].`);
|
|
108
|
+
}
|
|
103
109
|
|
|
104
110
|
if (typeof(tmpAppStateValue) !== 'undefined')
|
|
105
111
|
{
|
|
@@ -110,7 +116,10 @@ class PictServiceInformary extends libPictProvider
|
|
|
110
116
|
{
|
|
111
117
|
let tmpAppStateValue = tmpManifest.getValueAtAddress(pAppStateData, this.getComposedContainerAddress(tmpContainerAddress, tmpIndex, tmpDatumAddress));
|
|
112
118
|
|
|
113
|
-
this.
|
|
119
|
+
if (this.pict.LogNoisiness > 3)
|
|
120
|
+
{
|
|
121
|
+
this.log.trace(`Informary marshalling App State data ${tmpAppStateValue} to Browser Form element [${tmpDatumAddress}] in container [${tmpContainerAddress}] at index [${tmpIndex}].`);
|
|
122
|
+
}
|
|
114
123
|
|
|
115
124
|
if (typeof(tmpAppStateValue) !== 'undefined')
|
|
116
125
|
{
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
const libFableServiceBase = require('fable-serviceproviderbase');
|
|
2
|
+
|
|
3
|
+
// TODO: Separate this out into its own module so we can use it without copying it around.
|
|
4
|
+
class PictTemplateProvider extends libFableServiceBase
|
|
5
|
+
{
|
|
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, pOptions, pServiceHash)
|
|
12
|
+
{
|
|
13
|
+
super(pFable, pOptions, pServiceHash);
|
|
14
|
+
|
|
15
|
+
this.pict = this.fable;
|
|
16
|
+
|
|
17
|
+
this.serviceType = 'PictTemplate';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Render a template expression, returning a string with the resulting content.
|
|
22
|
+
*
|
|
23
|
+
* @param {string} pTemplateHash - The hash contents of the template (what's between the template start and stop tags)
|
|
24
|
+
* @param {object} pRecord - The json object to be used as the Record for the template render
|
|
25
|
+
* @param {array} pContextArray - An array of context objects accessible from the template; safe to leave empty
|
|
26
|
+
*
|
|
27
|
+
* @return {string} The rendered template
|
|
28
|
+
*/
|
|
29
|
+
render(pTemplateHash, pRecord, pContextArray)
|
|
30
|
+
{
|
|
31
|
+
return '';
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Render a template expression, deliver a string with the resulting content to a callback function.
|
|
36
|
+
*
|
|
37
|
+
* @param {string} pTemplateHash - The hash contents of the template (what's between the template start and stop tags)
|
|
38
|
+
* @param {object} pRecord - The json object to be used as the Record for the template render
|
|
39
|
+
* @param {array} pContextArray - An array of context objects accessible from the template; safe to leave empty
|
|
40
|
+
* @param {(error: Error?, content: String?) => void} fCallback - callback function invoked with the rendered template, or an error
|
|
41
|
+
*
|
|
42
|
+
* @return {void}
|
|
43
|
+
*/
|
|
44
|
+
renderAsync(pTemplateHash, pRecord, fCallback, pContextArray)
|
|
45
|
+
{
|
|
46
|
+
return fCallback(null, this.render(pTemplateHash, pRecord, pContextArray));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Provide a match criteria for a template expression. Anything between these two values is returned as the template hash.
|
|
51
|
+
*
|
|
52
|
+
* @param {string} pMatchStart - The string pattern to start a match in the template trie
|
|
53
|
+
* @param {string} pMatchEnd - The string pattern to stop a match in the trie acyclic graph
|
|
54
|
+
*
|
|
55
|
+
* @return {void}
|
|
56
|
+
*/
|
|
57
|
+
addPattern(pMatchStart, pMatchEnd)
|
|
58
|
+
{
|
|
59
|
+
return this.pict.MetaTemplate.addPatternBoth(pMatchStart, pMatchEnd, this.render, this.renderAsync, this);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Read a value from a nested object using a dot notation string.
|
|
64
|
+
*
|
|
65
|
+
* @param {string} pAddress - The address to resolve
|
|
66
|
+
* @param {object} pRecord - The record to resolve
|
|
67
|
+
* @param {Array<any>} pContextArray - The context array to resolve (optional)
|
|
68
|
+
*
|
|
69
|
+
* @return {any} The value at the given address, or undefined
|
|
70
|
+
*/
|
|
71
|
+
resolveStateFromAddress(pAddress, pRecord, pContextArray)
|
|
72
|
+
{
|
|
73
|
+
let tmpContextArray = (Array.isArray(pContextArray)) ? pContextArray : [this.pict];
|
|
74
|
+
|
|
75
|
+
return this.pict.manifest.getValueByHash(
|
|
76
|
+
{
|
|
77
|
+
Pict:this.pict,
|
|
78
|
+
AppData:this.pict.AppData,
|
|
79
|
+
Bundle:this.pict.Bundle,
|
|
80
|
+
Context:tmpContextArray,
|
|
81
|
+
Record:pRecord
|
|
82
|
+
}, pAddress);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
module.exports = PictTemplateProvider;
|
|
87
|
+
module.exports.template_hash = 'Default';
|