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
|
@@ -7839,6 +7839,10 @@ class InputErrorMessageComponent extends FieldBase {
|
|
|
7839
7839
|
return false;
|
|
7840
7840
|
}
|
|
7841
7841
|
const control = this.form.controls[this.data.Value];
|
|
7842
|
+
if (!control) {
|
|
7843
|
+
console.log(`Unable to find form control: ' ${this.data.Value}`);
|
|
7844
|
+
return false;
|
|
7845
|
+
}
|
|
7842
7846
|
const isShow = !control.valid && !control.untouched;
|
|
7843
7847
|
if (isShow) {
|
|
7844
7848
|
of(this.componentErrorHandler.getErrorMessageForInvalidInput(this.group, null, this.data.Value)).pipe(switchMap((errMessageTranslationInput) => {
|
|
@@ -11514,8 +11518,14 @@ class ZudfComponent extends ContainerFieldBase {
|
|
|
11514
11518
|
this.toastService = toastService;
|
|
11515
11519
|
this.componentErrorHandlerService = componentErrorHandlerService;
|
|
11516
11520
|
this.cdr = cdr;
|
|
11517
|
-
// formFields: any[]; // populate using field element.
|
|
11521
|
+
// formFields: any[]; // populate using field element.
|
|
11518
11522
|
this.componentProperties = new ZComponentProperties();
|
|
11523
|
+
this.prefixValueOption = '_zudfmvgOptions';
|
|
11524
|
+
this.prefixDataSourceName = '_zudfmvgDataSource';
|
|
11525
|
+
this.prefixColumnFieldsName = '_zudfmvgColumnFields';
|
|
11526
|
+
this.prefixCustomAddButtonOnClick = '_CustomAddButtonOnClick';
|
|
11527
|
+
this.prefixCustomResetButtonOnClick = '_CustomResetButtonOnClick';
|
|
11528
|
+
this.prefixCustomRemoveButtonOnClick = '_CustomRemoveButtonOnClick';
|
|
11519
11529
|
this.setEnable = (status) => {
|
|
11520
11530
|
this.componentProperties.isReadOnly = !status;
|
|
11521
11531
|
};
|
|
@@ -11541,8 +11551,14 @@ class ZudfComponent extends ContainerFieldBase {
|
|
|
11541
11551
|
obs = this.fieldService.getFormFieldCode(fieldName, 'FormField', this, 'fields');
|
|
11542
11552
|
}
|
|
11543
11553
|
super.initComponent().pipe(switchMap$1(() => obs), switchMap$1((field) => {
|
|
11554
|
+
if (this.data.FieldElementCode) {
|
|
11555
|
+
// use obs value only if FieldElementCode is set. if nto default as null.
|
|
11556
|
+
this.data.Value = field;
|
|
11557
|
+
}
|
|
11558
|
+
else {
|
|
11559
|
+
this.data.Value = null;
|
|
11560
|
+
}
|
|
11544
11561
|
// Store initial data value and set component scope and prefix
|
|
11545
|
-
this.data.Value = field;
|
|
11546
11562
|
this.initialDataValue = this.data.Value;
|
|
11547
11563
|
this.componentScopeName = 'zudf_' + this.data.Name;
|
|
11548
11564
|
this.componentPrefix = 'zudf_' + this.data.Name;
|
|
@@ -11708,16 +11724,20 @@ class ZudfComponent extends ContainerFieldBase {
|
|
|
11708
11724
|
renderFieldElement(fieldElements) {
|
|
11709
11725
|
this.clearZModel();
|
|
11710
11726
|
if (fieldElements) {
|
|
11727
|
+
this.loadedFieldsSequence = {};
|
|
11711
11728
|
const formControls = {};
|
|
11712
11729
|
fieldElements = this.generateFormControls(fieldElements, formControls);
|
|
11713
11730
|
// Render form controls to new form group.
|
|
11714
11731
|
this.form = new FormGroup(formControls);
|
|
11715
11732
|
this.data.Value = fieldElements;
|
|
11716
11733
|
this.group[this.componentScopeName].form = this.form;
|
|
11734
|
+
this.group[this.componentScopeName]['loadedFieldsSequence'] = this.loadedFieldsSequence;
|
|
11717
11735
|
}
|
|
11718
11736
|
}
|
|
11719
|
-
generateFormControls(fieldArray, formControls, containerName) {
|
|
11720
|
-
fieldArray.forEach(field => {
|
|
11737
|
+
generateFormControls(fieldArray, formControls, containerName, isMultiValueGroup = false, fieldValueGrouped = false, index = '') {
|
|
11738
|
+
fieldArray.forEach((field, i) => {
|
|
11739
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
11740
|
+
const fieldIndex = index ? `${index}_${i + 1}` : `${i}`;
|
|
11721
11741
|
this.fieldService.patchFieldProperty(field);
|
|
11722
11742
|
if (typeof field.Value === "string" && field.Value.indexOf(".") !== -1) {
|
|
11723
11743
|
if (['zgrid', 'ztree', 'zimg', 'textareajson'].indexOf(field.Type) === -1) {
|
|
@@ -11728,10 +11748,21 @@ class ZudfComponent extends ContainerFieldBase {
|
|
|
11728
11748
|
const zudfGroup = this.group[this.componentScopeName];
|
|
11729
11749
|
if (Array.isArray(field.Value)) {
|
|
11730
11750
|
// insert multivaluegroup to the card value if true
|
|
11751
|
+
const fieldValueGrouped = field.Type == ComponentType.grouping ? true : false;
|
|
11752
|
+
this.loadedFieldsSequence[fieldIndex] = {
|
|
11753
|
+
name: field.MultiValuedGroup ? `${this.generateFormControlName(field.Name)}${this.prefixValueOption}` : `${this.generateFormControlName(field.Name)}`,
|
|
11754
|
+
label: field.Title,
|
|
11755
|
+
type: field.Type,
|
|
11756
|
+
isMultiValueGroup: (_a = field.MultiValuedGroup) !== null && _a !== void 0 ? _a : false,
|
|
11757
|
+
isGrouped: false,
|
|
11758
|
+
isVisible: (_b = field.Visible) !== null && _b !== void 0 ? _b : false,
|
|
11759
|
+
isRequired: (_c = field.IsRequired) !== null && _c !== void 0 ? _c : false,
|
|
11760
|
+
isReadOnly: (_d = field.ReadOnly) !== null && _d !== void 0 ? _d : false
|
|
11761
|
+
};
|
|
11731
11762
|
if (field.MultiValuedGroup) {
|
|
11732
11763
|
this.setMultiValueGroup(field);
|
|
11733
11764
|
}
|
|
11734
|
-
this.generateFormControls(field.Value, formControls, field.Name);
|
|
11765
|
+
this.generateFormControls(field.Value, formControls, field.Name, field.MultiValuedGroup, fieldValueGrouped, fieldIndex);
|
|
11735
11766
|
}
|
|
11736
11767
|
else {
|
|
11737
11768
|
// before generate FormControl, we need to add 2 attribute to the field when render.
|
|
@@ -11747,8 +11778,21 @@ class ZudfComponent extends ContainerFieldBase {
|
|
|
11747
11778
|
const isVisible = ZComponentHelper.isVisibleFormControl(this, field);
|
|
11748
11779
|
const isRequired = ZComponentHelper.isRequiredFormControl(this, field);
|
|
11749
11780
|
if (isFormControl === true) {
|
|
11781
|
+
if (!this.loadedFieldsSequence) {
|
|
11782
|
+
this.loadedFieldsSequence = {};
|
|
11783
|
+
}
|
|
11750
11784
|
field.Name = this.generateFormControlName(field.Name, containerName);
|
|
11751
11785
|
field.Value = this.generateFormControlName(field.Value, containerName);
|
|
11786
|
+
this.loadedFieldsSequence[fieldIndex] = {
|
|
11787
|
+
name: field.Name,
|
|
11788
|
+
label: field.Label,
|
|
11789
|
+
type: field.Type,
|
|
11790
|
+
isMultiValueGroup: isMultiValueGroup,
|
|
11791
|
+
isGrouped: fieldValueGrouped,
|
|
11792
|
+
isVisible: (_e = field.Visible) !== null && _e !== void 0 ? _e : false,
|
|
11793
|
+
isRequired: (_f = field.IsRequired) !== null && _f !== void 0 ? _f : false,
|
|
11794
|
+
isReadOnly: (_g = field.ReadOnly) !== null && _g !== void 0 ? _g : false
|
|
11795
|
+
};
|
|
11752
11796
|
if (containerName) {
|
|
11753
11797
|
if (!zudfGroup[containerName].includes(field.Value)) {
|
|
11754
11798
|
zudfGroup[containerName].push(field.Value);
|
|
@@ -11836,8 +11880,8 @@ class ZudfComponent extends ContainerFieldBase {
|
|
|
11836
11880
|
// Update grid values for any arrays in the model data
|
|
11837
11881
|
for (const model in patchedModelData) {
|
|
11838
11882
|
if (Array.isArray(patchedModelData[model])) {
|
|
11839
|
-
const gridValue = `${model}
|
|
11840
|
-
const gridDataSource = `${model}
|
|
11883
|
+
const gridValue = `${model}${this.prefixValueOption}`;
|
|
11884
|
+
const gridDataSource = `${model}${this.prefixDataSourceName}`;
|
|
11841
11885
|
// Update the data source for the grid
|
|
11842
11886
|
group[gridDataSource] = patchedModelData[model];
|
|
11843
11887
|
// Update the grid value
|
|
@@ -12027,9 +12071,9 @@ class ZudfComponent extends ContainerFieldBase {
|
|
|
12027
12071
|
var _a;
|
|
12028
12072
|
// Need to declare name, value, datasource, columnfields attribute for grid.
|
|
12029
12073
|
const name = this.generateFormControlName(data.Name);
|
|
12030
|
-
const gridValueName = `${name}
|
|
12031
|
-
const gridDataSourceName = `${name}
|
|
12032
|
-
const gridColumnFieldsName = `${name}
|
|
12074
|
+
const gridValueName = `${name}${this.prefixValueOption}`;
|
|
12075
|
+
const gridDataSourceName = `${name}${this.prefixDataSourceName}`;
|
|
12076
|
+
const gridColumnFieldsName = `${name}${this.prefixColumnFieldsName}`;
|
|
12033
12077
|
// Generate a unique name for the multi-value group scope.
|
|
12034
12078
|
const multiValueGroupScopeName = `mvg_${data.Name}`;
|
|
12035
12079
|
if (!this.group['mvglist']) {
|
|
@@ -12091,10 +12135,10 @@ class ZudfComponent extends ContainerFieldBase {
|
|
|
12091
12135
|
});
|
|
12092
12136
|
this.group[gridDataSourceName] = [];
|
|
12093
12137
|
this.group[gridColumnFieldsName] = groupFieldElements;
|
|
12094
|
-
// Create grid column based on field elements and insert them into the grid.
|
|
12095
|
-
this.group[`${name}
|
|
12096
|
-
this.group[`${name}
|
|
12097
|
-
this.group[`${name}
|
|
12138
|
+
// Create grid column based on field elements and insert them into the grid.
|
|
12139
|
+
this.group[`${name}${this.prefixCustomAddButtonOnClick}`] = this.captureContainerFieldValueToModel.bind(this, this.group, gridValueName, gridDataSourceName, containerName);
|
|
12140
|
+
this.group[`${name}${this.prefixCustomResetButtonOnClick}`] = this.clearContainerRelatedFieldValue.bind(this, this.group, containerName);
|
|
12141
|
+
this.group[`${name}${this.prefixCustomRemoveButtonOnClick}`] = this.removeGridRow.bind(this, gridValueName, gridDataSourceName);
|
|
12098
12142
|
if (dataIndex) {
|
|
12099
12143
|
this.appendToDisplayModel(element, dataIndex);
|
|
12100
12144
|
}
|