@capillarytech/creatives-library 7.17.121 → 7.17.122

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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "7.17.121",
4
+ "version": "7.17.122",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -1442,6 +1442,14 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1442
1442
  return formData;
1443
1443
  }
1444
1444
 
1445
+ /**
1446
+ * Initializes the form with the given schema.
1447
+ *
1448
+ * @param {Object} schema - The schema object for the form.
1449
+ * @param {boolean} makeFormEmpty - Flag indicating whether to make the form empty.
1450
+ * @param {boolean} resetTabKeys - Flag indicating whether to reset tab keys.
1451
+ * @returns {void}
1452
+ */
1445
1453
  initialiseForm(schema, makeFormEmpty, resetTabKeys) {
1446
1454
  let formData = makeFormEmpty ? {} : _.cloneDeep(this.state.formData);
1447
1455
  let errorData = {};
@@ -1471,8 +1479,13 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1471
1479
  }
1472
1480
  }
1473
1481
  const tempFormData = _.cloneDeep(formData);
1482
+ // Store the value of 'template-name' before the deletion process
1483
+ const templateNameValue = tempFormData['template-name'];
1474
1484
  if (!this.props.isNewVersionFlow) {
1475
1485
  _.forEach(formData, (element, key) => {
1486
+ // This code block is used to clean up the tempFormData object.
1487
+ // If the element is not an object and the key of the element is not found in the formElements array,
1488
+ // then the element is removed from the tempFormData object.
1476
1489
  if (typeof element !== 'object' && this.formElements.indexOf(key) === -1) {
1477
1490
  delete tempFormData[key];
1478
1491
  } else if (typeof element === "object") {
@@ -1482,8 +1495,15 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1482
1495
  }
1483
1496
  });
1484
1497
  }
1498
+ // If the element is an object, it iterates over its properties (innerElement).
1499
+ // If the property key (innerKey) is not "tabKey", "base", "name", "imagePreview", "image"
1500
+ // and is not found in the formElements array, then the property is removed from the object in tempFormData.
1485
1501
  });
1486
1502
  }
1503
+ // If 'template-name' was deleted, re-add it to tempFormData for mobilepush channel
1504
+ if (!Object.prototype.hasOwnProperty.call(tempFormData, 'template-name') && this.props.schema.channel.toUpperCase() === MOBILE_PUSH) {
1505
+ tempFormData['template-name'] = templateNameValue;
1506
+ }
1487
1507
  formData = _.cloneDeep(tempFormData);
1488
1508
  this.setState({formData, errorData}, () => {
1489
1509
  this.validateForm();