pict-section-form 1.0.91 → 1.0.92
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/simple_distill/Simple-Form-Application.js +28 -0
- package/example_applications/simple_distill/html/index.html +1 -1
- package/package.json +1 -1
- package/source/providers/Pict-Provider-DynamicSolver.js +5 -0
- package/source/providers/dynamictemplates/Pict-DynamicTemplates-DefaultFormTemplates.js +33 -0
- package/source/providers/inputs/Pict-Provider-Input-TemplatedEntityLookup.js +192 -0
|
@@ -153,6 +153,34 @@ module.exports.default_configuration.pict_configuration = (
|
|
|
153
153
|
SelectOptionsRefresh: true
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
|
+
},
|
|
157
|
+
"BookAuthorJoin": {
|
|
158
|
+
Name: "BookAuthorJoinInfo",
|
|
159
|
+
Hash: "BookAuthorJoin",
|
|
160
|
+
DataType: "String",
|
|
161
|
+
PictForm: {
|
|
162
|
+
Section: "Book",
|
|
163
|
+
Group: "Book",
|
|
164
|
+
Row: 2, Width: 1,
|
|
165
|
+
InputType: "TemplatedEntityLookup",
|
|
166
|
+
Providers: ["Pict-Input-TemplateEntityLookup"],
|
|
167
|
+
TemplateEntityLookup:
|
|
168
|
+
{
|
|
169
|
+
Template: "Record GUIDBookAuthorJoin {~D:AppData.CurrentBookAuthorJoinForDisplayTemplate.GUIDBookAuthorJoin~} IDBook {~D:AppData.CurrentBookAuthorJoinForDisplayTemplate.IDBook~} is the first book for IDAuthor {~D:AppData.CurrentAuthor.IDAuthor~} AuthorName [{~D:AppData.CurrentAuthor.Name~}]",
|
|
170
|
+
|
|
171
|
+
EmptyValueTestList: ["AppData.CurrentBookAuthorJoinForDisplayTemplate"],
|
|
172
|
+
EmptyValueTemplate: "No BookAuthorJoin Found",
|
|
173
|
+
|
|
174
|
+
EntitiesBundle: [
|
|
175
|
+
{
|
|
176
|
+
"Entity": "BookAuthorJoin",
|
|
177
|
+
"Filter": "FBV~IDAuthor~EQ~{~D:AppData.CurrentAuthor.IDAuthor~}",
|
|
178
|
+
"Destination": "AppData.CurrentBookAuthorJoinForDisplayTemplate",
|
|
179
|
+
// This marshals a single record
|
|
180
|
+
"SingleRecord": true
|
|
181
|
+
}]
|
|
182
|
+
}
|
|
183
|
+
}
|
|
156
184
|
}
|
|
157
185
|
}
|
|
158
186
|
}
|
package/package.json
CHANGED
|
@@ -12,6 +12,7 @@ const libInputAutofillTriggerGroup = require('./inputs/Pict-Provider-Input-Autof
|
|
|
12
12
|
const libInputMarkdown = require('./inputs/Pict-Provider-Input-Markdown.js');
|
|
13
13
|
const libInputHTML = require('./inputs/Pict-Provider-Input-HTML.js');
|
|
14
14
|
const libInputPreciseNumber = require('./inputs/Pict-Provider-Input-PreciseNumber.js');
|
|
15
|
+
const libInputTemplateEntityLookup = require('./inputs/Pict-Provider-Input-TemplatedEntityLookup.js');
|
|
15
16
|
|
|
16
17
|
const _DefaultProviderConfiguration = (
|
|
17
18
|
{
|
|
@@ -98,6 +99,10 @@ class PictDynamicSolver extends libPictProvider
|
|
|
98
99
|
{
|
|
99
100
|
this.pict.addProvider('Pict-Input-PreciseNumber', libInputPreciseNumber.default_configuration, libInputPreciseNumber);
|
|
100
101
|
}
|
|
102
|
+
if (!this.pict.providers['Pict-Input-TemplateEntityLookup'])
|
|
103
|
+
{
|
|
104
|
+
this.pict.addProvider('Pict-Input-TemplateEntityLookup', libInputTemplateEntityLookup.default_configuration, libInputTemplateEntityLookup);
|
|
105
|
+
}
|
|
101
106
|
}
|
|
102
107
|
|
|
103
108
|
/**
|
|
@@ -245,6 +245,16 @@ Glug glug glug Oo... -->
|
|
|
245
245
|
<input type="hidden" {~D:Record.Macro.InputFullProperties~} {~D:Record.Macro.InputChangeHandler~} value="">
|
|
246
246
|
<span>{~D:Record.Name~}:</span>
|
|
247
247
|
<div id="DISPLAY-FOR-{~D:Record.Macro.RawHTMLID~}" class="pict-section-form-html"></div>
|
|
248
|
+
`
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
"HashPostfix": "-Template-Input-InputType-TemplatedEntityLookup",
|
|
252
|
+
"DefaultInputExtensions": ["Pict-Input-TemplatedEntityLookup"],
|
|
253
|
+
"Template": /*HTML*/`
|
|
254
|
+
<!-- InputType TemplatedEntityLookup {~D:Record.Hash~} {~D:Record.DataType~} -->
|
|
255
|
+
<input type="hidden" {~D:Record.Macro.InputFullProperties~} {~D:Record.Macro.InputChangeHandler~} value="">
|
|
256
|
+
<span>{~D:Record.Name~}:</span>
|
|
257
|
+
<div id="DISPLAY-FOR-{~D:Record.Macro.RawHTMLID~}"></div>
|
|
248
258
|
`
|
|
249
259
|
},
|
|
250
260
|
/*
|
|
@@ -393,6 +403,19 @@ Glug glug glug Oo... -->
|
|
|
393
403
|
<span>{~D:Record.PictForm.ExtraDescription~}</span>
|
|
394
404
|
<div id="DISPLAY-FOR-{~D:Record.Macro.RawHTMLID~}" class="pict-section-form-html"></div>
|
|
395
405
|
</div>
|
|
406
|
+
`
|
|
407
|
+
},
|
|
408
|
+
{
|
|
409
|
+
"HashPostfix": "-VerticalTemplate-Input-InputType-TemplatedEntityLookup",
|
|
410
|
+
"DefaultInputExtensions": ["Pict-Input-TemplatedEntityLookup"],
|
|
411
|
+
"Template": /*HTML*/`
|
|
412
|
+
<!-- InputType TemplatedEntityLookup {~D:Record.Hash~} {~D:Record.DataType~} -->
|
|
413
|
+
<div class="pict-form-vertical-input">
|
|
414
|
+
<input type="hidden" {~D:Record.Macro.InputFullProperties~} {~D:Record.Macro.InputChangeHandler~} value="">
|
|
415
|
+
<span>{~D:Record.Name~}:</span>
|
|
416
|
+
<span>{~D:Record.PictForm.ExtraDescription~}</span>
|
|
417
|
+
<div id="DISPLAY-FOR-{~D:Record.Macro.RawHTMLID~}"></div>
|
|
418
|
+
</div>
|
|
396
419
|
`
|
|
397
420
|
},
|
|
398
421
|
/*
|
|
@@ -780,6 +803,16 @@ Glug glug glug Oo... -->
|
|
|
780
803
|
"Template": /*HTML*/` value="">`
|
|
781
804
|
},
|
|
782
805
|
|
|
806
|
+
{
|
|
807
|
+
"HashPostfix": "-TabularTemplate-Begin-Input-InputType-TemplatedEntityLookup",
|
|
808
|
+
"Template": /*HTML*/`
|
|
809
|
+
<!-- InputType TemplatedEntityLookup {~D:Record.Hash~} {~D:Record.DataType~} -->
|
|
810
|
+
<input type="text" {~D:Record.Macro.HTMLName~} {~D:Record.Macro.InformaryTabular~} `
|
|
811
|
+
},
|
|
812
|
+
{
|
|
813
|
+
"HashPostfix": "-TabularTemplate-End-Input-InputType-TemplatedEntityLookup",
|
|
814
|
+
"Template": /*HTML*/` value="">`
|
|
815
|
+
},
|
|
783
816
|
|
|
784
817
|
/*
|
|
785
818
|
* END Tabular Input Templates
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
const libPictSectionInputExtension = require('../Pict-Provider-InputExtension.js');
|
|
2
|
+
|
|
3
|
+
const libMarked = require('marked');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* CustomInputHandler class.
|
|
7
|
+
*
|
|
8
|
+
* @class
|
|
9
|
+
* @extends libPictSectionInputExtension
|
|
10
|
+
* @memberof providers.inputs
|
|
11
|
+
*/
|
|
12
|
+
class CustomInputHandler extends libPictSectionInputExtension
|
|
13
|
+
{
|
|
14
|
+
constructor(pFable, pOptions, pServiceHash)
|
|
15
|
+
{
|
|
16
|
+
super(pFable, pOptions, pServiceHash);
|
|
17
|
+
|
|
18
|
+
/** @type {import('pict')} */
|
|
19
|
+
this.pict;
|
|
20
|
+
/** @type {import('pict') & { newAnticipate: () => any }} */
|
|
21
|
+
this.fable;
|
|
22
|
+
/** @type {any} */
|
|
23
|
+
this.log;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Generates the HTML ID for a content display input element.
|
|
28
|
+
*
|
|
29
|
+
* @param {string} pInputHTMLID - The HTML ID of the input element.
|
|
30
|
+
* @returns {string} - The generated HTML ID for the content display input element.
|
|
31
|
+
*/
|
|
32
|
+
getContentDisplayHTMLID(pInputHTMLID)
|
|
33
|
+
{
|
|
34
|
+
return `#DISPLAY-FOR-${pInputHTMLID}`;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Generates a tabular content display input ID based on the provided input HTML ID and row index.
|
|
39
|
+
*
|
|
40
|
+
* @param {string} pInputHTMLID - The input HTML ID.
|
|
41
|
+
* @param {number} pRowIndex - The row index.
|
|
42
|
+
* @returns {string} - The generated tabular content display input ID.
|
|
43
|
+
*/
|
|
44
|
+
getTabularContentDisplayInputID(pInputHTMLID, pRowIndex)
|
|
45
|
+
{
|
|
46
|
+
return `#${pInputHTMLID}-${pRowIndex}`;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
*
|
|
51
|
+
* @param {String} pDisplayID
|
|
52
|
+
* @param {Object} pInput - The PictForm Input Object
|
|
53
|
+
* @param {any} pValue
|
|
54
|
+
*/
|
|
55
|
+
assignDisplayEntityData(pDisplayID, pInput, pValue)
|
|
56
|
+
{
|
|
57
|
+
// 0. Manage state
|
|
58
|
+
let tmpDisplayTemplate = (typeof(pInput.PictForm.TemplateEntityLookup.Template) === "string") ? pInput.PictForm.TemplateEntityLookup.Template : "";
|
|
59
|
+
let tmpDisplayContent = '';
|
|
60
|
+
|
|
61
|
+
if (typeof(pInput) != "object")
|
|
62
|
+
{
|
|
63
|
+
this.log.error("Error in assignDisplayEntityData: pInput is not an object");
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (!(`PictForm` in pInput))
|
|
67
|
+
{
|
|
68
|
+
this.log.error("Error in assignDisplayEntityData: pInput.PictForm is not an object");
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (!(`TemplateEntityLookup` in pInput.PictForm))
|
|
72
|
+
{
|
|
73
|
+
this.log.error("Error in assignDisplayEntityData: pInput.PictForm.TemplateEntityLookup is not in the PictForm object");
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (!Array.isArray(pInput.PictForm.TemplateEntityLookup.EntitiesBundle))
|
|
77
|
+
{
|
|
78
|
+
this.log.error("Error in assignDisplayEntityData: pInput.PictForm.TemplateEntityLookup.EntitiesBundle is not an array");
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const tmpAnticipate = this.fable.newAnticipate();
|
|
83
|
+
|
|
84
|
+
// 1. Get the entities
|
|
85
|
+
tmpAnticipate.anticipate(
|
|
86
|
+
function (fNext)
|
|
87
|
+
{
|
|
88
|
+
this.pict.EntityProvider.gatherDataFromServer(pInput.PictForm.TemplateEntityLookup.EntitiesBundle, fNext);
|
|
89
|
+
}.bind(this));
|
|
90
|
+
|
|
91
|
+
// 2. Check the Empty Value Test List
|
|
92
|
+
|
|
93
|
+
// 3. Render the Template
|
|
94
|
+
tmpAnticipate.anticipate(
|
|
95
|
+
function (fNext)
|
|
96
|
+
{
|
|
97
|
+
this.pict.parseTemplate(tmpDisplayTemplate, {Value: pValue},
|
|
98
|
+
function (pError, pResult)
|
|
99
|
+
{
|
|
100
|
+
if (pError)
|
|
101
|
+
{
|
|
102
|
+
this.log.error("Error rendering template in assignDisplayEntityData", pError);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
tmpDisplayContent = pResult;
|
|
106
|
+
return fNext();
|
|
107
|
+
}.bind(this));
|
|
108
|
+
}.bind(this));
|
|
109
|
+
|
|
110
|
+
// 4. Assign the Content to the display element
|
|
111
|
+
tmpAnticipate.wait(
|
|
112
|
+
function (pError)
|
|
113
|
+
{
|
|
114
|
+
if (pError)
|
|
115
|
+
{
|
|
116
|
+
this.log.error("Error in assignDisplayEntityData", pError);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
this.pict.ContentAssignment.assignContent(pDisplayID, tmpDisplayContent);
|
|
120
|
+
}.bind(this));
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Initializes the input element for the Pict provider select input.
|
|
125
|
+
*
|
|
126
|
+
* @param {Object} pView - The view object.
|
|
127
|
+
* @param {Object} pGroup - The group object.
|
|
128
|
+
* @param {Object} pRow - The row object.
|
|
129
|
+
* @param {Object} pInput - The input object.
|
|
130
|
+
* @param {any} pValue - The input value.
|
|
131
|
+
* @param {string} pHTMLSelector - The HTML selector.
|
|
132
|
+
* @returns {boolean} - Returns true if the input element is successfully initialized, false otherwise.
|
|
133
|
+
*/
|
|
134
|
+
onInputInitialize(pView, pGroup, pRow, pInput, pValue, pHTMLSelector)
|
|
135
|
+
{
|
|
136
|
+
this.assignDisplayEntityData(this.getContentDisplayHTMLID(pInput.Macro.RawHTMLID), pInput, pValue);
|
|
137
|
+
return super.onInputInitialize(pView, pGroup, pRow, pInput, pValue, pHTMLSelector);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Initializes a tabular input element.
|
|
142
|
+
*
|
|
143
|
+
* @param {Object} pView - The view object.
|
|
144
|
+
* @param {Object} pGroup - The group object.
|
|
145
|
+
* @param {Object} pInput - The input object.
|
|
146
|
+
* @param {any} pValue - The input value.
|
|
147
|
+
* @param {string} pHTMLSelector - The HTML selector.
|
|
148
|
+
* @param {number} pRowIndex - The index of the row.
|
|
149
|
+
* @returns {any} - The result of the initialization.
|
|
150
|
+
*/
|
|
151
|
+
onInputInitializeTabular(pView, pGroup, pInput, pValue, pHTMLSelector, pRowIndex)
|
|
152
|
+
{
|
|
153
|
+
this.assignDisplayEntityData(this.getTabularContentDisplayInputID(pInput.Macro.RawHTMLID, pRowIndex), pInput, pValue);
|
|
154
|
+
return super.onInputInitializeTabular(pView, pGroup, pInput, pValue, pHTMLSelector, pRowIndex);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Marshals data to the form for the given input.
|
|
159
|
+
*
|
|
160
|
+
* @param {Object} pView - The view object.
|
|
161
|
+
* @param {Object} pGroup - The group object.
|
|
162
|
+
* @param {Object} pRow - The row object.
|
|
163
|
+
* @param {Object} pInput - The input object.
|
|
164
|
+
* @param {any} pValue - The value to be marshaled.
|
|
165
|
+
* @param {string} pHTMLSelector - The HTML selector.
|
|
166
|
+
* @returns {boolean} - Returns true if the value is successfully marshaled to the form, otherwise false.
|
|
167
|
+
*/
|
|
168
|
+
onDataMarshalToForm(pView, pGroup, pRow, pInput, pValue, pHTMLSelector)
|
|
169
|
+
{
|
|
170
|
+
this.assignDisplayEntityData(this.getContentDisplayHTMLID(pInput.Macro.RawHTMLID), pInput, pValue);
|
|
171
|
+
return super.onDataMarshalToForm(pView, pGroup, pRow, pInput, pValue, pHTMLSelector);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Marshals data to a form in tabular format.
|
|
176
|
+
*
|
|
177
|
+
* @param {Object} pView - The view object.
|
|
178
|
+
* @param {Object} pGroup - The group object.
|
|
179
|
+
* @param {Object} pInput - The input object.
|
|
180
|
+
* @param {any} pValue - The value parameter.
|
|
181
|
+
* @param {string} pHTMLSelector - The HTML selector parameter.
|
|
182
|
+
* @param {number} pRowIndex - The row index parameter.
|
|
183
|
+
* @returns {any} - The result of the data marshaling.
|
|
184
|
+
*/
|
|
185
|
+
onDataMarshalToFormTabular(pView, pGroup, pInput, pValue, pHTMLSelector, pRowIndex)
|
|
186
|
+
{
|
|
187
|
+
this.assignDisplayEntityData(this.getTabularContentDisplayInputID(pInput.Macro.RawHTMLID, pRowIndex), pInput, pValue);
|
|
188
|
+
return super.onDataMarshalToFormTabular(pView, pGroup, pInput, pValue, pHTMLSelector, pRowIndex);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
module.exports = CustomInputHandler;
|