mmhglobal-dynamicform 2.1.0 → 2.1.2
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/README.md +8 -1
- package/esm2020/lib/input-error-message/input-error-message.component.mjs +5 -1
- package/esm2020/lib/zudf/zudf.component.mjs +54 -15
- package/fesm2015/mmhglobal-dynamicform.mjs +58 -14
- package/fesm2015/mmhglobal-dynamicform.mjs.map +1 -1
- package/fesm2020/mmhglobal-dynamicform.mjs +57 -14
- package/fesm2020/mmhglobal-dynamicform.mjs.map +1 -1
- package/lib/zudf/zudf.component.d.ts +7 -0
- package/package.json +1 -1
|
@@ -7826,6 +7826,10 @@ class InputErrorMessageComponent extends FieldBase {
|
|
|
7826
7826
|
return false;
|
|
7827
7827
|
}
|
|
7828
7828
|
const control = this.form.controls[this.data.Value];
|
|
7829
|
+
if (!control) {
|
|
7830
|
+
console.log(`Unable to find form control: ' ${this.data.Value}`);
|
|
7831
|
+
return false;
|
|
7832
|
+
}
|
|
7829
7833
|
const isShow = !control.valid && !control.untouched;
|
|
7830
7834
|
if (isShow) {
|
|
7831
7835
|
of(this.componentErrorHandler.getErrorMessageForInvalidInput(this.group, null, this.data.Value)).pipe(switchMap((errMessageTranslationInput) => {
|
|
@@ -11495,8 +11499,14 @@ class ZudfComponent extends ContainerFieldBase {
|
|
|
11495
11499
|
this.toastService = toastService;
|
|
11496
11500
|
this.componentErrorHandlerService = componentErrorHandlerService;
|
|
11497
11501
|
this.cdr = cdr;
|
|
11498
|
-
// formFields: any[]; // populate using field element.
|
|
11502
|
+
// formFields: any[]; // populate using field element.
|
|
11499
11503
|
this.componentProperties = new ZComponentProperties();
|
|
11504
|
+
this.prefixValueOption = '_zudfmvgOptions';
|
|
11505
|
+
this.prefixDataSourceName = '_zudfmvgDataSource';
|
|
11506
|
+
this.prefixColumnFieldsName = '_zudfmvgColumnFields';
|
|
11507
|
+
this.prefixCustomAddButtonOnClick = '_CustomAddButtonOnClick';
|
|
11508
|
+
this.prefixCustomResetButtonOnClick = '_CustomResetButtonOnClick';
|
|
11509
|
+
this.prefixCustomRemoveButtonOnClick = '_CustomRemoveButtonOnClick';
|
|
11500
11510
|
this.setEnable = (status) => {
|
|
11501
11511
|
this.componentProperties.isReadOnly = !status;
|
|
11502
11512
|
};
|
|
@@ -11522,8 +11532,14 @@ class ZudfComponent extends ContainerFieldBase {
|
|
|
11522
11532
|
obs = this.fieldService.getFormFieldCode(fieldName, 'FormField', this, 'fields');
|
|
11523
11533
|
}
|
|
11524
11534
|
super.initComponent().pipe(switchMap$1(() => obs), switchMap$1((field) => {
|
|
11535
|
+
if (this.data.FieldElementCode) {
|
|
11536
|
+
// use obs value only if FieldElementCode is set. if nto default as null.
|
|
11537
|
+
this.data.Value = field;
|
|
11538
|
+
}
|
|
11539
|
+
else {
|
|
11540
|
+
this.data.Value = null;
|
|
11541
|
+
}
|
|
11525
11542
|
// Store initial data value and set component scope and prefix
|
|
11526
|
-
this.data.Value = field;
|
|
11527
11543
|
this.initialDataValue = this.data.Value;
|
|
11528
11544
|
this.componentScopeName = 'zudf_' + this.data.Name;
|
|
11529
11545
|
this.componentPrefix = 'zudf_' + this.data.Name;
|
|
@@ -11688,16 +11704,19 @@ class ZudfComponent extends ContainerFieldBase {
|
|
|
11688
11704
|
renderFieldElement(fieldElements) {
|
|
11689
11705
|
this.clearZModel();
|
|
11690
11706
|
if (fieldElements) {
|
|
11707
|
+
this.loadedFieldsSequence = {};
|
|
11691
11708
|
const formControls = {};
|
|
11692
11709
|
fieldElements = this.generateFormControls(fieldElements, formControls);
|
|
11693
11710
|
// Render form controls to new form group.
|
|
11694
11711
|
this.form = new FormGroup(formControls);
|
|
11695
11712
|
this.data.Value = fieldElements;
|
|
11696
11713
|
this.group[this.componentScopeName].form = this.form;
|
|
11714
|
+
this.group[this.componentScopeName]['loadedFieldsSequence'] = this.loadedFieldsSequence;
|
|
11697
11715
|
}
|
|
11698
11716
|
}
|
|
11699
|
-
generateFormControls(fieldArray, formControls, containerName) {
|
|
11700
|
-
fieldArray.forEach(field => {
|
|
11717
|
+
generateFormControls(fieldArray, formControls, containerName, isMultiValueGroup = false, fieldValueGrouped = false, index = '') {
|
|
11718
|
+
fieldArray.forEach((field, i) => {
|
|
11719
|
+
const fieldIndex = index ? `${index}_${i + 1}` : `${i}`;
|
|
11701
11720
|
this.fieldService.patchFieldProperty(field);
|
|
11702
11721
|
if (typeof field.Value === "string" && field.Value.indexOf(".") !== -1) {
|
|
11703
11722
|
if (['zgrid', 'ztree', 'zimg', 'textareajson'].indexOf(field.Type) === -1) {
|
|
@@ -11708,10 +11727,21 @@ class ZudfComponent extends ContainerFieldBase {
|
|
|
11708
11727
|
const zudfGroup = this.group[this.componentScopeName];
|
|
11709
11728
|
if (Array.isArray(field.Value)) {
|
|
11710
11729
|
// insert multivaluegroup to the card value if true
|
|
11730
|
+
const fieldValueGrouped = field.Type == ComponentType.grouping ? true : false;
|
|
11731
|
+
this.loadedFieldsSequence[fieldIndex] = {
|
|
11732
|
+
name: field.MultiValuedGroup ? `${this.generateFormControlName(field.Name)}${this.prefixValueOption}` : `${this.generateFormControlName(field.Name)}`,
|
|
11733
|
+
label: field.Title,
|
|
11734
|
+
type: field.Type,
|
|
11735
|
+
isMultiValueGroup: field.MultiValuedGroup ?? false,
|
|
11736
|
+
isGrouped: false,
|
|
11737
|
+
isVisible: field.Visible ?? false,
|
|
11738
|
+
isRequired: field.IsRequired ?? false,
|
|
11739
|
+
isReadOnly: field.ReadOnly ?? false
|
|
11740
|
+
};
|
|
11711
11741
|
if (field.MultiValuedGroup) {
|
|
11712
11742
|
this.setMultiValueGroup(field);
|
|
11713
11743
|
}
|
|
11714
|
-
this.generateFormControls(field.Value, formControls, field.Name);
|
|
11744
|
+
this.generateFormControls(field.Value, formControls, field.Name, field.MultiValuedGroup, fieldValueGrouped, fieldIndex);
|
|
11715
11745
|
}
|
|
11716
11746
|
else {
|
|
11717
11747
|
// before generate FormControl, we need to add 2 attribute to the field when render.
|
|
@@ -11727,8 +11757,21 @@ class ZudfComponent extends ContainerFieldBase {
|
|
|
11727
11757
|
const isVisible = ZComponentHelper.isVisibleFormControl(this, field);
|
|
11728
11758
|
const isRequired = ZComponentHelper.isRequiredFormControl(this, field);
|
|
11729
11759
|
if (isFormControl === true) {
|
|
11760
|
+
if (!this.loadedFieldsSequence) {
|
|
11761
|
+
this.loadedFieldsSequence = {};
|
|
11762
|
+
}
|
|
11730
11763
|
field.Name = this.generateFormControlName(field.Name, containerName);
|
|
11731
11764
|
field.Value = this.generateFormControlName(field.Value, containerName);
|
|
11765
|
+
this.loadedFieldsSequence[fieldIndex] = {
|
|
11766
|
+
name: field.Name,
|
|
11767
|
+
label: field.Label,
|
|
11768
|
+
type: field.Type,
|
|
11769
|
+
isMultiValueGroup: isMultiValueGroup,
|
|
11770
|
+
isGrouped: fieldValueGrouped,
|
|
11771
|
+
isVisible: field.Visible ?? false,
|
|
11772
|
+
isRequired: field.IsRequired ?? false,
|
|
11773
|
+
isReadOnly: field.ReadOnly ?? false
|
|
11774
|
+
};
|
|
11732
11775
|
if (containerName) {
|
|
11733
11776
|
if (!zudfGroup[containerName].includes(field.Value)) {
|
|
11734
11777
|
zudfGroup[containerName].push(field.Value);
|
|
@@ -11816,8 +11859,8 @@ class ZudfComponent extends ContainerFieldBase {
|
|
|
11816
11859
|
// Update grid values for any arrays in the model data
|
|
11817
11860
|
for (const model in patchedModelData) {
|
|
11818
11861
|
if (Array.isArray(patchedModelData[model])) {
|
|
11819
|
-
const gridValue = `${model}
|
|
11820
|
-
const gridDataSource = `${model}
|
|
11862
|
+
const gridValue = `${model}${this.prefixValueOption}`;
|
|
11863
|
+
const gridDataSource = `${model}${this.prefixDataSourceName}`;
|
|
11821
11864
|
// Update the data source for the grid
|
|
11822
11865
|
group[gridDataSource] = patchedModelData[model];
|
|
11823
11866
|
// Update the grid value
|
|
@@ -12006,9 +12049,9 @@ class ZudfComponent extends ContainerFieldBase {
|
|
|
12006
12049
|
setMultiValueGroup(data, dataIndex) {
|
|
12007
12050
|
// Need to declare name, value, datasource, columnfields attribute for grid.
|
|
12008
12051
|
const name = this.generateFormControlName(data.Name);
|
|
12009
|
-
const gridValueName = `${name}
|
|
12010
|
-
const gridDataSourceName = `${name}
|
|
12011
|
-
const gridColumnFieldsName = `${name}
|
|
12052
|
+
const gridValueName = `${name}${this.prefixValueOption}`;
|
|
12053
|
+
const gridDataSourceName = `${name}${this.prefixDataSourceName}`;
|
|
12054
|
+
const gridColumnFieldsName = `${name}${this.prefixColumnFieldsName}`;
|
|
12012
12055
|
// Generate a unique name for the multi-value group scope.
|
|
12013
12056
|
const multiValueGroupScopeName = `mvg_${data.Name}`;
|
|
12014
12057
|
if (!this.group['mvglist']) {
|
|
@@ -12070,10 +12113,10 @@ class ZudfComponent extends ContainerFieldBase {
|
|
|
12070
12113
|
});
|
|
12071
12114
|
this.group[gridDataSourceName] = [];
|
|
12072
12115
|
this.group[gridColumnFieldsName] = groupFieldElements;
|
|
12073
|
-
// Create grid column based on field elements and insert them into the grid.
|
|
12074
|
-
this.group[`${name}
|
|
12075
|
-
this.group[`${name}
|
|
12076
|
-
this.group[`${name}
|
|
12116
|
+
// Create grid column based on field elements and insert them into the grid.
|
|
12117
|
+
this.group[`${name}${this.prefixCustomAddButtonOnClick}`] = this.captureContainerFieldValueToModel.bind(this, this.group, gridValueName, gridDataSourceName, containerName);
|
|
12118
|
+
this.group[`${name}${this.prefixCustomResetButtonOnClick}`] = this.clearContainerRelatedFieldValue.bind(this, this.group, containerName);
|
|
12119
|
+
this.group[`${name}${this.prefixCustomRemoveButtonOnClick}`] = this.removeGridRow.bind(this, gridValueName, gridDataSourceName);
|
|
12077
12120
|
if (dataIndex) {
|
|
12078
12121
|
this.appendToDisplayModel(element, dataIndex);
|
|
12079
12122
|
}
|