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,13 +1,14 @@
|
|
|
1
1
|
const libPictViewClass = require('pict-view');
|
|
2
2
|
|
|
3
|
-
const libInformary = require('
|
|
4
|
-
const
|
|
3
|
+
const libInformary = require('../providers/Pict-Provider-Informary.js');
|
|
4
|
+
const libDynamicSolver = require('../providers/Pict-Provider-DynamicSolver.js');
|
|
5
|
+
const libFormsTemplateProvider = require('../providers/Pict-Provider-DynamicTemplates.js');
|
|
5
6
|
|
|
6
|
-
class
|
|
7
|
+
class PictViewDynamicForm extends libPictViewClass
|
|
7
8
|
{
|
|
8
9
|
constructor(pFable, pOptions, pServiceHash)
|
|
9
10
|
{
|
|
10
|
-
let tmpOptions = Object.assign({}, require('./Pict-
|
|
11
|
+
let tmpOptions = Object.assign({}, require('./Pict-View-DynamicForm-DefaultConfiguration.json'), pOptions);
|
|
11
12
|
|
|
12
13
|
if (!tmpOptions.Manifests)
|
|
13
14
|
{
|
|
@@ -35,14 +36,6 @@ class PictSectionFormView extends libPictViewClass
|
|
|
35
36
|
{
|
|
36
37
|
tmpOptions.SectionTemplateHash = `Pict-Form-Template-${tmpOptions.Hash}`;
|
|
37
38
|
}
|
|
38
|
-
if (!tmpOptions.SectionTabularRowVirtualTemplateHash)
|
|
39
|
-
{
|
|
40
|
-
tmpOptions.SectionTabularRowVirtualTemplateHash = `Pict-Form-Template-TabularRow-Virtual-${tmpOptions.Hash}`;
|
|
41
|
-
}
|
|
42
|
-
if (!tmpOptions.SectionTabularRowTemplateHash)
|
|
43
|
-
{
|
|
44
|
-
tmpOptions.SectionTabularRowTemplateHash = `Pict-Form-Template-TabularRow-${tmpOptions.Hash}`;
|
|
45
|
-
}
|
|
46
39
|
|
|
47
40
|
if (tmpOptions.Renderables.length < 1)
|
|
48
41
|
{
|
|
@@ -63,6 +56,20 @@ class PictSectionFormView extends libPictViewClass
|
|
|
63
56
|
// Initialize the section manifest -- instantiated to live only the lifecycle of this view
|
|
64
57
|
this.sectionManifest = this.fable.instantiateServiceProviderWithoutRegistration('Manifest', this.options.Manifests.Section);
|
|
65
58
|
|
|
59
|
+
// Shift solvers to an array of tasks
|
|
60
|
+
this.sectionSolvers = [];
|
|
61
|
+
// Pull in solvers
|
|
62
|
+
if (('Solvers' in this.options) && Array.isArray(this.options.Solvers))
|
|
63
|
+
{
|
|
64
|
+
for (let i = 0; i < this.options.Solvers.length; i++)
|
|
65
|
+
{
|
|
66
|
+
if (typeof(this.options.Solvers[i]) === 'string')
|
|
67
|
+
{
|
|
68
|
+
this.sectionSolvers.push(this.options.Solvers[i]);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
66
73
|
if (!this.pict.providers.PictFormSectionDefaultTemplateProvider)
|
|
67
74
|
{
|
|
68
75
|
let tmpDefaultTemplateProvider = this.pict.addProvider('PictFormSectionDefaultTemplateProvider', libFormsTemplateProvider.default_configuration, libFormsTemplateProvider);
|
|
@@ -73,6 +80,11 @@ class PictSectionFormView extends libPictViewClass
|
|
|
73
80
|
let tmpInformary = this.pict.addProvider('Informary', libInformary.default_configuration, libInformary);
|
|
74
81
|
tmpInformary.initialize();
|
|
75
82
|
}
|
|
83
|
+
if (!this.pict.providers.DynamicSolver)
|
|
84
|
+
{
|
|
85
|
+
let tmpDynamicSolver = this.pict.addProvider('DynamicSolver', libDynamicSolver.default_configuration, libDynamicSolver);
|
|
86
|
+
tmpDynamicSolver.initialize();
|
|
87
|
+
}
|
|
76
88
|
// This is for if we decide to abstract metatemplates into a separate provider for code simplification
|
|
77
89
|
// if (!this.pict.providers.PictFormSectionMetatemplateGenerator)
|
|
78
90
|
// {
|
|
@@ -115,6 +127,16 @@ class PictSectionFormView extends libPictViewClass
|
|
|
115
127
|
this.initializeFormGroups();
|
|
116
128
|
}
|
|
117
129
|
|
|
130
|
+
addSolver(pSolveFunctionString)
|
|
131
|
+
{
|
|
132
|
+
return (
|
|
133
|
+
{
|
|
134
|
+
"Type": "SingleSolve",
|
|
135
|
+
"Priority": 0,
|
|
136
|
+
"SolveFunction": pSolveFunctionString
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
|
|
118
140
|
renderToPrimary()
|
|
119
141
|
{
|
|
120
142
|
// Render to the primary view that the
|
|
@@ -212,25 +234,7 @@ class PictSectionFormView extends libPictViewClass
|
|
|
212
234
|
|
|
213
235
|
onSolve()
|
|
214
236
|
{
|
|
215
|
-
|
|
216
|
-
{
|
|
217
|
-
this.marshalFromView();
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
if (Array.isArray(this.options.Solvers))
|
|
221
|
-
{
|
|
222
|
-
for (let i = 0; i < this.options.Solvers.length; i++)
|
|
223
|
-
{
|
|
224
|
-
// TODO: Precompile the solvers (it's super easy)
|
|
225
|
-
this.log.trace(`Dynamic View [${this.UUID}]::[${this.Hash}] solving equation ${i} [${this.options.Solvers[i]}]`);
|
|
226
|
-
|
|
227
|
-
let tmpResultsObject = {};
|
|
228
|
-
|
|
229
|
-
let tmpSolutionValue = this.fable.ExpressionParser.solve(this.options.Solvers[i], this.getMarshalDestinationObject(), tmpResultsObject, this.sectionManifest, this.getMarshalDestinationObject());
|
|
230
|
-
|
|
231
|
-
this.log.trace(`[${this.options.Solvers[i]}] result was ${tmpSolutionValue}`);
|
|
232
|
-
}
|
|
233
|
-
}
|
|
237
|
+
this.pict.providers.DynamicSolver.solveViews([this.Hash]);
|
|
234
238
|
|
|
235
239
|
if (this.options.AutoMarshalDataOnSolve)
|
|
236
240
|
{
|
|
@@ -532,7 +536,7 @@ class PictSectionFormView extends libPictViewClass
|
|
|
532
536
|
return tmpBeginTemplate + tmpAddressTemplate + tmpEndTemplate;
|
|
533
537
|
}
|
|
534
538
|
|
|
535
|
-
// There
|
|
539
|
+
// There was some kind of catastrophic failure -- the above templates should always be loaded.
|
|
536
540
|
this.log.error(`PICT Form [${this.UUID}]::[${this.Hash}] catastrophic error generating tabular metatemplate: missing input template for Data Type ${pDataType} and Input Type ${pInputType}, Data Address ${pViewDataAddress} and Record Subaddress ${pRecordSubAddress}}.`)
|
|
537
541
|
return '';
|
|
538
542
|
}
|
|
@@ -559,6 +563,10 @@ class PictSectionFormView extends libPictViewClass
|
|
|
559
563
|
// Add this to the group object for metatemplating
|
|
560
564
|
tmpGroup.GroupIndex = i;
|
|
561
565
|
|
|
566
|
+
tmpGroup.SectionTabularRowVirtualTemplateHash = `Pict-Form-Template-TabularRow-Virtual-${this.options.Hash}-G${tmpGroup.GroupIndex}`;
|
|
567
|
+
tmpGroup.SectionTabularRowTemplateHash = `Pict-Form-Template-TabularRow-${this.options.Hash}-G${tmpGroup.GroupIndex}`;
|
|
568
|
+
|
|
569
|
+
|
|
562
570
|
// Group layouts are customizable
|
|
563
571
|
// The three basic group layouts:
|
|
564
572
|
// 1. Record (default) - Render the whole address as a singleton record
|
|
@@ -612,7 +620,7 @@ class PictSectionFormView extends libPictViewClass
|
|
|
612
620
|
|
|
613
621
|
|
|
614
622
|
tmpTemplateSetRecordRowTemplate += this.getMetatemplateTemplateReference(`-TabularTemplate-Cell-Prefix`, `getTabularRecordInput("${i}","${k}")`);
|
|
615
|
-
let tmpInputType = ('PictForm' in tmpInput) ? tmpInput.PictForm.InputType : 'Default';
|
|
623
|
+
let tmpInputType = (('PictForm' in tmpInput) && tmpInput.PictForm.InputType) ? tmpInput.PictForm.InputType : 'Default';
|
|
616
624
|
tmpTemplateSetRecordRowTemplate += this.getTabularInputMetatemplateTemplateReference(tmpInput.DataType, tmpInputType, `getTabularRecordInput("${i}","${k}")`, k);
|
|
617
625
|
tmpTemplateSetRecordRowTemplate += this.getMetatemplateTemplateReference(`-TabularTemplate-Cell-Postfix`, `getTabularRecordInput("${i}","${k}")`);
|
|
618
626
|
}
|
|
@@ -625,16 +633,16 @@ class PictSectionFormView extends libPictViewClass
|
|
|
625
633
|
// TODO: Consider making this function available in manyfest in some fashion it seems dope.
|
|
626
634
|
let tmpTemplateSetVirtualRowTemplate = '';
|
|
627
635
|
tmpTemplateSetVirtualRowTemplate += this.getMetatemplateTemplateReferenceRaw(`-TabularTemplate-Row-ExtraPrefix`, `Record`);
|
|
628
|
-
tmpTemplateSetVirtualRowTemplate += `\n\n{~T:${
|
|
636
|
+
tmpTemplateSetVirtualRowTemplate += `\n\n{~T:${tmpGroup.SectionTabularRowTemplateHash}:Record~}\n`;
|
|
629
637
|
tmpTemplateSetVirtualRowTemplate += this.getMetatemplateTemplateReferenceRaw(`-TabularTemplate-Row-ExtraPostfix`, `Record`);
|
|
630
638
|
|
|
631
639
|
// This is a custom template expression
|
|
632
|
-
tmpTemplate += `\n\n{~MTVS:${
|
|
640
|
+
tmpTemplate += `\n\n{~MTVS:${tmpGroup.SectionTabularRowVirtualTemplateHash}:${tmpGroup.GroupIndex}:${this.getMarshalDestinationAddress()}.${tmpGroup.RecordSetAddress}~}\n`;
|
|
633
641
|
|
|
634
642
|
tmpTemplate += this.getMetatemplateTemplateReference(`-TabularTemplate-Group-Postfix`, `getGroup("${i}")`);
|
|
635
643
|
// Add the TemplateSetTemplate
|
|
636
|
-
this.pict.TemplateProvider.addTemplate(
|
|
637
|
-
this.pict.TemplateProvider.addTemplate(
|
|
644
|
+
this.pict.TemplateProvider.addTemplate(tmpGroup.SectionTabularRowVirtualTemplateHash, tmpTemplateSetVirtualRowTemplate);
|
|
645
|
+
this.pict.TemplateProvider.addTemplate(tmpGroup.SectionTabularRowTemplateHash, tmpTemplateSetRecordRowTemplate);
|
|
638
646
|
break;
|
|
639
647
|
case 'Record':
|
|
640
648
|
default:
|
|
@@ -736,6 +744,18 @@ class PictSectionFormView extends libPictViewClass
|
|
|
736
744
|
}
|
|
737
745
|
}
|
|
738
746
|
|
|
747
|
+
getTabularRecordSet(pGroupIndex)
|
|
748
|
+
{
|
|
749
|
+
// The neat thing about how the tabular groups work is that we can make it clever about whether it's an object or an array.
|
|
750
|
+
let tmpGroup = this.getGroup(pGroupIndex);
|
|
751
|
+
if (!tmpGroup)
|
|
752
|
+
{
|
|
753
|
+
this.log.warn(`PICT View Metatemplate Helper getTabularRecordSet ${pGroupIndex} was not a valid group.`);
|
|
754
|
+
return false;
|
|
755
|
+
}
|
|
756
|
+
return this.sectionManifest.getValueByHash(this.getMarshalDestinationObject(), tmpGroup.RecordSetAddress);
|
|
757
|
+
}
|
|
758
|
+
|
|
739
759
|
getGroup(pGroupIndex)
|
|
740
760
|
{
|
|
741
761
|
if (isNaN(pGroupIndex))
|
|
@@ -776,6 +796,97 @@ class PictSectionFormView extends libPictViewClass
|
|
|
776
796
|
}
|
|
777
797
|
}
|
|
778
798
|
|
|
799
|
+
setDynamicTableRowIndex(pGroupIndex, pRowIndex, pNewRowIndex)
|
|
800
|
+
{
|
|
801
|
+
let tmpGroup = this.getGroup(pGroupIndex);
|
|
802
|
+
|
|
803
|
+
if (tmpGroup)
|
|
804
|
+
{
|
|
805
|
+
let tmpDestinationObject = this.sectionManifest.getValueByHash(this.getMarshalDestinationObject(), tmpGroup.RecordSetAddress);
|
|
806
|
+
|
|
807
|
+
if (Array.isArray(tmpDestinationObject))
|
|
808
|
+
{
|
|
809
|
+
let tmpRowIndex = parseInt(pRowIndex, 10);
|
|
810
|
+
let tmpNewRowIndex = parseInt(pNewRowIndex, 10);
|
|
811
|
+
if ((tmpDestinationObject.length <= tmpRowIndex) || (tmpRowIndex < 0))
|
|
812
|
+
{
|
|
813
|
+
this.pict.log.error(`Dynamic View [${this.UUID}]::[${this.Hash}] Group ${tmpGroup.Hash} attempting to move row [${pRowIndex}] to [${pNewRowIndex}] but the index is out of bounds.`);
|
|
814
|
+
return false;
|
|
815
|
+
}
|
|
816
|
+
let tmpElementToBeMoved = tmpDestinationObject.splice(tmpRowIndex, 1);
|
|
817
|
+
tmpDestinationObject.splice(tmpNewRowIndex, 0, tmpElementToBeMoved[0]);
|
|
818
|
+
this.render();
|
|
819
|
+
this.marshalToView();
|
|
820
|
+
}
|
|
821
|
+
else if (typeof(tmpDestinationObject) === 'object')
|
|
822
|
+
{
|
|
823
|
+
this.pict.log.error(`Dynamic View [${this.UUID}]::[${this.Hash}] Group ${tmpGroup.Hash} attempting to move row [${pRowIndex}] to [${pNewRowIndex}] but it's an object not an array; order isn't controllable.`);
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
moveDynamicTableRowDown(pGroupIndex, pRowIndex)
|
|
829
|
+
{
|
|
830
|
+
let tmpGroup = this.getGroup(pGroupIndex);
|
|
831
|
+
|
|
832
|
+
if (tmpGroup)
|
|
833
|
+
{
|
|
834
|
+
let tmpDestinationObject = this.sectionManifest.getValueByHash(this.getMarshalDestinationObject(), tmpGroup.RecordSetAddress);
|
|
835
|
+
|
|
836
|
+
if (Array.isArray(tmpDestinationObject))
|
|
837
|
+
{
|
|
838
|
+
let tmpRowIndex = parseInt(pRowIndex, 10);
|
|
839
|
+
if (tmpDestinationObject.length <= tmpRowIndex)
|
|
840
|
+
{
|
|
841
|
+
this.pict.log.error(`Dynamic View [${this.UUID}]::[${this.Hash}] Group ${tmpGroup.Hash} attempting to move row [${pRowIndex}] down but it's already at the bottom.`);
|
|
842
|
+
return false;
|
|
843
|
+
}
|
|
844
|
+
let tmpElementToBeMoved = tmpDestinationObject.splice(tmpRowIndex, 1);
|
|
845
|
+
tmpDestinationObject.splice(tmpRowIndex + 1, 0, tmpElementToBeMoved[0]);
|
|
846
|
+
this.render();
|
|
847
|
+
this.marshalToView();
|
|
848
|
+
}
|
|
849
|
+
else if (typeof(tmpDestinationObject) === 'object')
|
|
850
|
+
{
|
|
851
|
+
this.pict.log.error(`Dynamic View [${this.UUID}]::[${this.Hash}] Group ${tmpGroup.Hash} attempting to move row [${pRowIndex}] but it's an object not an array; order isn't controllable.`);
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
moveDynamicTableRowUp(pGroupIndex, pRowIndex)
|
|
857
|
+
{
|
|
858
|
+
let tmpGroup = this.getGroup(pGroupIndex);
|
|
859
|
+
|
|
860
|
+
if (tmpGroup)
|
|
861
|
+
{
|
|
862
|
+
let tmpDestinationObject = this.sectionManifest.getValueByHash(this.getMarshalDestinationObject(), tmpGroup.RecordSetAddress);
|
|
863
|
+
|
|
864
|
+
if (Array.isArray(tmpDestinationObject))
|
|
865
|
+
{
|
|
866
|
+
let tmpRowIndex = parseInt(pRowIndex, 10);
|
|
867
|
+
if (tmpRowIndex == 0)
|
|
868
|
+
{
|
|
869
|
+
this.pict.log.error(`Dynamic View [${this.UUID}]::[${this.Hash}] Group ${tmpGroup.Hash} attempting to move row [${pRowIndex}] up but it's already at the top.`);
|
|
870
|
+
return false;
|
|
871
|
+
}
|
|
872
|
+
if (tmpDestinationObject.length <= tmpRowIndex)
|
|
873
|
+
{
|
|
874
|
+
this.pict.log.error(`Dynamic View [${this.UUID}]::[${this.Hash}] Group ${tmpGroup.Hash} attempting to move row [${pRowIndex}] but the index is out of bounds.`);
|
|
875
|
+
return false;
|
|
876
|
+
}
|
|
877
|
+
let tmpElementToBeMoved = tmpDestinationObject.splice(tmpRowIndex, 1);
|
|
878
|
+
tmpDestinationObject.splice(tmpRowIndex - 1, 0, tmpElementToBeMoved[0]);
|
|
879
|
+
this.render();
|
|
880
|
+
this.marshalToView();
|
|
881
|
+
}
|
|
882
|
+
else if (typeof(tmpDestinationObject) === 'object')
|
|
883
|
+
{
|
|
884
|
+
this.pict.log.error(`Dynamic View [${this.UUID}]::[${this.Hash}] Group ${tmpGroup.Hash} attempting to move row [${pRowIndex}] but it's an object not an array; order isn't controllable.`);
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
|
|
779
890
|
deleteDynamicTableRow(pGroupIndex, pRowIndex)
|
|
780
891
|
{
|
|
781
892
|
let tmpGroup = this.getGroup(pGroupIndex);
|
|
@@ -870,4 +981,4 @@ class PictSectionFormView extends libPictViewClass
|
|
|
870
981
|
}
|
|
871
982
|
}
|
|
872
983
|
|
|
873
|
-
module.exports =
|
|
984
|
+
module.exports = PictViewDynamicForm;
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
const libPictViewClass = require('pict-view');
|
|
2
|
+
const libDynamicSolver = require('../providers/Pict-Provider-DynamicSolver.js');
|
|
2
3
|
|
|
3
|
-
const libFormsTemplateProvider = require('
|
|
4
|
+
const libFormsTemplateProvider = require('../providers/Pict-Provider-DynamicTemplates.js');
|
|
5
|
+
|
|
6
|
+
// TODO: Create an internalized list of views for this to manage, separate from the pict.views object
|
|
7
|
+
// TODO: Manage view lifecycle internally, including destruction
|
|
8
|
+
// Why? This allows us to dynamically add and remove sections without having to reload the application.
|
|
4
9
|
|
|
5
10
|
// "What dependency injection in javascript?"
|
|
6
11
|
// -- Ned
|
|
@@ -15,9 +20,12 @@ class PictFormMetacontroller extends libPictViewClass
|
|
|
15
20
|
|
|
16
21
|
if (!this.pict.providers.PictFormSectionDefaultTemplateProvider)
|
|
17
22
|
{
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
23
|
+
this.pict.addProvider('PictFormSectionDefaultTemplateProvider', {}, libFormsTemplateProvider);
|
|
24
|
+
}
|
|
25
|
+
if (!this.pict.providers.DynamicSolver)
|
|
26
|
+
{
|
|
27
|
+
let tmpDynamicSolver = this.pict.addProvider('DynamicSolver', libDynamicSolver.default_configuration, libDynamicSolver);
|
|
28
|
+
tmpDynamicSolver.initialize();
|
|
21
29
|
}
|
|
22
30
|
|
|
23
31
|
this.viewMarshalDestination = 'AppData';
|
|
@@ -55,10 +63,8 @@ class PictFormMetacontroller extends libPictViewClass
|
|
|
55
63
|
{
|
|
56
64
|
// This is safe -- if there is no settings.DefaultFormManifest configuration, it just doesn't do anything
|
|
57
65
|
this.bootstrapPictFormViewsFromManifest();
|
|
58
|
-
|
|
59
66
|
// Generate the metatemplate (the container for each section)
|
|
60
67
|
this.generateMetatemplate();
|
|
61
|
-
|
|
62
68
|
return super.onAfterInitializeAsync(fCallback);
|
|
63
69
|
}
|
|
64
70
|
|
|
@@ -76,14 +82,7 @@ class PictFormMetacontroller extends libPictViewClass
|
|
|
76
82
|
|
|
77
83
|
onSolve()
|
|
78
84
|
{
|
|
79
|
-
|
|
80
|
-
for (let i = 0; i < tmpViewList.length; i++)
|
|
81
|
-
{
|
|
82
|
-
if (this.fable.views[tmpViewList[i]].isPictSectionForm)
|
|
83
|
-
{
|
|
84
|
-
this.fable.views[tmpViewList[i]].marshalFromView();
|
|
85
|
-
}
|
|
86
|
-
}
|
|
85
|
+
this.pict.providers.DynamicSolver.solveViews();
|
|
87
86
|
return super.onSolve();
|
|
88
87
|
}
|
|
89
88
|
|
|
@@ -130,6 +129,12 @@ class PictFormMetacontroller extends libPictViewClass
|
|
|
130
129
|
}
|
|
131
130
|
}
|
|
132
131
|
|
|
132
|
+
/**
|
|
133
|
+
* Regenerates the DyunamicForm section templates based on the provided filter and sort function.
|
|
134
|
+
*
|
|
135
|
+
* @param {Function} fFormSectionFilter - (optional) The filter function used to determine which views to include in the regeneration.
|
|
136
|
+
* @param {Function} fSortFunction - (optional) The sort function used to determine the order of the views in the regeneration.
|
|
137
|
+
*/
|
|
133
138
|
regenerateFormSectionTemplates(fFormSectionFilter, fSortFunction)
|
|
134
139
|
{
|
|
135
140
|
let tmpViewList = this.filterViews(fFormSectionFilter, fSortFunction);
|
|
@@ -141,6 +146,13 @@ class PictFormMetacontroller extends libPictViewClass
|
|
|
141
146
|
this.pict.CSSMap.injectCSS();
|
|
142
147
|
}
|
|
143
148
|
|
|
149
|
+
/**
|
|
150
|
+
* Generates a meta template for the DynamicForm views managed by this Metacontroller.
|
|
151
|
+
*
|
|
152
|
+
* @param {Function} fFormSectionFilter - (optional) The filter function to apply on the form section.
|
|
153
|
+
* @param {Function} fSortFunction - (optional) The sort function to apply on the form section.
|
|
154
|
+
* @returns {void}
|
|
155
|
+
*/
|
|
144
156
|
generateMetatemplate(fFormSectionFilter, fSortFunction)
|
|
145
157
|
{
|
|
146
158
|
let tmpTemplate = ``;
|
|
@@ -167,6 +179,12 @@ class PictFormMetacontroller extends libPictViewClass
|
|
|
167
179
|
this.pict.TemplateProvider.addTemplate(this.options.MetaTemplateHash, tmpTemplate);
|
|
168
180
|
}
|
|
169
181
|
|
|
182
|
+
/**
|
|
183
|
+
* Retrieves a safe clone of the section definition for a given manyfest section description object.
|
|
184
|
+
*
|
|
185
|
+
* @param {object} pSectionObject - The section object.
|
|
186
|
+
* @returns {object|boolean} - The section definition if successful, otherwise false.
|
|
187
|
+
*/
|
|
170
188
|
getSectionDefinition(pSectionObject)
|
|
171
189
|
{
|
|
172
190
|
if (typeof(pSectionObject) != 'object')
|
|
@@ -210,6 +228,12 @@ class PictFormMetacontroller extends libPictViewClass
|
|
|
210
228
|
}
|
|
211
229
|
}
|
|
212
230
|
|
|
231
|
+
/**
|
|
232
|
+
* Bootstraps Pict DynamicForm views from a Manyfest description JSON object.
|
|
233
|
+
*
|
|
234
|
+
* @param {Object} pManifestDescription - The manifest description object.
|
|
235
|
+
* @returns {Array} - An array of section definitions.
|
|
236
|
+
*/
|
|
213
237
|
bootstrapPictFormViewsFromManifest(pManifestDescription)
|
|
214
238
|
{
|
|
215
239
|
let tmpManifestDescription = (typeof(pManifestDescription) === 'object') ? pManifestDescription : false;
|
|
@@ -311,11 +335,16 @@ class PictFormMetacontroller extends libPictViewClass
|
|
|
311
335
|
}
|
|
312
336
|
tmpViewConfiguration.Manifests.Section = tmpManifestDescription;
|
|
313
337
|
tmpViewConfiguration.AutoMarshalDataOnSolve = this.options.AutoMarshalDataOnSolve;
|
|
314
|
-
this.fable.addView(tmpViewHash, tmpViewConfiguration, require('./Pict-
|
|
338
|
+
this.fable.addView(tmpViewHash, tmpViewConfiguration, require('./Pict-View-DynamicForm.js'));
|
|
315
339
|
}
|
|
316
340
|
|
|
317
341
|
return tmpSectionList;
|
|
318
342
|
}
|
|
343
|
+
|
|
344
|
+
get isPictMetacontroller()
|
|
345
|
+
{
|
|
346
|
+
return true;
|
|
347
|
+
}
|
|
319
348
|
}
|
|
320
349
|
|
|
321
350
|
module.exports = PictFormMetacontroller;
|
|
@@ -324,6 +353,7 @@ module.exports.default_configuration = (
|
|
|
324
353
|
"AutoRender": true,
|
|
325
354
|
|
|
326
355
|
"AutoPopulateDefaultObject": true,
|
|
356
|
+
"AutoSolveBeforeRender": true,
|
|
327
357
|
"AutoPopulateAfterRender": true,
|
|
328
358
|
|
|
329
359
|
"DefaultRenderable": "Pict-Forms-Metacontainer",
|
|
File without changes
|