pict-section-form 1.0.157 → 1.0.158
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/package.json
CHANGED
|
@@ -473,9 +473,9 @@ class PictFormMetacontroller extends libPictViewClass
|
|
|
473
473
|
//FIXME: do we want to allow prefixing the data address? (ex. nesting it under a parent object) - caller can still do this themselves.
|
|
474
474
|
tmpRecordSetAddress = `${tmpGroup.RecordSetAddress}_${tmpUUID}`;
|
|
475
475
|
}
|
|
476
|
-
//TODO: does this need to go into the mappings?
|
|
477
|
-
tmpGroup.RecordSetAddress = tmpRecordSetAddress;
|
|
478
476
|
}
|
|
477
|
+
//TODO: does this need to go into the mappings if it isn't there?
|
|
478
|
+
tmpGroup.RecordSetAddress = tmpRecordSetAddress;
|
|
479
479
|
|
|
480
480
|
}
|
|
481
481
|
if (Array.isArray(tmpGroup.RecordSetSolvers) && tmpGroup.RecordSetSolvers.length > 0)
|
|
@@ -692,6 +692,195 @@ suite
|
|
|
692
692
|
}
|
|
693
693
|
);
|
|
694
694
|
test(
|
|
695
|
+
'Distinct Array Test 4',
|
|
696
|
+
(fDone) =>
|
|
697
|
+
{
|
|
698
|
+
//NOTE: code is a clone of Pict.safeLoadPictApplication
|
|
699
|
+
let _Pict;
|
|
700
|
+
const tmpApplicationClass = OrderedSolverApplication;
|
|
701
|
+
if (tmpApplicationClass && ('default_configuration' in tmpApplicationClass) && ('pict_configuration' in tmpApplicationClass.default_configuration))
|
|
702
|
+
{
|
|
703
|
+
_Pict = new libPict(tmpApplicationClass.default_configuration.pict_configuration);
|
|
704
|
+
}
|
|
705
|
+
else
|
|
706
|
+
{
|
|
707
|
+
_Pict = new libPict();
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
//_Pict.LogNoisiness = 0;
|
|
711
|
+
|
|
712
|
+
let tmpApplicationHash = 'DefaultApplication';
|
|
713
|
+
let tmpDefaultConfiguration = {};
|
|
714
|
+
|
|
715
|
+
if ('default_configuration' in tmpApplicationClass)
|
|
716
|
+
{
|
|
717
|
+
tmpDefaultConfiguration = tmpApplicationClass.default_configuration;
|
|
718
|
+
|
|
719
|
+
if ('Hash' in tmpApplicationClass.default_configuration)
|
|
720
|
+
{
|
|
721
|
+
tmpDefaultConfiguration = tmpApplicationClass.default_configuration;
|
|
722
|
+
tmpApplicationHash = tmpApplicationClass.default_configuration.Hash;
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
_Pict.log.info(`Loading the pict application [${tmpApplicationHash}] and associated views.`);
|
|
726
|
+
|
|
727
|
+
_Pict.addApplication(tmpApplicationHash, tmpDefaultConfiguration, tmpApplicationClass);
|
|
728
|
+
|
|
729
|
+
// Add the pict form service
|
|
730
|
+
_Pict.addServiceType('PictSectionForm', libPictSectionForm);
|
|
731
|
+
|
|
732
|
+
// Add the pict form metacontroller service, which provides programmaatic view construction from manifests and render/marshal methods.
|
|
733
|
+
_Pict.addView('PictFormMetacontroller', {}, libPictSectionForm.PictFormMetacontroller);
|
|
734
|
+
|
|
735
|
+
const tmpManifest =
|
|
736
|
+
{
|
|
737
|
+
Scope: 'OrderedSolverApplicationForm',
|
|
738
|
+
Descriptors:
|
|
739
|
+
{
|
|
740
|
+
'LevelOfIndirection.DataTableAddress':
|
|
741
|
+
{
|
|
742
|
+
Hash: 'NestedDataTable',
|
|
743
|
+
Name: 'Nested Data Table',
|
|
744
|
+
DataAddress: 'LevelOfIndirection.DataTableAddress',
|
|
745
|
+
DataType: 'Array',
|
|
746
|
+
FormGroup: 'DataTableGroup',
|
|
747
|
+
FormSection: 'DataTableSection',
|
|
748
|
+
},
|
|
749
|
+
'LevelOfIndirection.AggregateValueAddress':
|
|
750
|
+
{
|
|
751
|
+
Hash: 'IndirectAggregateValue',
|
|
752
|
+
Name: 'Indirect Aggregate Value',
|
|
753
|
+
DataAddress: 'LevelOfIndirection.AggregateValueAddress',
|
|
754
|
+
DataType: 'PreciseNumber',
|
|
755
|
+
FormGroup: 'DataTableGroup',
|
|
756
|
+
FormSection: 'DataTableSection',
|
|
757
|
+
},
|
|
758
|
+
'LevelOfIndirection.DataTableAddress[].ValueAddress':
|
|
759
|
+
{
|
|
760
|
+
Hash: 'ValueArray',
|
|
761
|
+
Name: 'Data Value',
|
|
762
|
+
DataAddress: 'LevelOfIndirection.DataTableAddress[].ValueAddress',
|
|
763
|
+
DataType: 'Array',
|
|
764
|
+
FormGroup: 'DataTableGroup',
|
|
765
|
+
FormSection: 'DataTableSection',
|
|
766
|
+
},
|
|
767
|
+
AggregateValueAddress:
|
|
768
|
+
{
|
|
769
|
+
Hash: 'AggregateValue',
|
|
770
|
+
Name: 'Aggregate Value',
|
|
771
|
+
DataAddress: 'AggregateValueAddress',
|
|
772
|
+
DataType: 'PreciseNumber',
|
|
773
|
+
FormGroup: 'DataTableGroup',
|
|
774
|
+
FormSection: 'DataTableSection',
|
|
775
|
+
},
|
|
776
|
+
AggregateValueAddress2:
|
|
777
|
+
{
|
|
778
|
+
Hash: 'AggregateValue2',
|
|
779
|
+
Name: 'Aggregate Value 2',
|
|
780
|
+
DataAddress: 'AggregateValueAddress2',
|
|
781
|
+
DataType: 'PreciseNumber',
|
|
782
|
+
FormGroup: 'DataTableGroup',
|
|
783
|
+
FormSection: 'DataTableSection',
|
|
784
|
+
},
|
|
785
|
+
},
|
|
786
|
+
Sections:
|
|
787
|
+
[
|
|
788
|
+
{
|
|
789
|
+
Name: 'Ordered Solver Section',
|
|
790
|
+
Hash: 'OrderedSolverSection',
|
|
791
|
+
Groups:
|
|
792
|
+
[
|
|
793
|
+
{
|
|
794
|
+
Name: 'Group Name',
|
|
795
|
+
Hash: 'GroupHash',
|
|
796
|
+
RecordSetAddress: 'LevelOfIndirection.DataTableAddress',
|
|
797
|
+
},
|
|
798
|
+
],
|
|
799
|
+
Solvers:
|
|
800
|
+
[
|
|
801
|
+
{ Ordinal: 5, Expression: 'AggregateValue = SUM(ValueArray)' },
|
|
802
|
+
{ Ordinal: 40, Expression: 'AggregateValue2 = SUM(LevelOfIndirection.DataTableAddress[].ValueAddress)' },
|
|
803
|
+
{ Ordinal: 60, Expression: 'IndirectAggregateValue = AggregateValue' },
|
|
804
|
+
],
|
|
805
|
+
},
|
|
806
|
+
],
|
|
807
|
+
};
|
|
808
|
+
|
|
809
|
+
let tmpHashedAggregateValue = null;
|
|
810
|
+
let tmpHashedAggregateValue2 = null;
|
|
811
|
+
let tmpHashedAggregateValue3 = null;
|
|
812
|
+
_Pict.PictApplication.initializeAsync(
|
|
813
|
+
function (pError)
|
|
814
|
+
{
|
|
815
|
+
if (pError)
|
|
816
|
+
{
|
|
817
|
+
_Pict.log.info('Error initializing the pict application: '+pError)
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
try
|
|
821
|
+
{
|
|
822
|
+
_Pict.log.info('Loading the Application and associated views.');
|
|
823
|
+
const tmpUUID = _Pict.getUUID().substring(0, 8);
|
|
824
|
+
const tmpDistinctManifest = _Pict.views.PictFormMetacontroller.createDistinctManifest(tmpManifest, tmpUUID);
|
|
825
|
+
_Pict.log.info('Distinct Manifest:', tmpDistinctManifest);
|
|
826
|
+
Expect(tmpDistinctManifest.Sections[0].Groups[0].RecordSetAddress).to.equal(`LevelOfIndirection_${tmpUUID}.DataTableAddress`, 'Group RecordSetAddress should be preserved in distinct manifest.');
|
|
827
|
+
tmpHashedAggregateValue = Object.entries(tmpDistinctManifest.Descriptors).find(([pKey, pValue]) => pValue.OriginalHash == 'AggregateValue')[0];
|
|
828
|
+
tmpHashedAggregateValue2 = Object.entries(tmpDistinctManifest.Descriptors).find(([pKey, pValue]) => pValue.OriginalHash == 'AggregateValue2')[0];
|
|
829
|
+
tmpHashedAggregateValue3 = Object.entries(tmpDistinctManifest.Descriptors).find(([pKey, pValue]) => pValue.OriginalHash == 'IndirectAggregateValue')[0];
|
|
830
|
+
const tmpInjectedSecionViews = _Pict.views.PictFormMetacontroller.injectManifest(tmpDistinctManifest);
|
|
831
|
+
_Pict.log.info('Injected Section Views:', tmpInjectedSecionViews.length);
|
|
832
|
+
_Pict.views.PictFormMetacontroller.updateMetatemplateInDOM();
|
|
833
|
+
setTimeout(() =>
|
|
834
|
+
{
|
|
835
|
+
for (const tmpView of tmpInjectedSecionViews)
|
|
836
|
+
{
|
|
837
|
+
tmpView.render();
|
|
838
|
+
}
|
|
839
|
+
for (const tmpView of tmpInjectedSecionViews)
|
|
840
|
+
{
|
|
841
|
+
tmpView.marshalToView();
|
|
842
|
+
}
|
|
843
|
+
//TODO: do we need to trigger a solve here?
|
|
844
|
+
}, 0);
|
|
845
|
+
_Pict.PictApplication.testDone = () =>
|
|
846
|
+
{
|
|
847
|
+
try
|
|
848
|
+
{
|
|
849
|
+
_Pict.log.info(`AppData after`, { AppData: _Pict.AppData, tmpHashedAggregateValue, tmpHashedAggregateValue2, tmpHashedAggregateValue3 });
|
|
850
|
+
Expect(_Pict.AppData[tmpHashedAggregateValue]).to.equal('15', 'AggregateValue should equal 15 (SUM of ValueArray via hash)');
|
|
851
|
+
Expect(_Pict.AppData[tmpHashedAggregateValue2]).to.equal('15', 'AggregateValue should equal 15 (SUM of ValueArray via address)');
|
|
852
|
+
Expect(_Pict.manifest.getValueByHash(_Pict.AppData, tmpHashedAggregateValue3)).to.equal('15', 'IndirectAggregateValue should equal 15 (via indirection) using manifest method');
|
|
853
|
+
}
|
|
854
|
+
catch (pError)
|
|
855
|
+
{
|
|
856
|
+
return fDone(pError);
|
|
857
|
+
}
|
|
858
|
+
fDone();
|
|
859
|
+
};
|
|
860
|
+
const [ tmpValueArrayKey, tmpValueArrayDescriptor ] = Object.entries(tmpDistinctManifest.Descriptors).find(([pKey, pDescriptor]) => pDescriptor.OriginalHash == 'ValueArray');
|
|
861
|
+
const tmpAddress = tmpValueArrayDescriptor.DataAddress;
|
|
862
|
+
_Pict.log.info('Setting up Distinct Array Test with address:', { tmpValueArrayKey, tmpValueArrayDescriptor, tmpAddress });
|
|
863
|
+
const tmpArrayAddress = tmpAddress.substring(0, tmpAddress.indexOf('[]'));
|
|
864
|
+
const tmpPropertyAddress = tmpAddress.substring(tmpAddress.indexOf('[]') + 3);
|
|
865
|
+
_Pict.manifest.setValueByHash(_Pict.AppData, tmpArrayAddress,
|
|
866
|
+
[
|
|
867
|
+
{ [tmpPropertyAddress]: '1' },
|
|
868
|
+
{ [tmpPropertyAddress]: '2' },
|
|
869
|
+
{ [tmpPropertyAddress]: '3' },
|
|
870
|
+
{ [tmpPropertyAddress]: '4' },
|
|
871
|
+
{ [tmpPropertyAddress]: '5' },
|
|
872
|
+
]);
|
|
873
|
+
_Pict.PictApplication.solve();
|
|
874
|
+
}
|
|
875
|
+
catch (pError)
|
|
876
|
+
{
|
|
877
|
+
_Pict.log.error('Error during Distinct Array Test:', pError);
|
|
878
|
+
return fDone(pError);
|
|
879
|
+
}
|
|
880
|
+
});
|
|
881
|
+
}
|
|
882
|
+
);
|
|
883
|
+
test(
|
|
695
884
|
'Solve Ordinals',
|
|
696
885
|
(fDone) =>
|
|
697
886
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Pict-View-Form-Metacontroller.d.ts","sourceRoot":"","sources":["../../../source/views/Pict-View-Form-Metacontroller.js"],"names":[],"mappings":";AAaA;;GAEG;AAEH;;;;;;GAMG;AACH;IAEC,2DAyBC;IAjBA,yBAA2B;IAE3B,wBAAsF;IAEtF,cAAkC;IAElC,gCAAkC;IAClC,8BAAiC;IAEjC;;;;;;MAOE;IAQH,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;IA8BD;;;;OAIG;IACH,WAFa,GAAG,CAMf;IAED,kCAGC;IAED,gDAGC;IAED,+CAGC;IAED;;;;OAIG;IACH,2DAJW,MAAM,GAEL,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAW9B;IAED;;;;;;OAMG;IACH,mCANW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,sBACnB,MAAM,UACN,MAAM,GAEL,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC,CAwBtD;IAED;;;;;OAKG;IACH,0BALW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,sBACnB,MAAM,GAEL,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC,CAgCtD;IAED;;;;;;;;;OASG;IACH,kCALW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,UACnB,MAAM,GAEL,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"Pict-View-Form-Metacontroller.d.ts","sourceRoot":"","sources":["../../../source/views/Pict-View-Form-Metacontroller.js"],"names":[],"mappings":";AAaA;;GAEG;AAEH;;;;;;GAMG;AACH;IAEC,2DAyBC;IAjBA,yBAA2B;IAE3B,wBAAsF;IAEtF,cAAkC;IAElC,gCAAkC;IAClC,8BAAiC;IAEjC;;;;;;MAOE;IAQH,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;IA8BD;;;;OAIG;IACH,WAFa,GAAG,CAMf;IAED,kCAGC;IAED,gDAGC;IAED,+CAGC;IAED;;;;OAIG;IACH,2DAJW,MAAM,GAEL,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAW9B;IAED;;;;;;OAMG;IACH,mCANW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,sBACnB,MAAM,UACN,MAAM,GAEL,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC,CAwBtD;IAED;;;;;OAKG;IACH,0BALW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,sBACnB,MAAM,GAEL,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC,CAgCtD;IAED;;;;;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