pict-section-form 1.0.21 → 1.0.22
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/Pict-Application-Postcard.js +5 -0
- package/example_applications/postcard_example/providers/PictProvider-BestPostcardTheme.js +11 -0
- package/example_applications/postcard_example/providers/PictProvider-Dynamic-Sections-MockServerResponse.json +1 -1
- package/example_applications/postcard_example/providers/PictProvider-PostKardInputExtension.js +23 -0
- package/package.json +1 -1
- package/source/providers/Pict-Provider-InputExtension.js +32 -0
- package/source/views/Pict-View-DynamicForm.js +79 -0
|
@@ -4,8 +4,11 @@ const libPictSectionForm = require('../../source/Pict-Section-Form.js');
|
|
|
4
4
|
|
|
5
5
|
const libProviderDynamicSection = require('./providers/PictProvider-Dynamic-Sections.js');
|
|
6
6
|
|
|
7
|
+
const libProviderInputExtension = require('./providers/PictProvider-PostKardInputExtension.js');
|
|
8
|
+
|
|
7
9
|
const libMainApplicationView = require('./views/PictView-Postcard-MainApplication.js')
|
|
8
10
|
|
|
11
|
+
|
|
9
12
|
class PostcardApplication extends libPictApplication
|
|
10
13
|
{
|
|
11
14
|
constructor(pFable, pOptions, pServiceHash)
|
|
@@ -15,6 +18,8 @@ class PostcardApplication extends libPictApplication
|
|
|
15
18
|
this.pict.addProvider('Postcard-DynamicSection-Provider', libProviderDynamicSection.default_configuration, libProviderDynamicSection);
|
|
16
19
|
this.pict.addProvider('Postcard-Default-Theme-Provider', {}, require('./providers/PictProvider-BestPostcardTheme.js'));
|
|
17
20
|
|
|
21
|
+
this.pict.addProvider('PostKardInputExtension', libProviderInputExtension.default_configuration, libProviderInputExtension);
|
|
22
|
+
|
|
18
23
|
this.pict.addView('PostcardNavigation', require('./views/PictView-Postcard-Navigation.json'));
|
|
19
24
|
this.pict.addView('PostcardAbout', require('./views/PictView-Postcard-Content-About.json'));
|
|
20
25
|
this.pict.addView('PostcardLegal', require('./views/PictView-Postcard-Content-Legal.json'));
|
|
@@ -106,6 +106,17 @@ Glug glug CUSTOMIZED glug Oo... -->
|
|
|
106
106
|
<textarea {~D:Record.Macro.HTMLID~} {~D:Record.Macro.InputFullProperties~} class="pure-u-23-24"></textarea>
|
|
107
107
|
</div>
|
|
108
108
|
|
|
109
|
+
`
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"HashPostfix": "-Template-Input-InputType-PostKardSignature",
|
|
113
|
+
"Template": /*HTML*/`
|
|
114
|
+
<div class="pure-u-1 pure-u-md-1-3">
|
|
115
|
+
<label {~D:Record.Macro.HTMLForID~}><em>{~D:Record.Name~}:</em></label>
|
|
116
|
+
<input type="text" {~D:Record.Macro.HTMLID~} {~D:Record.Macro.InputFullProperties~} class="pure-u-23-24" />
|
|
117
|
+
<a href="#" onclick="_Pict.views['{~D:Context[0].Hash~}'].inputEvent('{~D:Record.Hash~}', 'BestEventEvarrrr')" class="pure-button">Sign</a>
|
|
118
|
+
</div>
|
|
119
|
+
|
|
109
120
|
`
|
|
110
121
|
}
|
|
111
122
|
]});
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"Hash":"SignatureLine",
|
|
79
79
|
"Description":"How you would like your card signed.",
|
|
80
80
|
"DataType":"String"
|
|
81
|
-
,"PictForm": { "Section":"Postcard", "Group":"Content", "Row":4, "Width":12 }
|
|
81
|
+
,"PictForm": { "InputType":"PostKardSignature", "Section":"Postcard", "Group":"Content", "Row":4, "Width":12, "Providers": ["PostKardInputExtension"] }
|
|
82
82
|
},
|
|
83
83
|
"DeliveryDestination.StreetAddress1":
|
|
84
84
|
{
|
package/example_applications/postcard_example/providers/PictProvider-PostKardInputExtension.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const libPictFormSection = require('../../../source/Pict-Section-Form.js');
|
|
2
|
+
|
|
3
|
+
class CustomInputHandler extends libPictFormSection.PictInputExtensionProvider
|
|
4
|
+
{
|
|
5
|
+
constructor(pFable, pOptions, pServiceHash)
|
|
6
|
+
{
|
|
7
|
+
super(pFable, pOptions, pServiceHash);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
onEvent(pView, pInput, pValue, pHTMLSelector, pEvent)
|
|
11
|
+
{
|
|
12
|
+
console.log(`Alert alert event happened for ${pInput}: ${pEvent}`);
|
|
13
|
+
return super.onEvent(pView, pInput, pValue, pHTMLSelector, pEvent);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
onEventTabular(pView, pInput, pValue, pHTMLSelector, pRowIndex, pEvent)
|
|
17
|
+
{
|
|
18
|
+
console.log(`Alert alert event happened for ${pInput} row ${pRowIndex}: ${pEvent}`);
|
|
19
|
+
return super.onEventTabular(pView, pInput, pValue, pHTMLSelector, pRowIndex, pEvent);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
module.exports = CustomInputHandler;
|
package/package.json
CHANGED
|
@@ -152,6 +152,38 @@ class PictInputExtensionProvider extends libPictProvider
|
|
|
152
152
|
{
|
|
153
153
|
return true;
|
|
154
154
|
}
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Handles events for the Pict-Provider-InputExtension.
|
|
159
|
+
*
|
|
160
|
+
* @param {Object} pView - The view object.
|
|
161
|
+
* @param {Object} pInput - The input object.
|
|
162
|
+
* @param {string} pValue - The value from AppData.
|
|
163
|
+
* @param {string} pHTMLSelector - The HTML selector.
|
|
164
|
+
* @param {string} pEvent - The event hash that is expected to be triggered.
|
|
165
|
+
* @returns {boolean} - Returns true.
|
|
166
|
+
*/
|
|
167
|
+
onEvent(pView, pInput, pValue, pHTMLSelector, pEvent)
|
|
168
|
+
{
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Handles events for the Pict-Provider-InputExtension.
|
|
174
|
+
*
|
|
175
|
+
* @param {Object} pView - The view object.
|
|
176
|
+
* @param {Object} pInput - The input object.
|
|
177
|
+
* @param {string} pValue - The value from AppData.
|
|
178
|
+
* @param {string} pHTMLSelector - The HTML selector.
|
|
179
|
+
* @param {number} pRowIndex - The row index of the tabular data.
|
|
180
|
+
* @param {string} pEvent - The event hash that is expected to be triggered.
|
|
181
|
+
* @returns {boolean} - Returns true.
|
|
182
|
+
*/
|
|
183
|
+
onEventTabular(pView, pInput, pValue, pHTMLSelector, pRowIndex, pEvent)
|
|
184
|
+
{
|
|
185
|
+
return true;
|
|
186
|
+
}
|
|
155
187
|
}
|
|
156
188
|
|
|
157
189
|
module.exports = PictInputExtensionProvider;
|
|
@@ -1245,6 +1245,42 @@ class PictViewDynamicForm extends libPictViewClass
|
|
|
1245
1245
|
}
|
|
1246
1246
|
}
|
|
1247
1247
|
|
|
1248
|
+
inputEvent(pInputHash, pEvent)
|
|
1249
|
+
{
|
|
1250
|
+
let tmpInput = this.getInputFromHash(pInputHash);
|
|
1251
|
+
if (pInputHash)
|
|
1252
|
+
{
|
|
1253
|
+
let tmpHashAddress = this.sectionManifest.resolveHashAddress(pInputHash);
|
|
1254
|
+
try
|
|
1255
|
+
{
|
|
1256
|
+
let tmpMarshalDestinationObject = this.getMarshalDestinationObject();
|
|
1257
|
+
if (tmpInput && tmpInput.PictForm && ('Providers' in tmpInput.PictForm) && Array.isArray(tmpInput.PictForm.Providers))
|
|
1258
|
+
{
|
|
1259
|
+
let tmpValue = this.sectionManifest.getValueByHash(tmpMarshalDestinationObject, tmpHashAddress);
|
|
1260
|
+
for (let i = 0; i < tmpInput.PictForm.Providers.length; i++)
|
|
1261
|
+
{
|
|
1262
|
+
if (this.pict.providers[tmpInput.PictForm.Providers[i]])
|
|
1263
|
+
{
|
|
1264
|
+
this.pict.providers[tmpInput.PictForm.Providers[i]].onEvent(this, tmpInput, tmpValue, tmpInput.Macro.HTMLSelector, pEvent);
|
|
1265
|
+
}
|
|
1266
|
+
else
|
|
1267
|
+
{
|
|
1268
|
+
this.log.error(`Dynamic form [${this.Hash}]::[${this.UUID}] inputEvent ${pEvent} cannot find provider [${tmpInput.PictForm.Providers[i]}] for input [${tmpInput.Hash}].`);
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
catch (pError)
|
|
1274
|
+
{
|
|
1275
|
+
this.log.error(`Dynamic form [${this.Hash}]::[${this.UUID}] gross error running inputEvent ${pEvent} specific (${pInputHash}) data from view in dataChanged event: ${pError}`);
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
else
|
|
1279
|
+
{
|
|
1280
|
+
this.log.error(`Dynamic form [${this.Hash}]::[${this.UUID}] cannot find input hash [${pInputHash}] for inputEvent ${pEvent} event.`);
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1248
1284
|
inputDataRequestTabular(pGroupIndex, pInputIndex, pRowIndex)
|
|
1249
1285
|
{
|
|
1250
1286
|
let tmpInput = this.getTabularRecordInput(pGroupIndex, pInputIndex);
|
|
@@ -1288,6 +1324,49 @@ class PictViewDynamicForm extends libPictViewClass
|
|
|
1288
1324
|
this.marshalToView();
|
|
1289
1325
|
}
|
|
1290
1326
|
|
|
1327
|
+
inputEventTabular(pGroupIndex, pInputIndex, pRowIndex, pEvent)
|
|
1328
|
+
{
|
|
1329
|
+
let tmpInput = this.getTabularRecordInput(pGroupIndex, pInputIndex);
|
|
1330
|
+
if (pGroupIndex && pInputIndex && pRowIndex && tmpInput)
|
|
1331
|
+
{
|
|
1332
|
+
try
|
|
1333
|
+
{
|
|
1334
|
+
let tmpMarshalDestinationObject = this.getMarshalDestinationObject();
|
|
1335
|
+
if (tmpInput && tmpInput.PictForm && ('Providers' in tmpInput.PictForm) && Array.isArray(tmpInput.PictForm.Providers))
|
|
1336
|
+
{
|
|
1337
|
+
// TODO: Can we simplify this?
|
|
1338
|
+
let tmpValueAddress = this.pict.providers.Informary.getComposedContainerAddress(tmpInput.PictForm.InformaryContainerAddress, pRowIndex, tmpInput.PictForm.InformaryDataAddress);
|
|
1339
|
+
let tmpValue = this.sectionManifest.getValueByHash(tmpMarshalDestinationObject, tmpValueAddress);
|
|
1340
|
+
|
|
1341
|
+
let tmpVirtualInformaryHTMLSelector = tmpInput.Macro.HTMLSelectorTabular+`[data-i-index="${pRowIndex}"]`;
|
|
1342
|
+
for (let i = 0; i < tmpInput.PictForm.Providers.length; i++)
|
|
1343
|
+
{
|
|
1344
|
+
if (this.pict.providers[tmpInput.PictForm.Providers[i]])
|
|
1345
|
+
{
|
|
1346
|
+
this.pict.providers[tmpInput.PictForm.Providers[i]].onEventTabular(this, tmpInput, tmpValue, tmpVirtualInformaryHTMLSelector, pRowIndex, pEvent);
|
|
1347
|
+
}
|
|
1348
|
+
else
|
|
1349
|
+
{
|
|
1350
|
+
this.log.error(`Dynamic form [${this.Hash}]::[${this.UUID}] cannot find provider [${tmpInput.PictForm.Providers[i]}] for input [${tmpInput.Hash}] row ${pRowIndex} calling inputEvent ${pEvent}.`);
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
catch (pError)
|
|
1356
|
+
{
|
|
1357
|
+
this.log.error(`Dynamic form [${this.Hash}]::[${this.UUID}] gross error marshaling specific (${pInputHash}) tabular data for group ${pGroupIndex} row ${pRowIndex} from view in calling inputEvent ${pEvent}: ${pError}`);
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1360
|
+
else
|
|
1361
|
+
{
|
|
1362
|
+
// This is what is called whenever a hash is changed. We could marshal from view, solve and remarshal to view.
|
|
1363
|
+
this.marshalFromView();
|
|
1364
|
+
}
|
|
1365
|
+
// Run any dynamic input providers for the input hash.
|
|
1366
|
+
this.pict.PictApplication.solve();
|
|
1367
|
+
this.marshalToView();
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1291
1370
|
get isPictSectionForm()
|
|
1292
1371
|
{
|
|
1293
1372
|
return true;
|