mmhglobal-dynamicform 2.1.0 → 2.1.1

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.
@@ -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
  };
@@ -11688,16 +11698,19 @@ class ZudfComponent extends ContainerFieldBase {
11688
11698
  renderFieldElement(fieldElements) {
11689
11699
  this.clearZModel();
11690
11700
  if (fieldElements) {
11701
+ this.loadedFieldsSequence = {};
11691
11702
  const formControls = {};
11692
11703
  fieldElements = this.generateFormControls(fieldElements, formControls);
11693
11704
  // Render form controls to new form group.
11694
11705
  this.form = new FormGroup(formControls);
11695
11706
  this.data.Value = fieldElements;
11696
11707
  this.group[this.componentScopeName].form = this.form;
11708
+ this.group[this.componentScopeName]['loadedFieldsSequence'] = this.loadedFieldsSequence;
11697
11709
  }
11698
11710
  }
11699
- generateFormControls(fieldArray, formControls, containerName) {
11700
- fieldArray.forEach(field => {
11711
+ generateFormControls(fieldArray, formControls, containerName, isMultiValueGroup = false, fieldValueGrouped = false, index = '') {
11712
+ fieldArray.forEach((field, i) => {
11713
+ const fieldIndex = index ? `${index}_${i + 1}` : `${i}`;
11701
11714
  this.fieldService.patchFieldProperty(field);
11702
11715
  if (typeof field.Value === "string" && field.Value.indexOf(".") !== -1) {
11703
11716
  if (['zgrid', 'ztree', 'zimg', 'textareajson'].indexOf(field.Type) === -1) {
@@ -11708,10 +11721,21 @@ class ZudfComponent extends ContainerFieldBase {
11708
11721
  const zudfGroup = this.group[this.componentScopeName];
11709
11722
  if (Array.isArray(field.Value)) {
11710
11723
  // insert multivaluegroup to the card value if true
11724
+ const fieldValueGrouped = field.Type == ComponentType.grouping ? true : false;
11725
+ this.loadedFieldsSequence[fieldIndex] = {
11726
+ name: field.MultiValuedGroup ? `${this.generateFormControlName(field.Name)}${this.prefixValueOption}` : `${this.generateFormControlName(field.Name)}`,
11727
+ label: field.Title,
11728
+ type: field.Type,
11729
+ isMultiValueGroup: field.MultiValuedGroup ?? false,
11730
+ isGrouped: false,
11731
+ isVisible: field.Visible ?? false,
11732
+ isRequired: field.IsRequired ?? false,
11733
+ isReadOnly: field.ReadOnly ?? false
11734
+ };
11711
11735
  if (field.MultiValuedGroup) {
11712
11736
  this.setMultiValueGroup(field);
11713
11737
  }
11714
- this.generateFormControls(field.Value, formControls, field.Name);
11738
+ this.generateFormControls(field.Value, formControls, field.Name, field.MultiValuedGroup, fieldValueGrouped, fieldIndex);
11715
11739
  }
11716
11740
  else {
11717
11741
  // before generate FormControl, we need to add 2 attribute to the field when render.
@@ -11727,8 +11751,21 @@ class ZudfComponent extends ContainerFieldBase {
11727
11751
  const isVisible = ZComponentHelper.isVisibleFormControl(this, field);
11728
11752
  const isRequired = ZComponentHelper.isRequiredFormControl(this, field);
11729
11753
  if (isFormControl === true) {
11754
+ if (!this.loadedFieldsSequence) {
11755
+ this.loadedFieldsSequence = {};
11756
+ }
11730
11757
  field.Name = this.generateFormControlName(field.Name, containerName);
11731
11758
  field.Value = this.generateFormControlName(field.Value, containerName);
11759
+ this.loadedFieldsSequence[fieldIndex] = {
11760
+ name: field.Name,
11761
+ label: field.Label,
11762
+ type: field.Type,
11763
+ isMultiValueGroup: isMultiValueGroup,
11764
+ isGrouped: fieldValueGrouped,
11765
+ isVisible: field.Visible ?? false,
11766
+ isRequired: field.IsRequired ?? false,
11767
+ isReadOnly: field.ReadOnly ?? false
11768
+ };
11732
11769
  if (containerName) {
11733
11770
  if (!zudfGroup[containerName].includes(field.Value)) {
11734
11771
  zudfGroup[containerName].push(field.Value);
@@ -11816,8 +11853,8 @@ class ZudfComponent extends ContainerFieldBase {
11816
11853
  // Update grid values for any arrays in the model data
11817
11854
  for (const model in patchedModelData) {
11818
11855
  if (Array.isArray(patchedModelData[model])) {
11819
- const gridValue = `${model}_Options`;
11820
- const gridDataSource = `${model}_DataSource`;
11856
+ const gridValue = `${model}${this.prefixValueOption}`;
11857
+ const gridDataSource = `${model}${this.prefixDataSourceName}`;
11821
11858
  // Update the data source for the grid
11822
11859
  group[gridDataSource] = patchedModelData[model];
11823
11860
  // Update the grid value
@@ -12006,9 +12043,9 @@ class ZudfComponent extends ContainerFieldBase {
12006
12043
  setMultiValueGroup(data, dataIndex) {
12007
12044
  // Need to declare name, value, datasource, columnfields attribute for grid.
12008
12045
  const name = this.generateFormControlName(data.Name);
12009
- const gridValueName = `${name}_Options`;
12010
- const gridDataSourceName = `${name}_DataSource`;
12011
- const gridColumnFieldsName = `${name}_ColumnFields`;
12046
+ const gridValueName = `${name}${this.prefixValueOption}`;
12047
+ const gridDataSourceName = `${name}${this.prefixDataSourceName}`;
12048
+ const gridColumnFieldsName = `${name}${this.prefixColumnFieldsName}`;
12012
12049
  // Generate a unique name for the multi-value group scope.
12013
12050
  const multiValueGroupScopeName = `mvg_${data.Name}`;
12014
12051
  if (!this.group['mvglist']) {
@@ -12070,10 +12107,10 @@ class ZudfComponent extends ContainerFieldBase {
12070
12107
  });
12071
12108
  this.group[gridDataSourceName] = [];
12072
12109
  this.group[gridColumnFieldsName] = groupFieldElements;
12073
- // Create grid column based on field elements and insert them into the grid.
12074
- this.group[`${name}_CustomAddButtonOnClick`] = this.captureContainerFieldValueToModel.bind(this, this.group, gridValueName, gridDataSourceName, containerName);
12075
- this.group[`${name}_CustomResetButtonOnClick`] = this.clearContainerRelatedFieldValue.bind(this, this.group, containerName);
12076
- this.group[`${name}_CustomRemoveButtonOnClick`] = this.removeGridRow.bind(this, gridValueName, gridDataSourceName);
12110
+ // Create grid column based on field elements and insert them into the grid.
12111
+ this.group[`${name}${this.prefixCustomAddButtonOnClick}`] = this.captureContainerFieldValueToModel.bind(this, this.group, gridValueName, gridDataSourceName, containerName);
12112
+ this.group[`${name}${this.prefixCustomResetButtonOnClick}`] = this.clearContainerRelatedFieldValue.bind(this, this.group, containerName);
12113
+ this.group[`${name}${this.prefixCustomRemoveButtonOnClick}`] = this.removeGridRow.bind(this, gridValueName, gridDataSourceName);
12077
12114
  if (dataIndex) {
12078
12115
  this.appendToDisplayModel(element, dataIndex);
12079
12116
  }