pict-section-form 1.0.111 → 1.0.112
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/complex_table/Complex-Tabular-Application.js +33 -0
- package/example_applications/complex_table/html/index.html +1 -0
- package/package.json +5 -5
- package/source/views/Pict-View-Form-Metacontroller.js +295 -12
- package/types/source/views/Pict-View-Form-Metacontroller.d.ts +47 -2
- package/types/source/views/Pict-View-Form-Metacontroller.d.ts.map +1 -1
|
@@ -566,6 +566,39 @@ module.exports.default_configuration.pict_configuration = {
|
|
|
566
566
|
},
|
|
567
567
|
|
|
568
568
|
ReferenceManifests: {
|
|
569
|
+
DynamicSection1: {
|
|
570
|
+
Scope: "DynamicSection1",
|
|
571
|
+
Descriptors: {
|
|
572
|
+
DynamicField1: {
|
|
573
|
+
Name: "Dynamic Field 1",
|
|
574
|
+
Hash: "DynamicField1",
|
|
575
|
+
DataType: "String",
|
|
576
|
+
PictForm: { Section: "DynamicSection1", Group: "DynamicGroup1", Row: 1 },
|
|
577
|
+
},
|
|
578
|
+
DynamicField2: {
|
|
579
|
+
Name: "Dynamic Field 2",
|
|
580
|
+
Hash: "DynamicField2",
|
|
581
|
+
DataType: "String",
|
|
582
|
+
PictForm: { Section: "DynamicSection1", Group: "DynamicGroup2", Row: 1 },
|
|
583
|
+
},
|
|
584
|
+
},
|
|
585
|
+
Sections: [
|
|
586
|
+
{
|
|
587
|
+
Hash: "DynamicSection1",
|
|
588
|
+
Name: "Dynamic Section 1",
|
|
589
|
+
Groups: [
|
|
590
|
+
{
|
|
591
|
+
Hash: "DynamicGroup1",
|
|
592
|
+
Name: "Dynamic Group 1",
|
|
593
|
+
},
|
|
594
|
+
{
|
|
595
|
+
Hash: "DynamicGroup2",
|
|
596
|
+
Name: "Dynamic Group 2",
|
|
597
|
+
}
|
|
598
|
+
]
|
|
599
|
+
}
|
|
600
|
+
]
|
|
601
|
+
},
|
|
569
602
|
FruitEditor: {
|
|
570
603
|
Scope: "FruitEditor",
|
|
571
604
|
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
</style>
|
|
35
35
|
</head>
|
|
36
36
|
<body>
|
|
37
|
+
<button type="button" onclick="_Pict.views.PictFormMetacontroller.injectManifestsByHash(['DynamicSection1'], 'FruitGrid'); _Pict.views.PictFormMetacontroller.updateMetatemplateInDOM();">Add Dynamic Section</button>
|
|
37
38
|
<div id="Pict-Form-Container"></div>
|
|
38
39
|
<script src="./complex_tabular_application.js" type="text/javascript"></script>
|
|
39
40
|
</body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pict-section-form",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.112",
|
|
4
4
|
"description": "Pict dynamic form sections",
|
|
5
5
|
"main": "source/Pict-Section-Form.js",
|
|
6
6
|
"directories": {
|
|
@@ -27,16 +27,16 @@
|
|
|
27
27
|
"author": "steven velozo <steven@velozo.com>",
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@eslint/js": "^9.
|
|
30
|
+
"@eslint/js": "^9.36.0",
|
|
31
31
|
"browser-env": "^3.3.0",
|
|
32
|
-
"eslint": "^9.
|
|
32
|
+
"eslint": "^9.36.0",
|
|
33
33
|
"jquery": "^3.7.1",
|
|
34
|
-
"pict": "^1.0.
|
|
34
|
+
"pict": "^1.0.302",
|
|
35
35
|
"pict-application": "^1.0.27",
|
|
36
36
|
"pict-service-commandlineutility": "^1.0.15",
|
|
37
37
|
"quackage": "^1.0.42",
|
|
38
38
|
"tui-grid": "^4.21.22",
|
|
39
|
-
"typescript": "^5.
|
|
39
|
+
"typescript": "^5.9.2"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"fable-serviceproviderbase": "^3.0.15",
|
|
@@ -166,6 +166,144 @@ class PictFormMetacontroller extends libPictViewClass
|
|
|
166
166
|
return pViewFilterState;
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
+
/**
|
|
170
|
+
* @param {string} pSectionManifestHash - The hash of the section to find.
|
|
171
|
+
*
|
|
172
|
+
* @return {Record<string, any>} The section definition object, or undefined if not found.
|
|
173
|
+
*/
|
|
174
|
+
findDynamicSectionManifestDefinition(pSectionManifestHash)
|
|
175
|
+
{
|
|
176
|
+
const sectionManifest = this.manifestDescription?.ReferenceManifests?.[pSectionManifestHash];
|
|
177
|
+
if (typeof(sectionManifest) !== 'object')
|
|
178
|
+
{
|
|
179
|
+
this.log.error(`findDynamicSectionManifestDefinition() could not find a section manifest with hash [${pSectionManifestHash}]`);
|
|
180
|
+
return null;
|
|
181
|
+
}
|
|
182
|
+
return sectionManifest;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* @param {Record<string, any>} pManifest - The manifest to add
|
|
187
|
+
* @param {string} [pAfterSectionHash] - The hash of the section to add after. Omit to add to the start.
|
|
188
|
+
*/
|
|
189
|
+
injectManifest(pManifest, pAfterSectionHash)
|
|
190
|
+
{
|
|
191
|
+
const tmpAllViewKeys = Object.keys(this.pict.views);
|
|
192
|
+
const tmpReferenceManifestViewIndex = pAfterSectionHash ? tmpAllViewKeys.indexOf(`PictSectionForm-${pAfterSectionHash}`) : -1;
|
|
193
|
+
const tmpViewsToShift = [];
|
|
194
|
+
if (tmpReferenceManifestViewIndex >= 0)
|
|
195
|
+
{
|
|
196
|
+
// reorder views (hacky - add layer to do this more directly)
|
|
197
|
+
for (let i = tmpReferenceManifestViewIndex + 1; i < tmpAllViewKeys.length; i++)
|
|
198
|
+
{
|
|
199
|
+
const tmpKey = tmpAllViewKeys[i];
|
|
200
|
+
tmpViewsToShift.push({ key: tmpKey, view: this.pict.views[tmpKey] });
|
|
201
|
+
delete this.pict.views[tmpKey];
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
const tmpViewsToRender = this.bootstrapAdditiveManifest(pManifest, pAfterSectionHash);
|
|
205
|
+
for (const tmpViewToShift of tmpViewsToShift)
|
|
206
|
+
{
|
|
207
|
+
this.pict.views[tmpViewToShift.key] = tmpViewToShift.view;
|
|
208
|
+
}
|
|
209
|
+
// this ensures if we re-render everything, we have the new sections in the template
|
|
210
|
+
this.generateMetatemplate();
|
|
211
|
+
this.regenerateFormSectionTemplates();
|
|
212
|
+
//FIXME: for some reason, DOM append is not synchronous, so we need to delay the render....................?
|
|
213
|
+
setTimeout(() =>
|
|
214
|
+
{
|
|
215
|
+
for (const tmpViewToRender of tmpViewsToRender)
|
|
216
|
+
{
|
|
217
|
+
tmpViewToRender.render();
|
|
218
|
+
}
|
|
219
|
+
}, 0);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Changes:
|
|
224
|
+
* * The hashes of each section+group to be globally unique.
|
|
225
|
+
* * The data address of each element to map to a unique location.
|
|
226
|
+
*
|
|
227
|
+
* @param {Record<string, any>} pManifest - The manifest to create a distinct copy of.
|
|
228
|
+
* @param {string} [pUUID] - (optional) The UUID to use for uniqueness. If not provided, a new one will be generated.
|
|
229
|
+
*
|
|
230
|
+
* @return {Record<string, any>} A distinct copy of the manifest.
|
|
231
|
+
*/
|
|
232
|
+
createDistinctManifest(pManifest, pUUID)
|
|
233
|
+
{
|
|
234
|
+
const tmpUUID = pUUID != null ? pUUID : this.pict.getUUID().replace(/-/g, '');
|
|
235
|
+
const tmpManifest = JSON.parse(JSON.stringify(pManifest));
|
|
236
|
+
for (const tmpSection of tmpManifest.Sections || [])
|
|
237
|
+
{
|
|
238
|
+
tmpSection.Hash = `${tmpSection.Hash}_${tmpUUID}`;
|
|
239
|
+
for (const tmpGroup of tmpSection.Groups || [])
|
|
240
|
+
{
|
|
241
|
+
tmpGroup.Hash = `${tmpGroup.Hash}_${tmpUUID}`;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
const tmpNewDescriptors = {};
|
|
245
|
+
for (const [ tmpKey, tmpDescriptor ] of Object.entries(tmpManifest.Descriptors || {}))
|
|
246
|
+
{
|
|
247
|
+
//FIXME: do we want to allow prefixing the data address? (ex. nesting it under a parent object) - caller can still do this themselves.
|
|
248
|
+
tmpDescriptor.DataAddress = `${tmpDescriptor.DataAddress || tmpKey}_${tmpUUID}`;
|
|
249
|
+
if (tmpDescriptor.Hash)
|
|
250
|
+
{
|
|
251
|
+
tmpDescriptor.Hash = `${tmpDescriptor.Hash}_${tmpUUID}`;
|
|
252
|
+
}
|
|
253
|
+
if (tmpDescriptor.PictForm)
|
|
254
|
+
{
|
|
255
|
+
if (tmpDescriptor.PictForm.Section)
|
|
256
|
+
{
|
|
257
|
+
tmpDescriptor.PictForm.Section = `${tmpDescriptor.PictForm.Section}_${tmpUUID}`;
|
|
258
|
+
}
|
|
259
|
+
if (tmpDescriptor.PictForm.Group)
|
|
260
|
+
{
|
|
261
|
+
tmpDescriptor.PictForm.Group = `${tmpDescriptor.PictForm.Group}_${tmpUUID}`;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
tmpNewDescriptors[`${tmpKey}_${tmpUUID}`] = tmpDescriptor;
|
|
265
|
+
}
|
|
266
|
+
tmpManifest.Descriptors = tmpNewDescriptors;
|
|
267
|
+
return tmpManifest;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* @param {Array<string>} pManifestHashes - The hashes of the manifests to add.
|
|
272
|
+
* @param {string} [pAfterSectionHash] - The hash of the section to add after. Omit to add to the start.
|
|
273
|
+
* @param {string} [pUUID] - (optional) The UUID to use for uniqueness. If not provided, a new one will be generated.
|
|
274
|
+
*/
|
|
275
|
+
injectManifestsByHash(pManifestHashes, pAfterSectionHash, pUUID)
|
|
276
|
+
{
|
|
277
|
+
for (const tmpManifestHash of pManifestHashes)
|
|
278
|
+
{
|
|
279
|
+
const tmpManifest = this.findDynamicSectionManifestDefinition(tmpManifestHash);
|
|
280
|
+
if (tmpManifest)
|
|
281
|
+
{
|
|
282
|
+
const tmpUniqueManifest = this.createDistinctManifest(tmpManifest, pUUID);
|
|
283
|
+
this.injectManifest(tmpUniqueManifest, pAfterSectionHash);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* @param {Record<string, any>} pSectionsManifest - The section definition object.
|
|
290
|
+
* @param {string} [pAfterSectionHash] - The hash of the section to add after. Omit to add to the start.
|
|
291
|
+
*/
|
|
292
|
+
bootstrapAdditiveManifest(pSectionsManifest, pAfterSectionHash)
|
|
293
|
+
{
|
|
294
|
+
const tmpViewsToRender = [];
|
|
295
|
+
const tmpNewSectionDefinitions = this.bootstrapPictFormViewsFromManifest(pSectionsManifest, pAfterSectionHash);
|
|
296
|
+
for (const tmpNewSectionDefinition of tmpNewSectionDefinitions)
|
|
297
|
+
{
|
|
298
|
+
const tmpView = this.pict.views[`PictSectionForm-${tmpNewSectionDefinition.Hash}`];
|
|
299
|
+
if (tmpView)
|
|
300
|
+
{
|
|
301
|
+
tmpViewsToRender.push(tmpView);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
return tmpViewsToRender;
|
|
305
|
+
}
|
|
306
|
+
|
|
169
307
|
/**
|
|
170
308
|
* Filters the views based on the provided filter and sort functions.
|
|
171
309
|
*
|
|
@@ -180,6 +318,7 @@ class PictFormMetacontroller extends libPictViewClass
|
|
|
180
318
|
// Generate the filter state object
|
|
181
319
|
let tmpViewFilterState = (
|
|
182
320
|
{
|
|
321
|
+
//FIXME: need to be able to control this order better - adding dynamic sections will always put them at the end, which is rarely what you want
|
|
183
322
|
ViewHashList: Object.keys(this.pict.views),
|
|
184
323
|
// If there is no customization to the filter or sort, just render the last set.
|
|
185
324
|
RenderLastRenderedViewsWithoutCustomization: true,
|
|
@@ -378,7 +517,7 @@ class PictFormMetacontroller extends libPictViewClass
|
|
|
378
517
|
|
|
379
518
|
if (!this.formTemplatePrefix)
|
|
380
519
|
{
|
|
381
|
-
this.formTemplatePrefix = this.pict.providers.MetatemplateGenerator.baseTemplatePrefix
|
|
520
|
+
this.formTemplatePrefix = this.pict.providers.MetatemplateGenerator.baseTemplatePrefix;
|
|
382
521
|
}
|
|
383
522
|
|
|
384
523
|
// Add the Form Prefix stuff
|
|
@@ -422,6 +561,100 @@ class PictFormMetacontroller extends libPictViewClass
|
|
|
422
561
|
this.pict.TemplateProvider.addTemplate(this.options.MetaTemplateHash, tmpTemplate);
|
|
423
562
|
}
|
|
424
563
|
|
|
564
|
+
/**
|
|
565
|
+
* Generates a meta template for the DynamicForm views managed by this Metacontroller.
|
|
566
|
+
*
|
|
567
|
+
* @param {Function} [fFormSectionFilter] - (optional) The filter function to apply on the form section.
|
|
568
|
+
* @param {SortFunction} [fSortFunction] - (optional) The sort function to apply on the form section.
|
|
569
|
+
*
|
|
570
|
+
* @return {void}
|
|
571
|
+
*/
|
|
572
|
+
updateMetatemplateInDOM(fFormSectionFilter, fSortFunction)
|
|
573
|
+
{
|
|
574
|
+
if (!this.formTemplatePrefix)
|
|
575
|
+
{
|
|
576
|
+
this.formTemplatePrefix = this.pict.providers.MetatemplateGenerator.baseTemplatePrefix;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
let tmpViewList = this.filterViews(fFormSectionFilter, fSortFunction);
|
|
580
|
+
let tmpPrevDiv = null;
|
|
581
|
+
let tmpDeferredDivContent;
|
|
582
|
+
let tmpDeferredDivID = null;
|
|
583
|
+
|
|
584
|
+
for (let i = 0; i < tmpViewList.length; i++)
|
|
585
|
+
{
|
|
586
|
+
let tmpFormView = tmpViewList[i];
|
|
587
|
+
if (tmpFormView === this)
|
|
588
|
+
{
|
|
589
|
+
continue;
|
|
590
|
+
}
|
|
591
|
+
if (!tmpFormView.isPictSectionForm)
|
|
592
|
+
{
|
|
593
|
+
continue;
|
|
594
|
+
}
|
|
595
|
+
if (!tmpFormView.options.IncludeInMetatemplateSectionGeneration)
|
|
596
|
+
{
|
|
597
|
+
continue;
|
|
598
|
+
}
|
|
599
|
+
const tmpFormDivID = tmpFormView.options.CustomTargetID || `Pict-${this.UUID}-${tmpFormView.options.Hash}-Wrap`;
|
|
600
|
+
let tmpFormDivs = this.pict.ContentAssignment.getElement(`#${tmpFormDivID}`);
|
|
601
|
+
if (tmpFormDivs.length > 0)
|
|
602
|
+
{
|
|
603
|
+
const tmpFormDiv = tmpFormDivs[0];
|
|
604
|
+
if (tmpDeferredDivID)
|
|
605
|
+
{
|
|
606
|
+
// We have a deferred div ID, so we need to insert it before this one
|
|
607
|
+
this.pict.ContentAssignment.insertContentBefore(`#${tmpFormDivID}`, tmpDeferredDivContent);
|
|
608
|
+
tmpDeferredDivID = null;
|
|
609
|
+
tmpDeferredDivContent = null;
|
|
610
|
+
}
|
|
611
|
+
tmpPrevDiv = tmpFormDiv;
|
|
612
|
+
continue;
|
|
613
|
+
}
|
|
614
|
+
let tmpFormDivTemplate = '';
|
|
615
|
+
if (tmpFormView.options.IncludeInMetatemplateSectionGeneration)
|
|
616
|
+
{
|
|
617
|
+
tmpFormDivTemplate += `\n{~T:${this.formTemplatePrefix}-Template-Form-Container-Wrap-Prefix:Pict.views["${tmpFormView.Hash}"]~}`;
|
|
618
|
+
if (tmpFormView.isPictSectionForm)
|
|
619
|
+
{
|
|
620
|
+
tmpFormDivTemplate += `\n{~T:${this.formTemplatePrefix}-Template-Form-Container:Pict.views["${tmpFormView.Hash}"]~}`;
|
|
621
|
+
}
|
|
622
|
+
else
|
|
623
|
+
{
|
|
624
|
+
//NOTE: For now, requiring the destination address to be an ID for this case
|
|
625
|
+
tmpFormView.options.CustomTargetID = tmpFormView.options.DefaultDestinationAddress.replace(/#/, '');
|
|
626
|
+
tmpFormDivTemplate += `\n{~T:${this.formTemplatePrefix}-Template-Form-Container-Custom:Pict.views["${tmpFormView.Hash}"]~}`;
|
|
627
|
+
}
|
|
628
|
+
tmpFormDivTemplate += `\n{~T:${this.formTemplatePrefix}-Template-Form-Container-Wrap-Postfix:Pict.views["${tmpFormView.Hash}"]~}`;
|
|
629
|
+
}
|
|
630
|
+
else if (!tmpFormView.isPictSectionForm)
|
|
631
|
+
{
|
|
632
|
+
//NOTE: For now, requiring the destination address to be an ID for this case
|
|
633
|
+
tmpFormView.options.CustomTargetID = tmpFormView.options.DefaultDestinationAddress.replace(/#/, '');
|
|
634
|
+
tmpFormDivTemplate += `\n{~T:${this.formTemplatePrefix}-Template-Form-Container-Wrap-Prefix:Pict.views["${tmpFormView.Hash}"]~}`;
|
|
635
|
+
tmpFormDivTemplate += `\n{~T:${this.formTemplatePrefix}-Template-Form-Container-Custom:Pict.views["${tmpFormView.Hash}"]~}`;
|
|
636
|
+
tmpFormDivTemplate += `\n{~T:${this.formTemplatePrefix}-Template-Form-Container-Wrap-Postfix:Pict.views["${tmpFormView.Hash}"]~}`;
|
|
637
|
+
}
|
|
638
|
+
const tmpFormDivContent = this.pict.parseTemplate(tmpFormDivTemplate, tmpFormView, null, [this]);
|
|
639
|
+
if (tmpPrevDiv)
|
|
640
|
+
{
|
|
641
|
+
this.pict.ContentAssignment.insertContentAfter(`#${tmpPrevDiv.id}`, tmpFormDivContent);
|
|
642
|
+
tmpFormDivs = this.pict.ContentAssignment.getElement(`#${tmpFormDivID}`);
|
|
643
|
+
tmpPrevDiv = tmpFormDivs;
|
|
644
|
+
continue;
|
|
645
|
+
}
|
|
646
|
+
tmpDeferredDivID = tmpFormDivID;
|
|
647
|
+
tmpDeferredDivContent = tmpFormDivContent;
|
|
648
|
+
}
|
|
649
|
+
if (tmpDeferredDivID)
|
|
650
|
+
{
|
|
651
|
+
// this means the container was empty, so just add it to the end
|
|
652
|
+
this.pict.ContentAssignment.appendContent(`#Pict-${this.UUID}-FormContainer`, tmpDeferredDivContent);
|
|
653
|
+
tmpDeferredDivID = null;
|
|
654
|
+
tmpDeferredDivContent = null;
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
|
|
425
658
|
/**
|
|
426
659
|
* Retrieves a safe clone of the section definition for a given manyfest section description object.
|
|
427
660
|
*
|
|
@@ -475,9 +708,11 @@ class PictFormMetacontroller extends libPictViewClass
|
|
|
475
708
|
* Bootstraps Pict DynamicForm views from a Manyfest description JSON object.
|
|
476
709
|
*
|
|
477
710
|
* @param {Object} pManifestDescription - The manifest description object.
|
|
478
|
-
* @
|
|
711
|
+
* @param {string} [pAfterSectionHash] - The hash of the section to add after. Omit to add to the start.
|
|
712
|
+
*
|
|
713
|
+
* @returns {Array<Record<string, any>>} - An array of section definitions added.
|
|
479
714
|
*/
|
|
480
|
-
bootstrapPictFormViewsFromManifest(pManifestDescription)
|
|
715
|
+
bootstrapPictFormViewsFromManifest(pManifestDescription, pAfterSectionHash)
|
|
481
716
|
{
|
|
482
717
|
let tmpManifestDescription = (typeof(pManifestDescription) === 'object') ? pManifestDescription : false;
|
|
483
718
|
let tmpSectionList = [];
|
|
@@ -497,8 +732,51 @@ class PictFormMetacontroller extends libPictViewClass
|
|
|
497
732
|
return tmpSectionList;
|
|
498
733
|
}
|
|
499
734
|
}
|
|
500
|
-
this.manifestDescription
|
|
501
|
-
|
|
735
|
+
if (this.manifestDescription)
|
|
736
|
+
{
|
|
737
|
+
this.stashedManifestDescription = this.manifestDescription;
|
|
738
|
+
this.manifestDescription = tmpManifestDescription;
|
|
739
|
+
//FIXME: merge manifests more fully... should this be an external capability?
|
|
740
|
+
for (const [ tmpKey, tmpDescriptor ] of Object.entries(this.manifestDescription.Descriptors || {}))
|
|
741
|
+
{
|
|
742
|
+
if (this.stashedManifestDescription.Descriptors[tmpKey])
|
|
743
|
+
{
|
|
744
|
+
this.log.error(`PictFormMetacontroller.bootstrapPictFormViewsFromManifest() found a duplicate descriptor key [${tmpKey}] when merging manifests. The new descriptor will be skipped.`);
|
|
745
|
+
continue;
|
|
746
|
+
}
|
|
747
|
+
this.stashedManifestDescription.Descriptors[tmpKey] = JSON.parse(JSON.stringify(tmpDescriptor));
|
|
748
|
+
}
|
|
749
|
+
for (const tmpKey of Object.keys(this.manifestDescription.ReferenceManifests || {}))
|
|
750
|
+
{
|
|
751
|
+
if (this.stashedManifestDescription.ReferenceManifests[tmpKey])
|
|
752
|
+
{
|
|
753
|
+
this.log.warn(`PictFormMetacontroller.bootstrapPictFormViewsFromManifest() found a duplicate reference manifest key [${tmpKey}] when merging manifests. The new reference manifest will be skipped.`);
|
|
754
|
+
continue;
|
|
755
|
+
}
|
|
756
|
+
this.stashedManifestDescription.ReferenceManifests[tmpKey] = JSON.parse(JSON.stringify(this.manifestDescription.ReferenceManifests[tmpKey]));
|
|
757
|
+
}
|
|
758
|
+
let tmpInsertAtIndex = this.stashedManifestDescription.Sections.findIndex((pSection) => pSection.Hash == pAfterSectionHash);
|
|
759
|
+
if (tmpInsertAtIndex < 0)
|
|
760
|
+
{
|
|
761
|
+
tmpInsertAtIndex = 0;
|
|
762
|
+
}
|
|
763
|
+
else
|
|
764
|
+
{
|
|
765
|
+
// We want to insert AFTER the found index, so increment by 1
|
|
766
|
+
++tmpInsertAtIndex;
|
|
767
|
+
}
|
|
768
|
+
for (const tmpSection of this.manifestDescription.Sections || [])
|
|
769
|
+
{
|
|
770
|
+
const tmpClonedSection = JSON.parse(JSON.stringify(tmpSection));
|
|
771
|
+
this.stashedManifestDescription.Sections.splice(tmpInsertAtIndex, 0, tmpClonedSection);
|
|
772
|
+
++tmpInsertAtIndex;
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
else
|
|
776
|
+
{
|
|
777
|
+
this.manifestDescription = tmpManifestDescription;
|
|
778
|
+
}
|
|
779
|
+
let tmpManifest = this.fable.instantiateServiceProviderWithoutRegistration('Manifest', this.manifestDescription);
|
|
502
780
|
|
|
503
781
|
if (this.options.AutoPopulateDefaultObject)
|
|
504
782
|
{
|
|
@@ -511,11 +789,11 @@ class PictFormMetacontroller extends libPictViewClass
|
|
|
511
789
|
}
|
|
512
790
|
|
|
513
791
|
// Get the list of Explicitly Defined section hashes from the Sections property of the manifest
|
|
514
|
-
if (('Sections' in
|
|
792
|
+
if (('Sections' in this.manifestDescription) && Array.isArray(this.manifestDescription.Sections))
|
|
515
793
|
{
|
|
516
|
-
for (let i = 0; i <
|
|
794
|
+
for (let i = 0; i < this.manifestDescription.Sections.length; i++)
|
|
517
795
|
{
|
|
518
|
-
let tmpSectionDefinition = this.getSectionDefinition(
|
|
796
|
+
let tmpSectionDefinition = this.getSectionDefinition(this.manifestDescription.Sections[i]);
|
|
519
797
|
|
|
520
798
|
if (tmpSectionDefinition)
|
|
521
799
|
{
|
|
@@ -581,17 +859,17 @@ class PictFormMetacontroller extends libPictViewClass
|
|
|
581
859
|
{
|
|
582
860
|
tmpViewConfiguration.Manifests = {};
|
|
583
861
|
}
|
|
584
|
-
tmpViewConfiguration.Manifests.Section =
|
|
862
|
+
tmpViewConfiguration.Manifests.Section = this.manifestDescription;
|
|
585
863
|
tmpViewConfiguration.AutoMarshalDataOnSolve = this.options.AutoMarshalDataOnSolve;
|
|
586
864
|
this.pict.addView(tmpViewHash, tmpViewConfiguration, libPictViewDynamicForm);
|
|
587
865
|
}
|
|
588
866
|
|
|
589
|
-
if ('PickLists' in
|
|
867
|
+
if ('PickLists' in this.manifestDescription)
|
|
590
868
|
{
|
|
591
|
-
let tmpPickListKeys = Object.keys(
|
|
869
|
+
let tmpPickListKeys = Object.keys(this.manifestDescription.PickLists);
|
|
592
870
|
for (let i = 0; i < tmpPickListKeys.length; i++)
|
|
593
871
|
{
|
|
594
|
-
let tmpPickList =
|
|
872
|
+
let tmpPickList = this.manifestDescription.PickLists[tmpPickListKeys[i]];
|
|
595
873
|
this.pict.providers.DynamicMetaLists.buildList(tmpPickList);
|
|
596
874
|
}
|
|
597
875
|
}
|
|
@@ -606,6 +884,11 @@ class PictFormMetacontroller extends libPictViewClass
|
|
|
606
884
|
}
|
|
607
885
|
}
|
|
608
886
|
|
|
887
|
+
if (this.stashedManifestDescription)
|
|
888
|
+
{
|
|
889
|
+
this.manifestDescription = this.stashedManifestDescription;
|
|
890
|
+
delete this.stashedManifestDescription;
|
|
891
|
+
}
|
|
609
892
|
return tmpSectionList;
|
|
610
893
|
}
|
|
611
894
|
|
|
@@ -44,6 +44,39 @@ declare class PictFormMetacontroller extends libPictViewClass {
|
|
|
44
44
|
onSolve(): any;
|
|
45
45
|
onBeforeFilterViews(pViewFilterState: any): any;
|
|
46
46
|
onAfterFilterViews(pViewFilterState: any): any;
|
|
47
|
+
/**
|
|
48
|
+
* @param {string} pSectionManifestHash - The hash of the section to find.
|
|
49
|
+
*
|
|
50
|
+
* @return {Record<string, any>} The section definition object, or undefined if not found.
|
|
51
|
+
*/
|
|
52
|
+
findDynamicSectionManifestDefinition(pSectionManifestHash: string): Record<string, any>;
|
|
53
|
+
/**
|
|
54
|
+
* @param {Record<string, any>} pManifest - The manifest to add
|
|
55
|
+
* @param {string} [pAfterSectionHash] - The hash of the section to add after. Omit to add to the start.
|
|
56
|
+
*/
|
|
57
|
+
injectManifest(pManifest: Record<string, any>, pAfterSectionHash?: string): void;
|
|
58
|
+
/**
|
|
59
|
+
* Changes:
|
|
60
|
+
* * The hashes of each section+group to be globally unique.
|
|
61
|
+
* * The data address of each element to map to a unique location.
|
|
62
|
+
*
|
|
63
|
+
* @param {Record<string, any>} pManifest - The manifest to create a distinct copy of.
|
|
64
|
+
* @param {string} [pUUID] - (optional) The UUID to use for uniqueness. If not provided, a new one will be generated.
|
|
65
|
+
*
|
|
66
|
+
* @return {Record<string, any>} A distinct copy of the manifest.
|
|
67
|
+
*/
|
|
68
|
+
createDistinctManifest(pManifest: Record<string, any>, pUUID?: string): Record<string, any>;
|
|
69
|
+
/**
|
|
70
|
+
* @param {Array<string>} pManifestHashes - The hashes of the manifests to add.
|
|
71
|
+
* @param {string} [pAfterSectionHash] - The hash of the section to add after. Omit to add to the start.
|
|
72
|
+
* @param {string} [pUUID] - (optional) The UUID to use for uniqueness. If not provided, a new one will be generated.
|
|
73
|
+
*/
|
|
74
|
+
injectManifestsByHash(pManifestHashes: Array<string>, pAfterSectionHash?: string, pUUID?: string): void;
|
|
75
|
+
/**
|
|
76
|
+
* @param {Record<string, any>} pSectionsManifest - The section definition object.
|
|
77
|
+
* @param {string} [pAfterSectionHash] - The hash of the section to add after. Omit to add to the start.
|
|
78
|
+
*/
|
|
79
|
+
bootstrapAdditiveManifest(pSectionsManifest: Record<string, any>, pAfterSectionHash?: string): any[];
|
|
47
80
|
/**
|
|
48
81
|
* Filters the views based on the provided filter and sort functions.
|
|
49
82
|
*
|
|
@@ -93,6 +126,15 @@ declare class PictFormMetacontroller extends libPictViewClass {
|
|
|
93
126
|
* @returns {void}
|
|
94
127
|
*/
|
|
95
128
|
generateMetatemplate(fFormSectionFilter?: Function, fSortFunction?: SortFunction): void;
|
|
129
|
+
/**
|
|
130
|
+
* Generates a meta template for the DynamicForm views managed by this Metacontroller.
|
|
131
|
+
*
|
|
132
|
+
* @param {Function} [fFormSectionFilter] - (optional) The filter function to apply on the form section.
|
|
133
|
+
* @param {SortFunction} [fSortFunction] - (optional) The sort function to apply on the form section.
|
|
134
|
+
*
|
|
135
|
+
* @return {void}
|
|
136
|
+
*/
|
|
137
|
+
updateMetatemplateInDOM(fFormSectionFilter?: Function, fSortFunction?: SortFunction): void;
|
|
96
138
|
/**
|
|
97
139
|
* Retrieves a safe clone of the section definition for a given manyfest section description object.
|
|
98
140
|
*
|
|
@@ -104,9 +146,12 @@ declare class PictFormMetacontroller extends libPictViewClass {
|
|
|
104
146
|
* Bootstraps Pict DynamicForm views from a Manyfest description JSON object.
|
|
105
147
|
*
|
|
106
148
|
* @param {Object} pManifestDescription - The manifest description object.
|
|
107
|
-
* @
|
|
149
|
+
* @param {string} [pAfterSectionHash] - The hash of the section to add after. Omit to add to the start.
|
|
150
|
+
*
|
|
151
|
+
* @returns {Array<Record<string, any>>} - An array of section definitions added.
|
|
108
152
|
*/
|
|
109
|
-
bootstrapPictFormViewsFromManifest(pManifestDescription: any): any
|
|
153
|
+
bootstrapPictFormViewsFromManifest(pManifestDescription: any, pAfterSectionHash?: string): Array<Record<string, any>>;
|
|
154
|
+
stashedManifestDescription: any;
|
|
110
155
|
manifestDescription: any;
|
|
111
156
|
/**
|
|
112
157
|
* Trigger an event on all inputs on all views.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Pict-View-Form-Metacontroller.d.ts","sourceRoot":"","sources":["../../../source/views/Pict-View-Form-Metacontroller.js"],"names":[],"mappings":";AASA;;GAEG;AAEH;;;;;;GAMG;AACH;IAEC,2DAaC;IALA,yBAA2B;IAE3B,wBAAsF;IAEtF,cAAkC;IAQnC,wCAGC;IARD,kCAGC;IAOD;;;;OAIG;IACH,qBAFa,GAAG,CAaf;IAED;;;;OAIG;IACH,mBAFa,GAAG,CAaf;IAED,yCAYC;IAED;;;;;OAKG;IACH,kCAHW,aAAa,GACX,IAAI,CAsBhB;IAwBD;;;;OAIG;IACH,WAFa,GAAG,CAMf;IAED,gDAGC;IAED,+CAGC;IAED;;;;;;;;OAQG;IACH,wDAHW,YAAY,
|
|
1
|
+
{"version":3,"file":"Pict-View-Form-Metacontroller.d.ts","sourceRoot":"","sources":["../../../source/views/Pict-View-Form-Metacontroller.js"],"names":[],"mappings":";AASA;;GAEG;AAEH;;;;;;GAMG;AACH;IAEC,2DAaC;IALA,yBAA2B;IAE3B,wBAAsF;IAEtF,cAAkC;IAQnC,wCAGC;IARD,kCAGC;IAOD;;;;OAIG;IACH,qBAFa,GAAG,CAaf;IAED;;;;OAIG;IACH,mBAFa,GAAG,CAaf;IAED,yCAYC;IAED;;;;;OAKG;IACH,kCAHW,aAAa,GACX,IAAI,CAsBhB;IAwBD;;;;OAIG;IACH,WAFa,GAAG,CAMf;IAED,gDAGC;IAED,+CAGC;IAED;;;;OAIG;IACH,2DAJW,MAAM,GAEL,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAW9B;IAED;;;OAGG;IACH,0BAHW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,sBACnB,MAAM,QAiChB;IAED;;;;;;;;;OASG;IACH,kCALW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,UACnB,MAAM,GAEL,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAsC9B;IAED;;;;OAIG;IACH,uCAJW,KAAK,CAAC,MAAM,CAAC,sBACb,MAAM,UACN,MAAM,QAahB;IAED;;;OAGG;IACH,6CAHW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,sBACnB,MAAM,SAehB;IAED;;;;;;;;OAQG;IACH,wDAHW,YAAY,SAoHtB;IAED;;;;;;;OAOG;IACH,4CAHW,MAAM,GACJ,IAAI,CAShB;IAED;;;;OAIG;IACH,6BAFa,IAAI,CAQhB;IAED;;;;;;;OAOG;IACH,+DAFW,YAAY,QAatB;IAED;;;;;OAKG;IACH,8EAFW,YAAY,QAmBtB;IAED;;;;;;OAMG;IACH,oEAHW,YAAY,GACV,IAAI,CAkDhB;IAED;;;;;;;OAOG;IACH,uEAJW,YAAY,GAEX,IAAI,CAsFf;IAED;;;;;OAKG;IACH,qCAHW,MAAM,GACJ,MAAM,GAAC,OAAO,CA2C1B;IAED;;;;;;;OAOG;IACH,kFAJW,MAAM,GAEJ,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAoLtC;IA5JC,gCAA0D;IAC1D,yBAAiD;IA6JnD;;;OAGG;IACH,gCAFW,MAAM,QAgBhB;IAED;;;;OAIG;IACH,4BAFa,OAAO,CAKnB;CACD;;;;;qCAGU,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;oBAp5BjB,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,KAAK,MAAM"}
|