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.
@@ -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
  };
@@ -11708,16 +11718,20 @@ class ZudfComponent extends ContainerFieldBase {
11708
11718
  renderFieldElement(fieldElements) {
11709
11719
  this.clearZModel();
11710
11720
  if (fieldElements) {
11721
+ this.loadedFieldsSequence = {};
11711
11722
  const formControls = {};
11712
11723
  fieldElements = this.generateFormControls(fieldElements, formControls);
11713
11724
  // Render form controls to new form group.
11714
11725
  this.form = new FormGroup(formControls);
11715
11726
  this.data.Value = fieldElements;
11716
11727
  this.group[this.componentScopeName].form = this.form;
11728
+ this.group[this.componentScopeName]['loadedFieldsSequence'] = this.loadedFieldsSequence;
11717
11729
  }
11718
11730
  }
11719
- generateFormControls(fieldArray, formControls, containerName) {
11720
- fieldArray.forEach(field => {
11731
+ generateFormControls(fieldArray, formControls, containerName, isMultiValueGroup = false, fieldValueGrouped = false, index = '') {
11732
+ fieldArray.forEach((field, i) => {
11733
+ var _a, _b, _c, _d, _e, _f, _g;
11734
+ const fieldIndex = index ? `${index}_${i + 1}` : `${i}`;
11721
11735
  this.fieldService.patchFieldProperty(field);
11722
11736
  if (typeof field.Value === "string" && field.Value.indexOf(".") !== -1) {
11723
11737
  if (['zgrid', 'ztree', 'zimg', 'textareajson'].indexOf(field.Type) === -1) {
@@ -11728,10 +11742,21 @@ class ZudfComponent extends ContainerFieldBase {
11728
11742
  const zudfGroup = this.group[this.componentScopeName];
11729
11743
  if (Array.isArray(field.Value)) {
11730
11744
  // insert multivaluegroup to the card value if true
11745
+ const fieldValueGrouped = field.Type == ComponentType.grouping ? true : false;
11746
+ this.loadedFieldsSequence[fieldIndex] = {
11747
+ name: field.MultiValuedGroup ? `${this.generateFormControlName(field.Name)}${this.prefixValueOption}` : `${this.generateFormControlName(field.Name)}`,
11748
+ label: field.Title,
11749
+ type: field.Type,
11750
+ isMultiValueGroup: (_a = field.MultiValuedGroup) !== null && _a !== void 0 ? _a : false,
11751
+ isGrouped: false,
11752
+ isVisible: (_b = field.Visible) !== null && _b !== void 0 ? _b : false,
11753
+ isRequired: (_c = field.IsRequired) !== null && _c !== void 0 ? _c : false,
11754
+ isReadOnly: (_d = field.ReadOnly) !== null && _d !== void 0 ? _d : false
11755
+ };
11731
11756
  if (field.MultiValuedGroup) {
11732
11757
  this.setMultiValueGroup(field);
11733
11758
  }
11734
- this.generateFormControls(field.Value, formControls, field.Name);
11759
+ this.generateFormControls(field.Value, formControls, field.Name, field.MultiValuedGroup, fieldValueGrouped, fieldIndex);
11735
11760
  }
11736
11761
  else {
11737
11762
  // before generate FormControl, we need to add 2 attribute to the field when render.
@@ -11747,8 +11772,21 @@ class ZudfComponent extends ContainerFieldBase {
11747
11772
  const isVisible = ZComponentHelper.isVisibleFormControl(this, field);
11748
11773
  const isRequired = ZComponentHelper.isRequiredFormControl(this, field);
11749
11774
  if (isFormControl === true) {
11775
+ if (!this.loadedFieldsSequence) {
11776
+ this.loadedFieldsSequence = {};
11777
+ }
11750
11778
  field.Name = this.generateFormControlName(field.Name, containerName);
11751
11779
  field.Value = this.generateFormControlName(field.Value, containerName);
11780
+ this.loadedFieldsSequence[fieldIndex] = {
11781
+ name: field.Name,
11782
+ label: field.Label,
11783
+ type: field.Type,
11784
+ isMultiValueGroup: isMultiValueGroup,
11785
+ isGrouped: fieldValueGrouped,
11786
+ isVisible: (_e = field.Visible) !== null && _e !== void 0 ? _e : false,
11787
+ isRequired: (_f = field.IsRequired) !== null && _f !== void 0 ? _f : false,
11788
+ isReadOnly: (_g = field.ReadOnly) !== null && _g !== void 0 ? _g : false
11789
+ };
11752
11790
  if (containerName) {
11753
11791
  if (!zudfGroup[containerName].includes(field.Value)) {
11754
11792
  zudfGroup[containerName].push(field.Value);
@@ -11836,8 +11874,8 @@ class ZudfComponent extends ContainerFieldBase {
11836
11874
  // Update grid values for any arrays in the model data
11837
11875
  for (const model in patchedModelData) {
11838
11876
  if (Array.isArray(patchedModelData[model])) {
11839
- const gridValue = `${model}_Options`;
11840
- const gridDataSource = `${model}_DataSource`;
11877
+ const gridValue = `${model}${this.prefixValueOption}`;
11878
+ const gridDataSource = `${model}${this.prefixDataSourceName}`;
11841
11879
  // Update the data source for the grid
11842
11880
  group[gridDataSource] = patchedModelData[model];
11843
11881
  // Update the grid value
@@ -12027,9 +12065,9 @@ class ZudfComponent extends ContainerFieldBase {
12027
12065
  var _a;
12028
12066
  // Need to declare name, value, datasource, columnfields attribute for grid.
12029
12067
  const name = this.generateFormControlName(data.Name);
12030
- const gridValueName = `${name}_Options`;
12031
- const gridDataSourceName = `${name}_DataSource`;
12032
- const gridColumnFieldsName = `${name}_ColumnFields`;
12068
+ const gridValueName = `${name}${this.prefixValueOption}`;
12069
+ const gridDataSourceName = `${name}${this.prefixDataSourceName}`;
12070
+ const gridColumnFieldsName = `${name}${this.prefixColumnFieldsName}`;
12033
12071
  // Generate a unique name for the multi-value group scope.
12034
12072
  const multiValueGroupScopeName = `mvg_${data.Name}`;
12035
12073
  if (!this.group['mvglist']) {
@@ -12091,10 +12129,10 @@ class ZudfComponent extends ContainerFieldBase {
12091
12129
  });
12092
12130
  this.group[gridDataSourceName] = [];
12093
12131
  this.group[gridColumnFieldsName] = groupFieldElements;
12094
- // Create grid column based on field elements and insert them into the grid.
12095
- this.group[`${name}_CustomAddButtonOnClick`] = this.captureContainerFieldValueToModel.bind(this, this.group, gridValueName, gridDataSourceName, containerName);
12096
- this.group[`${name}_CustomResetButtonOnClick`] = this.clearContainerRelatedFieldValue.bind(this, this.group, containerName);
12097
- this.group[`${name}_CustomRemoveButtonOnClick`] = this.removeGridRow.bind(this, gridValueName, gridDataSourceName);
12132
+ // Create grid column based on field elements and insert them into the grid.
12133
+ this.group[`${name}${this.prefixCustomAddButtonOnClick}`] = this.captureContainerFieldValueToModel.bind(this, this.group, gridValueName, gridDataSourceName, containerName);
12134
+ this.group[`${name}${this.prefixCustomResetButtonOnClick}`] = this.clearContainerRelatedFieldValue.bind(this, this.group, containerName);
12135
+ this.group[`${name}${this.prefixCustomRemoveButtonOnClick}`] = this.removeGridRow.bind(this, gridValueName, gridDataSourceName);
12098
12136
  if (dataIndex) {
12099
12137
  this.appendToDisplayModel(element, dataIndex);
12100
12138
  }